In today's post I want to go over RInno for deploying Shiny apps to desktop as well as the benefits and how to get it all going. The My Understanding series is my attempt at writing concise guides for my future self on how to do complicated or infrequent jobs. The RInno package allows for installation of shiny apps onto computers acting as a bridge between R, Inno Setup, windows installers and Electron. This provides an alternative deployment solution to potentially IT heavy processes like Docker or running a Shiny server. I've really enjoyed working with Rinno and wanted to expand on the set-up process.
In general if you're looking to utilize Rinno as a deployment strategy for Shiny apps I'm going to assume that you have some experience with them. Additionally, I found myself having to use R 3.6.3 as the package has not been updated to the newest versions of R. For best reproducibility I recommend using this version (it really doesn't like version 4).
I ran into problems when initially attempting to install Rinno apparently due to using a 64bit OS. I eventually figured out what to do based on an issue on the github. This is how we get Rinno onto our computer instead of a normal install.packages() call.
#install.packages('installr')
require(installr)
install.inno(quick_start_pack = TRUE)
library(Rinno)
As mentioned earlier RInno at the time of writing hasn't been updated to cooperate with version 4 of R and onwards. Normally this may not be a problem but here it is, as the functions we'll be using later need to know what the most current version of R is. The solution I found, sourced again from the github is that we manually update the get_R() function to make sure its knows R version 4.0 and up exists. The downside to this solution is that it's temporary and needs to be done every session. We use trace() to pull up the definition of get_R() and replace the instances of "1-3" with "1-4" since right now it only looks for versions of R that start with 1-3.
trace(get_R,edit=T)
#Affected sections:
# latest_R_version <- readLines("https://cran.rstudio.com/bin/windows/base/",
# warn = F) %>% stringr::str_extract("[1-3]\\.[0-9]+\\.[0-9]+") %>%
# stats::na.omit() %>% unique()
# old_R_versions <- readLines("https://cran.rstudio.com/bin/windows/base/old/",
# warn = F) %>% stringr::str_extract("[1-3]\\.[0-9]+\\.[0-9]+")
The RInno package includes everything we need to make a quick example if you don't have a shiny app on hand. This is also what we'll be using here. It’s a simple function to generate the example app, after that we'll create the app, then lastly, compile it. You will likely want to observe your working directory after running each line of code so you can see what things are being added or changed.
example_app(app_dir = "app")
create_app(app_name = "myapp", app_dir = "app")
compile_iss()
There are a large number of arguments to create_app() that can be (found here)[https://www.ficonsulting.com/filabs/RInno] and include things like: including company information, password protection, including R and/or packages in the installation, changing the icons, and custom messaging among other things. Once the folder has been compiled we've got our installer. This is what we would give to anyone who was installing our app.
Now we're going to give a quick check that it works by installing it on our own computer. In the apps folder (in our example its "app") there's a lot more stuff now. The installer is in the Rinno_installer folder and will have the name setup_app (or whatever the app's name is).
You can install the app like you would any normal program. One thing of note is that the app will throw an error whenever it tries to create icons or shortcuts, meaning 1-2 errors at the end of installation. These errors simply inform you that these shortcuts were not created. I have no idea how to avoid these errors, if you find a way please let me know. But, once clicking through the errors we should be able to launch the app; either from the end of the installer or from where the app was installed (by default its in the Documents folder). Once the app opens up you'll be able to see the final result and that will be the birth of your app!
There's a lot more you can do with Rinno so you can check out these extra resources. I was unable to find any sort of tutorials other than the minimal example provided by the publisher but it shows a lot of the customizability of Rinno that I only glossed over here.
RInno project website https://www.ficonsulting.com/filabs/RInno
RInno project github https://github.com/ficonsulting/RInno
Shiny meets Electron: Turn your Shiny app into a standalone desktop app in no time https://youtu.be/ARrbbviGvjc