When I run this code in the R console, it works fine:
read.csv('https://courses.edx.org/c4x/MITx/15.071x_2/asset/WHO.csv')
But when I try to put in into an R markdown document and knit it, I get the following:
Error in open.connection(file, "rt") : cannot open the connection
Calls: <Anonymous> ... eval -> read.csv -> read.table -> open -> open.connection
Execution halted
I also tried using http
and url()
, but neither helped
read.csv('http://courses.edx.org/c4x/MITx/15.071x_2/asset/WHO.csv')
read.csv(url('http://courses.edx.org/c4x/MITx/15.071x_2/asset/WHO.csv'))
Both work fine in usual R sessions.
How can knitr? I hope there are ways that avoid downloading the file and placing it somewhere into working directory.
For linking purposes: It's the same issue as in read.table() and read.csv both Error in Rmd, but it my case I'm trying to read from an url, not from a file.