user3741672 - 1 year ago 370
R Question

# Side-by-side Forest Plot in R

So this is some generic data. I currently use the metafor package and

`par()`
function to make the plots side by side. However, I would like to ideally get rid of the study column in the second graph and the log RR estimates from both plots. I would like both forest plots to be moved closer together as well. Sorry for not providing data previously - I'm new at this.

``````library(metafor)
par(mfrow=c(1,2))

data(dat.bcg)
### calculate log relative risks and corresponding sampling variances
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)
### default forest plot of the observed log relative risks
forest(dat\$yi, dat\$vi)
### default forest plot of the observed log relative risks for second plot
forest(dat\$yi, dat\$vi)
``````

===============================

Does anyone know how to make a side-by-side forest plot in r?
I want to have the subgroup names on the left hand side, then two forest plots immediately to the right (beside each other)
Somewhat like this http://www.nature.com/ng/journal/v43/n8/images_article/ng.882-F1.jpg
but much simpler.

I have tried the
`par()`
function with metafor package but it does not work.

This gets you pretty close:

``````library(metafor)
data(dat.bcg)
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)

par(mfrow=c(1,2))
par(mar=c(5,4,1,1))
forest(dat\$yi, dat\$vi, annotate=FALSE, cex=.8, at=seq(-3,2,1), digits=1, xlim=c(-6,2))
text(0, 15, "Figure 1", cex=.8, font=2)
par(mar=c(5,3,1,2))
forest(dat\$yi, dat\$vi, annotate=FALSE, slab=rep("",length(dat\$yi)), cex=.8, at=seq(-3,2,1), digits=1, xlim=c(-5,3))
text(0, 15, "Figure 2", cex=.8, font=2)
``````

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download