1

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?

Till
  • 3,845
  • 1
  • 11
  • 18
  • 1
    I think exporting it as a `.png` file might not be a good idea. The package supports export as `.md`/`.html`, and see [here](https://htmlpreview.github.io/?https://github.com/dcomtois/summarytools/blob/master/doc/introduction.html#directing-output-to-files) for how to do it. Note then you can export as `.pdf` files. – Liang Zhang Jul 16 '23 at 16:28
  • @LiangZhang Why do you think so? I am working on a research paper and I need all tables & graphs to be in one file to submit. Also, the table shown above will be posted in the research report (MS Word file). As such, I found `png` to be the most convenient format to use. – ahmed asaleh Jul 18 '23 at 16:28
  • I meant to say that the author does not support to export as `.png`. For me, I think for tables, you could try to export them to excel. Or use {gt} package for word format support. – Liang Zhang Jul 18 '23 at 17:16

1 Answers1

1

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")
Till
  • 3,845
  • 1
  • 11
  • 18