If you’re responsible for the administration of R environments, you may have wished for an R equivalent of python’s pip tool for installing packages from the command line.
R was originally designed to be more of an interactive user environment. This means things exist first and foremost within R itself, including the package installation function,
More recently – and particularly since its usage has exploded – R’s user-base and the types of usage have diversified immensely. One such diversification is into production class Linux environments. These types of environments typically have a dedicated support team who may have little or no interest in R. They may also be highly automated, with no interactive administration at all. In these sorts of situations installing R packages interactively is far from optimal.
rip as a sort of R equivalent to pip. Truth be told,
rip doesn’t have nearly as many features but it wraps R’s built in package installation functionality reasonably well.
There’s no installer or anything like that for it yet, so you’ll need to copy the ‘rip.R’ file to your Linux system somewhere and run
chmod +x on it to make it executable.
Once it’s on your system, you can use it on on of three ways…
Installing a list of packages
If you just want to install a list of packages in a single hit, this is the option you want.
./rip -p ggplot2 plumber memoise httr
This will install the packages specified into the standard library for the current user.
As a wrapper for
install.packages() there is quite a lot of output. Use the ‘-q’ option to set
quiet = TRUE on the underlying function. Bear in mind that if an installation fails, this option may hide the reason.
rip also doesn’t do anything to help with any system level dependencies that may be required.
Installing from a file
If you’ve used pip, you may have used its
-r option to install packages from a ‘requirements.txt’ file. We can do something similar with
rip. By default
-r looks for a ‘Rrequirements.txt’ file in the current directory.
The Rrequirements.txt file should contain one package name per line. If you’d like to specify a different file you can use
--file followed by the path to the file, eg.
./rip -r --file /path/to/file.txt
Installing from a DESCRIPTION file
This is similar to the
-r option above, but
-d installs packages listed in the ‘Imports’ section of a package’s DESCRIPTION file. By default it looks for the DESCRIPTION file in the current directory but a different file can be specified using the
Hopefully this option will be useful in continuous integration settings where a package being built needs to have its dependencies installed before testing.