Defensive package loading for R
loadr
installs and loads those dependencies for anyone who runs your code.# If you don't currently have devtools
install.packages("devtools")
# then
devtools::install_github("briandk/loadr")
packages_my_code_needs <- c(
"ggplot2",
"tidyr",
"hadley/devtools" # you can specify user/repo combinations for github packages
)
# Automatically installs packages you don't have
# and automatically loads everything via `require()`
loadr::load_required_packages(packages_my_code_needs)
I wrote this package because sometimes
checkpoint
and packrat
are burdensome when you're doing rapid development (or
rapid manuscript-writing). These functions ensure your scripts and documents
will run for anyone with R.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.