| pkg_install | R Documentation |
Install one or more packages and their dependencies into a single package library.
pkg_install(
pkg,
lib = .libPaths()[[1L]],
upgrade = FALSE,
ask = interactive(),
dependencies = NA
)
pkg |
Package names or package references. E.g.
See "Package sources" for more details. |
lib |
Character vector of library paths to consider when creating the installation plan.
|
upgrade |
When When |
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. |
dependencies |
What kinds of dependencies to install. Most commonly one of the following values:
|
(Invisibly) A data frame with information about the installed package(s).
pkg_install("dplyr")
#> #> → 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:
pkg_install("dplyr", upgrade = TRUE)
#> #> → 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:
pkg_install("tidyverse/dplyr")
#> 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.
pkg_install("dplyr")
#> 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]
Get started with pak, Package sources, FAQ, The dependency solver.
Other package functions:
lib_status(),
pak(),
pkg_deps(),
pkg_deps_tree(),
pkg_download(),
pkg_remove(),
pkg_status(),
pkg_sysreqs()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.