Learn R Programming

rdocdump (version 0.1.0)

resolve_pkg_path: Resolve the path to a package directory or tarball

Description

This function resolves the path to a package directory or tarball, handling both installed packages and source packages from CRAN.

Usage

resolve_pkg_path(
  pkg,
  cache_path = NULL,
  force_fetch = FALSE,
  repos = getOption("rdocdump.repos", getOption("repos"))
)

Value

A list containing:

  • pkg_path: Path to the package directory or tarball.

  • extracted_path: Path to the extracted package directory (if applicable).

  • tar_path: Path to the tarball if it was downloaded.

  • is_installed: Logical indicating if the package is installed.

Arguments

pkg

A character string specifying the package. This can be:

  • an installed package name,

  • a full path to a package source directory,

  • a full path to a package archive file (tar.gz), or

  • a package name not installed (which will then be downloaded from CRAN).

cache_path

A character string specifying the directory where kept temporary files will be stored. By default, it uses the value of getOption("rdocdump.cache_path") which sets the cache directory to the temporary directory of the current R session.

force_fetch

logical. If TRUE, the package source will be fetched from CRAN as a tar.gz archive even if the package is already installed locally. Default is FALSE.

repos

A character vector of repository URLs. By default, it uses the value of getOption("rdocdump.repos") which sets the repository URLs to the default R repositories and is itself set to c("CRAN" = "https://cloud.r-project.org") on package load to prevent accidental downloads of pre-built packages from Posit Package Manager and R Universe.