Reading URLs in R and 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 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 checked and double-checked a thousand times, and everything seems to be exactly the same between RStudio and R (same versions, etc.), so why the error?

+5
source share
1 answer

In proxy settings or other network settings, there may be differences between RStudio and the R-console. As one example, the use of the parameter "internet2" (defined on the command line when calling R) may differ. setInternet2(NA)Each platform displays the setting. If the result of this is different, it can be a source of difference.

+5
source

All Articles