How should I deal with “package 'xxx' is n

2018-12-30 23:45发布

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?

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

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?
https://stackoverflow.com/questions/21580661/installing-predictabel-package-on-r-2-15-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)"
https://stackoverflow.com/questions/31439092/package-dplyr-is-not-available-for-r-version-3-1-1

16条回答
梦醉为红颜
2楼-- · 2018-12-31 00:15

I had the same problem (on Linux) which could be solved changing the proxy settings. If you are behind a proxy server check the configuration using Sys.getenv("http_proxy") within R. In my ~/.Renviron I had the following lines (from https://support.rstudio.com/hc/en-us/articles/200488488-Configuring-R-to-Use-an-HTTP-or-HTTPS-Proxy) causing the problem:

http_proxy=https://proxy.dom.com:port
http_proxy_user=user:passwd

Changing it to

http_proxy="http://user:passwd@proxy.dom.com:port"

solved the problem. You can do the same for https.

It was not the first thought when I read "package xxx is not available for r version-x-y-z" ...

HTH

查看更多
笑指拈花
3楼-- · 2018-12-31 00:21

As mentioned here (in French), this can happen when you have two versions of R installed on your computer. Uninstall the oldest one, then try your package installation again! It worked fine for me.

查看更多
伤终究还是伤i
4楼-- · 2018-12-31 00:22

This solution might break R but here is an easiest solution that works 99% of time.

You need to do is just:

install.packages('package-name',repos='http://cran.us.r-project.org')

As mentioned by the author over here

查看更多
若你有天会懂
5楼-- · 2018-12-31 00:28

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/:

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"))
查看更多
笑指拈花
6楼-- · 2018-12-31 00:28

Another minor addition, while trying to test for an old R version using the docker image rocker/r-ver:3.1.0

  1. The default repos setting is MRAN and this fails to get many packages.
  2. That version of R doesn't have https, so, for example: install.packages("knitr", repos = "https://cran.rstudio.com") seems to work.
查看更多
骚的不知所云
7楼-- · 2018-12-31 00:30

This is what I finally could do for installing psych package in R-3.4.1 when I got the same warning

1:Googled for that package.

2:downloaded it manually having tar.gz extension

3:Chose the option "Package Archive File (.zip;.tar.gz)" for install packages in R

4:browsed locally to the place where it was downloaded and clicked install

You may get a warning: dependencies 'xyz' not available for the package ,then first install those from the repository and then do steps 3-4 .

查看更多
登录 后发表回答