'How to save a non-ggplot plot in R?
I have a forest plot from the package metafor. As it's not a ggplot, I cannot use my favourite ggsave().
I have tried functions like png(filename="forest_plot_bmj.png", res=315, width=3312, height=1228) but the outcome I get is different than what I see in the console output.
What would be your suggestion?
Solution 1:[1]
In base R plots, one needs to define the start of the plotting action e.g. with png and the end of the plotting with dev.off():
library(metafor)
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)
png("out.png")
forest(dat$yi, dat$vi)
dev.off()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | danlooo |
