Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (5.3k points)

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?

closed

1 Answer

0 votes
by
edited
 
Best answer

You can do the following to deal with the package not available issue:

  • Check if the package name has been spelled correctly and also match the case
  • You have not selected a repository to search for the required package. To set the repository use the following function

 

setRepositories()

  • The repository you selected does not have the required package. To check it, use the following: 

 

 pack <- available.packages()

OR

View(pack) 

"package_name" %in% rownames(pack)

  • Your program does not require a package. To see available datasets, type

 data()

  • Your  version of R is out of date

It may require a recent version of R (or one of the packages that it imports/depends upon does). 

 

To update R to the latest version, use the following:

library(installr)

 updateR() 

  • The package is obsolete. 

 The package may have been archived. To load  an old version of the package using install_version()

library(remotes) 

install_version("package_name", "0.1.1")

#To install from the github CRAN mirror.

library(remotes) 

install_github("cran/package_name")

  • The package is on github

It may have a repository on Github. These packages require the remotes package to install.

install.packages(remotes)

library(remotes)

install_github("packageauthor/package_name") install_bitbucket("packageauthor/package_name") install_gitorious("packageauthor/package_name")

  • The source version of the package is not available

You can disable this check by the following code:

options(install.packages.check.source = "no")

If you want to learn more about R programming watch this tutorial on Introduction to Data Science with R 

Browse Categories

...