Back to Blog
Packrat size5/17/2023 ![]() For collaboration, you can either use your favourite version control system, or use packrat::bundle() to generate a bundled version of your project that collaborators can use with packrat::unbundle(). As you install and remove packages, you can use packrat::snapshot() and packrat::restore() to maintain the R packages in your project. Packrat supports a set of common analytic workflows:Īs-you-go: use packrat::init() to initialize packrat with your project, and use it to manage your project library while you develop your analysis. The external package is loaded only for the duration of the evaluated expression. packrat::with_extlib(): With an external package, evaluate an expression.packrat::extlib(): Load an external package.There are also utility functions for using and managing packages in the external / user library, and can be useful for leveraging packages in the user library that you might not want as project-specific dependencies, e.g. To install this package, you can use: packrat::set_opts(local.repos = "~/git/R") packrat::install_local() installs packages available in a local repository.įor example, suppose I have a local version of the package digest located within ~/git/R. ) can be used to specify local repositories that is, paths containing package sources. Manage local repositories: - packrat::set_opts(local.repos =. packrat::get_opts, packrat::set_opts: Get/set project-specific settings. Navigate projects and set/get options with: - packrat::on(), packrat::off(): Toggle packrat mode on and off, for navigating between projects within a single R session. packrat::unbundle(): Unbundle a packrat project, generating a project directory with libraries restored. Share a Packrat project with bundle and unbundle: - packrat::bundle(): Bundle a packrat project, for easy sharing. ![]() ![]() packrat::clean(): Remove unused packages from your library.packrat::restore(): Restore the library state saved in the most recent snapshot.packrat::snapshot(): Save the current state of your library.When you want to manage the state of your private library, you can use the Packrat functions: While in packrat mode, calls to functions like install.packages and remove.packages will modify the private project library, rather than the user library. This will install Packrat, set up a private library to be used for this project, and then place you in packrat mode. Then, start a new R session at the base directory of your project and type: packrat::init() Start by installing Packrat: if (!require("devtools")) install.packages("devtools")ĭevtools::install_github("rstudio/packrat") Read the release notes to learn what's new in Packrat. See the project page for more information, or join the discussion at packrat-discuss. Reproducible: Packrat records the exact package versions you depend on, and ensures those exact versions are the ones that get installed wherever you go.Packrat makes it easy to install the packages your project depends on. Portable: Easily transport your projects from one computer to another, even across different platforms.That's because packrat gives each project its own private package library. Isolated: Installing a new or updated package for one project won't break your other projects, and vice versa.Use packrat to make your R projects more: Packrat is a dependency management system for R.
0 Comments
Read More
Leave a Reply. |