如何解决我尝试使用R
因此,我尝试使用Covid数据分析。我正在尝试复制事物I read here。
但是我从一开始就有麻烦:
要下载其使用的数据
## source data files
filenames <- c('time_series_covid19_confirmed_global.csv','time_series_covid19_deaths_global.csv','time_series_covid19_recovered_global.csv')
url.path <- paste0('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/','master/csse_covid_19_data/csse_covid_19_time_series/')
## download files to local
download <- function(filename) {
url <- file.path(url.path,filename)
dest <- file.path('./data',filename)
download.file(url,dest)
}
bin <- lapply(filenames,download)
## load data into R
raw.data.confirmed <- read.csv('./data/time_series_covid19_confirmed_global.csv')
raw.data.deaths <- read.csv('./data/time_series_covid19_deaths_global.csv')
raw.data.recovered <- read.csv('./data/time_series_covid19_recovered_global.csv')
Error in file(file,"rt") : cannot open the connection
In addition: Warning message:
In file(file,"rt") :
cannot open file './data/time_series_covid19_confirmed_global.csv': No such file or directory
现在我已经探索了两个方向:
- 我认为链接可能已过时,因此我做了一些更改,但有一个相同的错误to go to this page:
## fichiers sources filenames <- c("10-31-2020.csv") url.path <- paste0("https://github.com/CSSEGISandData/COVID-19","blob/master/csse_covid_19_data/csse_covid_19_daily_reports") ## download files to local download <- function(filename) { url <- file.path(url.path,filename) dest <- file.path('./data',filename) download.file(url,download)
Error in download.file(url,dest) :
cannot open destfile './data/10-31-2020.csv',reason 'No such file or directory'
trying URL 'https://github.com/CSSEGISandData/COVID-19blob/master/csse_covid_19_data/csse_covid_19_daily_reports/10-31-2020.csv' Error in download.file(url,dest) : cannot open URL 'https://github.com/CSSEGISandData/COVID-19blob/master/csse_covid_19_data/csse_covid_19_daily_reports/10-31-2020.csv' In addition: Warning message: In download.file(url,dest) : Error in download.file(url,dest) : cannot open URL 'https://github.com/CSSEGISandData/COVID-19blob/master/csse_covid_19_data/csse_covid_19_daily_reports/10-31-2020.csv'
现在,我不确定为什么会更改错误,因为我认为dest
中的download(url,dest)
是本地保存,但不是硬保存
而且我甚至不确定下一步要检查什么。
我愿意以其他更安全/更可靠或可复制的方式下载此文件。 我只想要一种自动事实(每天从here获取新文件的方式)
解决方法
您的dest
文件路径中需要用斜杠结尾:
dest <- file.path('./data/',filename)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。