问题描述
我最近刚从我的大学收到一些数据。我被命令创建一个具有几率的森林图,但是主要的问题是除最终值外,我无权访问数据集。我对OR,95%的置信区间,总体,p值和变量都比较擅长。
我想在NEJM上创建一个类似于此森林图,但是我不知道该怎么做。如果有人可以帮助我,我将非常感激。我已经看到该平台中存在类似的问题,但是这些问题都不是针对手动引入的信息,而无需进行计算或回归。
我为您提供了指向我想要的图像的链接。
谢谢您的帮助。
解决方法
我和你的处境相似。我只有OR和CI。我创建了以下森林图,将我的数据输入向量中。您应该检查名为forestplot的软件包以及随附的文档。
test_data <- data.frame(coef1 =c(1.85,1.86,1.88,1.45,1.64,1.54,1.64),coef2 =c(1.54,1.85,5.85,5.86,5.88,1.45),coef3 =c(1.64,1.54),low1 =c(1.45,1.25,1.30,1.10,1.20,1.15,1.30),low2 =c(1.15,3.45,3.25,3.30,1.10),low3 =c(1.20,1.25),high1 =c(2.52,2.10,2.30,2.54,2.52,2.25,2.52),high2 =c(2.25,3.54,3.52,7.52,7.10,7.30,2.54),high3 =c(2.52,2.25))
tabletext<- c("Diabetes","Heart disease","Stroke","COPD","Asthma","Cancer","Arthtitis","Osteoporosis","Depression","Severe mental diseases","Dementia")
coef <- with(test_data,cbind(coef1,coef2,coef3))
low <- with(test_data,cbind(low1,low2,low3))
high <- with(test_data,cbind(high1,high2,high3))
library(forestplot)
forestplot(tabletext,coef,low,high,title="Comorbidities",zero= 1,lwd.zero = gpar(lwd=1),boxsize=0.18,line.margin = .1,xticks = c(0:8),clip=c(0,8),fn.ci_norm = c(fpDrawNormalCI,fpDrawDiamondCI,fpDrawCircleCI),col=fpColors(box=c("darkblue","darkred","darkgreen"),line=c("darkblue",zero = "black"),xlab="Odds ratio (95% CI)",new_page = TRUE,txt_gp = fpTxtGp(label = list(gpar(fontfamily = "Times New Roman",cex=1),xlab = gpar(fontfamily = "Times New Roman",ticks = gpar(fontfamily = "Times New Roman",cex=0.8),title = gpar(fontfamily = "Times New Roman",cex=1.2))),legend=c("Unadjusted","Adjusted for Age and Sex","Adjusted for all"),legend_args = fpLegend(title="Model Adjustment",pos = "top",r=unit(.2,"snpc"),gp = gpar(col="black",fill= "white",lwd=0.7)))