我曾经从github毫无问题地读取数据,现在使用相同的简单代码会出错。
x <- getURL("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv")
y <- read.csv(x, header = FALSE)
文件(文件,“ rt”)中的错误:无法打开连接
另外:
警告消息:在文件(文件,“ rt”)中:无法打开文件'HTTP / 1.1 200OK
使用data.table::fread
,我刚刚检查过就可以了
data.table::fread("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv")
作品
示例:
df <- data.table::fread("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv")
df[,1:5]
[0%] Downloaded 0 bytes...
Province/State Country/Region Lat Long 1/22/20
1: Afghanistan 33.00000 65.000000 0
2: Albania 41.15330 20.168300 0
3: Algeria 28.03390 1.659600 0
4: Andorra 42.50630 1.521800 0
5: Angola -11.20270 17.873900 0
---
260: Saint Pierre and Miquelon France 46.88520 -56.315900 0
261: South Sudan 6.87700 31.307000 0
262: Western Sahara 24.21550 -12.885800 0
263: Sao Tome and Principe 0.18636 6.613081 0
264: Yemen 15.55273 48.516388 0