我有以下时间序列:
library(lubridate)
library (zoo)
ts1 <- "f,c
1,19/11/2014 12:00,0.01
2,19/11/2014 13:00,0.01
3,20/11/2014 15:00,0.01
4,20/11/2014 16:00,0.01
5,20/11/2014 17:00,0.01
6,20/11/2014 19:00,0.01
7,20/11/2014 22:00,0.20
8,20/11/2014 23:00,0.03
9,21/11/2014 16:00,0.01
10,21/11/2014 17:00,0.01"
z <- read.zoo(text = ts1, tz = "", format = "%d/%m/%Y %H:%M", sep = ",")
我想创建z2
对象的向量/数组zoo
,例如:
z2[1]<-window(z, start = parse_date_time("20/11/2014 15:00", orders = "%d-%m-%Y H!:M!"),
end = parse_date_time("20/11/2014 16:00", orders = "%d-%m-%Y H!:M!"))
z2[2]<-window(z, start = parse_date_time("20/11/2014 17:00", orders = "%d-%m-%Y H!:M!"),
end = parse_date_time("20/11/2014 23:00", orders = "%d-%m-%Y H!:M!"))
z2[3]<-window(z, start = parse_date_time("21/11/2014 16:00", orders = "%d-%m-%Y H!:M!"),
end = parse_date_time("21/11/2014 17:00", orders = "%d-%m-%Y H!:M!"))
所以我将能够使用z2 [1],z2 [2]和z2 [3]作为每个动物园对象。
答案 0 :(得分:0)
感谢@ 42:
z2 <- list()
z2[[1]]<-window(z, start = parse_date_time("20/11/2014 15:00", orders = "%d-%m-%Y H!:M!"),
end = parse_date_time("20/11/2014 16:00", orders = "%d-%m-%Y H!:M!"))
z2[[2]]<-window(z, start = parse_date_time("20/11/2014 17:00", orders = "%d-%m-%Y H!:M!"),
end = parse_date_time("20/11/2014 23:00", orders = "%d-%m-%Y H!:M!"))
z2[[3]]<-window(z, start = parse_date_time("21/11/2014 16:00", orders = "%d-%m-%Y H!:M!"),
end = parse_date_time("21/11/2014 17:00", orders = "%d-%m-%Y H!:M!"))