Home > R > Friday Function: setInternet2

Friday Function: setInternet2

Corporate IT networks are a pain for programmers. Ideally, when programming, you want the freedom to download, install and run any software that you want. Unfortunately, in the interests of security, many programmers find themselves a little restricted at the office. (I’m sure that many network admins will protest that the situation works both ways – prgrammers are also a pain for corporate IT networks.)

With the default installation of R, you may find that connecting from R to the internet doesn’t work. This is a shame, since there are many useful features of R that require internet access, not least downloading packages and scraping data from webpages with RCurl.

For Windows users, there is a solution. By typing setInternet2(TRUE), R connects via internet2.dll, which Internet Explorer uses. From a network point of view this makes R appear to be the same as Internet Explorer, and sneak through.

In order to have this functionality every time you run R, add that line of code to your Rprofile.site file in the R.home("etc") directory. If you have control over the installation of R, choosing a custom installation gives you the option to connect via internet2.dll by default.

About these ads
  1. Paul
    17th April, 2011 at 19:49 pm

    This is a very helpful thing for people in the corporate world to know. Every time you upgrade R, the internet settings go back to the default installation. When you try to download a package, you get a cryptic message that the mirror site can’t be found. If you google this error message, you get many hits on the R-help archives, where you’re told that the mirror site is down. You can quickly detemine this is not the case, because no matter where in the world you try to link to, you get the error message. They can’t all be down. Getting to the root of the problem — setInternet2(TRUE) — was a long process, at least in my case. Then a few months later the next time you update R, for me the whole cycle starts again, because I’ve forgotten all about the setInternet2(TRUE) customization. I guess what I’m saying is that I can’t be reminded enough about this command, because it’s made you gunshy about updating R. I vaguely remember that something always breaks (the other hassle is keeping your old library and migrating it over to the updated version of
    R — I learned from hard experience about not over-writing the updated base R installation when copying over the old library. I’ll still probably get it wrong the next time I update R).

  2. 1st October, 2012 at 12:58 pm

    Be warned: this will not work if proxy authentication is required. There are some good instructions at StackOverflow, e.g. http://stackoverflow.com/questions/4832560/how-do-i-tell-the-r-interpreter-how-to-use-the-proxy-server

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 229 other followers

%d bloggers like this: