我试着安装一个包,使用

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)"


当前回答

我也有同样的问题(在Linux上),可以通过更改代理设置来解决。 如果您在代理服务器后面,请使用R. getenv("http_proxy")检查配置。 在我的~/。我有以下几行(来自https://support.rstudio.com/hc/en-us/articles/200488488-Configuring-R-to-Use-an-HTTP-or-HTTPS-Proxy)导致了这个问题:

http_proxy=https://proxy.dom.com:port
http_proxy_user=user:passwd

改为

http_proxy="http://user:passwd@proxy.dom.com:port"

解决了问题。你可以对https做同样的事情。

当我读到“包xxx不可用于r版本-x-y-z”时,我的第一个想法不是……

HTH

其他回答

这为我节省了大量调试错误的时间。在很多情况下,只是镜子过时了。该函数可以使用https://cran.rstudio.com/:安装多个包及其依赖项

packages <- function(pkg){
    new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
    if (length(new.pkg))
        install.packages(new.pkg, dependencies = TRUE, repos='https://cran.rstudio.com/')
    sapply(pkg, require, character.only = TRUE)
}

packages(c("foo", "bar", "baz"))

当我使用生物导体作为源,然后调用生物clite时,它几乎总是为我工作。例子:

source("https://bioconductor.org/biocLite.R")
biocLite("preprocessCore")

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

在R 3.2.3(2016年新发布)中有一个错误,有时会阻止它找到正确的包。解决方法是手动设置存储库:

install.packages("lubridate", dependencies=TRUE, repos='http://cran.rstudio.com/')

在其他问题中找到解决方案

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)