自定义rmeta - 森林图生成不起作用:“'x'和'units'必须具有长度> 0”

时间:2015-07-09 19:32:51

标签: r plot forestplot

我试图使用rmeta包生成一个没有汇总估计的“森林情节”。但是,使用?forestplot然后从描述或示例开始没有帮助,我总是得到相同的错误。我会假设它是一个简单的矩阵/矢量长度有点不排队但我不断改变和调整仍然无法找到错误......

以下是示例代码:

tabletext<-cbind(c(NA, NA, NA, NA, NA, NA),
             c(NA, NA, NA, NA, NA, NA),
             c("variable1","subgroup","2nd", "3rd", "4th", "5th"),
             c(NA,"mean","1.8683639", "2.5717301", "4.4966049, 9.0008054")
             )
tabletext
png("forestplot.png")
forestplot(tabletext, mean = c(NA, NA, 1.8683639, 2.5717301, 4.4966049, 9.0008054), lower = c(NA, NA, 1.4604643, 2.0163468, 3.5197956, 6.9469213), upper = c(NA, NA, 2.3955105, 3.2897459, 5.7672966, 11.7288609), 
is.summary = c(rep(FALSE, 6)), zero = 1, xlog=FALSE, boxsize=0.75, xticks = NULL, clip = c(0.9, 12))
dev.off()

错误讯息:

 clip = c(0.9, 12))
Error in unit(rep(1, sum(widthcolumn)), "grobwidth", labels[[1]][widthcolumn]) : 
  'x' and 'units' must have length > 0
 dev.off()

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

这适用于forestplot-package,但您需要删除xticks=NULL

tabletext<-cbind(c(NA, NA, NA, NA, NA, NA),
                 c(NA, NA, NA, NA, NA, NA),
                 c("variable1","subgroup","2nd", "3rd", "4th", "5th"),
                 c(NA,"mean","1.8683639", "2.5717301", "4.4966049, 9.0008054")
)

png("forestplot.png")
forestplot(tabletext, 
           mean = c(NA, NA, 1.8683639, 2.5717301, 4.4966049, 9.0008054), 
           lower = c(NA, NA, 1.4604643, 2.0163468, 3.5197956, 6.9469213), 
           upper = c(NA, NA, 2.3955105, 3.2897459, 5.7672966, 11.7288609), 
           is.summary = c(rep(FALSE, 6)), zero = 1, 
           xlog=FALSE, boxsize=0.75,  clip = c(0.9, 12))
dev.off()

给予(我建议在提交出版之前进行一些抛光):

enter image description here