glin / reactable

Interactive data tables for R
https://glin.github.io/reactable
Other
627 stars 80 forks source link

Question: possible to include reachable tables on Wordpress sites? #273

Open heerymichael opened 2 years ago

heerymichael commented 2 years ago

Hi - I have recently been doing some DataViz work for inclusion on a company's website which is published using Wordpress. We have been doing a lot of static tables but would really love to get some interactive tables up using reactable.

I was just wondering is there any guidance or advice how reactable tables can be shared with their website manager and he can publish them?

Thank you for any help you can offer

Michael

glin commented 2 years ago

Interesting question, I bet it's possible but have no experience with this. I did once see a reactable table on my local news channel's website, and they had included it in whatever CMS it was by embedding a separate R Markdown document using an iframe. Even without R Markdown, you can render a barebones reactable table using htmlwidgets::saveWidget():

tbl <- reactable(mtcars)

# With all script dependencies embedded, for a completely self-contained HTML file
htmlwidgets::saveWidget(tbl, "table.html")

# With script dependencies kept in a separate folder, probably better if you want to
# share scripts among several documents
htmlwidgets::saveWidget(tbl, "table.html", selfcontained = FALSE)

With this HTML file, you can either host it and include it on WordPress through an iframe, or manually copy the generated HTML content or something. You might have better luck searching for "using htmlwidgets in wordpress r", since this would be an issue with all HTML widgets, not just reactable. For example, https://stackoverflow.com/questions/42008179/embed-r-leaflet-map-in-wordpress