Unable to load caret package

Error while loading caret package

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

I tried to install recipes with this code- install.packages("recipes") after gotten the above error message, then tried to load caret with the code library ("caret"), still got the same error message above. I need help please.

Please post the complete console output you get when you try to install this package.

WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

Installing package into ‘C:/Users/AVENGERS/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
also installing the dependency ‘ipred’

There are binary versions available but the source
versions are later:
binary source needs_compilation
ipred 0.9-11 0.9-12 TRUE
recipes 0.1.16 0.2.0 FALSE

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
installing the source package ‘recipes’

trying URL 'https://cran.rstudio.com/src/contrib/recipes_0.2.0.tar.gz'
Content type 'application/x-gzip' length 582287 bytes (568 KB)
downloaded 568 KB

  • 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/AVENGERS/Documents/R/win-library/3.6/recipes'
    Warning in install.packages :
    installation of package ‘recipes’ had non-zero exit status

The downloaded source packages are in

Since you are using an old R version, the ipred package requires compilation to be updated, and for that, you need to have RTools installed in your system.

You can download a suitable version of RTools from here

Although, I would recommend updating to the latest R version (4.1.2) so you can get access to precompiled binaries

Thank you so much. It is working perfectly now, I updated to the newest R version as suggested.