1

I'm not able to install any packages in R. I tried in all versions of R starting from 3.2.2 till 3.2.4(revised), but I get the same error. It seems like a proxy issue to me as I'm connected to my college firewall. I was able to install the packages when I'm connected to my home network. Can you please guide me to resolve this issue.? Here are the error messages

> chooseCRANmirror()
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'
> install.packages("ggplot2")
Installing package into ‘C:/Users/HP/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository https://cran.rstudio.com/src/contrib
Warning: unable to access index for repository 
Warning: unable to access index for repository 
Warning: unable to access index for repository 
Warning message:
package ‘ggplot2’ is not available (for R version 3.2.2)
Dason
  • 60,663
  • 9
  • 131
  • 148
Jagdeesh R
  • 31
  • 1
  • 2
  • 6
  • 1
    library(utils) setInternet2(T) then check this out http://stackoverflow.com/questions/17783686/solution-how-to-install-github-when-there-is-a-proxy then check this out https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html – chinsoon12 Apr 01 '16 at 02:13
  • I think there is no problem with the R-Packages the problem is with your college net connection basically the college management will block some interrelated websites may be this "https://cran.rstudio.com/............." is also got struck in that list. so try to open the link in browser if its not opening ask your admin to provide access to it.(I except this would be the problem since you mentioned that you are able to install the packages when connected to your home network.) – Dinesh Apr 01 '16 at 09:55
  • can you access https://cran.r-project.org/CRAN_mirrors.csv via your browser? if yes, copy your browser proxy settings and look at first document from @chinsoon above to set it up (you may need to install httr manually, in that case, use the first answer below) – wotter Apr 01 '16 at 09:58

6 Answers6

5

This is the same problem I was also facing while installing any packages. The main reason what I think is that your R session can't connect to the files path on Cran server.

What I did was just manually go to the Cran website and download the windows release for that particular package. Now unzip the files and manually paste the folder into your library folder of R.

The library folder path will be something like this: C:\Program Files\R\R-3.2.3\library

Now go to your R console and load it with library(package name). You can now use your package.

Himanshu Rai
  • 156
  • 1
  • 10
  • Its fine, in case if the package doesn't have any dependencies. if the package has some 5to10 dependencies you cant download and copy them every time. so you need to check for a permanent solution not a temporary one. – Dinesh Apr 01 '16 at 10:01
  • yes you are right, in my case i have to do it manually every time as my connection was blocked by system administrator. – Himanshu Rai Apr 01 '16 at 10:21
4

Simply use HTTP mirror instead of HTTPS ones. To change mirror go to "Packages menu" -> "Set CRAN mirror" -> "(HTTP mirrors)" -> select any

basit
  • 178
  • 1
  • 5
  • Where is this menu you speak of? Shells don't have menus. – Volte Jun 26 '19 at 23:07
  • They mean the global options menu of RStudio – Barker Jan 29 '20 at 21:06
  • @Barker I believe this question was about the R graphical interface, not Rstudio. At least in RGui version 3.4.0 for Windows (2017-04-21),, there is a "Packages menu" with all those options. In my case, all mirrors are HTTPS, but there is a final "(other mirrors)" option in the list. Click that one, and a new list appears with both https and non https options. I selected one of those not marked as "[https]" and finally my RGui could download packages. – abu Jul 27 '21 at 09:25
0

Thanks for your valuable feedback guys. The solution to this problem drove me crazy. I have set my proxy settings according to my college network in MOZILLA, however, I have not set the same for IE. I guess, R downloads the packages based on IE settings, which was not configured. After setting the proxy to connect to the internet, I was able to download the packages without any issues.

Figured this out after trying all your solutions, but at last it was this silly thing that worked.

Thanks for all your time and suggestions.

Jagdeesh R
  • 31
  • 1
  • 2
  • 6
0

you can reset and restore your internet connection (for windows and your default explorer),The problem will be solved.

0

To fix:

  • Uncheck the 'use secure download method' checkbox in Rstudio global options.
  • Restart internet then restart Rstudio
-2

utils:::menuInstallPkgs() --- Please select a CRAN mirror for use in this session --- Warning: unable to access index for repository https://ftp.iitm.ac.in/cran/src/contrib: cannot open URL 'https://ftp.iitm.ac.in/cran/src/contrib/PACKAGES' Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : no packages were specified