rdata-science-experiencernotebookwatson-studio

Can not install the CRAN package `caret` on IBM Watson Studio R notebooks


While trying to install the R package caret on IBM Watson Studio R notebooks, it installs a lot of dependencies but in the end fails with non-zero exit status errors. The dependency recipes cannot be installed for some reason.

install.packages('caret')

Installing package into ‘/.../R/libs’
(as ‘lib’ is unspecified)
also installing the dependencies ‘numDeriv’, ‘SQUAREM’, ‘lava’, ‘kernlab’, ‘CVST’, ‘DEoptimR’, ‘prodlim’, ‘DRR’, ‘robustbase’, ‘sfsmisc’, ‘ipred’, ‘dimRed’, ‘lubridate’, ‘ddalpha’, ‘gower’, ‘RcppRoll’, ‘tidyselect’, ‘recipes’, ‘withr’

Warning message in install.packages("caret"):
“installation of package ‘recipes’ had non-zero exit status”Warning message in install.packages("caret"):
“installation of package ‘caret’ had non-zero exit status”

Solution

  • The package caret imports a lot of other R packages. One of them is recipes, which in-turn import packages like purrr, lubridate, tibble etc. Newest recipes packages seems to be relying on a mapping function called map_dfr from the purrr package which is not loaded to the namespace. Updating purrr (and maybe a list of other package) might solve the issue. I chose to go one version down on recipes and save a lot of re-installations. This worked for me:

    install.packages('https://cran.r-project.org/src/contrib/Archive/recipes/recipes_0.1.0.tar.gz')
    install.packages('caret')
    library('caret')