如何使用 Metafor/R 删除 Forest Plot 中的预打印文本?
How do I get rid off pre-printed text in Forest Plot using Metafor/R?
我正在使用 Metafor 包生成元分析,然后生成森林图。当我打印我的森林图时,一个 "RE Model"-文本会自动出现,如所附打印件所示。尽管我使用单独的文本脚本,但我不知道如何删除 "RE Model" 。我只希望我的 "own" 文本与多边形对齐。你能帮忙吗?
首先是 "load data" 然后是我的脚本:
### Load data
dat <- structure(list(study = structure(c(4L, 5L, 3L, 1L, 2L, 7L, 6L
), .Label = c("Battaglia et al.", "Hong et al.", "Kosyakove et al.",
"Lim et al.", "Rauch et al.", "Swachia et al.", "Tsounis et
al."
), class = "factor"), n1i = c(20L, 121L, 25L, 18L, 31L, 35L,
22L), m1i = c(12.8, 30.2, 24.6, 21, 25, 27,
18.2), sd1i = c(15.4,
21.6, 17, 33, 18, 13.8, 8.72), n2i = c(20L, 129L, 25L, 17L, 32L,
34L, 20L), m2i = c(12.1, 28.7, 25.1, 31, 26, 28.6, 14.7), sd2i = c(14.6,
21.6, 12.2, 25, 19, 24.2, 12.9), ntotal = c(40L, 250L, 50L, 35L,
63L, 69L, 42L), mean.age = c(3L, 3L, 1L, 4L, 4L, 3L, 3L), demograhic =
c(0L,
2L, 1L, 1L, 0L, 1L, 0L), adjusted.comorbid = c(1L, 1L, 1L, 1L,
0L, 1L, 1L), follow.up = c(1L, 3L, 3L, 1L, 2L, 2L, 2L), severity = c(2L,
4L, 1L, 4L, 4L, 4L, 4L), treat.sys = c(1L, 2L, 1L, 2L, 1L, 2L,
1L), treat.int = c(1L, 1L, 2L, 1L, 2L, 1L, 1L), year = c(2000L,
2000L, 2000L, 2000L, 2000L, 2000L, 2000L), citation = c(1L, 2L,
3L, 4L, 5L, 6L, 6L), yi = structure(c(0.700000000000001, 1.5,
-0.5, -10, -1, -1.6, 3.5), measure = "MD", ni = c(40L, 250L,
50L, 35L, 63L, 69L, 42L)), vi = c(22.516, 7.47261195464155, 17.5136,
97.2647058823529, 21.7328629032258, 22.6658487394958, 11.7767909090909
)), .Names = c("study", "n1i", "m1i", "sd1i", "n2i", "m2i", "sd2i",
"ntotal", "mean.age", "demograhic", "adjusted.comorbid", "follow.up",
"severity", "treat.sys", "treat.int", "year", "citation", "yi",
"vi"), row.names = c(NA, -7L), class = c("escalc", "data.frame"
), digits = 4, yi.names = "yi", vi.names = "vi")
和我的代码
### My code
res <- rma(yi, vi, data=dat, slab=paste(study, year, citation, sep=", "), method = "REML")
forest(res, xlim=c(-39,24), at=c(-12,-9,-6,-3,0,3,6,9,12), showweights = TRUE,
ilab=cbind(dat$m1i, dat$n1i, dat$sd1i, dat$m2i, dat$n2i, dat$sd2i),
ilab.xpos=c(-26,-24,-22,-18,-16,-14), cex=1, ylim=c(-2, 10), font=1, digits=2, col="darkgrey")
### Add own text
text(-39, -2, pos=4, cex=0.9, font=2,
bquote(paste("Random-effects model for all studies: Q = ",
.(formatC(q1$QE, digits=2, format="f")),
", df = ", .(q1$k - q1$p),", p = ",
.(formatC(q1$QEp, digits=2, format="f")),
", ", I^2, " = ",
.(formatC(q1$I2, digits=1, format="f")),
"%", ", ", tau^2 ==
.(formatC(q1$tau2, digits=2, format="f")))))
提前致谢!
要制作左下角没有 "RE Model" 文本的森林图,只需在 forest
函数调用中使用 mlab = ""
参数。
forest(res, xlim=c(-39,24), at=c(-12,-9,-6,-3,0,3,6,9,12), showweights = TRUE,
ilab=cbind(dat$m1i, dat$n1i, dat$sd1i, dat$m2i, dat$n2i, dat$sd2i),
ilab.xpos=c(-26,-24,-22,-18,-16,-14), cex=1, ylim=c(-2, 10),
font=1, digits=2, col="darkgrey", mlab = "")
很遗憾,我无法 运行 您提供的代码的 "Add own text" 部分,因为您没有提供 q1
对象。但是你应该可以自己解决这个问题。
我使用 Metafor-Project 网站解决了这个问题,特别是他们的 page on forest plots。
我正在使用 Metafor 包生成元分析,然后生成森林图。当我打印我的森林图时,一个 "RE Model"-文本会自动出现,如所附打印件所示。尽管我使用单独的文本脚本,但我不知道如何删除 "RE Model" 。我只希望我的 "own" 文本与多边形对齐。你能帮忙吗?
首先是 "load data" 然后是我的脚本:
### Load data
dat <- structure(list(study = structure(c(4L, 5L, 3L, 1L, 2L, 7L, 6L
), .Label = c("Battaglia et al.", "Hong et al.", "Kosyakove et al.",
"Lim et al.", "Rauch et al.", "Swachia et al.", "Tsounis et
al."
), class = "factor"), n1i = c(20L, 121L, 25L, 18L, 31L, 35L,
22L), m1i = c(12.8, 30.2, 24.6, 21, 25, 27,
18.2), sd1i = c(15.4,
21.6, 17, 33, 18, 13.8, 8.72), n2i = c(20L, 129L, 25L, 17L, 32L,
34L, 20L), m2i = c(12.1, 28.7, 25.1, 31, 26, 28.6, 14.7), sd2i = c(14.6,
21.6, 12.2, 25, 19, 24.2, 12.9), ntotal = c(40L, 250L, 50L, 35L,
63L, 69L, 42L), mean.age = c(3L, 3L, 1L, 4L, 4L, 3L, 3L), demograhic =
c(0L,
2L, 1L, 1L, 0L, 1L, 0L), adjusted.comorbid = c(1L, 1L, 1L, 1L,
0L, 1L, 1L), follow.up = c(1L, 3L, 3L, 1L, 2L, 2L, 2L), severity = c(2L,
4L, 1L, 4L, 4L, 4L, 4L), treat.sys = c(1L, 2L, 1L, 2L, 1L, 2L,
1L), treat.int = c(1L, 1L, 2L, 1L, 2L, 1L, 1L), year = c(2000L,
2000L, 2000L, 2000L, 2000L, 2000L, 2000L), citation = c(1L, 2L,
3L, 4L, 5L, 6L, 6L), yi = structure(c(0.700000000000001, 1.5,
-0.5, -10, -1, -1.6, 3.5), measure = "MD", ni = c(40L, 250L,
50L, 35L, 63L, 69L, 42L)), vi = c(22.516, 7.47261195464155, 17.5136,
97.2647058823529, 21.7328629032258, 22.6658487394958, 11.7767909090909
)), .Names = c("study", "n1i", "m1i", "sd1i", "n2i", "m2i", "sd2i",
"ntotal", "mean.age", "demograhic", "adjusted.comorbid", "follow.up",
"severity", "treat.sys", "treat.int", "year", "citation", "yi",
"vi"), row.names = c(NA, -7L), class = c("escalc", "data.frame"
), digits = 4, yi.names = "yi", vi.names = "vi")
和我的代码
### My code
res <- rma(yi, vi, data=dat, slab=paste(study, year, citation, sep=", "), method = "REML")
forest(res, xlim=c(-39,24), at=c(-12,-9,-6,-3,0,3,6,9,12), showweights = TRUE,
ilab=cbind(dat$m1i, dat$n1i, dat$sd1i, dat$m2i, dat$n2i, dat$sd2i),
ilab.xpos=c(-26,-24,-22,-18,-16,-14), cex=1, ylim=c(-2, 10), font=1, digits=2, col="darkgrey")
### Add own text
text(-39, -2, pos=4, cex=0.9, font=2,
bquote(paste("Random-effects model for all studies: Q = ",
.(formatC(q1$QE, digits=2, format="f")),
", df = ", .(q1$k - q1$p),", p = ",
.(formatC(q1$QEp, digits=2, format="f")),
", ", I^2, " = ",
.(formatC(q1$I2, digits=1, format="f")),
"%", ", ", tau^2 ==
.(formatC(q1$tau2, digits=2, format="f")))))
提前致谢!
要制作左下角没有 "RE Model" 文本的森林图,只需在 forest
函数调用中使用 mlab = ""
参数。
forest(res, xlim=c(-39,24), at=c(-12,-9,-6,-3,0,3,6,9,12), showweights = TRUE,
ilab=cbind(dat$m1i, dat$n1i, dat$sd1i, dat$m2i, dat$n2i, dat$sd2i),
ilab.xpos=c(-26,-24,-22,-18,-16,-14), cex=1, ylim=c(-2, 10),
font=1, digits=2, col="darkgrey", mlab = "")
很遗憾,我无法 运行 您提供的代码的 "Add own text" 部分,因为您没有提供 q1
对象。但是你应该可以自己解决这个问题。
我使用 Metafor-Project 网站解决了这个问题,特别是他们的 page on forest plots。