1

Say you have two tableGrobs of different sizes, and you want the smaller grob to be top aligned. How might you proceed?

Here is an example:


library(gridExtra)

t1 <- cars[1:9,]

t2 <- cars[10:14,]

grid.arrange(tableGrob(t1), tableGrob(t2), ncol = 2)

How do we push the smaller table up?

Kene David Nwosu
  • 828
  • 6
  • 12

1 Answers1

2

You can use gtable_combine() from library(gridExtra) to align the tables. Refer to this link for additional explanation. https://mirror.its.dal.ca/cran/web/packages/gridExtra/vignettes/tableGrob.html

library(grid) 
library(gridExtra)
t1 <- cars[1:9,]
t2 <- cars[10:14,]
grid.arrange(gtable_combine(tableGrob(t1), tableGrob(t2), along=1), ncol = 1)
  • Welcome to Stack Overflow. Please [edit] your answer to explain what this code does and how it answers the question, so that it is useful to the OP as well as other users with similar issues. Code-only answers are discouraged on Stack Overflow because they don't explain how it solves the problem. – FluffyKitten Oct 05 '20 at 05:34
  • My apologies. Updated! – Maad scientist Oct 06 '20 at 17:16