[R-SIG-Finance] How do I bin data into 5 min bins and compute the medians in the bins?
R. Michael Weylandt
michael.weylandt at gmail.com
Thu Jan 19 19:56:08 CET 2012
Use something like:
period.apply(X, endpoints(X, "minutes", 5), median)
Michael Weylandt
On Thu, Jan 19, 2012 at 1:54 PM, Michael <comtech.usa at gmail.com> wrote:
> I have also searched "crazily"... and read into both "xts" and "zoo"... but
> couldn't find a solution...
>
> My questions are:
>
> 1. How to handle the ".082225" part in "xts" and "zoo"?
>
> 2. The "xts/zoo" interval arithmatic only handles OHLC of an interval, not
> median of an interval, right?
>
> Thanks a lot!
>
> On Thu, Jan 19, 2012 at 12:51 PM, Jeffrey Ryan <jeffrey.ryan at lemnica.com>wrote:
>
>> Use a time series class. This has all been solved thousands of times
>> before in private and on the lists.
>>
>> Jeff
>>
>> On Thu, Jan 19, 2012 at 12:43 PM, Michael <comtech.usa at gmail.com> wrote:
>> > Hi all,
>> >
>> > I have data in the following format:
>> >
>> > How do I bucket the data into 5 min bins and then compute the median of
>> > quotes in the bins?
>> >
>> > Currently the "DateTimeStamps" are "factors" in the data frame and I
>> > ordered the rows according to these DateTimeStamps
>> >
>> > Thanks a lot!
>> >
>> > Bid Offer DateTimeStamps
>> >
>> > 46.00 46.10 2006-06-16 12:12:00.082225
>> >
>> > [[alternative HTML version deleted]]
>> >
>> > _______________________________________________
>> > R-SIG-Finance at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> > -- Subscriber-posting only. If you want to post, subscribe first.
>> > -- Also note that this is not the r-help list where general R questions
>> should go.
>>
>>
>>
>> --
>> Jeffrey Ryan
>> jeffrey.ryan at lemnica.com
>>
>> www.lemnica.com
>> www.esotericR.com <http://www.esotericr.com/>
>>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
More information about the R-SIG-Finance
mailing list