I have a standard XTS stock price object. I would like to add a column that consists of the forward one year return. So, if the row Iām evaluating is 2019-03-01, I would like the return of 2019-03-01 to 2020-03-01 to be added. I have experimented with some ugly for loops, but I figure there has to be an elegant solution to this problem. Thanks!
I created a subset using stockxts[ā2019-03-01/2020-03-01ā]
and then used first and last.