RStudio have released
packrat, an R package to manage dependencies between packages to ensure that what gets shipped with a project works.
Following the walkthrough example should give a pretty good idea of what you need to do.
Before you start
Ensure that you have the latest versions of
packrat from github, using
devtools from CRAN gave me an error.
library(devtools) install_github("devtools") devtools::install_github("rstudio/packrat")
With that done, you can procede as below…
Code I ran to get the Distance 6.2 packrat “project”.
Create a package directory and run (from the level above the package directory):
inside, this creates the requisite files and folders. You should get some messages asking you to restart R.
Now starting R again (and ensuring the working directory is our project folder), we effectively have a “fresh” R install, so we have to install all the packages again, but now they will be frozen at their “correct” versions.
We want the versions of
mrds currently on CRAN, so install them as usual:
packrat needs to find a
.R file with a
require call somewhere in the directory (I guess to prove you’re serious? I don’t know). Anyway just adding
to a file (I called mine
packrat-load.R) will keep it happy.
Now to take the snapshot of the package dependencies:
This downloaded the sources of the dependencies and install them. This means you have to have C and Fortran compilers installed!
Now when you launch R in the project directory we will get the right versions of the packages (
.Rprofile ensure this).
You don’t need to include the
library/ folder but you do need the other files added to your
When you clone the repository, you need to call
initPackrat() to install the source packages. In terms of shipping, building on the given platform should suffice.