list_required_packages: List packages required by R scripts in a directory

View source: R/list-packages.R

list_required_packagesR Documentation

List packages required by R scripts in a directory

Description

This function reports the names and currently installed versions of R packages used by all R scripts and R Markdown files in a given directory.

Usage

list_required_packages(path = ".", recursive = TRUE)

Arguments

path

A character vector of length one giving the directory you'd like searched for R scripts and R Markdown files

recursive

Should the function search for R scripts and R Markdown files recursively? Default is TRUE

Details

This function looks at all R scripts and R Markdown files contained in a directory (and its subdirectories if recursive is TRUE) and tries to identify all packages used in those R scripts and R Markdown files. It looks for names of packages in library() and require() calls, as well as packages used in the form ⁠package::function()⁠ or ⁠package:::function()⁠. Detection of packages used may be imperfect, but it should work fairly well.

The function also records the versions of those packages currently installed, as well as the R version being used, and if RStudio is installed, the RStudio version installed, and reports that information as well.

Value

An object of class RequiredPackages, which is a list of length three, with elements

R_version

A character vector of length one giving the R version

RStudio_version

A character vector of length one giving the RStudio version, if applicable, or NA if not.

packages

A character matrix with two columns, "Package", giving the names of the packages detected, and "Version", giving the version currently installed.

See Also

print.RequiredPackages()


duckmayr/quack documentation built on March 19, 2023, 9:13 p.m.