2

I am testing most of the models caret supports on a bunch of PCs. Unfortunately caret "suggested" packages do not include most of the model packages available to caret. Every time a new version of R comes out I have to sit in front of each PC and wait for each prompt to press the 1 button and Enter. Is there an option I could set to tell R or Rstudio to just install anything asked for? A for every a/s/n prompt too.

list.of.packages <- c("caretEnsemble","logicFS"," RWeka","ordinalNet","xgboost","mlr","caret","MLmetrics","bartMachine","spikeslab","party","rqPen","monomvn","foba","logicFS","rPython","qrnn","randomGLM","msaenet","Rborist","relaxo","ordinalNet","rrf","frbs","extraTrees","ipred","elasticnet","bst","brnn","Boruta","arm","elmNN","evtree","extraTrees","deepnet","kknn","KRLS","RSNNS","partDSA","plsRglm","quantregForest","ranger","inTrees")


new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages, dep = TRUE)


install.packages("mlr", dependencies = c("Depends", "Suggests"))
install.packages("caret", dependencies = c("Depends", "Suggests"))

Code I went with:

 list.of.packages <-getModelInfo(allmodel)[[1]]$library;
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])];
if(length(new.packages)) install.packages(new.packages, dep = TRUE)
ran8
  • 187
  • 11

2 Answers2

1

This code:

getPackages <- function(packs){
  packages <- unlist(
    tools::package_dependencies(packs, available.packages(),
                                which=c("Depends", "Imports", "Suggests"), # 
                                recursive=TRUE)
  )
  packages <- union(packs, packages)
  packages
}

packages <- getPackages(c("caret")) # add in other packages you want here
install.packages(packages)

from https://stackoverflow.com/a/15650828/6619250 allows you to install all dependencies (recursively) from "Depends", "Imports", and "Suggests"

However, actually trying out this code results in a list of 959 (!!) packages because of the list of 'Suggests' packages.

Hence, I would advice you to take a look at the list of "Suggests" packages in CRAN and replace caret with your own list, which you will have to do go through yourself to determine which packages you want.

hongsy
  • 1,498
  • 1
  • 27
  • 39
  • I'm afraid this does not really work for me. Or rather I already have a list and install caret's suggests too. But caret adds algorithms with new packages. – ran8 Jul 31 '17 at 12:03
  • what sort of new packages does it add? – hongsy Aug 01 '17 at 03:31
  • packages ・RWeka・ rPython・ are not available (for version..) – ran8 Aug 01 '17 at 04:05
  • but they will still be asked for every pass through the models list. And caret does not always add the necessary packages to "suggests". As you saw recursive suggests seems like it DLs the entire CRAN archive. – ran8 Aug 01 '17 at 04:19
  • getModelInfo()$adaboost$library So how do I use a variable instead of $adaboost$? – ran8 Aug 01 '17 at 10:19
  • according to [the caret documentation](https://www.rdocumentation.org/packages/caret/versions/6.0-76/topics/modelLookup), `getModelInfo` is meant to provide you with additional information (e.g. functions, metadata) associated with a model. the documentation suggests using `checkInstall()` to check if the packages needed are installed – hongsy Aug 02 '17 at 01:47
  • Code I went with: list.of.packages <-getModelInfo(allmodel)[[1]]$library; new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]; if(length(new.packages)) install.packages(new.packages, dep = TRUE); ::should I make this an answer? – ran8 Aug 04 '17 at 10:56
0

run it from .bat

"C:\Program Files\R\R-3.4.2\bin\x64\R.exe" CMD BATCH ULTIMATESTACKING3skippingMCandUS.R

and add

options(repos=structure(c(CRAN="https://cran.cnr.berkeley.edu/")))

to beginning of R file

ran8
  • 187
  • 11