Best way to embed R-generated content into a website

I have a Drupal website and want to publish in it a R-generated content. The content is basically static (no user interaction) containing some text and some charts. Data will be pulled out of database and content actualised in regular intervals (once a week say).
What is the best way to achieve this please?
I know there is a new package WebR, but it seems to be not trivial to make it work and I need some quick solution.
I was considering the Flexdahsboard and embedding it into Drupal page via iframe. Is it a good solution or are there better ways?
How to achieve the regular data actualisation, re-run the code at regular intervals?
Thanks in advance for any advices or suggestions...

The point of webR (and Shiny similarly) is to allow interactivity: the user can rerun R code themselves.

In your case, you just need to pre-generate some html and integrate it in a Drupal website. As I don't know Drupal, not sure about the best way, I think flexdashboard (that is rendered by Rmarkdown) can work. The current state of the art also includes quarto. I would say the difference is that quarto is good for creating a linear document (possibly quite long, mixing text, plots, and tables), flexdashboard is more about having a few components (typically plots and tables) side-by-side. Both get rendered into an html file that I imagine can be integrated in an iframe (but that's more a Drupal question).

In practice, flexdashboard and quarto function pretty much the same way: the R code is run, creating a markdown document, that is then processed by pandoc to get the html.

For the data actualization, I would go with a simple cron job.

Thank you @AlexisW, I understood most of the stuff you wrote. I heard of quarto, but do not have much experiences with it and would go with the Flexdashboard this time.
But, I still I can't imagine all the details of the workflow, how to make it work. When working on computer, I can create the flexdashboard and embed it into Drupal. But I don't want to do this each time manually, but automate it (probably using cron job as you mentioned). Saying this, I need to have the R code which creates the flaxdasboard available somewhere on the Internet, so it accessible by cron. Also, I guess it needs to have some IP or url, which I could embed as iframe into Drupal. And this is the part I can't figure out right now.
Any ideas please?

No problem, just to let you know, {Rmarkdown} is an R package that does this rendering from R + markdown to pure markdown, followed by a call to pandoc to make html. Flexdashboard is an extension to {Rmarkdown} to customize the output format. quarto is a re-implementation of {Rmarkdown} not as an R package, that can handle more languages etc. If you take a flexdashboard document and change its output format to html instead of flexdashboard, you'll have a standard Rmarkdown document, that you can also run through quarto.

That depends a lot on your setup. Where are Drupal, the database, and R installed? Will you pull into an iframe from a database entry, or do you need an html file on disk?

If Drupal is on a server you control (e.g. a vps), you could have this server run both Drupal and R, and the whole problem is just moving the results of the dashboard rendering to the right place on disk or database.

If R is running on a different server (that can always be accessed from the Internet), you could make the result of the rendering available through a plumber API. So on your Drupal server you'd have a cron-run process that calls the Plumber API to ask it to generate a fresh dashboard and receive the results.

You could also have R itself (called by cron on its own computer), that generates the report, and then contacts the database to update it, e.g. using DBI, or directly transfers an html file to the Drupal server using scp or similar.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.