Description Usage Arguments Value Examples
This function takes a vector of packages, determines which packages aren't currently installed, and installs only the missing dependencies.
1 2 | install_packages_if_necessary(dependencies,
installed_packages = utils::installed.packages())
|
dependencies |
A character vector of packages your code requires. If you
want to depend on a CRAN package, just use its bare name: |
installed_packages |
A character vector of packages already installed.
loadr will not attempt to install these packages. loadr will only install
packages in |
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.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.