Deploying R Shiny App as a Standalone Application

Deploying R shiny app as a standalone application

There is now a way to turn a Shiny app into a standalone Electron app (which is a desktop app, used for apps like Slack). To find out more, see this excellent presentation (YouTube) from useR 2018, which contains further links:

  • GitHub ColumbusCollaboratory: electron-quick-start

  • GitHub ColumbusCollaboratory: Photon. RStudio Add-in to build Shiny apps utilizing the Electron framework

  • @TravisHinkelman's blog "Deploying a Shiny app as a desktop application with Electron"

Mobile shiny app that runs offline, no connectivity

For an epidemiological cohort study, a Shiny app was developed to run completely offline in Android mobile devices. The app was designed for field level data capture. The code to setup the Android devices so that the Shiny app runs locally, offline, was published in GitHub, https://github.com/dmrodz/htrack. The installation_and_dependencies section contains the setup needed for the mobile device to run R (and the app) and deploy in the default browser (offline/locally).

The development of this app was peer-reviewed:

Rodríguez, D.M., Ryff, K., Sánchez-Gonzalez, L., Rivera-Amill, V., Paz-Bailey, G., Adams, L. (2020). HTrack: A new tool to facilitate public health field visits and electronic data capture. PLoS ONE 15(12): e0244028. https://doi.org/10.1371/journal.pone.0244028

Deploying a development version of a shiny app to shinyapps.io

I think there's no way to have one app installed with both a production and development version. I use RStudio Connect (should be similar enough to shinyapps.io), and we push to two different apps with similar names. That is, one might use each of the following depending on your updates:

rsconnect::deployApp(..., appName="MyApp")
rsconnect::deployApp(..., appName="MyApp_dev")

While I think it would be awesome to have a feature that "copies app A over app B" so that, when ready, you could just copy "MyApp_dev" over "MyApp" automatically, but ... I can't see that feature being incredibly useful all the time, so once we've confirmed that the dev version is sufficient, we push the code to "MyApp" without any updates from the dev code.

possible to run RShiny app without opening an R environment?

RStudio != R

There is a simple command-line interface to R, which you can run on Windows by running R.exe in the bin folder of your R installation.

There's also Rscript.exe, which can run an expression or a script file. For example:

C:\Program Files\R\R-2.15.2\bin\RScript -e hist(runif(1000))

will (given the right paths) create a PDF file with a histogram in it.

So,

  • your co-worker needs an R installation
  • you need that installation to have all the packages to run shiny
  • or you add a bunch of install.packages() lines to your code
  • you need to give them a folder with your shiny code
  • you add a windows .BAT file for them to click
  • they run that, it calls Rscript.exe which starts the shiny package you gave them

Or get it hosted on the RStudio guys' public shiny server, but then we can all see it.



Related Topics



Leave a reply



Submit