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

2019-02-16 02:17发布

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条回答
Root(大扎)
2楼-- · 2019-02-16 02:54

devtools + GitHub. These 3 lines (helped me on this error) were not yet mentioned:

install.packages("devtools")  # if not already installed
library(devtools)
install_git("https://github.com/profile/foobarbaz_repository")
查看更多
对你真心纯属浪费
3楼-- · 2019-02-16 02:55

I made the mistake of forgetting to put repos=NULL when installing the R package from source code. In this case the error message is slightly misleading: package 'foobarbaz' is not available (for R version x.y.z)

The problem was not the version of R, it was the repos parameter. I did install.packages('path/to/source/code/of/foobarbaz', type='source', repos=NULL) which worked for me in this occasion.

Hope this helps someone.

查看更多
别忘想泡老子
4楼-- · 2019-02-16 02:55

I encountered the same problem on installing package "sentiment". Started Searching and tried many commands. Finally the package installed using following command:

install_url("http://cran.r-project.org/src/contrib/Archive/sentiment/sentiment_0.2.tar.gz")
查看更多
对你真心纯属浪费
5楼-- · 2019-02-16 02:57

I fixed this error on Ubuntu by carefully following the instructions for installing R. This included:

  1. adding deb http://cran.utstat.utoronto.ca/bin/linux/ubuntu trusty/ to my /etc/apt/sources.list file
  2. Running sudo apt-get update
  3. Running sudo apt-get install r-base-dev

For step 1 you can chose any CRAN download mirror in place of my University of Toronto one if you would like.

查看更多
狗以群分
6楼-- · 2019-02-16 02:58

It almost always works for me when I use bioconductor as source and then invoke biocLite. Example:

source("https://bioconductor.org/biocLite.R")
biocLite("preprocessCore")
查看更多
Luminary・发光体
7楼-- · 2019-02-16 03:00

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"))
查看更多
登录 后发表回答