I've been pulling my hair out for the past week trying to figure out elementary R coding but can't seem to get anywhere (haven't used R since 2013 not that its a great excuse).
All I want is a 4x8 grid made up of 32 .png files (maps I've made), and I want to do it without loading one image file at a time (http://www.statmethods.net/advgraphs/layout.html).
So I think I can load the images within the folder writing (please correct me if my beliefs are bs)
img <- list.files(path='c:/a',patt='compo[0-32].*',full.names=T)
Then I was thinking maybe in the lines of par(mfrow=c())
, layout
, grid.arrange
(writing png plots into a pdf file in R), grid.raster
(How to join efficiently multiple rgl plots into one single plot?) - which I've read up on and experimented with accordingly not resulting in anything worthwhile..
The latter I employed only with the following outcome
It made me giggle.
I don't really think lattice
is the way to go anyway.
Any help would be greatly appreciated!
Another approach is to read the PNG images with readPNG then use grid and gridExtra:
library(png)
library(grid)
library(gridExtra)
plot1 <- readPNG('plot1.png')
plot2 <- readPNG('plot2.png')
grid.arrange(rasterGrob(plot1),rasterGrob(plot2),ncol=1)