Open rempsyc opened 7 months ago
@psforscher at first I got excited when I read that it was possible to embed shiny
code within rmarkdown
html files and flexdashboard
, e.g.
### Embedded Shiny apps Besides embedding individual Shiny inputs and outputs in R Markdown, it is also possible to embed a standalone Shiny application within a document.
Using shiny with flexdashboard
By adding Shiny to a flexdashboard, you can create dashboards that enable viewers to change underlying parameters and see the results immediately, or that update themselves incrementally as their underlying data changes (see
reactiveFileReader
andreactivePoll
). This is done by addingruntime: shiny
to a standard flexdashboard and then adding one or more input controls and/or reactive expressions that dynamically drive the appearance of the components within the dashboard. Using Shiny with flexdashboard turns a static R Markdown report into an Interactive Document.
However, a bit lower we can also (disappointingly) read:
It’s important to note that interactive documents need to be deployed to a Shiny Server to be shared broadly (whereas static R Markdown documents are standalone web pages that can be attached to emails or served from any standard web server).
Which is also confirmed by this RStudio help forum where a person had the same issue as we do:
Let's recall that a shiny document can't be rendered to a static html file like you can in a static website. It is way of creating shiny app from a single Rmd document, but it is still require to be hosted and run when consulted.
and
Note: If you are familiar with R Markdown, you might expect RStudio to save an HTML version of an interactive document in your working directory. However, this only works with static HTML documents. Each interactive document must be served by a computer that manages the document. As a result, interactive documents cannot be shared as a standalone HTML file.
So it seems we will have no choice but to rely on a shiny server of some sort. In the forum they also mention:
Know that, for including an app into a static document or website, like a bookdown, you can host the shinyapps somewhere (like shinyapps.io ) and include it in the document with
knitr::include_app
. see 2.11 Web pages and Shiny apps | bookdown: Authoring Books and Technical Documents with R Markdown
So perhaps it is possible to keep the flexdashboard infrastructure, host the shiny app elsewhere, and then embed it inside like described above...
In any case, it IS possible to deploy a shiny app on our own servers, and there are detailed instructions to this effect (example), but this is too complex even for someone like me. Do you have any specialized IT person at your organization which could help us set this up?
Yes, we do have a software team to work on projects like this. Let me consult with the software lead to get an estimate of the scope of work.
On Mon, Sep 9, 2024 at 7:25 PM Rémi Thériault @.***> wrote:
@psforscher https://github.com/psforscher at first I got excited when I read that it was possible to embed shiny code within rmarkdown html files and flexdashboard, e.g. https://bookdown.org/yihui/rmarkdown/shiny-embedded.html
Embedded Shiny apps
Besides embedding individual Shiny inputs and outputs in R Markdown, it is also possible to embed a standalone Shiny application within a document.
and https://rstudio.github.io/flexdashboard/articles/shiny.html
Using shiny with flexdashboard
By adding Shiny to a flexdashboard, you can create dashboards that enable viewers to change underlying parameters and see the results immediately, or that update themselves incrementally as their underlying data changes (see reactiveFileReader and reactivePoll). This is done by adding runtime: shiny to a standard flexdashboard and then adding one or more input controls and/or reactive expressions that dynamically drive the appearance of the components within the dashboard. Using Shiny with flexdashboard turns a static R Markdown report into an Interactive Document.
However, a bit lower we can also (disappointingly) read:
It’s important to note that interactive documents need to be deployed to a Shiny Server to be shared broadly (whereas static R Markdown documents are standalone web pages that can be attached to emails or served from any standard web server).
Which is also confirmed by this RStudio help forum https://forum.posit.co/t/embedding-shiny-with-inline-not-rendering-with-html-output/41175/4 where a person had the same issue as we do:
Let's recall that a shiny document can't be rendered to a static html file like you can in a static website. It is way of creating shiny app from a single Rmd document, but it is still require to be hosted and run when consulted.
and
Note: If you are familiar with R Markdown, you might expect RStudio to save an HTML version of an interactive document in your working directory. However, this only works with static HTML documents. Each interactive document must be served by a computer that manages the document. As a result, interactive documents cannot be shared as a standalone HTML file.
So it seems we will have no choice but to rely on a shiny server of some sort.
In the forum they also mention:
Know that, for including an app into a static document or website, like a bookdown, you can host the shinyapps somewhere (like shinyapps.io ) and include it in the document with knitr::include_app. see 2.11 Web pages and Shiny apps | bookdown: Authoring Books and Technical Documents with R Markdown https://bookdown.org/yihui/bookdown/web-pages-and-shiny-apps.html
So perhaps it is possible to keep the flexdashboard infrastructure, host the shiny app elsewhere, and then embed it inside like described above...
In any case, it IS possible to deploy a shiny app on our own servers, and there are detailed instructions to this effect (example https://docs.posit.co/shiny-server/), but this is too complex even for someone like me. Do you have any specialized IT person at your organization which could help us set this up?
— Reply to this email directly, view it on GitHub https://github.com/rempsyc/busara_dashboard/issues/10#issuecomment-2338552168, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDVEV6ZN6LW2J3YTURZM3PLZVXDRFAVCNFSM6AAAAABN45AGQ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZYGU2TEMJWHA . You are receiving this because you were mentioned.Message ID: @.***>
One reviewer noted,
And another noted,
For interactive data vizualisation, it might be possible to use Shiny in compatibility with
flexdashboard
: https://pkgs.rstudio.com/flexdashboard/articles/shiny.html