% Generated by roxygen2: do not edit by hand % Please edit documentation in R/package.R \name{pkg_install} \alias{pkg_install} \title{Install packages} \usage{ pkg_install( pkg, lib = .libPaths()[[1L]], upgrade = FALSE, ask = interactive(), dependencies = NA ) } \arguments{ \item{pkg}{Package names or package references. E.g. \itemize{ \item \code{ggplot2}: package from CRAN, Bioconductor or a CRAN-like repository in general, \item \code{tidyverse/ggplot2}: package from GitHub, \item \code{tidyverse/ggplot2@v3.4.0}: package from GitHub tag or branch, \item \verb{https://examples.com/.../ggplot2_3.3.6.tar.gz}: package from URL, \item \code{.}: package in the current working directory. } See "\link{Package sources}" for more details.} \item{lib}{Character vector of library paths to consider when creating the installation plan. \itemize{ \item The first library path is the target where packages will be installed. \item Additional library paths, if provided, are visible to the solver as candidates for satisfying dependency requirements. If a needed package is found here at an acceptable version, it won't be re-installed in \code{lib[1]}. \item Base and recommended packages in \code{.Library} are always considered, i.e. a recommended package is only duplicated in \code{lib[1]} if a newer version is required. }} \item{upgrade}{When \code{FALSE}, the default, pak does the minimum amount of work to give you the latest version(s) of \code{pkg}. It will only upgrade dependent packages if \code{pkg}, or one of their dependencies explicitly require a higher version than what you currently have. It will also prefer a binary package over to source package, even if the binary package is older. When \code{upgrade = TRUE}, pak will ensure that you have the latest version(s) of \code{pkg} and all their dependencies.} \item{ask}{Whether to ask for confirmation when installing a different version of a package that is already installed. Installations that only add new packages never require confirmation.} \item{dependencies}{What kinds of dependencies to install. Most commonly one of the following values: \itemize{ \item \code{NA}: only required (hard) dependencies, \item \code{TRUE}: required dependencies plus optional and development dependencies, \item \code{FALSE}: do not install any dependencies. (You might end up with a non-working package, and/or the installation might fail.) See \link{Package dependency types} for other possible values and more information about package dependencies. }} } \value{ (Invisibly) A data frame with information about the installed package(s). } \description{ Install one or more packages and their dependencies into a single package library. } \section{Examples}{ \if{html}{\out{
    }}\preformatted{pkg_install("dplyr")
    }\if{html}{\out{
}}\if{html}{\out{

    #>
    #> → Will install 5 packages.
    #> → All 5 packages (2.14 MB) are cached.
    #> + dplyr        1.0.9
    #> + generics     0.1.2
    #> + purrr        0.3.4
    #> + R6           2.5.1
    #> + tidyselect   1.1.2
    #> i No downloads are needed, 5 pkgs (2.14 MB) are cached
    #> v Got R6 2.5.1 (aarch64-apple-darwin20) (82.52 kB)
    #> v Installed R6 2.5.1  (43ms)
    #> v Installed generics 0.1.2  (62ms)
    #> v Installed dplyr 1.0.9  (88ms)
    #> v Installed purrr 0.3.4  (88ms)
    #> v Installed tidyselect 1.1.2  (94ms)
    #> v 1 pkg + 17 deps: kept 12, added 5, dld 1 (82.52 kB) [1.2s]

}} Upgrade dplyr and all its dependencies: \if{html}{\out{
    }}\preformatted{pkg_install("dplyr", upgrade = TRUE)
    }\if{html}{\out{
}}\if{html}{\out{

    #>
    #> → Will update 1 package.
    #> → The package (742.51 kB) is cached.
    #> + rlang 1.0.2 → 1.0.3 👷🏿‍♀️🔧
    #> i No downloads are needed, 1 pkg (742.51 kB) is cached
    #> i Building rlang 1.0.3
    #> v Built rlang 1.0.3 (5.8s)
    #> v Installed rlang 1.0.3  (32ms)
    #> v 1 pkg + 17 deps: kept 17, upd 1 [6.3s]

}} Install the development version of dplyr: \if{html}{\out{
    }}\preformatted{pkg_install("tidyverse/dplyr")
    }\if{html}{\out{
}}\if{html}{\out{

    #> v Loading metadata database ... done
    #>
    #> → Will install 16 packages.
    #> → All 16 packages (8.09 MB) are cached.
    #> + cli          3.4.1
    #> + dplyr        1.0.99.9000 👷🏾‍♂️🔧 (GitHub: e6252f8)
    #> + fansi        1.0.3
    #> + generics     0.1.3
    #> + glue         1.6.2
    #> + lifecycle    1.0.3
    #> + magrittr     2.0.3
    #> + pillar       1.8.1
    #> + pkgconfig    2.0.3
    #> + R6           2.5.1
    #> + rlang        1.0.6
    #> + tibble       3.1.8
    #> + tidyselect   1.2.0
    #> + utf8         1.2.2
    #> + vctrs        0.5.1
    #> + withr        2.5.0
    #> i No downloads are needed, 16 pkgs (8.09 MB) are cached
    #> v Installed R6 2.5.1  (58ms)
    #> v Installed cli 3.4.1  (69ms)
    #> v Installed fansi 1.0.3  (92ms)
    #> v Installed generics 0.1.3  (99ms)
    #> v Installed glue 1.6.2  (108ms)
    #> v Installed lifecycle 1.0.3  (144ms)
    #> v Installed magrittr 2.0.3  (152ms)
    #> v Installed pillar 1.8.1  (160ms)
    #> v Installed pkgconfig 2.0.3  (63ms)
    #> v Installed rlang 1.0.6  (37ms)
    #> v Installed tibble 3.1.8  (41ms)
    #> v Installed tidyselect 1.2.0  (38ms)
    #> v Installed utf8 1.2.2  (36ms)
    #> v Installed vctrs 0.5.1  (39ms)
    #> v Installed withr 2.5.0  (30ms)
    #> i Packaging dplyr 1.0.99.9000
    #> v Packaged dplyr 1.0.99.9000 (8.3s)
    #> i Building dplyr 1.0.99.9000
    #> v Built dplyr 1.0.99.9000 (5.2s)
    #> v Installed dplyr 1.0.99.9000 (github::tidyverse/dplyr@e6252f8) (24ms)
    #> v 1 pkg + 15 deps: added 16 [18.9s]

}} Switch back to the CRAN version. This will be fast because pak will have cached the prior install. \if{html}{\out{
    }}\preformatted{pkg_install("dplyr")
    }\if{html}{\out{
}}\if{html}{\out{

    #> v Updated metadata database: 2.43 MB in 6 files.
    #> v Updating metadata database ... done
    #>
    #> → Will install 16 packages.
    #> → All 16 packages (9.42 MB) are cached.
    #> + cli          3.4.1
    #> + dplyr        1.0.10
    #> + fansi        1.0.3
    #> + generics     0.1.3
    #> + glue         1.6.2
    #> + lifecycle    1.0.3
    #> + magrittr     2.0.3
    #> + pillar       1.8.1
    #> + pkgconfig    2.0.3
    #> + R6           2.5.1
    #> + rlang        1.0.6
    #> + tibble       3.1.8
    #> + tidyselect   1.2.0
    #> + utf8         1.2.2
    #> + vctrs        0.5.1
    #> + withr        2.5.0
    #> i No downloads are needed, 16 pkgs (9.42 MB) are cached
    #> v Installed R6 2.5.1  (66ms)
    #> v Installed cli 3.4.1  (76ms)
    #> v Installed dplyr 1.0.10  (111ms)
    #> v Installed fansi 1.0.3  (119ms)
    #> v Installed generics 0.1.3  (125ms)
    #> v Installed glue 1.6.2  (132ms)
    #> v Installed lifecycle 1.0.3  (149ms)
    #> v Installed magrittr 2.0.3  (162ms)
    #> v Installed pillar 1.8.1  (56ms)
    #> v Installed pkgconfig 2.0.3  (35ms)
    #> v Installed rlang 1.0.6  (57ms)
    #> v Installed tibble 3.1.8  (41ms)
    #> v Installed tidyselect 1.2.0  (40ms)
    #> v Installed utf8 1.2.2  (37ms)
    #> v Installed vctrs 0.5.1  (39ms)
    #> v Installed withr 2.5.0  (31ms)
    #> v 1 pkg + 15 deps: added 16 [7.2s]

}} } \seealso{ \link{Get started with pak}, \link{Package sources}, \link{FAQ}, \link{The dependency solver}. Other package functions: \code{\link{lib_status}()}, \code{\link{pak}()}, \code{\link{pkg_deps}()}, \code{\link{pkg_deps_tree}()}, \code{\link{pkg_download}()}, \code{\link{pkg_remove}()}, \code{\link{pkg_status}()}, \code{\link{pkg_sysreqs}()} } \concept{package functions}