saving nicely formatted htmlTable as image

hi all,

I had a set of summary stats in an excel table and I used
htmlTable() to format them for a paper. Now how can I save it as an image to put into my paper? This is what it looks like

It would be preferable not to have to recreate the table using some other function that has an output argument.

heres my code
thanks!

table <- htmlTable(data, header=c("Variable", "Mean", "Standard Deviation", "Source"), rnames=FALSE,
                   align="left", rgroup=c("County Demographics", "County Economics", "COVID-19",
                                          "Clusters"), n.rgroup=c(8,3,2,37))

Hi,

I think this should be possible using the save_kable function from the kableExtra package together with the magick package for converting it to an image.

library(htmlTable)
library(kableExtra)
library(magick)

htmlTable(mtcars[1:10, 1:5]) %>%
 save_kable(file = "test.png")

Hope this helps,
PJ

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.