Related
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?
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)"
1. You can't spell
The first thing to test is have you spelled the name of the package correctly? Package names are case sensitive in R.
2. You didn't look in the right repository
Next, you should check to see if the package is available. Type
setRepositories()
See also ?setRepositories.
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.
To permanently change this, add a line like setRepositories(ind = c(1:6, 8)) to your Rprofile.site file.
3. The package is not in the repositories you selected
Return all the available packages using
ap <- available.packages()
See also Names of R's available packages, ?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.
Another possible warnings message you may get when interacting with CRAN mirrors is:
Warning: unable to access index for repository
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. You don't want a package
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, 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 or Bioconductor is out of date
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"]
and consider updating your R installation to the current version. On Windows, this is most easily done via the installr package.
library(installr)
updateR()
(Of course, you may need to install.packages("installr") first.)
Equivalently for Bioconductor packages, you may need to update your Bioconductor installation.
source("http://bioconductor.org/biocLite.R")
biocLite("BiocUpgrade")
6. The package is out of date
It may have been archived (if it is no longer maintained and no longer passes R CMD check tests).
In this case, you can load an old version of the package using install_version()
library(remotes)
install_version("foobarbaz", "0.1.2")
An alternative is to install from the GitHub CRAN mirror.
library(remotes)
install_github("cran/foobarbaz")
7. There is no Windows/OS X/Linux binary
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).
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")
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. The package is on GitHub/Bitbucket/Gitorious
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")
(As with installr, you may need to install.packages("remotes") first.)
9. There is no source version of the package
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.
10. The package is in a non-standard repository
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 on the other hand isn't in a CRAN-like repository and has its own installation instructions.
In the R 3.2.3 (new in 2016) there was a bug, preventing it some times from finding correct package. The workaround is to set repository manually:
install.packages("lubridate", dependencies=TRUE, repos='http://cran.rstudio.com/')
Found solution in other question
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
There seems to be a problem with some versions of R and libcurl. I have had the same problem on Mac (R version 3.2.2) and Ubuntu (R version 3.0.2) and in both instances it was resolved simply by running this before the install.packages command
options(download.file.method = "wget")
The solution was suggested by a friend, however, I haven't been able to find it in any of the forums, hence submitting this answer for others.
Visit https://cran.r-project.org/src/contrib/Archive/.
Find the package you want to install with Ctrl + F
Click the package name
Determine which version you want to install
Open RStudio
Type "install.packages("https://cran.r-project.org/src/contrib/Archive/[NAME OF PACKAGE]/[VERSION NUMBER].tar.gz", repos = NULL, type="source")"
In some cases, you need to install several packages in advance to use the package you want to use.
For example, I needed to install 7 packages(Sejong, hash, rJava, tau, RSQLite, devtools, stringr) to install KoNLP package.
install.packages('Sejong')
install.packages('hash')
install.packages('rJava')
install.packages('tau')
install.packages('RSQLite')
install.packages('devtools')
install.packages('stringr')
library(Sejong)
library(hash)
library(rJava)
library(tau)
library(RSQLite)
library(devtools)
library(stringr)
install.packages("https://cran.r-project.org/src/contrib/Archive/KoNLP/KoNLP_0.80.2.tar.gz", repos = NULL, type="source")
library(KoNLP)
11. R (or another dependency) is out of date and you don't want to update it.
Warning this is not exactly best practice.
Download the package source.
Navigate to the DESCRIPTION file.
Remove the offending line with your text editor e.g.
Depends: R (>= 3.1.1)
Install from local (i.e. from the parent directory of DESCRIPTION) e.g.
install.packages("foo", type="source", repos=NULL)
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). 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). 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.
Edit (04/08/2020): I recently had an issue with a package (XML) reportedly not available for my R version (3.6.3, latest supported on Debian stretch), after an update of the package in CRAN. It was very unexpected because I already had installed it with success before (on the same version of R and same OS).
For some reason, the package was still there, but install.packages was only looking at the updated (and incompatible) version. The solution was to find the URL of the compatible version and force install.packages to use it, as follows:
install.packages("https://cran.r-project.org/src/contrib/Archive/XML/XML_3.99-0.3.tar.gz", repos=NULL, type="source", ask=FALSE)
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"))
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
.
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.
I fixed this error on Ubuntu by carefully following the instructions for installing R. This included:
adding deb http://cran.utstat.utoronto.ca/bin/linux/ubuntu trusty/ to my /etc/apt/sources.list file
Running sudo apt-get update
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.
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
Another reason + solution
I run into this error ("package XXX is not available for R version X.X.X") when trying to install pkgdown in my RStudio on my company's HPC.
Turns out, the CRAN snapshot they have on the HPC is from Jan. 2018 (almost 2 years old) and indeed pkgdown did not exist then. That was meant to control the source of packages for layman users, but as a developer, you can in most cases change that by:
## checking the specific repos you currently have
getOption("repos")
## updating your CRAN snapshot to a newer date
r <- getOption("repos")
r["newCRAN"] <- "https://cran.microsoft.com/snapshot/*2019-11-07*/"
options(repos = r)
## add newCRAN to repos you can use
setRepositories()
If you know what you are doing and may need more than one package that might not be available in your system's CRAN, you can set this up in your project .Rprofile.
If it's just one package, maybe just use install.packages("package name", repos = "a newer CRAN than your company's archaic CRAN snapshot").
In my case the solution was to simply upgrade R.
I found a slight variation on #6 package is out of date from the excellent solution by #Richie Cotton.
Sometimes the package maintainer may show R version gaps that it does not support. In that case, you have at least two options: 1) upgrade your R version to the next one the target package already supports, 2) install the most recent version from the older ones available that would work with your R version.
A concrete example: the latest CRAN version of package rattle for data mining, 5.3.0, does not support R version 3.4 because it had a big update between package versions 5.2.0 (R >= 2.13.0) and 5.3.0 (R >=3.5).
In a case like this, the alternative to upgrading the R installation is the solution already mentioned. Install the package devtools if you don't have it (it includes package remotes) and then install the specific version that will work in your current R. You can look up that information on the CRAN page for the specific package archives.
library("devtools")
install_version("rattle", version = "5.2.0", repos = "http://cran.us.r-project.org")
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")
Another minor addition, while trying to test for an old R version using the docker image rocker/r-ver:3.1.0
The default repos setting is MRAN and this fails to get many packages.
That version of R doesn't have https, so, for example:
install.packages("knitr", repos = "https://cran.rstudio.com") seems to work.
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 am using the R programming language. I am trying to install the "Data Mining with R" (DMwR) package. However, when I visit the CRAN website for this package, it seems to be gone:
Package ‘DMwR’ was removed from the CRAN repository.
Formerly available versions can be obtained from the archive.
Archived on 2021-03-16 as check problems were not corrected despite reminders.
A summary of the most recent check results can be obtained from the check results archive.
I visited the Github page for this package
Then, I tried to install this package directly from Github:
> library(devtools)
Loading required package: usethis
Warning message:
package ‘usethis’ was built under R version 4.0.5
> install_github("Luis Torgo/DMwR")
Error: Failed to install 'unknown package' from GitHub:
JSON: EXPECTED value GOT <
But this also is not working. Can someone please show me how to install this package?
Besides installing from the CRAN mirror repo, another option is
remotes::install_version("DMwR", version="0.4.1")
for this method, you do have to look up the last version in the archive directory (would probably be scrapeable if you wanted to write the code)
as with remotes::install_github("cran/<package>"), you will be installing from source, which means that if the package or any of its dependencies have compiled components (in this case it doesn't appear so), you'll need to have development tools (compiler etc.) installed on your system
A quick word of caution:
this will work well if packages have been archived recently, and if the reason for archiving was because the CRAN maintainers are being fussy (that's their prerogative);
however, a package may have become incompatible with the rest of the current R ecosystem (R version, dependencies) since its last update - in which case you may find yourself in dependency hell trying to install it (or, worse, your results may be unreliable).
Had the same message on R 4.1.0
install.packages("DMwR")
Warning message:
package ‘DMwR’ is not available for this version of R
An option is also to create a checkpoint. According to the CRAN package website, it is archived on '2021-03-16'. So, we could use the checkpoint one day before that date
library(checkpoint)
checkpoint("2021-03-15")
install.packages("DMwR")
library(DMwR)
#Loading required package: lattice
#Loading required package: grid
#Registered S3 method overwritten by 'quantmod':
# method from
# as.zoo.data.frame zoo
The checkpoint can be deleted as well
delete_all_checkpoints()
You can install it from the CRAN github mirror (despite it being removed from CRAN), e.g.
library(devtools)
install_github("cran/DMwR")
That package was in support of a book published in 2010. The author published a second edition in 2017 and the current version of the support package is https://cran.r-project.org/web/packages/DMwR2/index.html
It does have currently CRAN-hosted source and binary packages, and doesn't need compilation, so it should be able to be installed with:
install.packages("DMwR2", dependencies=TRUE)
You can get the most recent version by following the directions at the Github site:
library(devtools) # You need to install this package!
install_github("ltorgo/DMwR2",ref="develop")
Those are much more likely to run properly with recent versions of R.
How to install "RTAQ" package in R?
I found a website with 4 packages I need, but I can't download "RTAQ" file.(
http://r-forge.r-project.org/R/?group_id=316 )
This command below is invalid too.
install.packages("RTAQ", repos="http://R-Forge.R-project.org")
Warning in install.packages :
package ‘RTAQ’ is not available (for R version 3.4.4)
RTAQ has been archived from CRAN, since CRAN was unable to receive a clean update of the software since November 2012. For details, see the following message on the CRAN RTAQ page.
If you want to use RTAQ, you'll need to install an older version of R that is compatible with RTAQ, and use RTAQ with that version of R.
I would like to install a package when using the latest R version in RStudio.
In particular the quantstrat package
Is that possible?
This is the R latest version I have 3.4.1
my error message:
Warning in install.packages :
package ‘quantstrat’ is not available (for R version 3.4.1)
Because quantstrat build-fail at R-Forge, you can't get the pre-build file(.tar.gz). You can get the code from github and build by yourself.
install.packages("devtools")
require(devtools)
install_github("braverock/blotter") # dependency
install_github("braverock/quantstrat")
Can you provide the installation code that produced that error message? Are you trying to install it from CRAN?
That doesn't appear possible.
A post from 2014 states it's not on CRAN
quantstrat is a R package ... still under heavy development and can’t be installed from CRAN yet. You can install it from source and the process is straightforward.
It's not on the current list of available CRAN packages
It's R-Forge page states the current version 'Failed to build'.
You could download the previous version (and its dependency) from R-Forge at
http://download.r-forge.r-project.org/bin/windows/contrib/3.2/quantstrat_0.9.1739.zip and
http://download.r-forge.r-project.org/bin/windows/contrib/3.2/blotter_0.9.1741.zip
(or get the Linux tar.gz files). Assuming they're saved in your personal Downloads folder, install it in R with
install.packages("~/Downloads/blotter_0.9.1741.zip", repos = NULL)
install.packages("~/Downloads/quantstrat_0.9.1739.zip", repos = NULL)
According to that first link, you'll need to install these prereqs first, if they're not already:
install.packages("FinancialInstrument")
install.packages("PerformanceAnalytics")
install.packages("foreach")
Edit: see the comment below from #brian-g-peterson for how the current deployment avenue uses GitHub. https://github.com/braverock/quantstrat
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?
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)"
1. You can't spell
The first thing to test is have you spelled the name of the package correctly? Package names are case sensitive in R.
2. You didn't look in the right repository
Next, you should check to see if the package is available. Type
setRepositories()
See also ?setRepositories.
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.
To permanently change this, add a line like setRepositories(ind = c(1:6, 8)) to your Rprofile.site file.
3. The package is not in the repositories you selected
Return all the available packages using
ap <- available.packages()
See also Names of R's available packages, ?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.
Another possible warnings message you may get when interacting with CRAN mirrors is:
Warning: unable to access index for repository
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. You don't want a package
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, 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 or Bioconductor is out of date
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"]
and consider updating your R installation to the current version. On Windows, this is most easily done via the installr package.
library(installr)
updateR()
(Of course, you may need to install.packages("installr") first.)
Equivalently for Bioconductor packages, you may need to update your Bioconductor installation.
source("http://bioconductor.org/biocLite.R")
biocLite("BiocUpgrade")
6. The package is out of date
It may have been archived (if it is no longer maintained and no longer passes R CMD check tests).
In this case, you can load an old version of the package using install_version()
library(remotes)
install_version("foobarbaz", "0.1.2")
An alternative is to install from the GitHub CRAN mirror.
library(remotes)
install_github("cran/foobarbaz")
7. There is no Windows/OS X/Linux binary
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).
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")
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. The package is on GitHub/Bitbucket/Gitorious
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")
(As with installr, you may need to install.packages("remotes") first.)
9. There is no source version of the package
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.
10. The package is in a non-standard repository
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 on the other hand isn't in a CRAN-like repository and has its own installation instructions.
In the R 3.2.3 (new in 2016) there was a bug, preventing it some times from finding correct package. The workaround is to set repository manually:
install.packages("lubridate", dependencies=TRUE, repos='http://cran.rstudio.com/')
Found solution in other question
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
There seems to be a problem with some versions of R and libcurl. I have had the same problem on Mac (R version 3.2.2) and Ubuntu (R version 3.0.2) and in both instances it was resolved simply by running this before the install.packages command
options(download.file.method = "wget")
The solution was suggested by a friend, however, I haven't been able to find it in any of the forums, hence submitting this answer for others.
Visit https://cran.r-project.org/src/contrib/Archive/.
Find the package you want to install with Ctrl + F
Click the package name
Determine which version you want to install
Open RStudio
Type "install.packages("https://cran.r-project.org/src/contrib/Archive/[NAME OF PACKAGE]/[VERSION NUMBER].tar.gz", repos = NULL, type="source")"
In some cases, you need to install several packages in advance to use the package you want to use.
For example, I needed to install 7 packages(Sejong, hash, rJava, tau, RSQLite, devtools, stringr) to install KoNLP package.
install.packages('Sejong')
install.packages('hash')
install.packages('rJava')
install.packages('tau')
install.packages('RSQLite')
install.packages('devtools')
install.packages('stringr')
library(Sejong)
library(hash)
library(rJava)
library(tau)
library(RSQLite)
library(devtools)
library(stringr)
install.packages("https://cran.r-project.org/src/contrib/Archive/KoNLP/KoNLP_0.80.2.tar.gz", repos = NULL, type="source")
library(KoNLP)
11. R (or another dependency) is out of date and you don't want to update it.
Warning this is not exactly best practice.
Download the package source.
Navigate to the DESCRIPTION file.
Remove the offending line with your text editor e.g.
Depends: R (>= 3.1.1)
Install from local (i.e. from the parent directory of DESCRIPTION) e.g.
install.packages("foo", type="source", repos=NULL)
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). 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). 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.
Edit (04/08/2020): I recently had an issue with a package (XML) reportedly not available for my R version (3.6.3, latest supported on Debian stretch), after an update of the package in CRAN. It was very unexpected because I already had installed it with success before (on the same version of R and same OS).
For some reason, the package was still there, but install.packages was only looking at the updated (and incompatible) version. The solution was to find the URL of the compatible version and force install.packages to use it, as follows:
install.packages("https://cran.r-project.org/src/contrib/Archive/XML/XML_3.99-0.3.tar.gz", repos=NULL, type="source", ask=FALSE)
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"))
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
.
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.
I fixed this error on Ubuntu by carefully following the instructions for installing R. This included:
adding deb http://cran.utstat.utoronto.ca/bin/linux/ubuntu trusty/ to my /etc/apt/sources.list file
Running sudo apt-get update
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.
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
Another reason + solution
I run into this error ("package XXX is not available for R version X.X.X") when trying to install pkgdown in my RStudio on my company's HPC.
Turns out, the CRAN snapshot they have on the HPC is from Jan. 2018 (almost 2 years old) and indeed pkgdown did not exist then. That was meant to control the source of packages for layman users, but as a developer, you can in most cases change that by:
## checking the specific repos you currently have
getOption("repos")
## updating your CRAN snapshot to a newer date
r <- getOption("repos")
r["newCRAN"] <- "https://cran.microsoft.com/snapshot/*2019-11-07*/"
options(repos = r)
## add newCRAN to repos you can use
setRepositories()
If you know what you are doing and may need more than one package that might not be available in your system's CRAN, you can set this up in your project .Rprofile.
If it's just one package, maybe just use install.packages("package name", repos = "a newer CRAN than your company's archaic CRAN snapshot").
In my case the solution was to simply upgrade R.
I found a slight variation on #6 package is out of date from the excellent solution by #Richie Cotton.
Sometimes the package maintainer may show R version gaps that it does not support. In that case, you have at least two options: 1) upgrade your R version to the next one the target package already supports, 2) install the most recent version from the older ones available that would work with your R version.
A concrete example: the latest CRAN version of package rattle for data mining, 5.3.0, does not support R version 3.4 because it had a big update between package versions 5.2.0 (R >= 2.13.0) and 5.3.0 (R >=3.5).
In a case like this, the alternative to upgrading the R installation is the solution already mentioned. Install the package devtools if you don't have it (it includes package remotes) and then install the specific version that will work in your current R. You can look up that information on the CRAN page for the specific package archives.
library("devtools")
install_version("rattle", version = "5.2.0", repos = "http://cran.us.r-project.org")
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")
Another minor addition, while trying to test for an old R version using the docker image rocker/r-ver:3.1.0
The default repos setting is MRAN and this fails to get many packages.
That version of R doesn't have https, so, for example:
install.packages("knitr", repos = "https://cran.rstudio.com") seems to work.
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.