我试着安装一个包,使用

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

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

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

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

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

另一个原因+解决方案

当我试图在我公司的HPC上的RStudio中安装pkgdown时,我遇到了这个错误(“包XXX对于R版本X.X.X不可用”)。

事实证明,他们在HPC上拥有的CRAN快照是2018年1月(几乎2年前)的,而且pkgdown当时确实不存在。这意味着为外行用户控制包的源代码,但作为开发人员,在大多数情况下,您可以通过以下方式更改:

## checking the specific repos you currently have
getOption("repos")

## updating your CRAN snapshot to a newer date
r <- getOption("repos")
r["newCRAN"] <- "https://cran.microsoft.com/snapshot/*2019-11-07*/"
options(repos = r)

## add newCRAN to repos you can use
setRepositories()

如果您知道您在做什么,并且可能需要多个在您的系统的CRAN中不可用的包,您可以在您的项目. rprofile中进行设置。

如果只有一个包,可能只使用install。包(“包名”,repos =“一个比你公司的旧的CRAN快照更新的CRAN”)。

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)

另一个小的添加,当尝试使用docker映像摇杆/ R -ver:3.1.0测试旧R版本时

默认的回购设置是MRAN,这无法获得许多包。 那个版本的R没有https,所以,举个例子: 安装。Packages ("knitr", repos = "https://cran.rstudio.com")似乎可以工作。