I am trying to compute cumulative returns in R, using cumprod()
for $1 invested
I seem to be getting NA values after using the cumprod()
function, because the first return I'm trying to use is NA and therefore not successfully cumulating returns.
[1] NA -0.059898142 -0.267314770 -0.075349437 0.008658063 -0.008658063 0.000000000
The first row is NA and because of that, the cumprod(x+1)
function turns into all NAs
How do I remove the first row/ignore the NA?
Any input would be appreciated