How to export summarytools object in R to png

129 Views Asked by At

I have the following line of code which uses summarytools package to generate and view a description table using stby and desc functions

view(stby(meta.data$Age, meta.data$Diagnosis, descr,
          transpose = T, stats = c("mean", "sd")))

The above line generates the following. Table How can I export it to a png file instead of an HTML file?

1

There are 1 best solutions below

0
Till On

summarytools::view() produces a HTML file to be shown in the RStudio Viewer. You can print that file as e.g. PDF or PNG. pagedown::chrome_print() can do that in an automated fashion.

library(summarytools)
library(pagedown)

data("tobacco")

st_exp <- 
  with(tobacco, stby(BMI, gender, descr))

chrome_print(
  view(st_exp, footnote = ""),
  output = "st.png",
  format = "png")