我應該如何處理“軟件包'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"))
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章