One option is to use magick::image_montage. The only trick is to create a 2x2 grid and insert a blank image as the 3rd object.
library(magick)
#> Linking to ImageMagick 6.9.12.3
#> Enabled features: cairo, freetype, fftw, ghostscript, heic, lcms, pango, raw, rsvg, webp
#> Disabled features: fontconfig, x11
imgs_url <- c('https://i.stack.imgur.com/TqnwC.png',
'https://i.stack.imgur.com/qIDXh.png',
'https://i.stack.imgur.com/B36ko.png')
imgs <- image_read(imgs_url)
imgs <- c(imgs[1:2], image_blank(width = 3, height = 5), imgs[3])
image_montage(imgs, tile = '2x2', geometry = "x200+3+5")
Created on 2021-07-13 by the reprex package (v2.0.0)
If you want to group the images by name, one way is to capture the above workflow in a function, and add a grepl statement to identify which subset of images to plot.
I don't have all of the images, so this is untested. But it would look something like this.
my_files <- c("bart Cum Oil.jpg",
"bart GOR.jpg",
"bart Legend.jpg",
"bart Oil Rate.jpg",
"lisa Cum Oil.jpg",
"lisa GOR.jpg",
"lisa Legend.jpg",
"lisa Oil Rate.jpg",
"marge Cum Oil.jpg",
"marge GOR.jpg",
"marge Legend.jpg",
"marge Oil Rate.jpg")
# remove oil rate image paths
my_files <- my_files[!grepl('Oil Rate', my_files)]
# create function
make_grid <- function(group, path_to_files){
f <- files[grepl(group, files)]
imgs <- image_read(f)
imgs <- c(imgs[1:2], image_blank(width = 3, height = 5), imgs[3])
image_montage(imgs, tile = '2x2', geometry = "x200+3+5")
}
# create lisa image grid
make_grid('lisa', my_files)
# create all image grids
lapply(c('bart', 'lisa', 'marge'), make_grid, path_to_files = my_files)