I have some IDs, dates and Values. I want to sum values for each ID for the last 10 days.
This code can reproduce my dataset:
date<-as.Date(c("05/03/2017","05/10/2017","05/14/2017","05/19/2017","05/22/2017"),format="%m/%d/%Y")
value<-rpois(20,50)
id<-NULL
for(i in 1:4){id<-c(id,rep(i,5))}
mydata<-data.frame(id,date=rep(date,4),value)
So, the output would be the dataset above with a new column. This column would have the sum of values of lasts 10 days.
Thanks in advance.