#' Automagically install all required R packages
#' Searches a given directory for all R and R Markdown files, parses them for
#' required packages and attempts to install them from CRAN. More importantly,
#' if a `deps.yaml` file was made using \code{\link{make_deps_file}}, automagic
#' will use this rather than try to install based on a best guess.
#' @param directory folder to search for R and Rmd files
#' @export
#' @seealso \code{\link{install_package_guess}}, \code{\link{parse_packages}}

automagic <- function(directory = getwd()) {
  if (file.exists(file.path(directory,'deps.yaml'))) {
    message('\n\ninstalling from deps.yaml file at\n',
  } else {
    message('no deps.yaml file found in specified directory')
    message('parsing code and attempting to install packages from CRAN')
    get_dependent_packages(directory) %>% install_package_guess()

Try the automagic package in your browser

Any scripts or data that you put into this service are public.

automagic documentation built on May 2, 2019, 6:02 a.m.