简体   繁体   中英

Plot side-by-side forest plots using forest function in meta package

I'd like to be able to plot side by side forest plots using the forest() function in the meta package in R. I have successfully done this using the forest.default() function in the metafor package, but I prefer the forest() plots generated using the meta package. Here is what I have tried so far:

oldpar <- par(mfrow=c(1, 2)) 
oldpar
res <- metagen(TE=sens, seTE=sens.se, data=df, studlab=study) 
forest(res, data=df, method.tau="REML", comb.random=TRUE, 
leftcols="studlab", rightcols=c("effect", "ci") 
res2 <- metagen(TE=sens2, seTE=sens.se2, data=df, studlab=study) 
forest(res2, data=df, method.tau="REML", comb.random=TRUE, 
leftcols="studlab", rightcols=c("effect", "ci")

I have also tried:

par(mfrow=c(1,2))
par(mar=c(5,4,1,1))
res <- metagen(TE=sens, seTE=sens.se, data=df, studlab=study)
forest(res, data=df, method.tau="REML", comb.random=TRUE, 
leftcols="studlab", rightcols=c("effect", "ci")
par(mar=c(5,3,1,2))
res2 <- metagen(TE=sens2, seTE=sens.se2, data=df, studlab=study)
forest(res2, data=df, method.tau="REML", comb.random=TRUE, 
leftcols="studlab", rightcols=c("effect", "ci")

Finally, I have tried to work with the "grid" and "lattice" packages to no avail. When I attempt to store the plots as objects, they come up as "NULL" in the global environment.

Both of those methods have worked on other types of plots, but inexplicably do not appear to work for the forest plots generated by the forest function in the meta package.

Please let me know if you have a solution to this.

Thank you!

Update - the structure of my dataset:

structure(list(study = 1:7, sens = c(0.88, 0.86, 0.75, 0.9, 0.91, 
0.93, 0.98), sens.se = c(0.13, 0.08, 0.2, 0.06, 0.13, 0.15, 0.66
), sens2 = c(0.76, 0.68, 0.9, 0.82, 0.76, 0.85, 0.76), sens.se2 = c(0.14, 
0.08, 0.2, 0.06, 0.14, 0.15, 0.66)), class = "data.frame", row.names = 
c(NA, -7L))

Here a reproducible example using the dataset available in meta. As stated in the comments meta use very nice plot utilities but they are available in grid graphics system.

library(meta)
library(vcd)
library(gridGraphics)
library(gridExtra)

data(Olkin95)
meta.olkin95 <- metabin(event.e, n.e, event.c, n.c,
                        studlab = paste(author, year),
                        data = Olkin95, subset = c(41, 47, 51, 59),
                        method = "Inverse")
forest(meta.olkin95, comb.fixed = F)
plot.olkin95 <- grid.grab()

data(Fleiss93cont)
meta.fleiss93 <- metacont(n.e, mean.e, sd.e, n.c, mean.c, sd.c,
                          studlab = paste(study, year),
                          data=Fleiss93cont, 
                          sm="SMD")
forest(meta.fleiss93, comb.fixed = F)
plot.fleiss93 <- grid.grab()

grid.newpage()
grid.arrange(plot.olkin95, plot.fleiss93, ncol=1)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM