pkgs {tinycodet} | R Documentation |
Miscellaneous Package Related Functions
Description
The pkgs %installed in% lib.loc
operator
checks if one or more given packages (pkgs
) exist
in the given library paths (lib.loc
),
without loading the packages.
The syntax of this operator forces the user to make it
syntactically explicit
where to look for installed R-packages.
As pkgs %installed in% lib.loc
does not even load a package,
the user can safely use it
without fearing any unwanted side-effects.
The pkg_get_deps()
function gets the direct dependencies of a package
from the Description file. It works on non-CRAN packages also.
The pkg_get_deps_minimal()
function is the same as
pkg_get_deps()
,
except with
base, recom, rstudioapi, shared_tidy
all set to FALSE
,
and the default value for deps_type
is c("Depends", "Imports").
The pkg_lsf()
function
gets a list of exported functions/operators from a package.
One handy use for this function is to, for example,
globally attach all infix operators from a package using library
,
like so:
y <- pkg_lsf("packagename", type = "inops") library(packagename, include.only = y)
Usage
pkgs %installed in% lib.loc
pkg_get_deps(
package,
lib.loc = .libPaths(),
deps_type = c("LinkingTo", "Depends", "Imports"),
base = FALSE,
recom = TRUE,
rstudioapi = TRUE,
shared_tidy = TRUE
)
pkg_get_deps_minimal(
package,
lib.loc = .libPaths(),
deps_type = c("Depends", "Imports")
)
pkg_lsf(package, type, lib.loc = .libPaths())
Arguments
pkgs |
a character vector with the package name(s). |
lib.loc |
character vector specifying library search path
(the location of R library trees to search through). |
package |
a single string giving the package name. |
deps_type |
a character vector, giving the dependency types to be used. |
base |
logical,
indicating whether base/core R should be included ( |
recom |
logical,
indicating whether the pre-installed 'recommended' R-packages should be included
( |
rstudioapi |
logical,
indicating whether the 'rstudioapi' R-package should be included
( |
shared_tidy |
logical,
indicating whether the shared dependencies of the 'tidyverse' should be included
( |
type |
The type of functions to list. Possibilities:
|
Details
For pkg_get_deps()
:
For each string in argument deps_type
,
the package names in the corresponding field of the Description file are extracted,
in the order as they appear in that field.
The order given in argument deps_type
also affects the order of the returned character vector:
For example, c("LinkingTo", "Depends", "Imports")
,
means the package names are extracted from the fields in the following order:
"LinkingTo";
"Depends";
"Imports".
The unique (thus non-repeating)
package names are then returned to the user.
Value
For pkgs %installed in% lib.loc
:
Returns a named logical vector.
The names give the package names.
The value TRUE
indicates a package is installed in lib.loc
.
The value FALSE
indicates a package is not installed in lib.loc
.
The value NA
indicates a package is not actually a separate package,
but base/core 'R'
(i.e. 'base', 'stats', etc.).
For pkg_get_deps()
and pkg_get_deps_minimal()
:
A character vector of direct dependencies, without duplicates.
For pkg_lsf()
:
Returns a character vector of exported function names in the specified package.
References
O'Brien J., elegantly extract R-package dependencies of a package not listed on CRAN. Stack Overflow. (1 September 2023). https://stackoverflow.com/questions/30223957/elegantly-extract-r-package-dependencies-of-a-package-not-listed-on-cran
See Also
Examples
"dplyr" %installed in% .libPaths()
pkg_get_deps_minimal("dplyr")
pkgs <- pkg_get_deps("dplyr")
pkgs %installed in% .libPaths()
pkg_lsf("dplyr", "all")