% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pkgs.R
\name{pkgs}
\alias{pkgs}
\alias{\%installed in\%}
\alias{pkg_get_deps}
\alias{pkg_get_deps_minimal}
\alias{pkg_lsf}
\title{Miscellaneous Package Related Functions}
\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{
\item{pkgs}{a character vector with the package name(s).}

\item{lib.loc}{character vector specifying library search path
(the location of R library trees to search through). \cr
The \code{lib.loc} argument would usually be \code{.libPaths()}. \cr
See also \link[base]{loadNamespace}.}

\item{package}{a single string giving the package name.}

\item{deps_type}{a character vector, giving the dependency types to be used. \cr
The order of the character vector given in \code{deps_type} affects
the order of the returned character vector; see Details sections.}

\item{base}{logical,
indicating whether base/core R should be included (\code{TRUE}),
or not included (\code{FALSE}).}

\item{recom}{logical,
indicating whether the pre-installed 'recommended' R-packages should be included
(\code{TRUE}),
or not included (\code{FALSE}).}

\item{rstudioapi}{logical,
indicating whether the 'rstudioapi' R-package should be included
(\code{TRUE}),
or not included (\code{FALSE}).}

\item{shared_tidy}{logical,
indicating whether the shared dependencies of the 'tidyverse' should be included
(\code{TRUE}),
or not included (\code{FALSE}). \cr
\bold{Details:} \cr
Some of the (often many) dependencies 'tidyverse' packages have
are shared across the majority of the 'tidyverse'. \cr
The "official" list of shared dependencies in the 'tidyverse' currently is the following: \cr
'rlang', 'lifecycle', 'cli', 'glue', and 'withr'.}

\item{type}{The type of functions to list. Possibilities:
\itemize{
\item \code{"inops"} or \code{"operators"}: Only infix operators.
\item \code{"regfuns"}: Only regular functions (thus excluding infix operators).
\item \code{"all"}: All functions, both regular functions and infix operators. \cr \cr
}}
}
\value{
For  \code{pkgs \%installed in\% lib.loc}: \cr
Returns a named logical vector. \cr
The names give the package names. \cr
The value \code{TRUE} indicates a package is installed in \code{lib.loc}. \cr
The value \code{FALSE} indicates a package is not installed in \code{lib.loc}. \cr
The value \code{NA} indicates a package is not actually a separate package,
but base/core 'R'
(i.e. 'base', 'stats', etc.). \cr
\cr
For \code{pkg_get_deps()} and \code{pkg_get_deps_minimal()}: \cr
A character vector of direct dependencies, without duplicates. \cr
\cr
For \code{pkg_lsf()}: \cr
Returns a character vector of exported function names in the specified package. \cr \cr
}
\description{
The \code{pkgs \%installed in\% lib.loc} operator
checks if one or more given packages (\code{pkgs}) exist
in the given library paths (\code{lib.loc}),
without loading the packages. \cr
The syntax of this operator forces the user to make it
syntactically explicit
where to look for installed R-packages. \cr
As \code{pkgs \%installed in\% lib.loc} does not even load a package,
the user can safely use it
without fearing any unwanted side-effects. \cr
\cr
The \code{pkg_get_deps()} function gets the \bold{direct} dependencies of a package
from the Description file. It works on non-CRAN packages also. \cr
\cr
The \code{pkg_get_deps_minimal()} function is the same as
\code{pkg_get_deps()},
except with
\code{base, recom, rstudioapi, shared_tidy}
all set to \code{FALSE},
and the default value for \code{deps_type} is c("Depends", "Imports"). \cr
\cr
The \code{pkg_lsf()} function
gets a list of exported functions/operators from a package. \cr
One handy use for this function is to, for example,
globally attach all infix operators from a package using \code{library},
like so:

\if{html}{\out{<div class="sourceCode r">}}\preformatted{y <- pkg_lsf("packagename", type = "inops")
library(packagename, include.only = y)
}\if{html}{\out{</div>}}
}
\details{
For \code{pkg_get_deps()}: \cr
For each string in argument \code{deps_type},
the package names in the corresponding field of the Description file are extracted,
in the order as they appear in that field. \cr
The order given in argument \code{deps_type}
also affects the order of the returned character vector: \cr
For example, \code{c("LinkingTo", "Depends", "Imports")}, \cr
means the package names are extracted from the fields in the following order:

\enumerate{
\item "LinkingTo";
\item "Depends";
\item "Imports".
}
The unique (thus non-repeating)
package names are then returned to the user. \cr \cr
}
\examples{
\dontshow{if ("dplyr" \%installed in\% .libPaths()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
"dplyr" \%installed in\% .libPaths()

pkg_get_deps_minimal("dplyr")
pkgs <- pkg_get_deps("dplyr")
pkgs \%installed in\% .libPaths()
pkg_lsf("dplyr", "all")



\dontshow{\}) # examplesIf}
}
\references{
O'Brien J., elegantly extract R-package dependencies of a package not listed on CRAN. \emph{Stack Overflow}. (1 September 2023). \url{https://stackoverflow.com/questions/30223957/elegantly-extract-r-package-dependencies-of-a-package-not-listed-on-cran}
}
\seealso{
\link{tinycodet_import}
}
