Re: [R] Conditional operation on data frame, shift/roll of vector

2009-09-26 Thread David Winsemius
On Sep 26, 2009, at 12:52 PM, David Winsemius wrote: On Sep 26, 2009, at 11:46 AM, jiangrm wrote: Conditionally, when Ind of a certain row is 1, want to get sum or delta of Val in that row and 1 row above. Val Ind Val Ind Del 10 010 0NA 11

Re: [R] Conditional operation on data frame, shift/roll of vector

2009-09-26 Thread David Winsemius
On Sep 26, 2009, at 11:46 AM, jiangrm wrote: Conditionally, when Ind of a certain row is 1, want to get sum or delta of Val in that row and 1 row above. Val Ind Val Ind Del 10 010 0NA 11 011 0NA 13 1 ---

[R] Conditional operation on data frame, shift/roll of vector

2009-09-26 Thread jiangrm
Conditionally, when Ind of a certain row is 1, want to get sum or delta of Val in that row and 1 row above. Val Ind Val Ind Del 10 010 0NA 11 011 0NA 13 1 ---> 13 124 or 2 16 0