Skip to content
Prev 275664 / 398506 Next

question R regarding consecutive numbers

On 27/10/2011 8:43 AM, Samir Benzerfa wrote:
How about this?

 > runs <- rle(x)
 > with(runs, table(values, lengths))
       lengths
values 1 2 3
      1 2 1 1
      2 1 0 0
      3 1 0 0
      4 2 0 0
      5 2 0 0
      6 1 0 0
      9 2 0 0

Duncan