Caching proxy is a type of Internet/network caching technique that enables a proxy server to save recent and frequent website/webpage requests and data requested by one or more client machines. It is a means to accelerate webpage and website requests by saving an instance of frequently used content and resources locally on the proxy server.
I am facing problem while conecting R with internet in my office. May be this due to LAN settings. I tried the almost all possible ways I come across in the web (see below) but still in vain.
- Method1: Invoking R using
--internet2
- Method2: Invoking R by setting
~/Rgui.exe http_proxy=http:/999.99.99.99:8080/ http_proxy_user=ask
- Method3: Setting
Setinternet2=TRUE
- Method4:
In above all methods I can able to load packages directly from CRAN also able to download files using download.file command
But using
getURL(RCurl)
, readHTMLTable(XML)
, htmlTreeParse(XML)
commands I am unable to extract web data. I am getting ~<HEAD>n<TITLE>Access Denied</TITLE>n</HEAD>~
error.How to set LAN proxy settings for XML package in R?
techraf36.4k1818 gold badges8181 silver badges121121 bronze badges
AVSureshAVSuresh71722 gold badges99 silver badges1313 bronze badges
11 Answers
On Mac OS, I found the best solution here. Quoting the author, two simple steps are:
1) Open Terminal and do the following:
2) Run R and do the following:
double-check this with:
I am behind university proxy, and this solution worked perfectly. The major issue is to export the items in Terminal before running R, both in upper- and lower-case.
Geek On AcidGeek On Acid5,12522 gold badges3434 silver badges5858 bronze badges
The problem is with your curl options – the
RCurl
package doesn't seem to use internet2.dll
.You need to specify the port separately, and will probably need to give your user login details as network credentials, e.g.,Remember to escape any backslashes in your password. You may also need to wrap the URL in a call to
Richie CottonRichie CottoncurlEscape
.82.7k3030 gold badges196196 silver badges315315 bronze badges
For RStudio just you have to do this:
Firstly, open RStudio like always, select from the top menu:
Tools-GlobalOptions-Packages
Uncheck the option: Use Internet Explorer library/proxy for HTTP
And then close the Rstudio, furthermore you have to:
- Find the file (.Renviron) in your computer, most probably you would find it here: C:Usersyour user nameDocuments. Note that if it does not exist you can creat it just by writing this command in RStudio:
- Add these two lines to the initials of the file:
And that's it..??!!!
techraf36.4k1818 gold badges8181 silver badges121121 bronze badges
EliasElias
I had the same problem at my office and I solved it adding the proxy in the destination of the R shortcut; clik on right button of the R icon, preferences, and in the destination field add
Be sure to put the directory where you have the R program installed. That works for me. Hope this help.
Manuel RamónManuel Ramón2,17211 gold badge1414 silver badges2222 bronze badges
This post pertains to R proxy issues on *nix. You should know that R has many libraries/methods to fetch data over internet.
For 'curl', 'libcurl', 'wget' etc, just do the following:
- Open a terminal. Type the following command:
- Enter the following lines:Replace
username
,password
,abc.com
,xyz.com
andport
with these settings specific to your network. - Quit R and launch again.
This should solve your problem with 'libcurl' and 'curl' method. However, I have not tried it with 'httr'. One way to do that with 'httr' only for that session is as follows:
You need to substitute settings specific to your n/w in relevant fields.
techraf36.4k1818 gold badges8181 silver badges121121 bronze badges
adityakaranadityakaran
On Windows 7 I solved this by going into my environment settings (try this link for how) and adding user variables
jtromansjtromanshttp_proxy
and https_proxy
with my proxy details.2,08433 gold badges2626 silver badges2929 bronze badges
If you start R from a desktop icon, you can add the
techraf--internet
flag to the target line (right click -> Properties) e.g.36.4k1818 gold badges8181 silver badges121121 bronze badges
JackJack
Inspired by all the responses related on the internet, finally I've found the solution to correctly configure the Proxy for R and Rstudio.
There are several steps to follow, perhaps some of the steps are useless, but the combination works!
- Add environment variables
http_proxy
andhttps_proxy
with proxy details. - If you start R from a desktop icon, you can add the
--internet
flag to the target line (right click -> Properties)e.g.'C:Program FilesRR-2.8.1binRgui.exe' --internet2
- For RStudio just you have to do this:Firstly, open RStudio like always, select from the top menu:Tools-Global Options-PackagesUncheck the option: Use Internet Explorer library/proxy for HTTP
- Find the file (
.Renviron
) in your computer, most probably you would find it here:C:Usersyour user nameDocuments
.Note that: if it does not exist you can create it just by writing this command in R:Then add these six lines to the initials of the file: - Restart R. Type the following commands in R to assure that the configuration above works well:
- Now you can install the packages as you want by using the command like:It's important to add
method='libcurl'
, otherwise it won't work.
7,07999 gold badges4545 silver badges5555 bronze badges
Mina HEMina HE
Simplest way to get everything working in RStudio under
Windows 10
:Open up Internet Explorer, select
Internet Options
:Open editor for Environment variables:
Add a variable HTTP_PROXY in form:
Example:
RStudio should work:
ContangoContango42.7k4848 gold badges192192 silver badges241241 bronze badges
Tried all of these and also the solutions using netsh, winhttp etc.Geek On Acid's answer helped me download packages from the server but none of these solutions worked for using the package I wanted to run (twitteR package).
The best solution is to use a software that let's you configure system-wide proxy.
FreeCap (free) and Proxifier (trial) worked perfectly for me at my company.
Please note that you need to remove proxy settings from your browser and any other apps that you have configured to use proxy as these tools provide system-wide proxy for all network traffic from your computer.
Rishi DuaRishi Dua
My solution on a Windows 7 (32bit). R version 3.0.2
Kevin Panko7,07999 gold badges4545 silver badges5555 bronze badges
DanDan
Not the answer you're looking for? Browse other questions tagged r or ask your own question.
I am facing problem while conecting R with internet in my office. May be this due to LAN settings. I tried the almost all possible ways I come across in the web (see below) but still in vain.
- Method1: Invoking R using
--internet2
- Method2: Invoking R by setting
~/Rgui.exe http_proxy=http:/999.99.99.99:8080/ http_proxy_user=ask
- Method3: Setting
Setinternet2=TRUE
- Method4:
In above all methods I can able to load packages directly from CRAN also able to download files using download.file command
But using
getURL(RCurl)
, readHTMLTable(XML)
, htmlTreeParse(XML)
commands I am unable to extract web data. I am getting ~<HEAD>n<TITLE>Access Denied</TITLE>n</HEAD>~
error.How to set LAN proxy settings for XML package in R?
techraf36.4k1818 gold badges8181 silver badges121121 bronze badges
AVSureshAVSuresh71722 gold badges99 silver badges1313 bronze badges
11 Answers
On Mac OS, I found the best solution here. Quoting the author, two simple steps are:
1) Open Terminal and do the following:
2) Run R and do the following:
double-check this with:
I am behind university proxy, and this solution worked perfectly. The major issue is to export the items in Terminal before running R, both in upper- and lower-case.
Geek On AcidGeek On Acid5,12522 gold badges3434 silver badges5858 bronze badges
The problem is with your curl options – the
RCurl
package doesn't seem to use internet2.dll
.You need to specify the port separately, and will probably need to give your user login details as network credentials, e.g.,Remember to escape any backslashes in your password. You may also need to wrap the URL in a call to
Richie CottonRichie CottoncurlEscape
.82.7k3030 gold badges196196 silver badges315315 bronze badges
For RStudio just you have to do this:
Firstly, open RStudio like always, select from the top menu:
Tools-GlobalOptions-Packages
Uncheck the option: Use Internet Explorer library/proxy for HTTP
And then close the Rstudio, furthermore you have to:
- Find the file (.Renviron) in your computer, most probably you would find it here: C:Usersyour user nameDocuments. Note that if it does not exist you can creat it just by writing this command in RStudio:
- Add these two lines to the initials of the file:
And that's it..??!!!
techraf36.4k1818 gold badges8181 silver badges121121 bronze badges
EliasElias
I had the same problem at my office and I solved it adding the proxy in the destination of the R shortcut; clik on right button of the R icon, preferences, and in the destination field add
Be sure to put the directory where you have the R program installed. That works for me. Hope this help.
Manuel RamónManuel Ramón2,17211 gold badge1414 silver badges2222 bronze badges
This post pertains to R proxy issues on *nix. You should know that R has many libraries/methods to fetch data over internet.
For 'curl', 'libcurl', 'wget' etc, just do the following:
- Open a terminal. Type the following command:
- Enter the following lines:Replace
username
,password
,abc.com
,xyz.com
andport
with these settings specific to your network. - Quit R and launch again.
This should solve your problem with 'libcurl' and 'curl' method. However, I have not tried it with 'httr'. One way to do that with 'httr' only for that session is as follows:
You need to substitute settings specific to your n/w in relevant fields.
techraf36.4k1818 gold badges8181 silver badges121121 bronze badges
adityakaranadityakaran
On Windows 7 I solved this by going into my environment settings (try this link for how) and adding user variables
jtromansjtromanshttp_proxy
and https_proxy
with my proxy details.2,08433 gold badges2626 silver badges2929 bronze badges
If you start R from a desktop icon, you can add the
techraf--internet
flag to the target line (right click -> Properties) e.g.36.4k1818 gold badges8181 silver badges121121 bronze badges
JackJack
Inspired by all the responses related on the internet, finally I've found the solution to correctly configure the Proxy for R and Rstudio.
There are several steps to follow, perhaps some of the steps are useless, but the combination works!
- Add environment variables
http_proxy
andhttps_proxy
with proxy details. - If you start R from a desktop icon, you can add the
--internet
flag to the target line (right click -> Properties)e.g.'C:Program FilesRR-2.8.1binRgui.exe' --internet2
- For RStudio just you have to do this:Firstly, open RStudio like always, select from the top menu:Tools-Global Options-PackagesUncheck the option: Use Internet Explorer library/proxy for HTTP
- Find the file (
.Renviron
) in your computer, most probably you would find it here:C:Usersyour user nameDocuments
.Note that: if it does not exist you can create it just by writing this command in R:Then add these six lines to the initials of the file: - Restart R. Type the following commands in R to assure that the configuration above works well:
- Now you can install the packages as you want by using the command like:It's important to add
method='libcurl'
, otherwise it won't work.
7,07999 gold badges4545 silver badges5555 bronze badges
Mina HEMina HE
Simplest way to get everything working in RStudio under
Windows 10
:Open up Internet Explorer, select
Internet Options
:Open editor for Environment variables:
Add a variable HTTP_PROXY in form:
Example:
RStudio should work:
ContangoContango42.7k4848 gold badges192192 silver badges241241 bronze badges
Tried all of these and also the solutions using netsh, winhttp etc.Geek On Acid's answer helped me download packages from the server but none of these solutions worked for using the package I wanted to run (twitteR package).
The best solution is to use a software that let's you configure system-wide proxy.
FreeCap (free) and Proxifier (trial) worked perfectly for me at my company.
Please note that you need to remove proxy settings from your browser and any other apps that you have configured to use proxy as these tools provide system-wide proxy for all network traffic from your computer.
Rishi DuaRishi Dua
My solution on a Windows 7 (32bit). R version 3.0.2
Kevin Panko7,07999 gold badges4545 silver badges5555 bronze badges
DanDan