This is probably a very simple question, but I am not familiar with the images in R.
I want a PDF file with two related imported images and a data frame, as shown in the image:

This is the code that I use but does not work.
library(grid)
library(useful)
library(magick)
imageA <- image_read("imageA.jpg")
imageB <- image_read("imageB.jpg")
df <- data.frame(1:3)
pdf("/Mydocument.pdf", width = 10, height = 20)
grid.newpage()
pushViewport(viewport(layout = grid.layout(1, 3)))
print(imageA, vp = vplayout(1, 1))
print(imageB, vp = vplayout(1, 2))
print(df, vp = vplayout(1, 3))
dev.off()
source
share