0

我有一个可视化森林图的代码。该代码包含多变量回归分析和森林图美学的数据:

library(forestplot)

names <- c("Variable", 
           "Year of the studies \u2265 4",
           "Faculty: medicine***",
           "Family doctor recommendation*",
           "Specialist doctor recommendation***",
           "Friend recommendation*")

coef2 <- c(1.30,1.89,1.82,4.03,0.58)
high2 <-c(0.92, 1.33, 1.05, 2.15, 0.38)
low2 <-c(1.83, 2.68, 3.14,7.54,0.90)
boxsize2 <- c(0.2,0.2,0.2,0.2,0.2)
test_data <- data.frame(coef=coef2, low=low2,high=high2,           boxsize=boxsize2)
test_data <- rbind(NA,  test_data)

row_names <-cbind(names, c("OR [95%CI]", "1.30 [0.92-1.84]", "1.89 [1.33-2.68]", "1.82 [1.05-3.14]", "4.03 [2.15-7.54]", "0.58 [0.38-0.90]"))

#####FIGURE
forestplot(labeltext = row_names,
           mean = test_data$coef, upper = test_data$high,
           lower = test_data$low,
           is.summary=c(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE),
           boxsize = test_data$boxsize,
           zero = 1,
           xlog = FALSE,
           xlab = "OR (95% CI)",
           col = fpColors(lines="black", box="black"),
           ci.vertices = TRUE,
           xticks = c(0, 1, 2.5, 5,7.5),
           colgap = unit(0.03,'npc'),
           hrzl_lines= TRUE,
           lineheight = unit(1.1,"cm"),
           graphwidth = "auto",
           txt_gp=fpTxtGp(label = gpar(cex = 0.8),
                          title = gpar(cex = 1),
                          ticks = gpar(cex = 0.7),
                          xlab = gpar(cex = 0.7)))

生成的图: 在此处输入图像描述

但是我无法生成置信区间。我应该改变什么来可视化置信区间?

4

1 回答 1

0

我发现了问题。只需将向量的名称更改为:

low2 <-c(0.92, 1.33, 1.05, 2.15, 0.38)
high2 <-c(1.83, 2.68, 3.14,7.54,0.90)

在此处输入图像描述

于 2019-05-03T16:06:31.290 回答