Hi all

I have a question about aggegating statistics by time intervals. I have a
data set with 3 columns : time, bid, and ask. Time is specified as a
millisecond timestamp since epoch. I would like to compute summary
statistics for the data set on an hourly basis. Here is what I have tried so
far:

# Data is in pricedata

t <- ISODatetime(1970, 1, 1, 0, 0, 0) + pricedata$time
agg <- aggregate(pricedata$spread, list(byhour=format(t, "%Y-%m %H")), mean)

This seems to do what I want - however, what really want to do is more
specific: I would like to be able to extract a subset of the data frame
pricedata, and not just the aggregated entries - for instance, instead of
just extracting pricedata$spread by hour, I would like to extract a slice of
columns, e.g. pricedata$spread and pricedata$time on an hourly basis, and
pass these into a function that can compute a time-weighted average spread,
for instance. Does anyone know an elegant way to do this? I have a feeling
zoo may do what I want, but I'm new to zoo ...

Cheers
Rory

	[[alternative HTML version deleted]]

