简体   繁体   中英

R zoo aggregate truncate to: aggregate time series to select last element in specific time interval

I have been reading a few posts here on how I can select the last data point in a specified time interval.

My data is 1 minute city moisture readings. The data is extracted from mySQL and saved in a zoo object without a time object. So R has no way of knowing the time interval. But given that I know that the data is 1 minute data can I in any way aggregate the data to select the last data point every 5 minutes, 10 minutes, 15 minutes etc.

I have been reading ?aggregate and ?trunc but I think my situation is a little different because I don't have a date/time-interval column associated with the moisture data.

Any help would be greatly appreciated.

Like you would do it with any vector :

> Test <- as.zoo(1:33)
> Test[seq(5,length(Test),by=5)]
 5 10 15 20 25 30 
 5 10 15 20 25 30 

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