Let's say that I just created 4 histograms in ggplot2. After finishing, I realized that I should have used grid.arrange to combine some of the plots into a single graphics device. There is the png and jpeg packages in CRAN, both of which can be used to overlay graphics on a plot. Besides rerunning the visualizations again, are there packages in R that can be used to import multiple png files and then used to arrange a graphics device with each of them on it?
Here's some sample code, though the visualization are all the same.
df = data.frame(one=c(1,3,5,6,7,3,4,5,2,5,3,1,2))
df
library(ggplot2)
p1 = qplot(one, data=df, geom="histogram")
p2 = qplot(one, data=df, geom="histogram")
p3 = qplot(one, data=df, geom="histogram")
p4 = qplot(one, data=df, geom="histogram")
png("my_viz1.png")
p1
dev.off()
png("my_viz2.png")
p2
dev.off()
png("my_viz3.png")
p3
dev.off()
png("my_viz4.png")
p4
dev.off()
rl = lapply(sprintf("my_viz%i.png", 1:4), png::readPNG)
gl = lapply(rl, grid::rasterGrob)
gridExtra::grid.arrange(grobs=gl)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With