R Language Configuration for the Proxy

If you use the open-source R statistical programing language, you can configure it to carry out HTTP or HTTPS proxy requests. R has distributions that can be run in Windows, Linux, and Mac.

You'll need to point to the proxy by adding one or more environment variables to your installation. Add the environment variables to the R environment file.

  • On RStudio Server, the filepath is R_HOME/etc/Renviron.site.
  • On RStudio Desktop, the filepath in the user home directory is ~/.Renviron.
  • Access your .Renviron file by running the command file.edit('~/.Renviron') in RStudio.

If these files don't exist in the default installation of R, you'll need to create them.

Here are examples of environment file entries for proxy configuration:
 
http_proxy=http://proxy.dom.com/ 
http_proxy_user=user:passwd 
https_proxy=http://proxy.dom.com/ 
https_proxy_user=user:passwd
	

Tips

  • Note that HTTPS requests require extra work to make use of custom headers.
  • The R package "RCurl" provides more comprehensive facilities to download data from URLs.
You'll find more information at:

R with Web Browsers

For web browsers, you must use IP address authentication, then configure your network proxy settings. If you use Firefox or Chrome, the FoxyProxy plugin makes it very easy to configure your proxy settings.

You'll find more information in our article How to Change Web Browser Proxy Settings.

For testing, the article referenced above, How to drive a Web browser with R (and RSelenium), includes detail on how to set up R Studio to open several different browsers in succession.

R and Selenium

For automated testing, the R Studio provides a link to install the Selenium 2.0 WebDriver. Here is a link to a general how-to: How to drive a Web browser with R (and RSelenium).

The "RSelenium" package, with a complete set of R language bindings for Selenium WebDriver 2.0, is available as a PDF.

Scraping with Selenium discusses a variety of ways R and Selenium can be used together with a proxy.

Still need help? Contact Us Contact Us