user3741672 - 6 months ago 150

R Question

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

`par()`

`library(metafor)`

par(mfrow=c(1,2))

### load BCG vaccine data

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()`

Answer

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)
```