There are a number of ways to share a package internally at an organization. This article outlines four of the easiest methods:
Option A: Share a Compressed Folder
- Build the package into a source / tar file. This can be done in the IDE:
- Put the tar file in a shared network location. Users can either download the tar file and then install the package, or install the package directly from the compressed folder on the shared drive:
install.packages("path/to/tar/file", source = TRUE, repos=NULL)
Option B: Use Git
Put the whole R package (the R folder, namespace file, description, etc) into a git repo (either an internal repo or github).
Users can install the package using devtools:
Option C: Use Local Repository
These instructions: https://rstudio.github.io/packrat/custom-repos.html provide a framework for setting up a local repository and adding packages. In particular:
- Create a local repository, which is just a specific folder structure.
Update the package’s DESCRIPTION file to include:
Build the package and move the tar file into the correct location in the local repository.
Update the local repository’s PACKAGE files using
Users can install the package with:
install.packages('package_name', source = TRUE, repos=repoURI)
Option D: System Library
If you are using RStudio Workbench (previously RStudio Server Pro), you can make the package automatically available to users by installing the package in the system library. To do so, just use one of the methods above (A-C) and install the package into the system library:
install.packages('my_package', source=TRUE, lib.loc = "/path/to/system/lib", repos=NULL)