I want to calculate weeks of cover products by group. I am still a learner in R Below is the dataset
WK<-c('wk1','wk2','wk3','wk4','wk5','wk6','wk7','wk8','wk9','wk10','wk11','wk12')
Model<-c('AB','AB','AB','AB','AB','AB','AB','BC','BC','BC','BC','BC')
QTY<-c(100,200,300,400,500,600,800,500,230,500,600,900)
stock<-c(300,600,100,250,362,850,985,236,652,758,550,700)
df<-data.frame(WK,Model,QTY,stock)
'Cover week' is calculated based on Stock(current week)/average(QTY for next 4 weeks). Needs to be calculated for all weeks by model.
