【问题标题】:R - Quick question about narrowing plot of the forest plot using metafor package; too wideR - 关于使用 metafor 包缩小森林图的快速问题;太宽了
【发布时间】:2021-05-06 14:37:08
【问题描述】:

在一些好心人的帮助下,我能够通过 metafor 包将森林图中的比例转换为百分比。

我相信我的森林地块还有一个问题,那就是宽度。正如您在照片中看到的,中间的数据图太宽了;它占据了图片空间的 2/3

--- 我怎样才能缩小这个情节,同时减少文本列之间的差距(例如,“研究”、“事件”、总计“)还有剧情?

请忽略蓝色框;我只是模糊了数据,因为它在这里不相关。从本质上讲,您可以看到我在左侧有三列:Study、Events 和 Total,右侧有两列:Weight 和 % [95% CI]

这是我目前的代码

forest(dat.back$yi, ci.lb=dat.back$ci.lb, ci.ub=dat.back$ci.ub, psize=1, xlab = "CNCP Prevalence (%)", slab = Study.Name, atransf = mytransf, xlim = c(-0.35,1.05), ylim = c(-1.5,16), header = c("Study", "Weight       %    [95% CI]"), refline = 0.399, digits = 1, ilab = cbind(dat.back$xi, dat.back$ni, dat.back$wt), ilab.xpos = c(-0.15, -0.05, 0.88), at = c(0.10, 0.40, 0.70))

text(c(-0.15, -0.05), 15, c("Events", "Total"), font= 2)
text(c(-0.15, -0.05), -0.5, c("108293", "224624"), font = 1)
text(c(0.88), -0.5, c("100%"), font = 1)

addpoly(pred$pred, ci.lb=pred$ci.lb, ci.ub=pred$ci.ub, row=-0.5, digits=1, mlab="Total (RE Model)", efac=1.5, atransf = mytransf, cex = 1.00)

text(-0.35, -1.5, pos = 4, cex = 1.00, bquote(paste(tau^2, " = ", .(formatC(res$tau2, digits = 2, format = "f")), " , ", I^2, " = ", .(formatC(res$I2, digits = 2, format = "f")), " , ", chi^2, " = ", .(formatC(res$QE, digits = 1, format = "f")), " , ", p, " = ", .(formatC(res$QEp, digits=4, format="f")))))

以下是我将 str() 用于我的森林图时得到的结果:

List of 8
 $ xlim    : num [1:2] -0.35 1.05
 $ alim    : num [1:2] 0.1 0.7
 $ at      : num [1:7] 0.1 0.2 0.3 0.4 0.5 0.6 0.7
 $ ylim    : num [1:2] -3 17
 $ rows    : int [1:13] 1 2 3 4 5 6 7 8 9 10 ...
 $ cex     : num 1
 $ cex.lab : num 1
 $ cex.axis: num 1

非常感谢您的帮助。谢谢!!

【问题讨论】:

    标签: r width forestplot metafor


    【解决方案1】:

    您有 plotwidth 参数,该参数将减少森林图,例如:plotwidth=unit(10, "mm")。另外,添加colgap(您可以调整数字以适合您的需要):

    forest(dat.back$yi, ci.lb=dat.back$ci.lb, ci.ub=dat.back$ci.ub, psize=1, xlab = "CNCP Prevalence (%)", slab = Study.Name, atransf = mytransf, xlim = c(-0.35,1.05), ylim = c(-1.5,16), header = c("Study", "Weight       %    [95% CI]"), refline = 0.399, digits = 1, ilab = cbind(dat.back$xi, dat.back$ni, dat.back$wt), ilab.xpos = c(-0.15, -0.05, 0.88), at = c(0.10, 0.40, 0.70),plotwidth=unit(10, "mm"),colgap =unit(2, "mm"))
    

    【讨论】:

    • 这听起来是个好主意。问题是我收到一条错误消息:``` 50: In doTryCatch(return(expr), name, parentenv, handler) : "colgap.forest.right" 不是图形参数 `` ;还有另一个错误```说:49:在doTryCatch(return(expr),name,parentenv,handler)中:“colgap.forest.left”不是图形参数```
    • 是的,你是对的,colgap.forest.right 用于forest.meta() 函数,我刚刚更新了colgap 参数用于forest 函数
    • 这些都行不通。使用的forest() 函数来自metafor 包,而不是meta 包。对于前者,您应该使用 xlim 参数。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-15
    • 2016-11-12
    • 2022-11-10
    • 1970-01-01
    • 2015-03-21
    • 2014-08-11
    相关资源
    最近更新 更多