6

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 ?

Alexi Coard
  • 7,106
  • 12
  • 38
  • 58
geo_dd
  • 283
  • 1
  • 5
  • 22
  • What package is it and could you please share your code? – Hack-R Jul 05 '16 at 15:28
  • I can access all four URLs and see meaningful content ... maybe only from your access point? Did you try a different package provider aka mirror? ... and as @Hack-R kindly requests: Please state if you issue code commands, R-Studio generates R code whatever - that you copy into the question. Thanks. – Dilettant Jul 05 '16 at 15:29
  • I tried : require(ggplot2) and I got this and then I tried from the menu packages>install but as soon as I click install I get these message (before even I write the names of the packages I want). – geo_dd Jul 05 '16 at 15:32
  • You may have a network issue. Try pasting this into the console and see if it gives the same error `install.packages("ggplot2", dependencies=TRUE)` . – Hack-R Jul 05 '16 at 15:35
  • I tried this and I got : Installing package into ‘C:/Users/somme/Documents/R/win-library/3.3’ (as ‘lib’ is unspecified) – geo_dd Jul 05 '16 at 15:40
  • And also I get this: cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES': HTTP status was '403 Forbidden' Warning in install.packages : unable to access index for repository http://cran.rstudio.com/src/contrib: cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES' – geo_dd Jul 05 '16 at 15:41

3 Answers3

2

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.

CSJCampbell
  • 2,025
  • 15
  • 19
1

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

RitaL
  • 31
  • 6
0

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)
mastropi
  • 1,354
  • 1
  • 10
  • 14