Error with new R 3.1.3 version
Update to RStudio version 0.98.1103, it's available (even if it says in RStudio's updater that there's not a newer version available).
Edit a few months later
Though RStudio has been updated a few times since this question was first asked, the idea remains the same for those with this problem: Update RStudio to its latest version, and remember to check the website because the auto-updater may not work.
How should I deal with package 'xxx' is not available (for R version x.y.z) warning?
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.
Error: This is R 3.1.3, package ‘weightr’ needs = 3.3.3
You need to upgrade R separately from RStudio. The current version of R is 3.5.1, and can be found at https://cran.rstudio.com/ or https://cran.r-project.org/.
Changes in install.packages() from R 3.1.2 to R 3.2.1
I have found the problem.
The R 3.2.1 NEWS section (https://cran.r-project.org/src/base/NEWS) says
- The default for option pkgType on platforms using binary packages is now "both", so source packages will be tried if binary versions
are not available or not up to date.
The problem is that RStudio does not directly call install.packages
but via a few other functions such as .rs.callAs
. In one of these functions, available.packages()
gets called without any arguments. So it determines the argument type
via getOption("pkgType")
. But since R 3.2.1 this is now "both"
and not "win.binary"
as in R 3.1.2.
A quick workaround for the problem is thus to add
options(pkgType="win.binary")
to the yourRinstallpath/etc/Rprofile.site
Unable to install xlsx package on R version 3.1.3
I found my own answer! I figured the problem was that for installing all those packages, the required package was "rjava" that couldn't be loaded. The reason was the fact I am using a 64-bit OS and R version but do not have Java installed with the same architecture.I downloaded Java 64-bit(Windows Offline (64-bit)) from this page: https://www.java.com/en/download/manual.jsp After that just reloaded the xlsx package and it worked
Related Topics
How to Split a Dataframe Column by The First Instance of a Character in Its Values
Get Plot() Bounding Box Values
How to Add Geo-Spatial Connections on a Ggplot Map
How to Find The Indices Where There Are N Consecutive Zeroes in a Row
How to Add Multiple Columns to a Tibble
How to Subscript The X Axis Tick Label
"Update by Reference" Vs Shallow Copy
What Happens When Prob Argument in Sample Sums to Less/Greater Than 1
How to Make Install.Packages Return an Error If an R Package Cannot Be Installed
Ggplot2 Positive and Negative Values Different Color Gradient
Error Installing R Package for Linux
Strange Behaviour Dropping Column from Data.Frame in R
Plot Histogram with Points Instead of Bars
Schedule a Rscript Crontab Everyminute
R Not Responding Request to Interrupt Stop Process
Group/Bin/Bucket Data in R and Get Count Per Bucket and Sum of Values Per Bucket