File: use_package.Rd

package info (click to toggle)
r-cran-usethis 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,228 kB
  • sloc: sh: 26; makefile: 17; cpp: 6; ansic: 3
file content (59 lines) | stat: -rw-r--r-- 2,323 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/package.R
\name{use_package}
\alias{use_package}
\alias{use_dev_package}
\title{Depend on another package}
\usage{
use_package(package, type = "Imports", min_version = NULL)

use_dev_package(package, type = "Imports", remote = NULL)
}
\arguments{
\item{package}{Name of package to depend on.}

\item{type}{Type of dependency: must be one of "Imports", "Depends",
"Suggests", "Enhances", or "LinkingTo" (or unique abbreviation). Matching
is case insensitive.}

\item{min_version}{Optionally, supply a minimum version for the package. Set
to \code{TRUE} to use the currently installed version or use a version string
suitable for \code{\link[=numeric_version]{numeric_version()}}, such as "2.5.0".}

\item{remote}{By default, an \code{OWNER/REPO} GitHub remote is inserted.
Optionally, you can supply a character string to specify the remote, e.g.
\code{"gitlab::jimhester/covr"}, using any syntax supported by the \href{https://remotes.r-lib.org/articles/dependencies.html#other-sources}{remotes package}.}
}
\description{
\code{use_package()} adds a CRAN package dependency to \code{DESCRIPTION} and offers a
little advice about how to best use it. \code{use_dev_package()} adds a dependency
on an in-development package, adding the dev repo to \code{Remotes} so it will be
automatically installed from the correct location. There is no helper to
remove a dependency: to do that, simply remove that package from your
\code{DESCRIPTION} file.

\code{use_package()} exists to support a couple of common maneuvers:
\itemize{
\item Add a dependency to \code{Imports} or \code{Suggests} or \code{LinkingTo}.
\item Add a minimum version to a dependency.
\item Specify the minimum supported version for R.
}

\code{use_package()} probably works for slightly more exotic modifications, but at
some point, you should edit \code{DESCRIPTION} yourself by hand. There is no
intention to account for all possible edge cases.
}
\examples{
\dontrun{
use_package("ggplot2")
use_package("dplyr", "suggests")
use_dev_package("glue")

# Depend on R version 4.1
use_package("R", type = "Depends", min_version = "4.1")
}
}
\seealso{
The \href{https://r-pkgs.org/dependencies-mindset-background.html}{dependencies section} of
\href{https://r-pkgs.org}{R Packages}.
}