Case Study: Analyzing City Time Series Data in R
Lore Dirick
Manager of Data Science Curriculum at Flatiron School
Use saveRDS()
and readRDS()
saveRDS(citydata, file = "citydata.rds")
Maintains time index of xts objects
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
Use write.zoo()
and read.zoo()
write.zoo(citydata, file = "citydata.csv", sep = ",")
Must re-convert to 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
Case Study: Analyzing City Time Series Data in R