0

In order to access CRAN packages from within R on OSX I've been using

Sys.setenv(http_proxy="http://blah_blah:1234/")

as the first command in the R GUI for a while, but would really like to set this proxy automatically.

I've tried unsuccessfully to get the same command to work in a .Rprofile file in ~/

I've also tried http_proxy="http://blah_blah:1234/", but this fails too.

The error I get when I try to view packages is a drop-down window that says:

Fetching Package List Failed
Please consult R Console output for details

The GUI then gives:

Error in read.dcf(file = tmpf) : Line starting '<head> ...' is malformed!

The .Rprofile file itself seems to be loading (checked using cat("my profile works\n"))

Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
R_usr
  • 75
  • 5

3 Answers3

2

Couldn't you just use .First ?

http://cran.r-project.org/doc/manuals/R-intro.html#Customizing-the-environment

richiemorrisroe
  • 9,307
  • 3
  • 22
  • 20
1

This thread appears first when searching for setting R proxy on OS X, so here's what I use in my .Rprofile:

Sys.setenv(http_proxy=system("networksetup -getwebproxy Ethernet | awk {'print $2'} | awk {'getline l2; getline l3; print \"http://\"l2\":\"l3'} | head -n 1",intern=TRUE))

Change Ethernet to Airport if necessary.

Credit for the awk part goes to Chealion

Community
  • 1
  • 1
Sam Inverso
  • 441
  • 4
  • 7
0

I think I have managed to solve this using trial and error...

A combination of .First and Sys.setenv() works.

If anyone has any ideas I'd be interested to know why.

R_usr
  • 75
  • 5