So, I want to calc the mean of values in a time series as it goes along. It's super easy in excel, let me show you what I mean:
The window size increases by 1 for each row down. I tried to do this with the data.table function like so:
DT[,RollingAvg:=lapply(.SD,frollmean,n=.I,fill=NA),.SDcols=c("Value")]
Thinking I was being clever by having n = .I which represents the row number... Doesn't work, returns a list in fact.
So how would I replicate the easy excel formula? (Yes, I prefer data.table over dplyr type solutions)
Thanks