#' Dynamically install packages as needed and load them
#'
#' @param ... packages as character strings
#'
#' @examples
#' usingPkg("dplyr", "tidyr", "ggplot2")
#' @export
#'
usingPkg <- function(...) {
libs <- unlist(list(...))
req <- unlist(lapply(libs, require, character.only = TRUE))
need <- libs[req == FALSE]
if(length(need) > 0) {
install.packages(need)
lapply(need, require, character.only = TRUE)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.