Problems in installing Caret package

I have been trying to load CARET package for starting a machine learning course . It takes 4-5 hours to download but fails in the end. I am using R studio

Any help or tips as to what I am doing wrong?

Every time I get error message as below:

Loading required package: lattice

Error: package or namespace load failed for ‘caret’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):

there is no package called ‘recipes’

Information about the R version I am using is below:

sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base

loaded via a namespace (and not attached):
[1] compiler_3.6.3 cli_2.5.0 tools_3.6.3

Have you tried installing the missing package dependency?

install.packages("recipes")

Hi Andresrcs,

I did try to load the Recipes package separately but that failed as well. So I am still stuck with the issues

Can you please be more specific? Do you get an error message? If so, post the complete output message you get when you try to install the recipes package.

Hi Andresrcs,

Here is the error message I am getting when I try to load recipes package:
installing source package 'recipes' ...

** package 'recipes' successfully unpacked and MD5 sums checked

** using staged installation

** R

** inst

** byte-compile and prepare package for lazy loading

Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :

namespace 'ipred' 0.9-11 is being loaded, but >= 0.9.12 is required

Calls: ... namespaceImportFrom -> asNamespace -> loadNamespace

Execution halted

ERROR: lazy loading failed for package 'recipes'

  • removing 'C:/Users/Rekha Rao/Desktop/R-3.6.3/library/recipes'

Warning in install.packages :

installation of package ‘recipes’ had non-zero exit status

The downloaded source packages are in

‘C:\Users\Rekha Rao\AppData\Local\Temp\RtmpQz4lBT\downloaded_packages’

OK, now this is asking you to update the ipred package

install.packages("ipred")

You have to keep debugging this way until you reach the root cause.

Hi Andresrcs,

I did try to load "ipred " package but I am getting errors again

install.packages("ipred", dependencies = TRUE)
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/

There is a binary version available but the source version is
later:
binary source needs_compilation
ipred 0.9-11 0.9-12 TRUE

Binaries will be installed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/ipred_0.9-11.zip'
Content type 'application/zip' length 401183 bytes (391 KB)
downloaded 391 KB

package ‘ipred’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\Rekha Rao\AppData\Local\Temp\RtmpQz4lBT\downloaded_packages

After I tried installing "ipred" I tried again to re-install recipes and got the same error message

installing source package 'recipes' ...
** package 'recipes' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace 'ipred' 0.9-11 is being loaded, but >= 0.9.12 is required
Calls: ... namespaceImportFrom -> asNamespace -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'recipes'

  • removing 'C:/Users/Rekha Rao/Desktop/R-3.6.3/library/recipes'
    Warning in install.packages :
    installation of package ‘recipes’ had non-zero exit status

Basically I am doing Harvard University Course. Trying to create Test and Training sets using CreateDataPartition and getting an error that there is no such function.

test_index <- createDataPartition(y, times = 1, p = 0.5, list = FALSE)
Error in createDataPartition(y, times = 1, p = 0.5, list = FALSE) :
could not find function "createDataPartition"

Thats y I am working backwards to understand what is causing this problem

This is the root cause, you need to install a newer version of the ipred package which is only available in source form for your R version. To install packages from source you need a compiler, for Windows systems this compiler is RTools, which is a separate software that you need to install in your system (not in R).

You can download older versions of RTools (suitable for your older R version) from here:

Although, I would recommend you to update your entire R environment (including base R, RTools and your package library) to the latest versions.

1 Like

I am not a quick typist and posted after andresrcs!

You have successfully installed ipred, but it is still version 0.9-11 and you need 0.9-12. Because you are using an old version of R, 3.6.3, a compiled (binary) version of the newer 0.9-12 is not available on CRAN (CRAN has binaries of 0.9-12 for R 4.0 and R 4.1, the two most recent versions).
You could compile for R 3.6.3 from source but would need to install Rtools first (Rtools is the set of tools to compile packages from C/C++/Fortran code, it is not an R package). Another option is to update the version of R. This will let you install binary versions of packages from CRAN, making life much easier.

Thank you Andresrcs for your patience and help.

I upgraded to the latest version of R and caret package is now working.

Thank you EconProf.

I upgraded the R to latest 4.1.2 version and caret package is now working

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.