我试着安装一个包,使用
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)"
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)
我发现@Richie Cotton的出色解决方案中#6包的一个轻微变化已经过时了。
有时包维护者可能会显示它不支持的R版本差距。在这种情况下,您至少有两个选择:1)将您的R版本升级到目标包已经支持的下一个版本,2)从可用的旧版本中安装最新的版本,以配合您的R版本。
一个具体的例子:用于数据挖掘的包的最新CRAN版本5.3.0不支持R版本3.4,因为它在包版本5.2.0 (R >= 2.13.0)和5.3.0 (R >=3.5)之间有很大的更新。
在这种情况下,升级R安装的替代方案是前面提到的解决方案。如果您没有devtools包(其中包括包远程),请安装devtools包,然后安装可以在当前r中工作的特定版本。您可以在CRAN页面上查找特定的包存档信息。
library("devtools")
install_version("rattle", version = "5.2.0", repos = "http://cran.us.r-project.org")