My existing data frame looks line given below
NAV_Date NAV Year Day Units Amount Balance_Units
2013-06-01 282.5 2013 Saturday 3.540 1000 3.540
2013-06-08 279.3 2013 Saturday 3.581 1000 3.581
2013-06-15 276.0 2013 Saturday 3.623 1000 3.623
2013-06-22 261.6 2013 Saturday 3.822 1000 3.822
2013-06-29 273.3 2013 Saturday 3.659 1000 3.659
I want my new data frame to have Balance_Units column have entries like given below using R Language i.e Balance unit column should be the sum of previous value and present value This is need to be done on the list of dataframe
NAV_Date NAV Year Day Units Amount Balance_Units
2013-06-01 282.5 2013 Saturday 3.540 1000 3.540
2013-06-08 279.3 2013 Saturday 3.581 1000 7.121
2013-06-15 276.0 2013 Saturday 3.623 1000 10.744
2013-06-22 261.6 2013 Saturday 3.822 1000 14.566
2013-06-29 273.3 2013 Saturday 3.659 1000 18.225
I tried this but , this is not working
for( i in 1:length(W)) {
W[[i]]$Units = 1000/W[[i]]$NAV
W[[i]]$Amount = 1000
W[[i]]$Balance_Units = 0
W[[i]]$Balance_Units = W[[i]]$Units + W[[i]]$Balance_Units
}