#' Package Test
#'
#' Checks if a package is installed and loaded, if not is does so.
#'
#' @param package The package to check for installation and load.
#' @return The desired package installed and loaded into the environment.
#'
#' @importFrom utils install.packages
#'
#' @export
#'
pkgTest <- function(package) {
if(!require(package, character.only = TRUE)) {
install.packages(package, dependencies = TRUE, repos='http://cran.us.r-project.org')
if(!require(package,character.only = TRUE)) stop('Package not found')
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.