[R] Histogram of gaps

From: Creighton, Sean <sean.creighton_at_citi.com>
Date: Tue, 10 Jun 2008 14:23:35 +0100


Hi

I consider myself not a complete beginner in R, however an elegant solution to this problem stumps me. I have a fairly long time series of 60000 or so points, I need to gather the data to create a histogram of the length of continuous zero periods in a data set.

So image the data looks like this (where as a pre-condition all numbers are single digit so assume commas if you which, I have the time series properly formatted in a zoo object)

333343245352352352353252335000003343253532523523522352352353253225325300 002352352332552533252353200325235235

I should get the following zero periods out:

333343245352352352353252335 <00000>
33432535325235235223523523532532253253 <0000> 23523523325525332523532 <00> 325235235

So I have three entries for my histogram 5,4 and 2. Now can anyone give me any tips that doesn't involve using a loop which will be quite time consuming? Is there some function in a libray that already does something like this?

Thanks
Sean



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 10 Jun 2008 - 13:47:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 10 Jun 2008 - 14:30:39 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive