Daily average calculation from multiple year daily weather data?

巧了我就是萌 提交于 2019-12-24 19:18:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!