shawnl
shawnl

Reputation: 1939

grid.arrange align all tables to the top in Rmarkdown

How do I align all tables in grid.arrange to top? The tables seem to mid-align by default.

df1 = data.frame(x=c(1, 2, 3), y=c('a', 'b', 'c'))
df2 = data.frame(x=rep(1, 10), y=rep('a', 10))
grid.arrange(tableGrob(df1), tableGrob(df2),
             nrow=1, ncol=2)

enter image description here

Upvotes: 4

Views: 953

Answers (1)

Adam Quek
Adam Quek

Reputation: 7153

g1 <- tableGrob(df1)    
g2 <- tableGrob(df2)

grid.draw(combine(g1, g2, along=1))

enter image description here

Upvotes: 5

Related Questions