UseR10085
UseR10085

Reputation: 8176

Daily average calculation from multiple year daily weather data?

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?

Upvotes: 0

Views: 673

Answers (1)

AdamO
AdamO

Reputation: 4930

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)

Upvotes: 1

Related Questions