How to install Caret package? While installing, I am getting this message

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

Upvotes: 7

Views: 74268

Answers (11)

Alejandro
Alejandro

Reputation: 21

Wrote the command

install.packages("caret")

on my rmd file and had problems with the installation. It was solved just by typing the same line in the console.

Upvotes: 0

RLB
RLB

Reputation: 21

when attempting: install.packages("caret")

I'm getting the following errors:

Warning: unable to access index for repository https://cran.mtu.edu/src/contrib: cannot open URL 'https://cran.mtu.edu/src/contrib/PACKAGES' Warning: unable to access index for repository https://cran.mtu.edu/bin/macosx/el-capitan/contrib/3.6: cannot open URL 'https://cran.mtu.edu/bin/macosx/el-capitan/contrib/3.6/PACKAGES' Warning message: package ‘~/Downloads/caret’ is not available (for R version 3.6.1)

(yes, I should upgrade)

Solved by installing from the Rstudio CRAN repo:

install.packages('caret', repos='http://cran.rstudio.com/')

Upvotes: 1

Ecaterina Vidrascu
Ecaterina Vidrascu

Reputation: 136

I had a similar issue for another package, and the easiest way to fix it was as follows(in RStudio):

  1. Close all open .rmd, .r and .rnw files.
  2. On the right hand lower corner I pressed on Packages and then on update. I selected all packages that needed an update and updated them. (You might also need to restart R, which can be done via Ctrl + Shift + F10).

After this I had no problems.

Upvotes: 1

Eduard Simioni
Eduard Simioni

Reputation: 21

In Ubuntu:

sudo apt-get update
sudo apt-get install r-cran-caret

Upvotes: 2

Sachin Patil
Sachin Patil

Reputation: 21

Try this ...

install.packages('caret', repos='http://cran.rstudio.com/')

Upvotes: 1

Kean Rawr
Kean Rawr

Reputation: 33

I had the same problem when updating to R 3.5, if you changed R versions using something like the updater function from the installr package, it has some problems copying the libraries between major releases (3.4 -> 3.5).

The solution that worked for me was installing manually all the previous libraries.

Upvotes: 0

Nithin kumar
Nithin kumar

Reputation: 1

As Ian suggested, try installing the package mentioned in the error message. I had the same issue and the error was 'there is no package as Biobase'. So I searched on the web for Biobase, installed it, tried library(caret) and it asked for another package and I kept installing till library(caret) worked. In your case, it shows 'there is no package called ‘gtable’. So start with installing gtable and load caret and keep at it.

Upvotes: 0

Roseline Adediran
Roseline Adediran

Reputation: 45

So what worked for me is a bit old school: after installing the caret package and getting that error, I did a quick search on my PC for caret (In my case; I went to ThisPC > RoseAdediran), deleted the caret folder, searched for plyr and deleted the folder as well. Went back to RStudio, restarted the session and tried this code again

install.packages('caret', dependencies=T)
library(caret)

Once you load the library, other imports would be loaded as well.

Upvotes: 1

IanS
IanS

Reputation: 1604

I had the same issue (R 3.5 for Windows).

Just had to keep going installing the missing dependencies until everything installed (for me there were about 10 dependencies missing)

This even required changing to a different mirror when the files could not be found!

Hope this helps someone in future...

> install.packages('caret', dependencies = TRUE)
> 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
> install.packages('gtable', dependencies = TRUE)
> install.packages('ggplot2', dependencies = TRUE)
> library('caret')
Error: package or namespace load failed for ‘caret’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 there is no package called ‘gower’
> install.packages('gower', dependencies = TRUE)
...

Upvotes: 2

Amil Sajeev
Amil Sajeev

Reputation: 280

just try this

install.packages(pkgs = "caret", 
             dependencies = c("Depends", "Imports"))

Upvotes: -1

pyll
pyll

Reputation: 1764

Try this...

install.packages('caret', dependencies = TRUE)

Upvotes: 8

Related Questions