xtsオブジェクトの保存とエクスポート

ケーススタディ:Rで都市の時系列データを分析する

Lore Dirick

Manager of Data Science Curriculum at Flatiron School

rdsで保存

  • 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
ケーススタディ:Rで都市の時系列データを分析する

csvで保存

  • 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で都市の時系列データを分析する

練習しましょう!

ケーススタディ:Rで都市の時系列データを分析する

Preparing Video For Download...