【问题标题】:Unable to downlad file to load data on R无法下载文件以在 R 上加载数据
【发布时间】:2014-09-06 11:45:03
【问题描述】:

操作系统- Windows 7
R 3.0.3 版
我在 R 控制台上输入的内容

if(!file.exists("data")){dir.create("data")}
fileUrl <- "https://data.baltimorecity.gov/api/views/dz54-2aru/rows.xlsx?accessType=DOWNLOAD"
download.file(fileUrl,destfile="./data/cameras.xlsx",method="curl")
dateDownloaded <- date()

我在 R 控制台上得到了什么

警告信息:

1: running command 'curl  "https://data.baltimorecity.gov/api/views/dz54-2aru/rows.xlsx?accessType=DOWNLOAD"  -o "./data/cameras.xlsx"' had status 127 
2: In download.file(fileUrl, destfile = "./data/cameras.xlsx", method = "curl") :

下载的退出状态非零

我怎样才能做到正确?

【问题讨论】:

  • 这是一些“有趣”的格式。您至少可以使代码格式化吗? FWIW,粗体字体不会使内容更具可读性。
  • https 更改为仅http 并跳过download.file 中的method="curl"。这并不总是有效,但该文件可以通过普通的 'ol http 获得。

标签: r


【解决方案1】:

您的代码对我有用。您的系统上可能没有安装 cURL。见?download.file:

对于方法“wget”、“curl”和“lynx”,系统调用方法提供的工具,并且相应的程序必须安装在您的系统上并且在可执行文件的搜索路径中。

安装cURL 并确保它在您的路径中。

【讨论】:

    【解决方案2】:

    去掉method="curl"参数后,在Windows上运行良好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-21
      • 2015-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-23
      • 1970-01-01
      相关资源
      最近更新 更多