Installing R Packages So They Are Available For All RStudio Server Users & Understanding CRAN Fields "Imports" Vs "Reverse Depends" Vs "Reverse Imports" Vs "Reverse Suggests"

Hello,

We are in the initial stages of building a RStudio Server Pro environment. Based on feedback from our R users, I am trying to put together a list of R packages that we will want to make available for all users of the RStudio IDE by default.

As a newbie to R, I'm having trouble identifying from CRAN what the prerequisite R packages are for each R package.

For example the R package forecast

On its CRAN page I see R packages listed in the fields:

Imports:
LinkingTo:
Suggests:
Reverse depends:
Reverse imports:
Reverse Suggests:

So on our RStudio server, if we execute this command from the R console > install.packages("forecast"), what fields from the CRAN page above actually list the R packages that will be installed?

Thanks Stuart

If you execute install.packages("forecast"), with no additional arguments, R will check to see that the packages in Depends, Imports, and LinkingTo are installed. If packages in these fields aren't installed, or if R can't find them in your library trees/paths, R will install them for you. Packages found in the existing search paths will not be re-installed. Hope this helps!

1 Like

Thanks Chris, what about the "Reverse" depends, imports & suggests?

Similar to how the forecast package depends on and imports other packages in order for it to function properly, other packages depend on and import the forecast package. “Reverse depends/imports” refers to this latter situation.

1 Like

Thanks Chris for clarifying.

1 Like

Sure thing. Happy to help!

While it is not really answering your question, I think such a setup is a bad habbit and will eventually fail if its the only solution (its a good foundation). Especially when packages on the server have different versions and probably different functionality.
Project specific dependencies are much better... and can support things like CI and if you want to go in the direction of DevOps.
As I am using a Shiny Server Pro as well I put my ideas up for discussion:

Probably I'm wrong though with my views as unfortunately no one really replied to my thread so far...

1 Like

I think this excerpt from R Packages describes in good detail the intent of each of the respective fields for what a package needs to run.

One clean way to view what is truly necessary for a package is by attempting to build it from source (either from CRAN or from Github):

#Build source code from CRAN
install.packages("forecast", type = "source" )

I'm not an admin by any means, BUT I would strongly recommend that you consider using Docker to orchestrate building your RStudio Server Pro environment, especially with packages like forecast so that you can easily keep track of packages installed, in addition to any system libraries necessary (prophet is a good example, as it needs a particular compiler with some system libraries)

If you would like more info on Docker, I have put together a blog post here which is a tutorial for beginners on getting started: Creating Sandbox Environments for R with Docker | by peterjgensler | Towards Data Science

1 Like