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 rel="noreferrer">?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
[gen/prote/metabol/transcript]omics biological
analyses.
To permanently change this, add a line
like setRepositories(ind = c(1:6, 8))
to your href="https://www.rdocumentation.org/packages/base/topics/Startup"
rel="noreferrer">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, href="https://www.rdocumentation.org/packages/utils/topics/available.packages"
rel="noreferrer">?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 href="http://cran.r-project.org/web/packages/available_packages_by_name.html"
rel="noreferrer">CRAN, href="http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/" rel="noreferrer">CRAN
(extras), href="http://www.bioconductor.org/packages/release/BiocViews.html#___Software"
rel="noreferrer">Bioconductor, href="https://r-forge.r-project.org/softwaremap/full_list.php"
rel="noreferrer">R-forge, rel="noreferrer">RForge, and href="https://github.com/search?l=R&q=R&type=Repositories"
rel="noreferrer">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
href="http://cran.r-project.org/doc/FAQ/R-FAQ.html#What-is-the-difference-between-package-and-library_003f"
rel="noreferrer">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 href="https://cran.r-project.org/web/packages/installr/index.html"
rel="noreferrer">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 href="http://cran.r-project.org/src/contrib/Archive/"
rel="noreferrer">archived (if it is no longer maintained and no longer
passes rel="noreferrer">R CMD check
tests).
In this case, you can load an old
version of the package using href="https://www.rdocumentation.org/packages/remotes/topics/install_version"
rel="noreferrer">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 href="http://cran.r-project.org/bin/windows/contrib/3.2/ReadMe"
rel="noreferrer">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
repository (see
(extras)setRepositories
above).
If the package requires compiling code (e.g. C,
C++, FORTRAN) then on Windows install href="http://cran.r-project.org/bin/windows/Rtools/"
rel="noreferrer">Rtools or on OS X install the href="https://stackoverflow.com/q/9329243/324364">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 href="https://cran.r-project.org/web/packages/remotes/index.html"
rel="noreferrer">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 href="https://www.rdocumentation.org/packages/utils/topics/install.packages"
rel="noreferrer">?install.packages
.
/>
10. The package is in a non-standard
repository
Your package is in a
non-standard repository (e.g. href="https://stackoverflow.com/questions/13807729/package-rbbg-is-not-available-for-r-version-2-15-2">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")
href="http://www.datadr.org"
rel="noreferrer">RHIPE
on the other hand isn't in
a CRAN-like repository and has its own rel="noreferrer">installation instructions.
No comments:
Post a Comment