Calculate running sum/decay value in time series
问题 I'm looking to calculate a specific type of 'diminishing' sum or decay value within a time series. For instance, say I have some simple data: thedata <- data.frame(magicseeds = c(30,20,10,40,20) ,week = seq(from = 1, to = 5, by = 1)) I would like to calculate the value of 'magicseeds', such that it has a diminishing impact over time. For instance, lets say each value has 20% of the value the following week, so the first value in the magicseeds column (30) would be 30*0.2+6*0.2 and so on until