微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在森林图中将特定行的字体更改为粗体

如何解决在森林图中将特定行的字体更改为粗体

我使用“forestplot”包编写了一个脚本。我想将变量分组到某些类别中,我想以粗体显示,以突出这些类别。我如何调整我的脚本,以便只有某些行,即风险因素 OR (95% CI)、患者特征、用药史、合并症、手术史和其他以粗体显示我有两列和 18 行。有人能帮我吗?我将不胜感激!! 我的脚本如下:

tabletext <- cbind(
  c("Risk factor","Patient characteristics","Sex,male*","Bmi (5 points)","Alcohol (5 units)","Smoking*","Medication history","Steroid use","Anticoagulant use*","Comorbidities","copD GOLD 1/2","copD GOLD 3/4","Other pulmonary disease","Surgical history","PrevIoUs colorectal surgery*","PrevIoUs abdominal surgery (other)","Other","HIPEC*"),c("OR (95% CI)",NA,"1.78 (1.20-2.68)","1.15 (0.95-1.38)","1.04 (0.94-1.14)","1.78 (1.11-2.80)"," 1.40 (0.68-2.67)","1.55 (1.02-2.32)","1.40 (0.70-2.61)","1.56 (0.42-4.67)","1.78 (0.63-4.28)","1.61 (1.03-2.49)","0.80 (0.47-1.32)","4.14 (2.14-7.73)"))


?fpTxtGp
require(forestplot)
forestplot(tabletext,txt_gp = fpTxtGp(label = list(gpar(fontfamily = "Times",fontface="bold"),gpar(fontfamily = "",col = "black"))),df_c,new_page = TRUE,Boxsize = 0.2,is.summary = c(rep(FALSE,32)),clip = c(0,17),xlab = 'Odds ratio with 95% confidence interval
  * indicates significance',xlog = FALSE,zero = 1,plotwidth=unit(12,"cm"),colgap=unit(2,"mm"),col = fpColors(Box = "royalblue",line = "darkblue",summary = "royalblue"))

解决方法

不清楚 df_c 是什么,所以我只是根据您的 tabletext 矩阵创建了它:

df_c <- data.frame(mean = c(NA,NA,1.78,1.15,1.04,1.4,1.55,1.56,1.61,0.8,4.14),lower = c(NA,1.2,0.95,0.94,1.11,0.68,1.02,0.7,0.42,0.63,1.03,0.47,2.14),upper = c(NA,2.68,1.38,1.14,2.8,2.67,2.32,2.61,4.67,4.28,2.49,1.32,7.73))

从那里开始,只需调整传递给 is.summary 的值:

   forestplot(tabletext,txt_gp = fpTxtGp(label = list(gpar(fontfamily = "Times"),gpar(fontfamily = "",col = "black"))),df_c,new_page = TRUE,boxsize = 0.2,is.summary = c(TRUE,TRUE,rep(FALSE,4),FALSE,3),4)),clip = c(0,17),xlab = 'Odds ratio with 95% confidence interval
      * indicates significance',xlog = FALSE,zero = 1,plotwidth=unit(12,"cm"),colgap=unit(2,"mm"),col = fpColors(box = "royalblue",line = "darkblue",summary = "royalblue"))

生成下图:

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。