# First create an xts object similar to the one you describe
x <- .xts(c(100,105,115.5,103.95), 1:4, dimnames=list(NULL, "Index"), tzone="UTC")
x$Return <- c(0, ROC(x$Index, type="discrete", na.pad=FALSE))
The cumulative arithmetic return at any time is just the product of 1 plus the returns (minus 1). cumprod
will calculate the cumulative product for you.
x$CumulativeReturn <- cumprod(1 + x$Return) - 1
# Index Return CumulativeReturn
#1970-01-01 00:00:01 100.00 0.00 0.0000
#1970-01-01 00:00:02 105.00 0.05 0.0500
#1970-01-01 00:00:03 115.50 0.10 0.1550
#1970-01-01 00:00:04 103.95 -0.10 0.0395
If you were working with log returns, you could simply do cumsum(x$Return)