所以我使用meta.for
中的R
包进行元分析。我准备在科学期刊上发表数据,我想在我的森林地块中添加p值,但科学注释格式为
x10-04
而不是标准
e-04
然而,ilab
函数中的参数forest
不接受expression
类对象,只接受向量
以下是一个例子:
library(metafor)
data(dat.bcg)
## REM
res <- rma(ai = tpos, bi = tneg, ci = cpos, di = cneg, data = dat.bcg,
measure = "RR",
slab = paste(author, year, sep = ", "), method = "REML")
# MADE UP PVALUES
set.seed(513)
p.vals <- runif(nrow(dat.bcg), 1e-6,0.02)
# Format pvalues so only those bellow 0.01 are scientifically notated
p.vals <- ifelse(p.vals < 0.01,
format(p.vals,digits = 3,scientific = TRUE,trim = TRUE),
format(round(p.vals, 2), nsmall=2, trim=TRUE))
## Forest plot
forest(res, ilab = p.vals, ilab.xpos = 3, order = "obs", xlab = "Relative Risk")
我希望将p值的科学记数法格式化为
x10-04
我所见过的类似问题的所有答案建议使用expression()
,但这会使Error in cbind(ilab) : cannot create a matrix from type 'expression'
有意义,因为forest
上的帮助文件指定了ilab
参数应该是一个载体。
关于我如何解决这个问题或解决它的任何想法?
答案 0 :(得分:5)
一个hacky解决方案是
var on = 1;
function name () {
if(on == 1){
alert('ON');
on = 0;
}else if(on == 0){
alert('OFF');
on = 1;
}
}
name();
name();
转到第574行并更改
forest.rma <- edit(forest.rma)
到
## line 574
text(ilab.xpos[l], rows, ilab[, l], pos = ilab.pos[l],
修正你的p值并绘制
text(ilab.xpos[l], rows, parse(text = ilab[, l]), pos = ilab.pos[l],