Calculate average returns in daily time series over 5 days prior to event date

We probably need to see the rest of your code, any error messages and some sample data.

FAQ

A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here.data