The following code computes yearly returns every month on the xts seqence s.

s=xts(1:1000,as.Date(0:999))
yret_by_month = diff(s,lag=365)/lag(s,k=365)[endpoints(s,on="months")]

There is a more efficient way to avoid diff and lag to perform computations over the whole sequence? Thanks in advance for any help.


Regards,
F. Pollastri

_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to