glin / reactable

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

output as raw html - New feature request #86

Open algo-se opened 4 years ago

algo-se commented 4 years ago

Hi @glin, first congratulations on reactable, I´m loving it. I think it is hands down the best R package to get good looking tables.

I´ve been using reactable with Shiny and it´s just great, but then I´ve tried to use it with blastula and it does not work. However, you can use gt pkg to display HTML tables in blastula beacuse it has a function, as_raw_html() that returns the raw HTML with all the styles inlined.

Would it be posible to add something similar to reactable? I´d really rather use it instead of gt.

Thank you for your work. Best regards, Alejandro.

mattwarkentin commented 4 years ago

I second this. I would love to send automated emails with gmailr using reactable tables.

glin commented 4 years ago

Hi, thanks for the feedback!

I think this is technically possible, but really tough to do, and probably not worth the effort. reactable is rendered entirely via JavaScript, so you'd have to run a headless browser or something like Node.js to generate the HTML. The external table CSS would also have to be converted to inline styles, which is another challenge.

If you want to embed reactable in an email, I would recommend taking a screenshot instead. Or using something like webshot2 to take screenshots automatically: https://github.com/glin/reactable/issues/67#issuecomment-674581250

Alternatively, you can save the table to a file using htmlwidgets::saveWidget() or by rendering a separate Rmd, and attach the file using blastula::add_attachment().

reactable, like other HTML widgets, are heavily dependent on JavaScript for rendering and interactivity. Since most email clients don't allow running JavaScript (including gmail), reactable wouldn't work in an email even if you had the raw HTML. If you just need tables in an email, I'd recommend using a pure HTML table like gt. If you need interactive tables or HTML widgets, I'd suggest attaching or linking to an external page.

algo-se commented 4 years ago

Thank you for the detailed answer. I'll try all the things you've suggested.