#' get packages required to run R code
#' @details parses all R and Rmd files in a directory and uses \code{\link{parse_packages}}
#'     to find all R packages required for the code to run
#' @param directory folder to search for R and Rmd files
#' @return a vector of package names
#' @export
get_dependent_packages <- function(directory = getwd()) {
  fls <- list.files(path=directory,pattern='^.*\\.R$|^.*\\.Rmd$',
  pkg_names <- unlist(sapply(fls,parse_packages))
  pkg_names <- unique(pkg_names)
  if (length(pkg_names)==0) {
    message('warning: no packages found in specified directory')

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.