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 |
Package library to install the packages to. Note that all
dependent packages will be installed here, even if they are
already installed in another library. The only exceptions are base
and recommended packages installed in |
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 #> ℹ No downloads are needed, 5 pkgs (2.14 MB) are cached #> ✔ Got R6 2.5.1 (aarch64-apple-darwin20) (82.52 kB) #> ✔ Installed R6 2.5.1 (43ms) #> ✔ Installed generics 0.1.2 (62ms) #> ✔ Installed dplyr 1.0.9 (88ms) #> ✔ Installed purrr 0.3.4 (88ms) #> ✔ Installed tidyselect 1.1.2 (94ms) #> ✔ 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 👷🏿♀️🔧 #> ℹ No downloads are needed, 1 pkg (742.51 kB) is cached #> ℹ Building rlang 1.0.3 #> ✔ Built rlang 1.0.3 (5.8s) #> ✔ Installed rlang 1.0.3 (32ms) #> ✔ 1 pkg + 17 deps: kept 17, upd 1 [6.3s]
Install the development version of dplyr:
pkg_install("tidyverse/dplyr")
#> ✔ 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 #> ℹ No downloads are needed, 16 pkgs (8.09 MB) are cached #> ✔ Installed R6 2.5.1 (58ms) #> ✔ Installed cli 3.4.1 (69ms) #> ✔ Installed fansi 1.0.3 (92ms) #> ✔ Installed generics 0.1.3 (99ms) #> ✔ Installed glue 1.6.2 (108ms) #> ✔ Installed lifecycle 1.0.3 (144ms) #> ✔ Installed magrittr 2.0.3 (152ms) #> ✔ Installed pillar 1.8.1 (160ms) #> ✔ Installed pkgconfig 2.0.3 (63ms) #> ✔ Installed rlang 1.0.6 (37ms) #> ✔ Installed tibble 3.1.8 (41ms) #> ✔ Installed tidyselect 1.2.0 (38ms) #> ✔ Installed utf8 1.2.2 (36ms) #> ✔ Installed vctrs 0.5.1 (39ms) #> ✔ Installed withr 2.5.0 (30ms) #> ℹ Packaging dplyr 1.0.99.9000 #> ✔ Packaged dplyr 1.0.99.9000 (8.3s) #> ℹ Building dplyr 1.0.99.9000 #> ✔ Built dplyr 1.0.99.9000 (5.2s) #> ✔ Installed dplyr 1.0.99.9000 (github::tidyverse/dplyr@e6252f8) (24ms) #> ✔ 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")
#> ✔ Updated metadata database: 2.43 MB in 6 files. #> ✔ 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 #> ℹ No downloads are needed, 16 pkgs (9.42 MB) are cached #> ✔ Installed R6 2.5.1 (66ms) #> ✔ Installed cli 3.4.1 (76ms) #> ✔ Installed dplyr 1.0.10 (111ms) #> ✔ Installed fansi 1.0.3 (119ms) #> ✔ Installed generics 0.1.3 (125ms) #> ✔ Installed glue 1.6.2 (132ms) #> ✔ Installed lifecycle 1.0.3 (149ms) #> ✔ Installed magrittr 2.0.3 (162ms) #> ✔ Installed pillar 1.8.1 (56ms) #> ✔ Installed pkgconfig 2.0.3 (35ms) #> ✔ Installed rlang 1.0.6 (57ms) #> ✔ Installed tibble 3.1.8 (41ms) #> ✔ Installed tidyselect 1.2.0 (40ms) #> ✔ Installed utf8 1.2.2 (37ms) #> ✔ Installed vctrs 0.5.1 (39ms) #> ✔ Installed withr 2.5.0 (31ms) #> ✔ 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_tree()
,
pkg_deps()
,
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.