R/pkgTest.R

Defines functions pkgTest

Documented in pkgTest

#' 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')

  }
}
blazickjoe/DataScienceLibrary documentation built on Nov. 5, 2019, 2:26 p.m.