简体   繁体   中英

Make a time series data in R

I have a numeric variable and a date which includes just year and month, I was wondering how I can have a time series data.

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)

May be we could use read.zoo

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM