我应该如何处理“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?

查看:14
本文介绍了我应该如何处理“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)
包钻石"不可用(对于 R版本 3.0.0)
是plyr包对于 R 版本 3.0.2 不可用?
包 bigmemory 未安装在 R 64 3.0.2 上
包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,如果使用 Windows,则选择 CRAN (extras),以及 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)

或者,可用包的列表可以在浏览器中查看 CRANCRAN(附加)Bioconductor, R-forge, R-forge,以及 GitHub.

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 检查 测试).

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天全站免登陆