rempsyc / busara_dashboard

The Missing Majority in Behavioural Science Dashboard
https://remi-theriault.com/dashboards/missing_majority
1 stars 0 forks source link

Add shiny to dashboard for interactive data vizualisation #10

Open rempsyc opened 7 months ago

rempsyc commented 7 months ago

One reviewer noted,

A wish list (which may not be technically possible), would be on the home page for you to be able to check the journals you want to include and then have the waffle plot dynamically update.

And another noted,

I guess the more advanced version of this would be if the website let users pick what variables to plot and let us make new graphs

For interactive data vizualisation, it might be possible to use Shiny in compatibility with flexdashboard: https://pkgs.rstudio.com/flexdashboard/articles/shiny.html

rempsyc commented 2 days 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.

and

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 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?

psforscher commented 2 days ago

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: @.***>