Posts Tagged ‘tricks’

Friday Function: setInternet2

15th April, 2011 2 comments

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 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.