我应该如何处理“软件包'xxx'不可用(对于R版本xyz)”警告?

本文翻译自:How should I deal with “package 'xxx' is not available (for R version x.y.z)” warning?

I tried to install a package, using 我尝试使用安装软件包

install.packages("foobarbaz")

but received the warning 但收到警告

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

Why doesn't R think that the package is available? R为什么不认为该软件包可用?

See also these questions referring to specific instances of this problem: 另请参阅以下有关此问题的特定实例的问题:

My package doesn't work for R 2.15.2 我的软件包不适用于R 2.15.2
package 'Rbbg' is not available (for R version 2.15.2) 软件包“ Rbbg”不可用(对于R版本2.15.2)
package is not available (for R version 2.15.2) 软件包不可用(对于R版本2.15.2)
package doMC NOT available for R version 3.0.0 warning in install.packages 软件包doMC不适用于install.packages中的R版本3.0.0警告
Dependency 'Rglpk' is not available for package 'fPortfolio' 依赖项“ Rglpk”不适用于软件包“ fPortfolio”
What to do when a package is not available for our R version? 当我们的R版本不提供软件包时该怎么办?
Is the bigvis package for R not available for R version 3.0.1? R的bigvis软件包是否不适用于R版本3.0.1?
package 'syncwave'/'mvcwt' is not available (for R version 3.0.2) 软件包'syncwave'/'mvcwt'不可用(对于R版本3.0.2)
package 'diamonds' is not available (for R version 3.0.0) 软件包“ diamonds”不可用(对于R版本3.0.0)
Is the plyr package for R not available for R version 3.0.2? R的plyr软件包是否不适用于R版本3.0.2?
https://stackoverflow.com/questions/21580661/installing-predictabel-package-on-r-2-15-2 https://stackoverflow.com/questions/21580661/installing-predictabel-package-on-r-2-15-2
Package bigmemory not installing on R 64 3.0.2 软件包bigmemory未安装在R 64 3.0.2上
package "makeR" is not available (for version 3.0.2) 软件包“ makeR”不可用(对于版本3.0.2)
package 'RTN' is not available (for R version 3.0.1) 软件包“ RTN”不可用(对于R版本3.0.1)
Trouble Installing geoR package 无法安装geoR软件包
package 'twitterR' is not available (for R version 3.1.0) 软件包'twitterR'不可用(对于R版本3.1.0)
How to install 'Rcpp, package? 如何安装'Rcpp,包? I got "package is not available" 我收到“程序包不可用”的信息
package 'dataset' is not available (for R version 3.1.1) 软件包“数据集”不可用(对于R版本3.1.1)
"package 'rhipe' is not available (for R version 3.1.2)" “软件包'rhipe'不可用(对于R版本3.1.2)”
https://stackoverflow.com/questions/31439092/package-dplyr-is-not-available-for-r-version-3-1-1 https://stackoverflow.com/questions/31439092/package-dplyr-is-not-available-for-r-version-3-1-1


#1楼

参考:https://stackoom.com/question/1jvR6/我应该如何处理-软件包-xxx-不可用-对于R版本xyz-警告


#2楼

1. You can't spell 1.你不能拼写

The first thing to test is have you spelled the name of the package correctly? 要测试的第一件事是您是否正确拼写了包装名称? Package names are case sensitive in R. 程序包名称在R中区分大小写。


2. You didn't look in the right repository 2.您没有在正确的存储库中查找

Next, you should check to see if the package is available. 接下来,您应该检查包装是否可用。 Type 类型

setRepositories()

See also ?setRepositories . 另请参见?setRepositories

To see which repositories R will look in for your package, and optionally select some additional ones. 要查看R将寻找哪个存储库,并选择其他附加存储库。 At the very least, you will usually want CRAN to be selected, and CRAN (extras) if you use Windows, and the Bioc* repositories if you do any 最起码,你通常会想CRAN被选中,并CRAN (extras) ,如果你使用的是Windows和Bioc*仓库,如果你做任何 [gen/prote/metabol/transcript]omics [gen / prote / metabol / transcript]组学 biological analyses. 生物学分析。

