Skip to content

I think not so hard question

1 message · Liaw, Andy

#
Mark,

It's a bit unclear whether you're looking for a run of exactly 3, or at
least 3.  If it's exactly 3, what Prof. Koenker suggested (using rle())
should help you a lot.  If you want runs of at least 3, it should work
similarly as well.
[1] -1 -1  1  1 -1  1  1  1  1 -1 -1 -1  1 -1  1 -1  1  1 -1  1  1 -1  1
-1 -1 -1
 [27] -1 -1  1 -1 -1  1 -1 -1  1  1  1 -1  1 -1  1  1  1  1  1  1 -1 -1  1
1 -1  1
 [53] -1 -1 -1 -1 -1  1  1 -1  1 -1 -1 -1  1 -1 -1  1 -1  1 -1  1 -1 -1 -1
1  1 -1
 [79]  1  1 -1  1 -1 -1  1 -1  1 -1 -1 -1 -1 -1  1  1  1  1 -1 -1  1  1
[,1] [,2] [,3] [,4]
[1,]   -1    1   -1   -1
[2,]   -1    1   -1   -1
[3,]   -1    1   -1   -1
[1] 10 35 62 73

Andy


From: Mark Leeds