I am trying to find the Yield to Date for a monthly raw data with lag function. Is there a better way to code it instead of the one here? After this I would need to find the YTD for daily data and I believe with the code I have, it will take ages, hence I would need advice on a better way to code it. Thx.
YTD<- (lag(Data2,0) + lag(Data2,1) + lag(Data2,2) + lag(Data2,3) +
lag(Data2,4) + lag(Data2,5) + lag(Data2,6) + lag(Data2,7) +
lag(Data2,8) + lag(Data2,9) + lag(Data2,10) + lag(Data2,11) +
lag(Data2,12))