在RStudio

时间:2018-01-24 06:29:53

标签: r r-caret

我一直在尝试使用插入库来处理简单的ML应用程序。我使用的是最新版本的R(3.4.3)和RStudio(1.1.414)。这是我的方法

install.packages("caret",repos = "http://cran.r-project.org", dependencies = c("Depends", "Imports", "Suggests"))

当我运行代码库(插入符号)时,我收到以下错误

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’

现在我前进并安装了它一一建议的软件包,即DEOPtimR,gower等。这个列表永远不会结束,因为一旦我安装了一个软件包,它就会要求另一个软件包。我很沮丧。我确实在每个论坛都抬头但它并没有解决我的问题。我不知道为什么代码install.package没有安装所有必需的包,即使我明确要求这样做。当我检查.libPaths()时,我可以看到它可以访问我的两个库目录

[1] "C:/Users/omid/Documents/R/win-library/3.4"
[2] "C:/Program Files/R/R-3.4.3/library" 

有人能帮忙吗?

编辑1:

install.packages("caret",repos = "https://cran.r-project.org", dependencies = c("Depends", "Imports"))
Installing package into ‘C:/Users/omidm/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.r-project.org/bin/windows/contrib/3.4/caret_6.0-78.zip'
Content type 'application/zip' length 5155777 bytes (4.9 MB)
downloaded 4.9 MB

package ‘caret’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\omidm\AppData\Local\Temp\RtmpGuZ1vH\downloaded_packages

library(caret)
Loading required package: lattice
Loading required package: ggplot2
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’

我还卸载了R和RStudio并再次安装它们。仍然得到同样的错误。

解决:

我设法以某种方式解决了这个问题,但是,我仍然不确定如何。这就是我做的事情

打开R GUI(不是RStudio)并运行:

install.packages("installr") # install 
installr::updateR() # updating R

键入q()退出然后打开RStudio。转到包并更新所有包

根据@chinsoon和@Ronald

的评论安装包插入符号
install.packages("caret", dependencies=c("Depends", "Imports"))

如果您仍然收到有关任何软件包的错误,请安装该软件包。它不会要求任何其他包,因为您已从依赖项中删除“建议”。希望这可以解决一些人的问题。

1 个答案:

答案 0 :(得分:0)

简单易用:

install.packages("gower")
library(caret)