r中的rpart包安装

时间:2011-10-29 06:01:43

标签: r rpart

我正在尝试在R中安装“rpart”包。但是我收到以下错误。

> install.packages('rpart')
Warning in install.packages("rpart") :
  argument 'lib' is missing: using '/home/sandeep/R/i686-pc-linux-gnu-library/2.11'
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
  package ‘rpart’ is not available

任何人都可以告诉我们有什么错误吗?怎么解决?

2 个答案:

答案 0 :(得分:3)

开始提示:如果您不确定是否已有包裹,可以使用例如find.package()功能来检查:

> find.package('rpart')
[1] "D:/R/library/rpart"
> find.package('lololool')
Error in find.package("lololool") : there is no package called 'lololool'

问题不在于它是默认安装的。可以使用install.packages('rpart')从CRAN下载并安装它,但如果您在package page on CRAN处查看,则会看到一条非常重要的行:

Depends:    R (≥ 2.13.0), graphics, stats, grDevices

告诉您它仅适用于R 2.13及以下版本。从你的错误中,我推断你仍然运行2.11。相当一些软件包不再适用于CRAN的旧R版本,所以你最好更新你的R.否则你会更频繁地遇到这个问题。

请注意,如果你运行Debian,你将不得不做更多的努力,因为debian中的默认R总是过时的。为了以防万一,您可以找到执行此操作的说明here

答案 1 :(得分:0)

I found that once I restarted RStudio that I was able to install the package and find.package() showed I did, now, have the packages.