find_project_dependenices: Find all R-packages used in a project.

Description Usage Arguments Details Value Author(s) Examples

View source: R/utils.R

Description

This is essentially a wrapper around renv::dependencies(), but returns the packages as a character vector which can be supplied directly to install.packages() or similar. In addition, it figures out which packages are installed from GitHub and prepends the correct username/organization to the package name, for use in e.g. remotes::install_github() or BiocManager::install(). Optionally, an R script is written containing code to install the packages.

Usage

1
find_project_dependenices(path = ".", write_script = FALSE)

Arguments

path

Path to the project to be parsed. Used the current directory by default.

write_script

Should an install script be written? Can be either logical or a character string containing the name of the file to be written. Default: FALSE.

Details

NOTE that this function only works in projects with renv set up! At the least, it requires a renv.lock file to be present.

Value

If write_script = FALSE, returns a character vector of all packages used in the project. If write_script = TRUE, writes a file install.R (or a custom file name if provided) containing code to install all found packages.

Author(s)

Milan Malfait

Examples

1
2
3
4
5
6
7
8
## Not run: 
find_project_dependencies()

## Writing to a custom file
tmp <- tempfile()
find_project_dependencies(write_script = tmp)

## End(Not run)

milanmlft/MMmotley documentation built on Feb. 4, 2022, 7:42 a.m.