R 中的 rpart 包安装

发布于 2024-12-12 06:35:06 字数 370 浏览 1 评论 0原文

我正在尝试在 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

谁能告诉我错误是什么吗?怎么解决?

I am trying to install "rpart" package in R. But I am getting the following error.

> 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

Can anyone please tell whats the error about? How to solve?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云胡 2024-12-19 06:35:06

开始提示:如果您不确定是否已有软件包,您可以使用例如函数 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 下载并安装它,没有任何问题,但是如果您检查 CRAN 上的包页面,你会看到很重要的一行:

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

它告诉你它仅适用于 R 2.13 及以下版本。根据您的错误,我推断您仍在运行 2.11。相当多的软件包不再适用于 CRAN 的旧 R 版本,因此您最好更新您的 R。否则您会更频繁地遇到此问题。

请注意,如果您运行 Debian,则需要付出更多努力,因为 Debian 中的默认 R 总是过时的。以防万一,您可以在此处找到执行此操作的说明。

A tip to start: If you're not sure whether you have a package already, you can use eg the function find.package() to check:

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

The problem is not so much that it is installed by default. It can be downloaded and installed from CRAN without problem using install.packages('rpart'), but if you check at the package page on CRAN, you see a very important line:

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

which tells you that it is only available for R 2.13 and following versions. From your error, I deduce you still run 2.11. Quite some packages are not available for that old R version from CRAN any more, so you better update your R. Otherwise you'll run into this problem more often.

Be aware that if you run Debian, you'll have to do a bit more effort, as the default R in debian is always outdated. Just in case, you find the directions to do that here.

递刀给你 2024-12-19 06:35:06

我发现,一旦重新启动 RStudio,我就能够安装该软件包,并且 find.package() 显示我现在已经拥有了这些软件包。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文