简体   繁体   中英

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

library(caret)

加载所需的包:ggplot2 错误:loadNamespace(i,c(lib.loc,.libPaths())中的“ggplot2”的包或命名空间加载失败,versionCheck = vI[[i]]):没有名为“gtable”的包' 错误:无法加载包 'ggplot2'

尝试这个...

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

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)
...

In Ubuntu:

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

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.

Try this ...

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

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.

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/ ')

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.

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.

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.

My honest opinion, this package is absolutely absurd. I have tried everything that everybody has mentioned here and still, this package has screwed up most of my libraries again. And now what do I do?

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

just try this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM