简体   繁体   English

如何安装 Caret 包? 安装时,我收到此消息

[英]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).我有同样的问题(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)只需要继续安装缺少的依赖项,直到所有东西都安装好(对我来说,缺少大约 10 个依赖项)

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:在 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.所以对我有用的是有点老派:安装 caret 包并出现错误后,我在我的电脑上快速搜索了 caret(在我的情况下;我去了 ThisPC > RoseAdediran),删除了 caret 文件夹,搜索了对于plyr并删除了该文件夹。 Went back to RStudio, restarted the session and tried this code again回到 RStudio,重新启动会话并再次尝试此代码

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/ ') 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):我对另一个包有类似的问题,修复它的最简单方法如下(在 RStudio 中):

  1. Close all open .rmd, .r and .rnw files.关闭所有打开的 .rmd、.r 和 .rnw 文件。
  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). (您可能还需要重新启动 R,这可以通过 Ctrl + Shift + F10 完成)。

After this I had no problems.在此之后我没有任何问题。

when attempting: install.packages("caret")尝试时: 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)警告:无法访问存储库的索引https://cran.mtu.edu/src/contrib :无法打开 URL ' https://cran.mtu.edu/src/contrib/PACKAGES ' 警告:无法访问存储库的索引https://cran.mtu.edu/bin/macosx/el-capitan/contrib/3.6 :无法打开 URL 'https://cran.mtu.edu/bin/macosx/el-capitan/contrib/3.6/PACKAGES '警告消息:包 '~/Downloads/caret' 不可用(对于 R 版本 3.6.1)

(yes, I should upgrade) (是的,我应该升级)

Solved by installing from the Rstudio CRAN repo:通过从 Rstudio CRAN repo 安装解决:

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

As Ian suggested, try installing the package mentioned in the error message.正如 Ian 建议的那样,尝试安装错误消息中提到的软件包。 I had the same issue and the error was 'there is no package as Biobase'.我遇到了同样的问题,错误是“没有像 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.所以我在网上搜索了 Biobase,安装了它,尝试了 library(caret),它要求另一个包,我一直安装直到 library(caret) 工作。 In your case, it shows 'there is no package called 'gtable'.在你的情况下,它显示'没有名为'gtable'的包。 So start with installing gtable and load caret and keep at it.因此,从安装 gtable 并加载插入符号开始并坚持下去。

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).更新到 R 3.5 时我遇到了同样的问题,如果您使用installr包中的updater功能更改 R 版本,则在主要版本(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.在我的 rmd 文件上,安装有问题。 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"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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