1
votes

I've made a foresplot in r using the metafor package with the following code:

res <- metafor::rma(cohens_d, variance, data = my_data)


par(mar=c(3.4,0,0,0))
par(cex=2.5, font=4)
metafor::forest.rma(res, alim=c(-3.75, 3.75), xlab = "Cohen's D with 95% CI", 
                slab = my_data$Paper)

which gives me the image: forestplot

I'd like to flip the x axis, meaning have the negative on the right. Any ideas on how to do this?

Thank you!

2

2 Answers

1
votes

Okay, this is a really ridiculous hack, but it works. Basically, you have to draw the plot twice, once to add the points (with reversed signs) and once to add the annotations (without the reversed signs).

library(metafor)

dat <- get(data(dat.bcg))
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)
res <- rma(yi, vi, data=dat)

### default plot
forest(res, xlim=c(-8,8))

### trick into reverse x-axis
forest(res, xaxt="n", transf=function(x) -1*x, annotate=FALSE, xlim=c(-8,8), xlab="Log Relative Risk")
axis(side=1, at=seq(-3, 3, 1), labels=seq(3,-3,-1))
par(new=TRUE)
forest(res, xaxt="n", xlim=c(-8,8), col="white", border="white", pch=NA, lty="blank", efac=NA, xlab="", slab=NA, mlab=NA)
par(new=FALSE)
0
votes

I would simply just flip the estimated coefficients of the model (b component of the rma class) prior to plotting:

res <- metafor::rma(cohens_d, variance, data = my_data)
res$b <- -res$b