init: Initialize Packrat on a new or existing R project

Description Usage Arguments Details Note See Also Examples

Description

Given a project directory, makes a new packrat project in the directory.

Usage

1
2
init(project = ".", options = NULL, enter = TRUE, restart = enter,
  infer.dependencies = TRUE)

Arguments

project

The directory that contains the R project.

options

An R list of options, as specified in packrat-options.

enter

Boolean, enter packrat mode for this project after finishing a init?

restart

If TRUE, restart the R session after init.

infer.dependencies

If TRUE, infer package dependencies by examining the R code.

Details

init works as follows:

  1. Application dependencies are computed by examining the R code throughout the project for library and require calls. You can opt out of this behavior by setting infer.dependencies to FALSE.

  2. A snapshot is taken of the version of each package currently used by the project as described in snapshot, and each package's sources are downloaded.

  3. A private library is created in the directory.

  4. The snapshot is applied to the directory as described in restore.

When init is finished, all the packages on which the project depends are installed in a new, private library located inside the project directory.

You must restart your R session in the given project directory after running init in order for the changes to take effect!

When R is started in the directory, it will use the new, private library. Calls to require and library will load packages from the private library (except for 'base' or 'recommended' R packages, which are found in the system library), and functions such as install.packages will modify that private library. You can sync this private library with packrat using snapshot and restore.

Note

The restart parameter will only result in a restart of R when the R environment packrat is running within makes available a restart function via getOption("restart").

See Also

packrat for a description of the files created by init.

Examples

1
2
3
4
5
6
7
## Not run: 

## initialize a project using a local repository of packages
packrat::init(options = list(local.repos = "~/projects/R"))


## End(Not run)

packrat documentation built on May 2, 2019, 6:24 a.m.