Calculate cumulative average (mean)
问题 I would like to know how to calculate the cumulative average for some numbers. I will give a simple example to describe what I am looking for. I have the following numbers vec <- c(1, 2, 3, 4, 5) If I do the average of these numbers I will get 3 as a result. Now, how to do the cumulative average of these numbers. 回答1: In analogy to the cumulative sum of a list I propose this: The cumulative average avg of a vector x would contain the averages from 1st position till position i . One method is