Senin, 30 Maret 2015

How to Enable Proxy Access to R, When You are Behind a Particularly Fussy Proxy Provider

Yes, I am calling my proxy provider fussy. Yes, perhaps it is not to blame, even though I strongly suspect it is. It requires double authentication for each time we access the Internet, and for some applications, it requires me to input my credentials four times. Yes, four.

Anyway, when you are working in an organization, such as school, it might be the situation that you are behind a proxy. However you might feel about it, here's one way to enable web access from R that works for me. I use RStudio, but I think this might work for R-Gui, too.


1. Create a .Renviron file, which contains the following lines:

options(internet.info = 0)
http_proxy=http://your_proxy_address:port_number/
http_proxy_user=ask

Save the .Renviron file in your "Documents" or "My Documents" folder. I know, it is a somewhat weird place to put it. There's a discussion about it here.

2. Check that the http_proxy variable is already read by R, by issuing, in R Studio:

Sys.getenv("http_proxy")

If it works, R should return a string which contains your proxy address.

3. Make sure, in R Studio, that Tools > Global Options > Packages > Use Internet Explorer library / proxy for HTTP is unchecked.

4. Restart your R Studio. Now you can (hopefully) access the Internet from R!