[R] (no subject)

Marine Andersson Marine.Andersson at ki.se
Fri Jan 28 15:37:07 CET 2011

I have a data set with each column containing data like this:
row column1
1 1.2 
2 NA 
3 NA 
4 3 
5 5
6 NA 
7 1.5 
8 NA 
9 NA 
10  NA 
11 3 
12 NA 
13  3 
14  NA 
15 NA 
16 NA 
17 NA 
18 3 
19 1.2 
20 NA

>From this I would like to extract the sequence containing at least three rows of 3 in a row (exlcuding NAs). I would also like to have the row numbers showing the place of the last number unequal to 3 befor the first 3 in the sequence and the place of the next number after the last 3 in the sequence.
So in this example I would get  11 to 18 as the sequence rows and row 7 to 19 as the rows showing the numbers before and after that are unequal to three.
The rle does not work since it is not possible to exlude the NAs.

I hope you understand the question. All help is highly appreciated.


More information about the R-help mailing list