开发者

R XTS package to.minutes3

开发者 https://www.devze.com 2023-01-16 10:07 出处:网络
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 colu

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号