To permanently change this, add a line like setRepositories(ind = c(1:6, 8)) to your Rprofile.site file. 要永久更改此设置,请在Rprofile.site文件中添加诸如setRepositories(ind = c(1:6, 8))行。


3. The package is not in the repositories you selected 3.该软件包不在您选择的存储库中

Return all the available packages using 使用以下命令返回所有可用的软件包

ap <- available.packages()

See also Names of R's available packages , ?available.packages . 另请参见R可用软件包的名称 ?available.packages

Since this is a large matrix, you may wish to use the data viewer to examine it. 由于这是一个大矩阵,因此您可能希望使用数据查看器进行检查。 Alternatively, you can quickly check to see if the package is available by testing against the row names. 另外,您可以通过对行名进行测试来快速检查包是否可用。

View(ap)
"foobarbaz" %in% rownames(ap)

Alternatively, the list of available packages can be seen in a browser for CRAN , CRAN (extras) , Bioconductor , R-forge , RForge , and github . 另外,可用的软件包列表可以在浏览器中看到CRANCRAN(extras)BioconductorR- forgeRForgegithub

Another possible warnings message you may get when interacting with CRAN mirrors is: 与CRAN镜像进行交互时,您可能会收到的另一条警告消息是:

Warning: unable to access index for repository

Which may indicate the selected CRAN repository is currently be unavailable. 这可能表明所选的CRAN存储库当前不可用。 You can select a different mirror with chooseCRANmirror() and try the installation again. 您可以使用chooseCRANmirror()选择其他镜像, chooseCRANmirror()再次尝试安装。


There are several reasons why a package may not be available. 软件包可能不可用的原因有很多。


4. You don't want a package 4.您不想要包裹

Perhaps you don't really want a package. 也许您真的不需要包装。 It is common to be confused about the difference between a package and a library , or a package and a dataset. 对于包和库之间的差异,或者包和数据集之间的差异,通常会感到困惑。

A package is a standardized collection of material extending R, eg providing code, data, or documentation. 包是扩展R(例如提供代码,数据或文档)的材料的标准化集合。 A library is a place (directory) where R knows to find packages it can use 库是R知道找到它可以使用的包的地方(目录)

To see available datasets, type 要查看可用的数据集,请输入

data()

5. R or Bioconductor is out of date 5. R或生物导体已过期

It may have a dependency on a more recent version of R (or one of the packages that it imports/depends upon does). 它可能依赖于R的最新版本(或它导入/依赖的软件包之一)。 Look at 看着

ap["foobarbaz", "Depends"]

and consider updating your R installation to the current version. 并考虑将R安装更新到当前版本。 On Windows, this is most easily done via the installr package. 在Windows上,最容易通过installr程序包来完成。

library(installr)
updateR()

(Of course, you may need to install.packages("installr") first.) (当然,您可能需要先安装install.packages("installr") 。)

Equivalently for Bioconductor packages, you may need to update your Bioconductor installation. 等效于Bioconductor软件包,您可能需要更新Bioconductor安装。

source("http://bioconductor.org/biocLite.R")
biocLite("BiocUpgrade")

6. The package is out of date 6.包已过期

It may have been archived (if it is no longer maintained and no longer passes R CMD check tests). 它可能已存档 (如果不再维护并且不再通过R CMD check测试)。

In this case, you can load an old version of the package using install_version() 在这种情况下,您可以使用install_version()加载软件包的旧版本。

library(remotes)
install_version("foobarbaz", "0.1.2")

An alternative is to install from the github CRAN mirror. 另一种方法是从github CRAN镜像安装。

library(remotes)
install_github("cran/foobarbaz")

7. There is no Windows/OS X/Linux binary 7.没有Windows / OS X / Linux二进制文件

It may not have a Windows binary due to requiring additional software that CRAN does not have. 由于需要CRAN所没有的其他软件,它可能没有Windows二进制文件 Additionally, some packages are available only via the sources for some or all platforms. 此外,某些软件包仅可通过某些或所有平台的来源获得。 In this case, there may be a version in the CRAN (extras) repository (see setRepositories above). 在这种情况下, CRAN (extras)存储库中可能会有一个版本(请参见上面的setRepositories )。

