Installing R packages through postInstall
A few notes on flags and parameters you may need to add
In general, don't do this. Most of the time, Code Ocean's available package managers will be simple and quick to use.
You may need to use the postInstall script, however, if you:
Need to install packages in a very specific order.
Build packages that are no longer on CRAN (installing them from archives).
Add parameters to
devtools::install_github()
, such assubdir=
.
This help article includes some code snippets and an example that may help.
Set helpful options
At the top of your script, put the following:
This will address a variety of installation issues you'd have otherwise (likely) encountered. (You don't need to use the official CRAN mirror.)
Set the tar command
In your Rscript
command(s), include Sys.setenv(TAR = '/bin/tar');
.
Write everything as one string of commands
To avoid setting the same parameters multiple times, string R commands together with the delimiting character ;
a \
character will allow multi-line commands. For instance, your final script might look like this:
This script sets the necessary options and then installs packages all at once.
Last updated