View source: R/misc_functions.R
dependencies | R Documentation |
This is a wrapper to require
and install.packages
.
Specifically, this will first try to load the package(s) and if not found
it will install then load and attach the packages. Additionally, if the
update=TRUE
parameter is specified it will check the currently
installed package version with what is available on CRAN (or mirror) and
install the newer version.
dependencies(
pkges,
install = TRUE,
update = FALSE,
quiet = TRUE,
verbose = FALSE,
...
)
pkges |
a character vector with the names of the packages to load. |
install |
if TRUE (default), any packages not already installed will be. |
update |
if TRUE, this function will install a newer version of the package if available. |
quiet |
if TRUE (default), package startup messages will be suppressed. |
verbose |
if TRUE (default), diagnostic messages will be printed. |
... |
other parameters passed to |
The function was originally created by Jason Bryer
here
and the source is available here.
Note: I renamed the function to dependencies
and adapted it to attach
instead of only load the packages.
a data frame with four columns and rownames corresponding to the
packages to be loaded. The four columns are: loaded (logical
indicating whether the package was successfully loaded), installed
(logical indicating that the package was installed or updated),
loaded.version (the version string of the installed package), and
available.version (the version string of the package currently
available on CRAN). Note that this only reflects packages listed in
the pkges
parameter. Other packages may be loaded and/or
installed as necessary by install.packages
and require
.
If verbose=FALSE
the data frame will be returned using
invisible
.
## Not run:
dependencies(c('devtools','lattice','ggplot2','psych'))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.