load_required_packages: Load packages you need; optionally install them if they're...

Description Usage Arguments Value Examples

Description

Load packages you need; optionally install them if they're not already installed

Usage

1
2
load_required_packages(required_packages,
  try_installing_if_not_present = TRUE)

Arguments

required_packages

A character vector of the quoted names of packages you'd like loaded via the library() function. Because library() isn't vectorised, this function lets you avoid typing a separate library() call for each package you want loaded.

try_installing_if_not_present

Should the function try to install any of your dependencies if need be? This setting is useful if you know what your code requires, but you can't safely assume which (if any) of your required packages will be installed on a user's system. Defaults to TRUE

Value

an invisible copy of the dependencies you passed in

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
load_required_packages(c("boot", "MASS"))

# If you wish to be super-careful,
# you can say NO to automatic package installation.
# If you say no, the function will only try to load your requirements;
# it won't attempt to install anything new even if the package
# you're requiring isn't currently installed
load_required_packages("utils", try_installing_if_not_present = FALSE)
## Not run:  #
https://github.com/hadley/tidyverse
some_packages_from_the_tidyverse <- c( "ggplot2"
                                       , "tidyr"
                                       , "broom" )
load_required_packages(some_packages_from_the_tidyverse) 
## End(Not run)

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