How to reference to other periods or columns when using aggregate()
When using aggregate, how can I make reference to a previous period within the function? For example if aggregating by days how can make reference to the previous day from the next day in order to calculate the function.
For example if I had a one year hourly time series and I like to calculate the maximum of one day minus the minimum of the previous day I could use two different aggregates, shifting one of them and substracting from the other, but how could I do it all from within just one aggregate?
How can I know the number of the piece (here the day) w开发者_开发问答here am I in order to use it inside the function?
cheers
As long as you have it appropriately sorted, you can use the shift()
function I provided in response to a (much more specific) question.
精彩评论