问题
I have a daily data for 31 years from 1984 to 2014. I would like to compute the daily average for 31 years for the variables
date Min_daily Max_daily Rain_daily
01-01-1984 18.8 3.6 0
02-01-1984 20.2 3.8 0
03-01-1984 19 4.2 0
.
.
.
30-12-2014 19.4 2.2 0
31-12-2014 18.5 7 0
01-01-2015 17.2 7.2 0
How to do it in R software?
回答1:
Create a new variable
yourData$day <- format(yourData$date, format='%m-%d')
And use your favorite mean aggregator, in base R tapply
or aggregate
work a treat.
Example: aggregate(cbind(Min_daily, Max_daily, Rain_daily) ~ day, data=yourData)
来源:https://stackoverflow.com/questions/48386324/daily-average-calculation-from-multiple-year-daily-weather-data