Dear R-experts,

The forest.rma() function from the metafor package creates nice forest
plots for presenting the results of a meta-analysis. These plots can be
annotated for e.g. giving names to the columns. E.g. as in the
documentation of the package:

data(dat.bcg)

### meta-analysis of the log relative risks using a random-effects model
res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure="RR",
           slab=paste(author, year, sep=", "), method="REML")

           forest(res, slab=paste(dat.bcg$author, dat.bcg$year, sep=", "),
       xlim=c(-16, 6), at=log(c(.05, .25, 1, 4)), atransf=exp,
       ilab=cbind(dat.bcg$tpos, dat.bcg$tneg, dat.bcg$cpos, dat.bcg$cneg),
       ilab.xpos=c(-9.5,-8,-6,-4.5), cex=.75)
op <- par(cex=.75, font=2)
text(c(-9.5,-8,-6,-4.5), 15, c("TB+", "TB-", "TB+", "TB-"))
text(c(-8.75,-5.25),     16, c("Vaccinated", "Control"))
text(-16,                15, "Author(s) and Year",     pos=4)
text(6,                  15, "Relative Risk [95% CI]", pos=2)
par(op)


However the column names have to be re-positioned everytime the number of
included studies in the meta-analysis changes.
E.g.:

dat.bcg <- dat.bcg[1:12,]

### meta-analysis of the log relative risks using a random-effects model
res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure="RR",
           slab=paste(author, year, sep=", "), method="REML")

forest(res, slab=paste(dat.bcg$author, dat.bcg$year, sep=", "),
       xlim=c(-16, 6), at=log(c(.05, .25, 1, 4)), atransf=exp,
       ilab=cbind(dat.bcg$tpos, dat.bcg$tneg, dat.bcg$cpos, dat.bcg$cneg),
       ilab.xpos=c(-9.5,-8,-6,-4.5), cex=.75)
op <- par(cex=.75, font=2)
text(c(-9.5,-8,-6,-4.5), 15, c("TB+", "TB-", "TB+", "TB-"))
text(c(-8.75,-5.25),     16, c("Vaccinated", "Control"))
text(-16,                15, "Author(s) and Year",     pos=4)
text(6,                  15, "Relative Risk [95% CI]", pos=2)
par(op)

Is there a way to define the colum names' position relatively to the plot
so they would be adequately positioned no matter what is the number of
studies included in the plot?


Many thanks for your help!,
Jokel

	[[alternative HTML version deleted]]

