我应该如何处理“package 'xxx' is not available (for R version x.y.z)";警告? [英] How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?

查看:17
本文介绍了我应该如何处理“package 'xxx' is not available (for R version x.y.z)";警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试安装一个包,使用

I tried to install a package, using

install.packages("foobarbaz")

但收到警告

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

为什么 R 不认为该包可用?

Why doesn't R think that the package is available?

另请参阅有关此问题的特定实例的这些问题:

See also these questions referring to specific instances of this problem:

我的包不适用于 R 2.15.2
包Rbbg"不可用(对于 R版本 2.15.2)
包不可用(对于 R 版本 2.15.2)
软件包 doMC 不可用对于 install.packages 中的 R 版本 3.0.0 警告
依赖关系Rglpk"不适用于包fPortfolio"
遇到包裹该怎么办不适用于我们的 R 版本?
是bigvis包吗对于 R 版本 3.0.1 不可用?
包'syncwave'/'mvcwt'不可用(对于 R 版本 3.0.2)
包diamonds"不可用(对于 R版本 3.0.0)
是plyr包对于 R 版本 3.0.2 不可用?
未在 R 64 3.0.2 上安装的包 bigmemory
包makeR";不可用(适用于 3.0.2 版)
包RTN"不可用(对于 R版本 3.0.1)
安装 geoR 包时遇到问题
包twitterR"不可用(对于 R版本 3.1.0)
如何安装'Rcpp,包?我收到包裹不可用"
包数据集"不可用(对于 R版本 3.1.1)
包‘rhipe’不可用(对于 R 版本 3.1.2)"

推荐答案

1.你不会拼写

首先要测试的是您是否正确拼写了包的名称?包名称在 R 中区分大小写.

The first thing to test is have you spelled the name of the package correctly? Package names are case sensitive in R.

2.您没有查看正确的存储库

接下来,您应该检查包是否可用.输入

Next, you should check to see if the package is available. Type

setRepositories()

另见?setRepositories.

要查看 R 将在哪些存储库中查找您的包,并可选择选择一些其他存储库.至少,您通常希望 CRAN 被选中,CRAN (extras)(如果您使用 Windows)和 Bioc* 存储库如果您进行任何生物分析.

To see which repositories R will look in for your package, and optionally select some additional ones. 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 biological analyses.

要永久更改此设置,请将类似 setRepositories(ind = c(1:6, 8)) 的行添加到您的 Rprofile.site 文件.

To permanently change this, add a line like setRepositories(ind = c(1:6, 8)) to your Rprofile.site file.

3.该软件包不在您选择的存储库中

使用

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

或者,可以在 CRAN 的浏览器中查看可用软件包列表, CRAN(附加), Bioconductor, R-forge, RForgeGitHub.

Alternatively, the list of available packages can be seen in a browser for CRAN, CRAN (extras), Bioconductor, R-forge, RForge, and GitHub.

在与 CRAN 镜像交互时您可能会收到的另一条可能的警告消息是:

Another possible warnings message you may get when interacting with CRAN mirrors is:

Warning: unable to access index for repository

这可能表示所选的 CRAN 存储库当前不可用.您可以使用 chooseCRANmirror() 选择不同的镜像,然后再次尝试安装.

Which may indicate the selected CRAN repository is currently be unavailable. You can select a different mirror with chooseCRANmirror() and try the installation again.

包不可用的原因有多种.

There are several reasons why a package may not be available.

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.

包是扩展 R 的标准化材料集合,例如提供代码、数据或文档.库是 R 知道可以找到它可以使用的包的地方(目录)

A package is a standardized collection of material extending R, e.g. providing code, data, or documentation. A library is a place (directory) where R knows to find packages it can use

要查看可用数据集,请键入

To see available datasets, type

data()


5.R 或 Bioconductor 已过时

它可能依赖于更新版本的 R(或它导入/依赖的包之一).看看

It may have a dependency on a more recent version of R (or one of the packages that it imports/depends upon does). Look at

ap["foobarbaz", "Depends"]

并考虑将您的 R 安装更新到当前版本.在 Windows 上,这最容易通过 installr 包.

and consider updating your R installation to the current version. On Windows, this is most easily done via the installr package.

library(installr)
updateR()

(当然,您可能需要先install.packages(installr").)

(Of course, you may need to install.packages("installr") first.)

对于 Bioconductor 软件包,您可能需要更新您的 Bioconductor 安装.

Equivalently for Bioconductor packages, you may need to update your Bioconductor installation.

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


6.包裹已过期

它可能已经归档(如果它不再维护并且不再通过 R CMD check 测试).

It may have been archived (if it is no longer maintained and no longer passes R CMD check tests).

在这种情况下,您可以使用 加载旧版本的包install_version()

In this case, you can load an old version of the package using install_version()

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

另一种方法是从 GitHub CRAN 镜像安装.

An alternative is to install from the GitHub CRAN mirror.

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


7.没有 Windows/OS X/Linux 二进制文件

它可能没有 Windows 二进制文件,原因是需要 CRAN 没有的附加软件.此外,某些软件包只能通过某些或所有平台的源获得.在这种情况下,CRAN (extras) 存储库中可能有一个版本(请参阅上面的 setRepositories).

It may not have a Windows binary due to requiring additional software that CRAN does not have. 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).

如果软件包需要编译代码(例如 C、C++、FORTRAN),则在 Windows 上安装 Rtools 或在 OS X 上安装 XCode 随附的开发者工具,并安装包的源版本通过:

If the package requires compiling code (e.g. 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:

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

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

在 CRAN 上,您可以通过查看说明中的 NeedsCompilation 标志来判断是否需要特殊工具来从源代码构建包.

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.

8.该软件包位于 GitHub/Bitbucket/Gitorious

它可能在 GitHub/Bitbucket/Gitorious 上有一个存储库.这些软件包需要 remotes安装包.

It may have a repository on GitHub/Bitbucket/Gitorious. These packages require the remotes package to install.

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

(与installr 一样,您可能需要先install.packages("remotes").)

(As with installr, you may need to install.packages("remotes") first.)

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

imanuelc 的这个 SO 答案?install.packages.

10.包位于非标准存储库中

您的软件包位于非标准存储库中(例如 Rbbg).假设它合理地符合CRAN标准,您仍然可以使用install.packages下载它;您只需要指定存储库 URL.

Your package is in a non-standard repository (e.g. Rbbg). Assuming that it is reasonably compliant with CRAN standards, you can still download it using install.packages; you just have to specify the repository URL.

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

RHIPE 另一方面,不在类似 CRAN 的存储库中并有自己的安装说明.

这篇关于我应该如何处理“package 'xxx' is not available (for R version x.y.z)";警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