Mean of repeated loops in a time series

In this dataframe, Temperature column is a random number.
How can I get the average temperature after 10 loops?


df <- data.frame(
  Date = as.Date(c("2011-01-01", "2011-09-23", "2012-11-15", "2013-05-11",
                   "2015-05-27")),
  Temperature = rnorm(5, mean=5, sd=2)
)

I am expecting like this


        Date   Temperature  avg.Temperature after 10 loops
1 2012-01-01    3.179709          x
2 2013-09-23    3.839912          x
3 2014-11-15    4.900131          x
4 2014-05-11    6.218348          x
5 2015-03-27    2.122353          x

Thanks

What do you mean by "after 10 loops"? Do you want the the average of the previous 10 Temperature observations?

I want to create the temperature 10 times and eventually show the output of mean of its different date/rows.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.