coatless / quarto-webr

Community developed Quarto Extension to Embed webR for HTML Documents, RevealJS, Websites, Blogs, and Books.
https://quarto-webr.thecoatlessprofessor.com/
394 stars 19 forks source link

[Q&A]: How to show interactive outputs (from plotly or reactable) using quarto-webr ? #195

Closed JauntyJJS closed 7 months ago

JauntyJJS commented 7 months ago

What's your question?

Hi,

I am new to webR and have managed to create this document https://jauntyjjs.github.io/fertility_webr/. The source code is in the index.qmd of this GitHub repository, https://github.com/JauntyJJS/fertility_webr.

Unfortunately, I seem to have some difficulties running codes that uses reactable or plotly.

For example, there is no error in seeing the output of fertility_rate_data directly

image

But when I run the code below, it gives this error message Error: 'browser' must be a non-empty character string

image

instead of this

image

May I ask if some extra steps need to be done ?

Thank you for your time

coatless commented 7 months ago

@JauntyJJS thanks for the question! One quick note, webR is the main project that quarto-webr is derived from so I've modified the title slightly to reflect that.

Regarding the questions:

reactable

Support for reactable isn't likely to be supported anytime soon in the near term as it requires implementing a viewer window similar to RStudio to support the browser() call. Plus, this would require deploying the HTML file using a communication channel of "shared-array-buffer" instead of the default "post-message" since the default does not have support for the browser() functionality.

https://quarto-webr.thecoatlessprofessor.com/qwebr-communication-channels.html

plotly

For plotly to work, we would likely need to set up a new listener and have the plotly graph be converted to JSON to so that it can be constructed correctly.

In conclusion

In short, there isn't a way to use either reactable or plotly libraries under the quarto-webr cell paradigm. You can potentially use it by directly working with webR.