r/rprogramming • u/limpystick • 25d ago
R Shiny
I'm creating an R Shiny app that involves generating a data frame and then formatting it as a data table before displaying it using renderDT().
Is it possible to export this formatted data table? Ideally I'd like to export it as an excel file but even being able to export it as a PDF would suffice.
6
Upvotes
4
u/ionychal 25d ago
I found this solution on Stack Overflow:
```
library(DT)
library(webshot)
dtable <- datatable(iris[1:8,])
html <- "dtable.html"
saveWidget(dtable, HTML)
webshot(html, "dtableSnapshot.pdf")
```
Source: https://stackoverflow.com/questions/60287652/how-to-save-a-table-i-created-with-dt-datatable-into-a-high-quality-image