Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R - cannot access urls for package installation

Tags:

package

r

I recently installed R Studio (Version 0.99.892) on a personal computer (windows 8) and am trying to install, among others, the following packages: ggplot2; dplyr; rmarkdown; tidyr.

Neither R nor R Studio is able to install any of these packages. Each time I attempt to install a package, I get the set of warnings I include at the bottom of this post.

I have used the install.packages command as well as the built-in package installation tool. I have tried several different mirrors.

I have tried a public university internet source, my own private internet source, and a phone tether. I have tried to connect through a VPN. I have added R Studio to my Windows Firewall exception list and have also completely disabled the Windows Firewall. I am running no other firewalls.

I have toggled the various connection options in the "Packages" tab in Global Options.

I can access the URLs in a browser.

Here are the warnings from R Studio:

> install.packages("devtools")
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository https://cran.fhcrc.org/src/contrib:
  cannot open URL 'https://cran.fhcrc.org/src/contrib/PACKAGES'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be     resolved'
Warning in install.packages :
  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'
Installing package into ‘C:/Users/Nikhailovich/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository https://cran.fhcrc.org/src/contrib:
  cannot open URL 'https://cran.fhcrc.org/src/contrib/PACKAGES'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  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'
Warning in install.packages :
  package ‘devtools’ is not available (for R version 3.2.3)
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository https://cran.fhcrc.org/bin/windows/contrib/3.2:
  cannot open URL 'https://cran.fhcrc.org/bin/windows/contrib/3.2/PACKAGES'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning in install.packages :
  unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.2:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.2/PACKAGES'

Here are the warnings from R (3.2.3):

> install.packages("ggplot2")
Installing package into ‘C:/Users/Nikhailovich/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Error in download.file(url, destfile = f, quiet = TRUE) : 
  cannot open URL 'https://cran.r-project.org/CRAN_mirrors.csv'
In addition: Warning message:
In download.file(url, destfile = f, quiet = TRUE) :
  InternetOpenUrl failed: 'The server name or address could not be resolved'
Warning: unable to access index for repository https://dirichlet.mat.puc.cl/src/contrib:
  cannot open URL 'https://dirichlet.mat.puc.cl/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'
Warning: unable to access index for repository https://dirichlet.mat.puc.cl/bin/windows/contrib/3.2:
  cannot open URL 'https://dirichlet.mat.puc.cl/bin/windows/contrib/3.2/PACKAGES'
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.2:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.2/PACKAGES'
Warning message:
package ‘ggplot2’ is not available (for R version 3.2.3) 

There are several stackexchange posts on package installation in R and R Studio, but I was not able to find any that answered my particular situation. Thanks in advance to anyone that knows what's going on

like image 543
N. Engel Avatar asked Mar 11 '16 02:03

N. Engel


4 Answers

Run this command:

options(repos="https://CRAN.R-project.org")

after that try install.packages;it should work.Tested on my system.

like image 68
Awinash Singh Avatar answered Oct 21 '22 22:10

Awinash Singh


This has happened to me before. Try explicitly specifying the location:

install.packages("devtools", repos="https://cran.rstudio.com/")
like image 20
Markus Avatar answered Oct 21 '22 22:10

Markus


You can indeed specify the location when using the install.packages() function with the argument repos=, but you can also choose your favorite repository which will be used each time you download a package.

    options(repos="my_favorite_CRAN_mirror")

You can see a list of all availables mirrors on the CRAN website. Juste copy/paste the adress of the closest CRAN repository to you.

You should be able after this step to retry install.packages('ggplot2')

like image 24
bobolafrite Avatar answered Oct 21 '22 21:10

bobolafrite


You should try following code:

install.packages("ggbiplot",dependencies = TRUE, repos = 'http://cran.rstudio.com/')

It will help you to install the packages for the error:

package is not available for this version

like image 30
user10451153 Avatar answered Oct 21 '22 22:10

user10451153