Learn R Programming

rang (version 0.3.0)

resolve: Resolve Dependencies Of R Packages

Description

This function recursively queries dependencies of R packages at a specific snapshot time. The dependency graph can then be used to recreate the computational environment. The data on dependencies are provided by R-hub.

Usage

resolve(
  pkgs = ".",
  snapshot_date,
  no_enhances = TRUE,
  no_suggests = TRUE,
  query_sysreqs = TRUE,
  os = "ubuntu-20.04",
  verbose = FALSE
)

Value

a rang S3 object with the following items

call

original function call

ranglets

List of dependency graphs of all packages in pkgs

snapshot_date

snapshot_date

no_enhances

no_enhances

no_suggests

no_suggests

unresolved_pkgsrefs

Packages that can't be resolved

sysreqs

System requirements as Linux commands

r_version

The latest R version as of snapshot_date

os

os

Arguments

pkgs

pkgs can be 1) a character vector of R packages to resolve, 2) a path to a renv lockfile, or 3) a data structure that as_pkgrefs() can convert to a character vector of package references. For 1) pkgs can be either in shorthands, e.g. "rtoot", "ropensci/readODS", or in package references, e.g. "cran::rtoot", "github::ropensci/readODS". Please refer to the Package References documentation of pak for details. Currently, this package supports only cran and github packages. For 2) as_pkgrefs() support the output of sessionInfo(), a renv lockfile or a single directory. If it is a single directory, all R scripts are scanned for R packages used using renv::dependencies(). Currently, the default is to scan the R scripts in the current working directory. Please also note that this scanning only assumes there are CRAN and Bioconductor packages. We strongly recommend checking whether this is really the case (see example below).

snapshot_date

Snapshot date, if not specified, assume to be a month ago

no_enhances

logical, whether to ignore packages in the "Enhances" field

no_suggests

logical, whether to ignore packages in the "Suggests" field

query_sysreqs

logical, whether to query for System Requirements. Important: Archived CRAN can't be queried for system requirements. Those packages are assumed to have no system requirement.

os

character, which OS to query for system requirements

verbose

logical, whether to display messages

References

Package References

See Also

dockerize()

Examples

Run this code
# \donttest{
if (interactive()) {
    graph <- resolve(pkgs = c("openNLP", "LDAvis", "topicmodels", "quanteda"),
                snapshot_date = "2020-01-16")
    graph
    ## to resolve github packages
    gh_graph <- resolve(pkgs = c("https://github.com/schochastics/rtoot"),
                   snapshot_date = "2022-11-28")
    gh_graph
    ## scanning
    graph <- resolve(snapshot_date = "2022-11-28")
    ## But we recommend this:
    pkgs <- as_pkgrefs(".")
    pkgs ## check the accuracy
    graph <- resolve(pkgs, snapshot_date = "2022-11-28")
}
# }

Run the code above in your browser using DataLab