Skip to content
Prev 275803 / 398506 Next

question R regarding consecutive numbers

On Oct 28, 2011, at 11:26 AM, William Dunlap wrote:

            
I answered earlier in a posting that did not get threaded properly in  
my mailer and this is  a pr?cis:

 > xtbl <- with(rle(x), table(values, lengths))
 > xtbl["1", which( as.numeric( attr(xtbl, "dimnames")$lengths) >=2 )]
3 5
1 1

Since character-numeric comparisons appear to get properly coerced the  
as numeric may not be necessary:

 > xtbl["1", which( attr(xtbl, "dimnames")$lengths >=2 )]
3 5
1 1