Gt: Render gt into a gtable grob

Created on 27 Nov 2019  Â·  2Comments  Â·  Source: rstudio/gt

It would be very nice to put table designs created with gt into figures. For this to be possible gt objects need to be able to be rendered into gtable objects (or another type of grob).

For an example of this functionality (without the gt styling) see gridExtra::tableGrob()

[3] Advanced [3] High [2] Medium ★ Enhancement

Most helpful comment

This is a great feature request, thanks!

All 2 comments

This is a great feature request, thanks!

A workaround until this is implemented is to save the table as PNG and then add this PNG to the plot with e.g. {patchwork}.
(It is probably possible to skip saving to disk, but I'm unsure how).

Example:

tmp <- tempfile(fileext = '.png') #generate path to temp .png file
gtsave(gt, tmp) #save gt table as png
table_png <- png::readPNG(tmp, native = TRUE) # read tmp png file

library(patchwork)
plot_1 + table_png
Was this page helpful?
0 / 5 - 0 ratings

Related issues

thisisnickb picture thisisnickb  Â·  5Comments

vikram-rawat picture vikram-rawat  Â·  3Comments

tbradley1013 picture tbradley1013  Â·  3Comments

vincentarelbundock picture vincentarelbundock  Â·  4Comments

higgi13425 picture higgi13425  Â·  3Comments