Reformat daily stock and return data to weekly/monthly
问题 I have some stock data together with some returns that are presented below. Now I would like to coerce both the daily price changes (open, high, low, close, volume, adj. close) and the returns given to weekly or monthly values. I know that the weekly prices can be obtained by xts::to.weekly() , but this drops the return. I don't know the exact mechanism behind the to.weekly function, but the returns need to be summarized with the sum function (I'm thinking of using xts::apply.weekly() ), but