首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R: forestplot -绘图上的置信区间

R: forestplot -绘图上的置信区间
EN

Stack Overflow用户
提问于 2019-05-03 23:44:29
回答 1查看 491关注 0票数 0

我有一个代码来可视化森林图。代码包含多元回归分析的数据和林地的美感:

代码语言:javascript
复制
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)))

生成的图:

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

EN

回答 1

Stack Overflow用户

发布于 2019-05-04 00:06:31

我找到问题了。只需更改向量的名称:

代码语言:javascript
复制
low2 <-c(0.92, 1.33, 1.05, 2.15, 0.38)
high2 <-c(1.83, 2.68, 3.14,7.54,0.90)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55973183

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档