My problem is somewhat related to this question.
I have a data as below
V1   V2
..   1
..   2
..   1
..   3
I need to calculate variance of data in V1 for each value of V2 cumulatively (This means that for a particular value of V2 say n,all the rows of V1 having corresponding V2 less than n need to be included. 
Will ddply help in such a case? 
 
     
    