Thanks for that, that helps. So the code I got previously does work, however ti actually doesn't do precisely what I was after. for example, I get this: n total_buyvolume avg 1 38224.373 . 2 50590.5011 . . . . 252 292598.3558 . 253 550276.994 3078902.8083 the problem here is that the avg figure on observation 253 is from observation 2 to observation 253. However, I'd like the avg figure on observation 253 it to be from observation 1 to observation 252. Meaning that I'd like to have the previous 252 days on a given day without including the figure on that particular day. Does it make sense? How do I do that?
... View more