【问题标题】:Can datapoints be colored in Funnel Plot based on category in Metafor package/R?可以根据 Metafor 包/R 中的类别在漏斗图中对数据点进行着色吗?
【发布时间】:2018-11-28 13:03:30
【问题描述】:

是否可以为漏斗图中的数据点着色?我正在使用 metafor 包。

 # Load package
 library(metafor)

 # Load data
 data(dat.bcg)

 # Code 
 ex <- rma(ai=tpos, bi=tneg, ci=cpos, 
 di=cneg, data=dat.bcg, measure="OR",
 slab=paste(author, year, sep=", "), method="FE")

# Funnel plot
funnel(ex, transf = exp, ylab="Test group", xlab="Control")

是否可以根据变量为点着色?

Fx 蓝色数据点代表:

dat.bcg$alloc==random

谢谢你,C。

【问题讨论】:

    标签: r metafor


    【解决方案1】:

    我检查了funnel 方法的源代码,令人恼火的是,不,您不能将颜色向量传递给col 参数。

    一个简单的解决方法是将funnel() 的输出分配给一个变量,该变量将为您提供漏斗图中点的 x 和 y 坐标,然后用彩色点在漏斗图上的原始点上绘制。

    # Create vector of colors
    my_colors <- c('red','blue')[(dat.bcg$alloc == 'random') + 1]
    
    # Create funnel plot, catching output
    funnelplotdata <- funnel(ex, transf = exp, ylab="Test group", xlab="Control")
    
    # Plot over points
    with(funnelplotdata, points(x, y, col = my_colors, pch = 19))
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-06
    • 2018-09-22
    • 2018-01-07
    • 2013-06-16
    相关资源
    最近更新 更多