get_packages: Get information about the package used in the project

Description Usage Arguments Value See Also Examples

Description

The function returns a data frame containing information about packages that are loaded with library(), require(), used with :: operator, listed in the DESCRIPTION file, and/or already loaded.

Usage

1
2
3
4
5
6
get_packages(
  project_path = ".",
  include_pattern = "\\.R(md)?$",
  exclude_pattern = "tests/",
  package_options = c("referenced", "library", "description")
)

Arguments

project_path

A string representing the path of the project root in which the function will look recursively in order to find files that fit include_pattern

include_pattern

A string representing a regex that matches project files in which to look for packages. By default, get_packages looks for all .R and .Rmd files in the current project.

exclude_pattern

A string representing a regex that matches project files to exclude. By default, get_packages excludes all files found in "tests" folder.

package_options

A character vector that represents the method through which packages are loaded or referenced. The options are: referenced for packages referenced by the :: operator, library for packages loaded using library() or require(), description for packages mentioned in DESCRIPTION file, and loaded for packages already loaded in the current session.

Value

A data frame containing package information:

package_name

The name of the package

requested_by

The context in which the package was used

is_base

Whether package is part of the core R packages

source

The source from which the package was installed

version

The version of the package, if installed locally

is_installed

Whether the package is installed locally

See Also

generate_install_file

Examples

1
2
3
4
5
6
7
8
## Not run: 
package_df <- get_packages(
    project_path = '.',
    include_pattern = '\\.R$', 
    exclude_pattern = '', 
    package_options = c('referenced'))

## End(Not run)

Nmisc documentation built on April 28, 2021, 5:10 p.m.