在R中下载大文件

时间:2017-09-20 11:46:07

标签: r csv shiny

我使用read.csv方法下载大文件

data <- read.csv(url("http://some_url/data.csv"),sep=";",header=FALSE,nrows=number_of_row) 

当我从本地运行它时,我没有问题,但是当我将它部署在远程ShinyApp服务器中时

Warning in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  :
2017-09-20T11:32:12.685102+00:00 shinyapps[214798]:   URL 'http://some_url/data.csv': status was 'Transferred a partial file'
2017-09-20T11:32:12.685912+00:00 shinyapps[214798]: Warning: Error in scan: cannot read from connection
2017-09-20T11:32:12.689155+00:00 shinyapps[214798]: Stack trace (innermost first):
2017-09-20T11:32:12.689157+00:00 shinyapps[214798]:     56: read.table
2017-09-20T11:32:12.689159+00:00 shinyapps[214798]:     55: read.csv
2017-09-20T11:32:12.689159+00:00 shinyapps[214798]:     54: loadIncidenceData
2017-09-20T11:32:12.689160+00:00 shinyapps[214798]:     53: prepare_incidence_data [/srv/connect/apps/predictiviz/ui.R#11]

有人有想法吗?

编辑:按照下面的一些建议,这里

URL <- "some_url"
  download.file(URL, destfile = "./data/data.csv")
  file <- file.path("data", "data.csv") 
  data <- read.csv(file,sep=";",header=FALSE,nrows=some_rows)

我收到完全相同的消息错误

0 个答案:

没有答案