Wednesday, 28 August 2013

R building a subset based on value in previous row

R building a subset based on value in previous row

I have a problem figuering this out: suppose this is how my data looks like:
Num condition y
1 a 1
2 a 2
3 a 3
4 b 4
5 b 5
6 b 6
7 c 7
8 c 8
9 c 9
10 b 10
11 b 11
12 b 12
I now want to make calculation (e.g., mean) on b, depending on whether
value was in the row before b, in this example a or c? Thanks for any
help!!! Angelika

No comments:

Post a Comment