Can't Install Caret and Recipes

Hi! I'm trying to install caret using this code

install.packages("caret", dependencies = TRUE)
library("caret")

But the console output says

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

So I tried installing recipes like this

install.packages("recipes")

But it cannot be installed. Here's the error message in console.

> 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/
> Installing package into ‘C:/Users/Bili/OneDrive/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
> 	C:\Users\Bili\AppData\Local\Temp\RtmpCc9Ydn\downloaded_packages
> 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
> 
> Warning in strptime(xx, f, tz = tz) :
>   unable to identify current timezone 'W':
> please set environment variable 'TZ'
> * 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
> Warning message:
> package 'dplyr' was built under R version 3.6.3 
> Warning in as.POSIXlt.POSIXct(Sys.time()) :
>   unable to identify current timezone 'W':
> please set environment variable 'TZ'
> 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: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace
> Execution halted
> ERROR: lazy loading failed for package 'recipes'
> * removing 'C:/Users/Bili/OneDrive/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
> 	‘C:\Users\Bili\AppData\Local\Temp\RtmpCc9Ydn\downloaded_packages’
> 
> Can somebody please help me with the problem? I'm a beginner RStudio user and would really appreciate a useful tip. Thank you
> ```
> ```
> 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/
> Installing package into ‘C:/Users/Bili/OneDrive/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
> 	C:\Users\Bili\AppData\Local\Temp\RtmpCc9Ydn\downloaded_packages
> 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
> 
> Warning in strptime(xx, f, tz = tz) :
>   unable to identify current timezone 'W':
> please set environment variable 'TZ'
> * 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
> Warning message:
> package 'dplyr' was built under R version 3.6.3 
> Warning in as.POSIXlt.POSIXct(Sys.time()) :
>   unable to identify current timezone 'W':
> please set environment variable 'TZ'
> 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: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace
> Execution halted
> ERROR: lazy loading failed for package 'recipes'
> * removing 'C:/Users/Bili/OneDrive/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
> 	‘C:\Users\Bili\AppData\Local\Temp\RtmpCc9Ydn\downloaded_packages’

You are using a very old R version so the latest package versions are only available for you as source code which requires compilation to be installed. For compiling packages on Windows systems you need to install RTools, you can download a suitable version (for your R version) from here.

Although I would recommend updating your R version

1 Like

Hi, andresrcs!
Thank you so much for the answer. I upgraded my R version to 4.1.3 and it worked just fine. I really appreciate it