0

I want to print two table (3x2 and 2x3) at the top of a PDF page next to each other. The following code prints them in the centre despite pagecentre = FALSE:

      tab2 <- tableGrob(df2)
      tab3 <- tableGrob(df3)

      pdf("file.pdf", height = 20, width = 15, pagecentre = FALSE)
      grid.arrange(tab2, tab3, ncol = 2, nrow = 1))
      dev.off()

How do I fix this using layout()? I looked at the function but can't understand how the to set the matrix.

I'd also like to add table titles. Do I do this with using a data frame function or while writing to df to pdf?

jay.sf
  • 60,139
  • 8
  • 53
  • 110
HelpWithR
  • 17
  • 4
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Mar 12 '21 at 04:32
  • You probably can't, since `layout()` is designed for R base graphics. Try `gridExtra::grid.arrange()` instead. – jay.sf Mar 12 '21 at 05:02
  • @jay.sf when I use grid.arrange() like in the code above, it prints the two tables next the each other in the centre of the page. I want to know if there's a way to move them around the page by defining the x and y axis (like in grid.text()) – HelpWithR Mar 12 '21 at 06:58
  • Please study MrFlick's source first, otherwise we can't help you. – jay.sf Mar 12 '21 at 09:35

0 Answers0