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"


#1

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


#2

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!


#3

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


#4

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.


#5

Thanks Chris for clarifying.


#6

Sure thing. Happy to help!


#7

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…


#8

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.
http://r-pkgs.had.co.nz/description.html

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: https://medium.com/@peterjgensler/creating-sandbox-environments-for-r-with-docker-def54e3491a3