0

When I directly call the following in RStudio, it works fine.

readLines("https://raw.githubusercontent.com/renkun-ken/rlist-tutorial/master/data/sample.yaml")

However, when I call from rterm or save the code to a .R file (say, readlines.R) and call

system("rscript readlines.R")

Then an error occurs:

Error in file(con, "r") : cannot open the connection
Calls: readLines -> file
In addition: Warning message:
In file(con, "r") : unsupported URL scheme
Execution halted
Warning message:
running command 'rscript readlines.R' had status 1 

I tried a HTTP URL and there's no problem but HTTPS URL like I used always ends up in this error if the code is called from external.

How can I fix this?

My session info:

R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_3.1.1
Kun Ren
  • 4,715
  • 3
  • 35
  • 50
  • doesn't work for me interactively (haven't tried it from a script). Results of `sessionInfo()` from your interactive session? Does it work if you start R with `--vanilla` ? – Ben Bolker Oct 24 '14 at 02:19
  • Use `getURL` from the `RCurl` package. – jdharrison Oct 24 '14 at 02:20
  • @jdharrison In fact I'm using yaml and jsonlite packages which internally calls readLines() which leads to errors when called from external. – Kun Ren Oct 24 '14 at 02:26
  • 1
    Maybe this: http://stackoverflow.com/a/21857323/1201032 or this http://stackoverflow.com/questions/19890633/r-produces-unsupported-url-scheme-error-when-getting-data-from-https-sites will be useful. – flodel Oct 24 '14 at 02:35
  • Thanks a lot, @flodel, `--internet2` solves the problem! Just call `rscript --internet2 readlines.R` and it works. – Kun Ren Oct 24 '14 at 02:43

0 Answers0