R/check_required_pkgs.R

Defines functions check_required_pkgs

Documented in check_required_pkgs

#' Check the required packages and install them
#'
#' @param pkgs_vec a character vector contains names of required packages.
#'
#' @return None (invisible `NULL`)
#'
#' @export
#'
#' @examples
#' # library(antgreens)
#' # pkgs <- c('data.table', 'tidyverse', 'Rcpp')
#' # check_required_pkgs(pkgs)
check_required_pkgs <- function(pkgs_vec = c("data.table", "readxl", "readr", "bookdown")) {
  void <- lapply(
    pkgs_vec,
    function(pkg) {
      if (system.file(package = pkg) == '') utils::install.packages(pkg)
    }
  )
  message("Finished checking and installing required packages.")
}
YuanchenZhu2020/antgreens documentation built on Dec. 18, 2021, 8:20 p.m.