🔥 A friendly package manager for R
- Designed for reproducibility (thanks to Packrat, no more global installs!)
- Lightweight (adds just three files to your project)
- Secure by default
- Works from both R and the command line
Inspired by Yarn, Bundler, and Pipenv
Install Jetpack
install.packages("jetpack")
Jetpack creates a DESCRIPTION
file to store your project dependencies. It stores the specific version of each package in packrat.lock
. This makes it possible to have a reproducible environment. You can edit dependencies in the DESCRIPTION
file directly, but Jetpack provides functions to help with this.
Open a project and run:
jetpack::init()
Install packages for a project
jetpack::install()
This ensures all the right versions are installed locally. As dependencies change, collaborators should run this command to stay synced.
Be sure to prefix commands with
jetpack::
. Jetpack isn’t installed in your virtual environment, solibrary(jetpack)
won’t work.
Add a package
jetpack::add("randomForest")
Add multiple packages
jetpack::add(c("randomForest", "DBI"))
Add a specific version
jetpack::add("DBI@1.0.0")
Add from GitHub or another remote source
jetpack::add("plyr", remote="hadley/plyr")
Supports these remotes
Bioconductor packages do not currently work
Add from a specific tag, branch, or commit
jetpack::add("plyr", remote="hadley/plyr@v1.8.4")
Add from a local source
jetpack::add("plyr", remote="local::/path/to/plyr")
The local directory must have the same name as the package
Update a package
jetpack::update("randomForest")
For local packages, run this anytime the package code is changed
Update multiple packages
jetpack::update(c("randomForest", "DBI"))
Remove a package
jetpack::remove("randomForest")
Remove multiple packages
jetpack::remove(c("randomForest", "DBI"))
Remove remotes as well
jetpack::remove("plyr", remote="hadley/plyr")
Check that all dependencies are installed
jetpack::check()
Get info for a package
jetpack::info("stringr")
Get info for a specific version
jetpack::info("stringr@1.0.0")
Search for packages
jetpack::search("xgboost")
Works with title, description, authors, maintainers, and more
Be sure to commit the files Jetpack generates to source control.
Install Jetpack on the server and run:
jetpack::install(deployment=TRUE)
Create an init.R
with:
install.packages("jetpack")
jetpack::install(deployment=TRUE)
And add it into your Dockerfile
:
FROM r-base
RUN apt-get update && apt-get install -qq -y --no-install-recommends \
libxml2-dev libssl-dev libcurl4-openssl-dev libssh2-1-dev
RUN mkdir -p /app
WORKDIR /app
COPY init.R DESCRIPTION packrat.lock ./
RUN Rscript init.R
COPY . .
CMD Rscript app.R
There’s ongoing work to get Packrat working with the R buildpack.
In the meantime, you can use Docker Deploys on Heroku.
Jetpack can also be run from the command line. To install the CLI, run:
jetpack::cli()
On Windows, add
C:\ProgramData\jetpack\bin
to your PATH. See instructions for how to do this.
All the Jetpack commands are now available
jetpack init
jetpack install
jetpack add randomForest
jetpack add DBI@1.0.0
jetpack add plyr --remote=hadley/plyr
jetpack update randomForest
jetpack remove DBI
jetpack check
You can also use it to manage global packages
jetpack global add randomForest
jetpack global update DBI
jetpack global remove plyr
jetpack global list
Or get info about packages
jetpack info stringr
jetpack info stringr@1.0.0
jetpack search xgboost
jetpack search "neural network"
For the full list of commands, use:
jetpack help
To upgrade, rerun the installation instructions.
Jetpack 0.3.0 greatly reduces the number of files in your projects. To upgrade a project:
- Move
packrat/packrat.lock
topackrat.lock
- Delete the
packrat
directory - Delete
.Rbuildignore
and.gitignore
if they only contain Packrat references - Replace all Jetpack and Packrat code in your
.Rprofile
with:
if (requireNamespace("jetpack", quietly=TRUE)) {
jetpack::load()
} else {
message("Install Jetpack to use a virtual environment for this project")
}
- Open R and run:
jetpack::install()
View the changelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features