R XTS package to.minutes3
I try am trying to use the "to.minutes3" function in the xts package to segment my data.
This function does correctly put the time column in开发者_如何学JAVAto the desired intervals. But data columns becomes "open" , "close", "high" and "low". Is there are way tell the function to average the data points that fall into the same interval?
Thanks, Derek
You want period.apply
. Assuming your data are in object x
and are more frequent than 3-minutes, the code below will give you a mean for each distinct, non-overlapping, 3-minute interval.
> period.apply(x, endpoints(x,k=3,"minutes"), mean)
It looks to me like the answer is no, without completely changing that function, based on help("to.period"). to.minutes
uses to.period
, which says the following w.r.t. the OHLC parameter:
OHLC should an OHLC object be returned? (only OHLC=TRUE currently supported)
So other return values aren't supported.
精彩评论