Nghiên cứu tình huống: Phân tích dữ liệu chuỗi thời gian của thành phố bằng R
Lore Dirick
Manager of Data Science Curriculum at Flatiron School
Dùng saveRDS() và readRDS()
saveRDS(citydata, file = "citydata.rds")
Giữ nguyên chỉ mục thời gian của 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
Dùng write.zoo() và read.zoo()
write.zoo(citydata, file = "citydata.csv", sep = ",")
Cần chuyển lại về 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
Nghiên cứu tình huống: Phân tích dữ liệu chuỗi thời gian của thành phố bằng R