-1

Good evening,

I installed R (version 3.5.1) and I work with RStudio (version 1.1.456) on a 64 bits Windows 7 Home Premium with 4.00 GB (RAM). I downloaded the caret package and I loaded it (library(caret)), but when I attempt to use any of its functions the following messages appear. First, with

library(caret)
Loading required package: ggplot2
Error: package or namespace load failed for ‘ggplot2’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
 there is no package called ‘gtable’
Error: package ‘ggplot2’ could not be loaded
In addition: Warning messages:
1: package ‘caret’ was built under R version 3.5.3 
2: package ‘ggplot2’ was built under R version 3.5.3 

And then, when using any of its functions:

myFolds <- createFolds(y_sd_tr, k = 10)
Error in createFolds(y_sd_tr, k = 10) : 
  could not find function "createFolds"

As a result, I am unable to use caret. Can someone provide some help?

Than you, Marc

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
Marc
  • 1
  • 1
    Your question clearly explains what you need to do. You need to upgrade your R (3.5.1) to 3.5.3 (package ‘caret’ was built under R version 3.5.3) – DavidPostill Nov 03 '19 at 19:12
  • Thank you, David. I am new to R; how can I upgrade R to 3.5.3? – Marc Nov 03 '19 at 19:28
  • 1
    [A step by step (screenshots) tutorial for upgrading R on Windows | R-statistics blog](https://www.r-statistics.com/2015/06/a-step-by-step-screenshots-tutorial-for-upgrading-r-on-windows/) – DavidPostill Nov 03 '19 at 19:43
  • Great, thank you! – Marc Nov 03 '19 at 20:49

1 Answers1

1

The warnings are irrelevant here. And usually those warnings about R version are of no consequence. The real problem is:

there is no package called ‘gtable’

Because that is missing ggplot2 refuses to load and because caret requires ggplot2 caret is never loaded.

I wonder what you meant by "downloaded". You should use install.packages to install packages and that should automatically install dependencies unless something went wrong.

Jan Stanstrup
  • 191
  • 1
  • 10
  • Good morning Jan, by downloaded I meant using install.packages("caret") and library(caret). I guess then that something went wrong with the initial installation of caret due to the comment on gtable. In the end, I followed David's advice: I updated R and now caret seems to be running smoothly... – Marc Nov 07 '19 at 10:16
  • The process David links to also updates all packages after the R upgrade. I think that solve it rather than the upgrade of R itself. – Jan Stanstrup Nov 07 '19 at 14:06