[R] Histogram of gaps

Creighton, Sean sean.creighton at citi.com
Tue Jun 10 15:23:35 CEST 2008


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)


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?


More information about the R-help mailing list