【问题标题】:Create labels for funnel plot points in metafor在 metafor 中为漏斗图点创建标签
【发布时间】:2014-04-23 14:03:07
【问题描述】:

查看 metafor 页面上的funnel plot examples - 似乎有一种方法可以为漏斗图添加标签。 funnel plot page 提供了更多详细信息,但没有列出添加标签的示例。

提供的例子:

library(metafor)
png(filename="contour_enhanced_funnel_plot.png",
    res=92, width=680, height=600, type="cairo")
par(mar=c(5,4,1,2))
data(dat.bcg)
res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure="RR",
           slab=paste(author, year, sep=", "), method="REML")
funnel(res, level=c(90, 95, 99), shade=c("white", "gray", "darkgray"), refline=0)
dev.off()

包括一个标签字段,但在示例中没有生成。 如何在漏斗图中添加标签?

查看here,似乎使用 pch 可能是一种替代方法。大致如下:

pch=paste(StudyName, StudyMeasure, sep=", ")

但这只会产生一个字母点。 .

【问题讨论】:

    标签: r plot labels


    【解决方案1】:

    在浏览 rma()funnel.rma() 的来源(来自 metafor 的 1.9-2 版)时,我找不到将标签放入漏斗图中的任何具体规定。然而,为了绘制您自己的标签,这些位置原则上似乎可以从rma-object 重现,因此可以在这些数字的基础上进行构建,而无需重新计算所有内容。这种方法当然至少取决于 yaxis 参数的选择值,但默认情况下 sqrt(vi) ~ yi 似乎有效:

    # ...
    funnel(res, level=c(90, 95, 99), shade=c("white", "gray", "darkgray"), refline=0)
    text(res$yi,sqrt(res$vi)+.016,res$slab,cex=.8)
    

    有时图形外观当然会因为重叠的标签变得不可读而变得糟糕。

    或者,您可以尝试自己分配有意义的pch-值(通常应该是整数),并尝试用图例来解释这些:

    alloc.factor <- factor(dat.bcg$alloc) 
    stopifnot(res$k==length(alloc.factor))
    funnel(res, level=c(90, 95, 99), shade=c("white", "gray", "darkgray"), refline=0,
        pch=as.numeric(alloc.factor),lwd=2,cex=1.6)
    legend("topright",levels(alloc.factor),pch=1:3,pt.lwd=2,cex=1.6)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-28
      • 2019-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-23
      • 1970-01-01
      相关资源
      最近更新 更多