Download a package and its dependenciesSource:
TODO: explain result
pkg_download( pkg, dest_dir = ".", dependencies = FALSE, platforms = NULL, r_versions = NULL )
Package names or package references. E.g.
ggplot2: package from CRAN, Bioconductor or a CRAN-like repository in general,
tidyverse/ggplot2: package from GitHub,
email@example.com: package from GitHub tag or branch,
https://examples.com/.../ggplot2_3.3.6.tar.gz: package from URL,
.: package in the current working directory.
See "Package sources" for more details.
Destination directory for the packages. If it does not exist, then it will be created.
What kinds of dependencies to install. Most commonly one of the following values:
NA: only required (hard) dependencies,
TRUE: required dependencies plus optional and development dependencies,
FALSE: do not install any dependencies. (You might end up with a non-working package, and/or the installation might fail.) See Package dependency types for other possible values and more information about package dependencies.
Types of binary or source packages to download. The default is the value of
R version(s) to download packages for. (This does not matter for source packages, but it does for binaries.) It defaults to the current R version.
Data frame with information about the downloaded packages, invisibly. Columns:
Builtfield from the
DESCRIPTIONfile of binary packages, for which this information is available.
cache_status: whether the package file is in the package cache. It is
dep_types: character vector of dependency types that were considered for this package. (This is a list column.)
deps: dependencies of the package, in a data frame. See "Package dependency tables" below.
direct: whether this package (ref, really) was directly specified, or added as a dependency.
error: this is a list column that contains error objects for the refs that pkgdepends failed to resolve.
filesize: the file size in bytes, or
NAif this information is not available.
license: license of the package, or
NAif not available.
md5sum: MD5 checksum of the package file, if available, or
metadata: a named character vector. These fields will be (should be) added to the installed
DESCRIPTIONfile of the package.
mirror: URL of the CRAN(-like) mirror site where the metadata was obtained from. It is NA for non-CRAN-like sources, e.g. local files, installed packages, GitHub, etc.
needscompilation: whether the package needs compilation.
package: package name.
priority: this is
"base"for base packages,
"recommended"for recommended packages, and
ref: package reference.
remote: the parsed
parse_pkg_refs(). This is a list column.
repodir: the directory where this package should be in a CRAN-like repository.
sha256: SHA256 hash of the package file, if available, otherwise
sources: URLs where this package can be downloaded from. This is not necessarily a URL that you can download with a HTTP client. E.g. for
local::refs it is a path, and for
git::refs it is a URL for git. It is a zero length vector for
status: status of the dependency resolution,
target: path where this package should be saved in a CRAN-repository.
type: ref type.
version: package version.
fulltarget: absolute path to the downloaded file. At most one of
fulltarget_treemust exist on the disk.
fulltarget_tree: absolute path to a package tree directory. At most one of
fulltarget_treemust exist on the disk.
"Got", depending on whether the file was obtained from the cache.
download_error: error object for failed downloads.
file_size: Size of the file, or
installed::refs, it is
NA, and it is also
NAfor refs that created
fulltarget, if it exists, contains a packaged (via
R CMD build) source R package. If
fulltarget_treeexists, it is a package tree directory, that still needs an
R CMD buildcall.Additional columns might be present. They are either used internally or they are experimental. They might be removed or changed at any time.All columns are of type character, except for
deps(list column, see "Package dependency tables" below),
sources(list of character vectors),
Package dependency tables
A package dependency tables in the
deps list column have five columns
ref: the package ref of the dependency.
type: the dependency type, in all lowercase. I.e.
package: package name of the dependency.
op: operator for version requirements, e.g.
version: version number, for version requirements.
dl <- pkg_download("forcats")
#> ℹ No downloads are needed, 2 pkgs (641.53 kB) are cached
#> # A data frame: 2 × 35 #> ref type direct direc…¹ status package version license needs…² #> <chr> <chr> <lgl> <lgl> <chr> <chr> <chr> <chr> <lgl> #> 1 forcats standard TRUE TRUE OK forcats 0.5.2 MIT + … FALSE #> 2 forcats standard TRUE TRUE OK forcats 0.5.2 MIT + … FALSE #> # … with 26 more variables: priority <chr>, md5sum <chr>, sha256 <chr>, #> # filesize <int>, built <chr>, platform <chr>, rversion <chr>, #> # repotype <chr>, repodir <chr>, target <chr>, deps <list>, #> # mirror <chr>, sources <list>, remote <list>, error <list>, #> # metadata <list>, extra <list>, dep_types <list>, params <list>, #> # sysreqs <chr>, cache_status <chr>, fulltarget <chr>, #> # fulltarget_tree <chr>, download_status <chr>, …
#>  "./bin/macosx/big-sur-arm64/contrib/4.2/forcats_0.5.2.tgz" #>  "./src/contrib/forcats_0.5.2.tar.gz"
pkg_download("r-lib/pak", platforms = "source")
#> ℹ No downloads are needed, 1 pkg is cached
Other package functions: