Skip to content

How do I bin data into 5 min bins and compute the medians in the bins?

13 messages · Jeff Ryan, Michael, G See +1 more

#
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:

  
    
#
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:
#
You should lead with what you have tried, it lets everyone have a
better idea of what you are looking for.

That said, the .082225 is perfectly acceptable to xts, though
precision-wise you are near the limit of floating point precision on
many platforms.  The previous post in this thread is on target to what
you want.

Take a good look at ?endpoints and to a lesser extend ?period.apply.

HTH
Jeff
On Thu, Jan 19, 2012 at 12:54 PM, Michael <comtech.usa at gmail.com> wrote:

  
    
#
Michael comtech,

You might also consider reading one of the 2 e-mails that Brian sent
you on-list in the last month that say to look at
?strftime

For example ... the second example on that page
format(Sys.time(), "%H:%M:%OS3")
On Thu, Jan 19, 2012 at 1:01 PM, Jeffrey Ryan <jeffrey.ryan at lemnica.com> wrote:
#
It is preserved, just not displayed.

options(digits.secs=6)

HTH
Jeff
On Thu, Jan 19, 2012 at 1:36 PM, Michael <comtech.usa at gmail.com> wrote:

  
    
#
It's remarkable how often people's R problems are actually Excel problems.

:-)

Michael Weylandt
On Fri, Jan 20, 2012 at 11:35 AM, Michael <comtech.usa at gmail.com> wrote: