install_packages_if_necessary: Selectively install the packages you specify

Description Usage Arguments Value Examples

Description

This function takes a vector of packages, determines which packages aren't currently installed, and installs only the missing dependencies.

Usage

1
2
install_packages_if_necessary(dependencies,
  installed_packages = utils::installed.packages())

Arguments

dependencies

A character vector of packages your code requires. If you want to depend on a CRAN package, just use its bare name: "ggplot". If you want to depend on a package hosted on Github, specify your package as "user/repo" and loadr will automatically install the package from Github.

installed_packages

A character vector of packages already installed. loadr will not attempt to install these packages. loadr will only install packages in dependencies that do not appear here. The parameter defaults to utils::installed.packages(), which I'm pretty sure is what you want. But on the off chance you want to supply some alternative list of packages, you can just override this default.

Value

An invisible character vector of the packages that were required but not present in installed_packages. Ideally, this should be a vector of just the packages that were installed, but on the off chance an installation fails, a package name may appear here even if it wasn't successfully installed. So, I'll try to work on that.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
install_packages_if_necessary("ggplot2")
# specifying a package as "user/repo" will
# install from Github using devtools::install_github()
install_packages_if_necessary("briandk/granovagg")
my_dependencies = c("tidyr", "hadley/testthat")
install_packages_if_necessary(my_dependencies)

## End(Not run)

briandk/loadr documentation built on May 13, 2019, 7:41 a.m.