我试着安装一个包,使用

install.packages("foobarbaz")

却收到了警告

Warning message:
package 'foobarbaz' is not available (for R version x.y.z)

为什么R认为这个包是不可用的?

参见这些问题的具体例子:

My package doesn't work for R 2.15.2 package 'Rbbg' is not available (for R version 2.15.2) package is not available (for R version 2.15.2) package doMC NOT available for R version 3.0.0 warning in install.packages Dependency ‘Rglpk’ is not available for package ‘fPortfolio’ What to do when a package is not available for our R version? Is the bigvis package for R not available for R version 3.0.1? package ‘syncwave’/‘mvcwt’ is not available (for R version 3.0.2) package ‘diamonds’ is not available (for R version 3.0.0) Is the plyr package for R not available for R version 3.0.2? Package bigmemory not installing on R 64 3.0.2 package "makeR" is not available (for version 3.0.2) package ‘RTN’ is not available (for R version 3.0.1) Trouble Installing geoR package package ‘twitterR’ is not available (for R version 3.1.0) How to install 'Rcpp, package? I got "package is not available" package ‘dataset’ is not available (for R version 3.1.1) "package ‘rhipe’ is not available (for R version 3.1.2)"


当前回答

当我在R-3.4.1中得到相同的警告时,这就是我最终可以为安装psych软件包所做的事情

1:谷歌那个包裹。

2:手动下载,扩展名为tar.gz

3:选择“包归档文件(.zip;.tar.gz)”选项安装R中的包

4:本地浏览到下载的地方,点击安装

你可能会得到一个警告:软件包的依赖项'xyz'不可用,然后首先从存储库安装这些依赖项,然后执行步骤3-4 .

其他回答

在我的例子中,解决方案是简单地升级R。

这个解决方案可能会破坏R,但这里有一个最简单的解决方案,99%的时间都有效。

你需要做的只是:

install.packages('package-name',repos='http://cran.us.r-project.org')

正如作者在这里提到的

正如这里(用法语)提到的,当您的计算机上安装了两个版本的R时,就会发生这种情况。卸载旧的包,然后再次尝试包安装!这对我来说很有效。

11. R(或其他依赖项)已经过期,您不想更新它。

警告:这并不是最佳实践。

下载包源代码。 导航到DESCRIPTION文件。 用你的文本编辑器删除恼人的行。 取决于:R (>= 3.1.1) 从本地安装(即从DESCRIPTION的父目录安装)。 安装。packages("foo", type="source", repos=NULL)

One thing that happened for me is that the version of R provided by my linux distribution (R version 3.0.2 provided by Ubuntu 14.04) was too old for the latest version of the package available on CRAN (in my case, plyr version 1.8.3 as of today). The solution was to use the packaging system of my distribution instead of trying to install from R (apt-get install r-cran-plyr got me version 1.8.1 of plyr). Maybe I could have tried to update R using updateR(), but I'm afraid that doing so would interfere with my distribution's package manager.


编辑(04/08/2020):我最近遇到了一个包(XML)的问题,据报道,在CRAN中的包更新后,我的R版本(3.6.3,Debian伸展上的最新支持)不可用。这非常出乎意料,因为我之前已经成功地安装了它(在相同的R版本和相同的操作系统上)。

由于某种原因,软件包仍然在那里,但是请安装。Packages只查看更新的(且不兼容的)版本。解决方案是找到兼容版本的URL并强制安装。使用它的包,如下:

install.packages("https://cran.r-project.org/src/contrib/Archive/XML/XML_3.99-0.3.tar.gz", repos=NULL, type="source", ask=FALSE)