[R] convert zoo object to "standard" R object so I can plot and output to csv file
Gabor Grothendieck
ggrothendieck at gmail.com
Thu Feb 23 05:17:07 CET 2012
On Wed, Feb 22, 2012 at 9:54 PM, Henry <hccoles at lbl.gov> wrote:
> Gabor,
> Thanks very much.
> I have all the zoo functions to get 1 minute aggregation and 15 min. means
> working and now able to write out to a file/etc.
>
> One question on the 15 min. mean results.
>
> m1 <- times("00:01:00")
> g <- seq(trunc(start(z),m1),end(z),by = m1)
> z1<-na.approx(z,xout = g)
> m15 <- times("00:15:00")
> ag15 <- aggregate(z1,trunc(time(z1),m15),mean)
>
> Does the value of ag15 get assigned to the "center" of the time, front or
> rear?
> Can this be defined?
> It seems aggregate(z1,trunc(time(z1),m15),mean) is getting the mean and
> "assigning" it to the first time stamp, not a time stamp assigned to 7.5
> minutes from the first 1 minute data point used to get the mean.
>
> Is there an option to "create" a new regular timestamp on 15 periods but
> centered or reporting on 7.5 minute periods?
>
The by argument of aggregate.zoo defines the time index (as discussed
in ?aggregate.zoo) so time index of ag15 is trunc(time(z1), m15);
therefore, to push it ahead by 7.5 minutes just use trunc(time(z1),
m15) + as.numeric(m15)/2 in its place.
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list