Is renv suitable for this project?

Hi all

I have created a R Shiny app. I use lot of different packages.

library(shiny)
library(shinybusy) #loading icons, process bars...
library(fontawesome) #icons in menus
library(shinyWidgets) #dropdowns, checkbox...
library(lubridate) #working with datestamps
library(tidyverse) #fluient interaction
library(ggplot2) #high-end visualizations
library(shinythemes) #overall theme of the app
library(celestial) #common astronomy conversion routines
library(data.table) #working with data/tables
library(shinyBS) #pop-ups
library(tidyr) #reshaping datasets

I want to share the app over the colleagues on their pc, when installing R studio and opening the script for the first time, the app suggest in a yellow banner on top of the code to install the needed packages.
This is a quick fix, but I know their is a possibility to use renv and take a snapshot of the used packages and their versions.
I have already read a lot of information on the internet, but I can't figure out how it exactly works.

This is what I think:
After the library section, I need to mention the renv::snapshot command to save all the packages and their version, but what do I need to do after that? Can I already send the app to the colleagues, how do they use the reproducible environment? Maybe the yellow banner is sufficient for this project?

I have found this info in a course:

Thanks in advance!

This video may help you fine-tune your set-up Using renv to track the version of your packages in R (CC229) - YouTube

If you are going to distribute the app as source code for others to run on their own computer I think you could run renv::isolate() to make a hard copy of the used packages into the project library and share the whole project folder (including the package library) but this will only work if the other people has at least the same major R version. It is not a robust solution.

This scenario is usually solved by sharing your app as a Docker container to ensure reproducibility and portability but this adds a significant degree of complexity. There is always a tradeoff.

An alternative, which is also the way shiny apps are intended to be used, is to deploy your app to a server, either locally or in the cloud, so your colleagues can simply access the app through a web browser without having to I install anything.

Also, as a side note, you might want to check the packages you are loading, for example, by loading tidyverse which is a package agregator (that already includes ggplot2, tidyr and lubridate) , you are indirectly loading a bunch of possibly unnecessary packages which is un efficient.

This topic was automatically closed 54 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.