Error in download.file unsupported URL scheme

2020-03-03 09:14发布

问题:

I am working with an algorithm R that calls a webservice that makes a query to a database and returns a JSON object.

url <- "https://example.com?id=1"
json_file <- "C:/xampp/htdocs/example/Download/data.json"
download.file(url, json_file)
document <- fromJSON(json_file)

On my machine the algorithm usually works bad when I go up to the server and run, I get the following error:

Error in download.file(url, json_file) : unsupported URL scheme

here is some problem for the url be https?

回答1:

From the Details section of ?download.file.

 Note that 'https://' URLs are only supported if '--internet2' or
 environment variable 'R_WIN_INTERNET2' was set or
 'setInternet2(TRUE)' was used (to make use of Internet Explorer
 internals), and then only if the certificate is considered to be
 valid.


回答2:

In Ubuntu, you can use method = "curl" to use curl to download.