Calculate the average based on other columns
问题 I want to calculate "average of the closing prices for the 5,10,30 consecutive trading days immediately preceding and including the Announcement Day, but excluding trading halt days (days on which trading volume is 0 or NA) For example, now we set 2014/5/7 is the Announcement day. then average of price for 5 consecutive days : average of (price of 2014/5/7,2014/5/5, 2014/5/2, 2014/4/30,2014/4/29), price of 2014/5/6 and 2014/5/1 was excluded due to 0 trading volume on those days. EDIT on 11/9