Adding R dependencies to your project

andrea.loweandrea.lowe Member, Moderator, Domino Posts: 17 mod

If you are working in R, an alternative to using Domino environments is to install packages into your project itself, so that the package installations persist between runs of your project. While this will be less performant than using a compute environment, it's easy to implement while developing projects. To do so, you should install packages to a subfolder inside your Domino project and tell R to look in that folder when it loads packages. E.g.,

dir.create("rlibs")
.libPaths("rlibs")
install.packages("some.package", dependencies=TRUE, repos='http://cran.us.r-project.org')

Then, in the scripts that you want to normally run (e.g. main.R), tell R to look in your rLibs directory if it can't find a package in the standard location, by using this command:

.libPaths(c(.libPaths(), "~/userLibrary"))

This way the packages will be loaded from the project dir without the need to install on every run.

Sign In or Register to comment.