Join images with data frames in r

Viewed 2360

This is probably a very basic question, but I am not familiar with images in R.

I want a PDF file with two joined imported images and a data frame as the image exemplifies:

Final output

This is the code that I am using but is not working.

library(grid)
library(useful)
library(magick)

# Read external images
imageA <- image_read("imageA.jpg") 
imageB <- image_read("imageB.jpg") 

# Create data frame
df <- data.frame(1:3)

# Create PDF
pdf("/Mydocument.pdf", width = 10, height = 20)
grid.newpage() 

# Create matrix layout
pushViewport(viewport(layout = grid.layout(1, 3)))

# Place elements inside grid
print(imageA, vp = vplayout(1, 1)) 
print(imageB, vp = vplayout(1, 2))
print(df, vp = vplayout(1, 3)) 

dev.off()
1 Answers
Related