The new package pak
does this.
library(pak)
pak::pkg_install("ggplot2")
Since ggplot2
was already installed on my machine, this does nothing:
i Checking for package metadata updates
v Downloaded metadata files, 2.35 MB in 4 files.
√ Updating metadata database
v Using cached package metadata
v 1 + 32 pkgs | kept 29, updated 0, new 0 | downloaded 0 (0 B) [11.8s]
But using update = TRUE
triggers a dry run of what will happen:
pak::pkg_install("ggplot2", upgrade = TRUE)
Resulting in:
i Checking for package metadata updates
v All 10 metadata files are current.
v Using session cached package metadata
v Using cached package metadata
> Will update 4 packages:
Matrix, mgcv, MASS, nlme
> Will not update 29 packages.
> Will download 3 CRAN packages (7.88 MB).
> Will download 1 packages with unknown size.
? Do you want to continue (Y/n)
The package pak
is on CRAN, has pkgdown
documentation at https://pak.r-lib.org/ and a recording of Gabor's video at RStudio::conf(2019). (Note that in the video, the package was still called pkgman
, and was subsequently renamed to pak
.)