Skip to content
Prev 49625 / 398498 Next

Finding indices where

On 19 May 2004 at 13:26, Ravi Varadhan wrote:

            
Hallo
not complete maybe not ellegant but

y<-rle(diff(x))
res1<-x[(cumsum(y$length))[y$length>1]]+1
res2<-res1-y$length[y$length>1]

gives you the numbers you want in two vectors (res1,  res2). Than you can do 
any formating and selection you want.

Cheers
Petr
Petr Pikal
petr.pikal at precheza.cz