在R中制作时间序列数据

时间:2018-06-28 15:54:28

标签: r time series

我有一个数字变量和一个仅包含年份和月份的日期,我想知道如何获取时间序列数据。

A<-c(1,2,3,4,55,66,7,88,88,99,99,55,56,6,7,7,8)
Date<-c("1999-01","1999-02","1999-01","1999-10","1999-10","1999-01","1999-01","1999-11","1999-11","1999-01","1999-05","1999-03","1999-12","1999-4","1999-01","1999-12","1999-2")
Data<-data.frame(A,Date)

1 个答案:

答案 0 :(得分:0)

也许我们可以使用read.zoo

library(zoo)
read.zoo(Data, FUN = as.yearmon, format = "%Y-%m", index.column = 2)