How to install R packages with many dependencies
Installing one R-package in Sandbox's R can be done manually see here.
However, if the package requires other dependent packages which themselves require other packages, the list of packages to install manually becomes unworkable.
We show here a three-step solution. First, an R script ran on your local machine's RStudio downloads and zips all the dependencies of a given package. This zip is imported into Sandbox. Finally, an R script ran on Sandbox's RStudio unzips and installs the given package and its dependencies.
Step 1: Get packages and dependencies
Run the following script in an R session in your local machine with a connection to the internet.
Assign to list_packages
the list of packages you want to install.
Optionally you can specify the working forder in working_path
. If not, a temporary folder will be created and used.
If succesful, the script will tell you the location of the created zip file. This zip includes the given package names and its dependent packages.
Step 2: Upload the zipped packages to Sandbox
To upload the newly created zip into Sandbox follow the following instructions here
Step 3: Unzip and install in Sandbox
Once the zip file is uploaded in Sandbox and visible in /finngen/green
, you can run the following script in an R session in the sandbox.
Assign to packages_zip
the path to the zip that you just uploaded.
Optionally you can specify the working folder in working_path
. If not, a temporary folder will be created and used.
(destination_library <- .libPaths()[1]
should give you the local library path, but change it if you get errors)
Last updated