package_names <- c("boot", "caret", "deSolve", "epiR", "FME", "ggeffects", "ggplot2", "gridExtra", "lme4", "MuMIn", "parallel", "png", "readr", "reshape2", "rlang", "sjlabelled", "sjmisc", "sjPlot", "sjstats") #' Get package dependencies #' #' @param packs A string vector of package names #' #' @return A string vector with packs plus the names of any dependencies getDependencies <- function(packs){ dependencyNames <- unlist( tools::package_dependencies(packages = packs, db = available.packages(), which = c("Depends", "Imports"), recursive = TRUE)) packageNames <- union(packs, dependencyNames) packageNames } # Calculate dependencies packages <- getDependencies(package_names) # Download the packages to the working directory # Package names and filenames are returned in a matrix. setwd("C:/Users/Tim/Downloads/packages/") #Windows pkgInfo <- download.packages(pkgs = packages, destdir = getwd(), type = "win.binary") # Save just the package file names (basename() strips off the full paths leaving just the filename) write.csv(file = "pkgFilenames.csv", basename(pkgInfo[, 2]), row.names = FALSE) setwd("C:/Users/Tim/Downloads/packages/mac/") #Mac pkgInfo_mac <- download.packages(pkgs = packages, destdir = getwd(), type = "mac.binary.el-capitan") # Save just the package file names (basename() strips off the full paths leaving just the filename) write.csv(file = "pkgFilenames_mac.csv", basename(pkgInfo_mac[, 2]), row.names = FALSE)