Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading URL in R and RStudio

Tags:

r

rstudio

When I type the following in RStudio it works fine:

nyt1 <- read.csv(url("http://stat.columbia.edu/~rachel/datasets/nyt1.csv"))

But when I type the same thing in the R console, I get this error:

Error in open.connection(file, "rt") : cannot open the connection
In addition: Warning message:
In open.connection(file, "rt") : cannot open: HTTP status was '0 (nil)'

I have checked and rechecked a thousand times and everything seems to be exactly the same between RStudio and R (same versions, etc), so why the error?

like image 677
Sylvia Avatar asked Sep 28 '12 20:09

Sylvia


1 Answers

There can be differences in proxy settings or other network settings between RStudio and the R Console. As one example, the use of the "internet2" option (defined on the command line when R is invoked) could differ. setInternet2(NA) on each platform will show the setting. If the result of that differs, that could be the source of the difference.

like image 192
Brian Diggs Avatar answered Nov 01 '22 07:11

Brian Diggs