Adding R dependencies to your project

In most cases, our standard approach to installing packages works well. The disadvantage of this approach is that your packages install each time your code runs — and this can problematic if your packages take a very long time to install.

Our first-class solution to solving this problem is our compute environments: In addition to environments we manage, we also allow you to make your own custom compute environments, in which you can specify packages and libraries you want preloaded for your runs and workspace sessions. 

If you are working in R, an alternative to using compute environments is to install packages into your project itself, so that the package installations persist between runs of your project. While this well 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.,

install.packages("some.package", dependencies=TRUE, repos='')

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.

As always, if this isn't sufficient or you need software that cannot be installed this way, please ask us

Was this article helpful?
0 out of 0 found this helpful