What you think is the r + 1 cumulative product . For my "data"
> r <- matrix(rnorm(40,0.05,0.01),5,8) > r [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.04305611 0.03545166 0.05882694 0.03910892 0.04796011 0.05631498 [2,] 0.05623084 0.03747785 0.04809927 0.05644677 0.06747468 0.05405979 [3,] 0.04389437 0.05353846 0.04600529 0.04363427 0.05399780 0.04260270 [4,] 0.04644610 0.05471288 0.06279882 0.02195831 0.05971777 0.05024525 [5,] 0.04426485 0.03294009 0.04325665 0.06006569 0.07416615 0.06585176 [,7] [,8] [1,] 0.02724187 0.03515898 [2,] 0.04285792 0.04220358 [3,] 0.04302487 0.06662048 [4,] 0.04948629 0.04256084 [5,] 0.04659738 0.03395883
here's how to get it:
> t(apply(r+1, 1, cumprod)) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 1.043056 1.080034 1.143569 1.188293 1.245284 1.315412 1.351246 1.398755 [2,] 1.056231 1.095816 1.148524 1.213355 1.295225 1.365245 1.423756 1.483844 [3,] 1.043894 1.099783 1.150379 1.200575 1.265403 1.319313 1.376076 1.467751 [4,] 1.046446 1.103700 1.173011 1.198769 1.270356 1.334186 1.400210 1.459804 [5,] 1.044265 1.078663 1.125322 1.192916 1.281390 1.365771 1.429413 1.477954
(Don't ask me why t() needed.)
Then all this is multiplied by the original size:
> t(apply(r+1, 1, cumprod)) * 100 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 104.3056 108.0034 114.3569 118.8293 124.5284 131.5412 135.1246 139.8755 [2,] 105.6231 109.5816 114.8524 121.3355 129.5225 136.5245 142.3756 148.3844 [3,] 104.3894 109.9783 115.0379 120.0575 126.5403 131.9313 137.6076 146.7751 [4,] 104.6446 110.3700 117.3011 119.8769 127.0356 133.4186 140.0210 145.9804 [5,] 104.4265 107.8663 112.5322 119.2916 128.1390 136.5771 142.9413 147.7954
Oh, and remember to also add a column for the initial size:
> cbind(1, t(apply(r+1, 1, cumprod))) * 100 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 100 104.3056 108.0034 114.3569 118.8293 124.5284 131.5412 135.1246 [2,] 100 105.6231 109.5816 114.8524 121.3355 129.5225 136.5245 142.3756 [3,] 100 104.3894 109.9783 115.0379 120.0575 126.5403 131.9313 137.6076 [4,] 100 104.6446 110.3700 117.3011 119.8769 127.0356 133.4186 140.0210 [5,] 100 104.4265 107.8663 112.5322 119.2916 128.1390 136.5771 142.9413 [,9] [1,] 139.8755 [2,] 148.3844 [3,] 146.7751 [4,] 145.9804 [5,] 147.7954