I tried to use mutate and them the accumulate, but I keep getting only the 1+port figure.
mutate(acc_growth_p1 = accumulate(1+port1, '*'))
I tried to use mutate and them the accumulate, but I keep getting only the 1+port figure.
mutate(acc_growth_p1 = accumulate(1+port1, '*'))
mutate(acc_growth_p1 = cumprod(port1 + 1))
For example:
data.frame(rates = seq(0, 0.5, by = 0.1)) %>%
mutate(growth = cumprod(rates + 1))
rates growth
1 0.0 1.0000
2 0.1 1.1000
3 0.2 1.3200
4 0.3 1.7160
5 0.4 2.4024
6 0.5 3.6036