[R] How to calc ratios base on current and previous row?

Marcus Drescher drescher at tum.de
Fri Aug 27 19:17:50 CEST 2010


Hi all,

I want to calculate in each row a ratio based on number in the current row and the previous row.
Is there a way to do this without for-loops because that is extremely slow.

	A	B	
[1]	2	2	
[2]	2	3 	
[3]	4	5,5
...

B2 = A2 + 0.5*B1


Thanks in advance.
Best
Marcus



More information about the R-help mailing list