I have a markdown document using a bit of LaTeX to produce a .pdf with the following chunk:
grid.arrange(
grobs = list(
gtable_combine(
gtable_add_grob(
tableGrob(mtcars[1:3, 1:2], rows = NULL),
grobs = segmentsGrob(y1 = unit(0, "npc"),
gp = gpar(fill = NA, lwd = 2)),
t = 1,
l = 1,
r = ncol(mtcars[1:3, 1:2])
),
gtable_add_grob(
tableGrob(mtcars[1:3, 1:2], rows = NULL),
grobs = segmentsGrob(y1 = unit(0, "npc"),
gp = gpar(fill = NA, lwd = 2)),
t = 1,
l = 1,
r = ncol(mtcars[1:3, 1:2])
),
along = 2),
gtable_add_grob(
tableGrob(mtcars[1:8, 1:2], rows = NULL),
grobs = segmentsGrob(y1 = unit(0, "npc"),
gp = gpar(fill = NA, lwd = 2)),
t = 1,
l = 1,
r = ncol(mtcars[1:8, 1:2])
)
),
ncol = 2
)
The output is centre aligned, and I would like it aligned at the top. My sticking point is that the left hand side is two combined tables already, and I seem to be unable to nest the output of that function into another cal to gtable_combine()
. I also haven't had any luck using the layout_matrix=
argument in gridExtra, as this adds a huge amount of space between the left two tables.
How can I have the left two tables very close (adjoined is fine), and also have the top of the top-most left table and the top of the right table horizontally aligned?