If the package requires compiling code (eg C, C++, FORTRAN) then on Windows install Rtools or on OS X install the developer tools accompanying XCode, and install the source version of the package via: 如果软件包需要编译代码(例如C,C ++,FORTRAN),则在Windows上安装Rtools或在OS X上安装XCode附带的开发人员工具 ,然后通过以下方式安装软件包的源版本:

install.packages("foobarbaz", type = "source")

# Or equivalently, for Bioconductor packages:
source("http://bioconductor.org/biocLite.R")
biocLite("foobarbaz", type = "source")

On CRAN, you can tell if you'll need special tools to build the package from source by looking at the NeedsCompilation flag in the description. 在CRAN上,您可以通过查看描述中的NeedsCompilation标志来判断是否需要特殊的工具来从源代码构建软件包。


8. The package is on github/Bitbucket/Gitorious 8.软件包在github / Bitbucket / Gitorious上

It may have a repository on Github/Bitbucket/Gitorious. 它可能在Github / Bitbucket / Gitorious上有一个存储库。 These packages require the remotes package to install. 这些软件包需要安装remotes软件包。

library(remotes)
install_github("packageauthor/foobarbaz")
install_bitbucket("packageauthor/foobarbaz")
install_gitorious("packageauthor/foobarbaz")

(As with installr , you may need to install.packages("remotes") first.) (与installr ,您可能需要先安装install.packages("remotes") 。)


9. There is no source version of the package 9.没有软件包的源版本

Although the binary version of your package is available, the source version is not. 尽管软件包的二进制版本可用,但源版本不可用。 You can turn off this check by setting 您可以通过设置关闭此检查

options(install.packages.check.source = "no")

as described in this SO answer by imanuelc and the Details section of ?install.packages . imanuelc的SO解答?install.packages的Details部分中所述。


10. The package is in a non-standard repository 10.软件包位于非标准存储库中

Your package is in a non-standard repository (eg Rbbg ). 您的软件包位于非标准存储库中(例如Rbbg )。 Assuming that it is reasonably compliant with CRAN standards, you can still download it using install.packages ; 假设它合理地符合CRAN标准,您仍然可以使用install.packages下载它。 you just have to specify the repository URL. 您只需要指定存储库URL。

install.packages("Rbbg", repos = "http://r.findata.org")

RHIPE on the other hand isn't in a CRAN-like repository and has its own installation instructions . 另一方面, RHIPE不在类似CRAN的存储库中,而是具有其自己的安装说明


#3楼

11. R (or another dependency) is out of date and you don't want to update it. 11. R(或其他依赖项)已过期,并且您不想更新它。

Warning this is not exactly best practice. 警告这并非最佳做法。

  • Download the package source. 下载包源。
  • Navigate to the DESCRIPTION file. 导航到DESCRIPTION文件。
  • Remove the offending line with your text editor eg 用您的文本编辑器删除有问题的行,例如

     Depends: R (>= 3.1.1) 
  • Install from local (ie from the parent directory of DESCRIPTION ) eg 从本地安装(即从DESCRIPTION的父目录安装),例如

     install.packages("foo", type="source", repos=NULL) 

#4楼

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). 对我而言,发生的一件事情是我的Linux发行版提供的R版本(Ubuntu 14.04提供的R版本3.0.2)对于CRAN上可用的软件包的最新版本(在我的情况下为plyr版本1.8)而言太旧了。截至今天为3)。 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 ). 解决的办法是使用我发行版的打包系统,而不是尝试从R安装( apt-get install r-cran-plyr得到了我plyr 1.8.1版本)。 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. 也许我可以尝试使用updateR()更新R,但恐怕这样做会干扰我发行版的软件包管理器。


#5楼

It almost always works for me when I use bioconductor as source and then invoke biocLite. 当我使用生物导体作为来源然后调用biocLite时,它几乎总是对我有用。 Example: 例:

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

#6楼

This saved me a lot of time debugging what's wrong. 这为我节省了大量调试问题的时间。 In many cases are just mirrors out of date. 在许多情况下,镜像只是过时的。 This function can install multiple packages with their dependencies using https://cran.rstudio.com/ : 此功能可以使用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"))
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值