[英]Select time range from zoo time series
I have the following time series: 我有以下时间序列:
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 = ",")
I would like to create a new zoo - z1
that will be subset of z that will include the time range 20/11/2014 15:00
till 20/11/2014 23:00
. 我想创建一个新的zoo-
z1
,它将是z的子集,其中将包括时间范围20/11/2014 15:00
到20/11/2014 23:00
。 It will include the following: 它将包括以下内容:
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
library(lubridate)
window(z, start = parse_date_time("20/11/2014 15:00", orders = "%d-%m-%Y H!:M!"),
end = parse_date_time("20/11/2014 23:00", orders = "%d-%m-%Y H!:M!"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.