案例研究:在 R 中分析城市时间序列数据
Lore Dirick
Manager of Data Science Curriculum at Flatiron School
使用 saveRDS() 和 readRDS()
saveRDS(citydata, file = "citydata.rds")
保留 xts 对象的时间索引
readRDS("citydata.rds")
pop pct_growth
1980-01-01 562994 NA
1990-01-01 574823 2.057851
2000-01-01 589141 2.430318
2010-01-01 617594 4.607072
使用 write.zoo() 和 read.zoo()
write.zoo(citydata, file = "citydata.csv", sep = ",")
需重新转换为 xts
citydata <- read.zoo("citydata.csv", sep = ",", header = TRUE)as.xts(citydata)
pop pct_growth
1980-01-01 562994 NA
1990-01-01 574823 2.057851
2000-01-01 589141 2.430318
2010-01-01 617594 4.607072
案例研究:在 R 中分析城市时间序列数据