geo_dd
geo_dd

Reputation: 313

unable to access index for repository in R

I am on Windows 7 and I am using R Studio 0.99.902 with R3.3.1. When I am trying to install a package I get the Warnings:

Warning: unable to access index for repository http://cran.rstudio.com/src/contrib:
  cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'

It is the first time I see it and I cannot solve it. Can anyone help me ?

Upvotes: 6

Views: 25324

Answers (3)

RitaL
RitaL

Reputation: 31

Running options(download.file.method="libcurl") then installing packages did the trick for me. You may find an answer here.

Upvotes: 1

mastropi
mastropi

Reputation: 1414

Please note that compiling from source for Windows requires the appropriate version of Rtools that is compatible with the R version you are working with. This list is available at the Rtools site:

https://cran.r-project.org/src/contrib/Archive/

If compilation from source is complicated, it is also possible to find the Windows-compiled binaries (.zip files) for older versions of R at:

https://cran-archive.r-project.org/bin/windows/contrib

This link is referenced by the ReadMe file available at the "regular" repository for Windows binaries for different versions of R, namely at:

https://cran.r-project.org/bin/windows/contrib

Once the zip file is downloaded, you can run the following R code line to install the package:

# Use repos=NULL so that the first argument is a path to the local zip file
# containing the binary package to install
# (as opposed to just the name of the package to install from the web)
install.packages("<local-path-to-downloaded-zip-file>", repos=NULL)

Upvotes: 0

CSJCampbell
CSJCampbell

Reputation: 2115

This issue is likely caused by the package being too old or too new for your R version. For example, if a package is released during R-3.4.1, it will not be available for R-3.3.1. Packages which are removed from CRAN before your R version are also not available. The package DESCRIPTION file shows if there is a hard restriction on which R versions the package will run.

Search for the package's CRAN page and see its status. You may still be able to install the package by downloading the package source (the tar.gz file) and in RStudio selecting Install from: Package Archive File in the Tools/Install Packages... menu (or using install.packages with repos = NULL). Beware that the package is not available from CRAN for a reason; you may need to make some changes to the package for it to work correctly.

Upvotes: 2

Related Questions