[R] refer to next line within a data-frame an select cases

Jörg Groß joerg at licht-malerei.de
Tue Dec 16 04:35:45 CET 2008


Hi,

I have a problem sorting and selecting entries within a data-frame and  
I don't know if it is possible to solve it with R ... (probably yes,  
but I have no idea how).


Following Data;


row1	row2
a		12
pos		NA
a		3
neg		NA
a		5
neg		NA
a		11
pos		NA


I want to extract the values in row 2 in the lines with an  "a" in row1.

But I want to have two vectors: vector x with all a-values (in row2)  
when the label in the next line is "pos"
and vector y with all a-values when the label in the next line is "neg".


So:

x = 12, 11
y = 4, 5


How can I do that? How can I refer to values of the next line?



More information about the R-help mailing list