我正在尝试使用R中的transtats.bts.gov包从skynet下载2019年1月的航班数据中的所有字段
首先,我为程序创建了测试数据,使用链接手动选择文件。
https://www.transtats.bts.gov/DL_SelectFields.asp?gnoyr_VQ=FGJ&QO_fu146_anzr=b0-gvzr
当我使用来自CRAN的skynet包和函数download_ontime(2019,1)时,它只下载字段的一个子集。
如果无法下载飞行数据,我更愿意使用skynet包或不同的包,因为很可能下载链接将被修复在包中,以防它在网页上发生变化,否则以后可能会导致代码崩溃。
使用skynet下载(并不包括所有字段)的工作如下:
require("skynet")
download_ontime(2019, 2, auto = TRUE)我不能100%确定它是否下载所有字段,因为我看不到它存储文件的位置。
检查所有字段是否为downloaded
发布于 2022-04-10 05:08:25
不使用skynet包,我们可以从上面的url下载和导入文件,
url = 'https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_2019_2.zip'
temp <- tempfile()
#download the file
download.file(url, temp)
#unzip in your working directory
unzip(temp)
files <- list.files(pattern = ".csv", full.names = T)
#as its a large csv file we shall read it using fread
library(data.table)
df = read.csv(files)
#dimension
dim(df)
[1] 533175 110https://stackoverflow.com/questions/71800988
复制相似问题