Search code examples
raggregateaverage

calculate mean values of weather data for each hour and day of the year based on historical data


I need to calculate average values of meteorological data for each day and hour of the year based on hourly historic data of 2015 - 2023 in r programming. The average hourly values will be used to create a series for 2024 that will represent "normal weather". Does anyone have any idea on how I could do that? Thanks in advance.


Solution

  • Here is an example of how to calculate daily means for some hourly weather data:

    library(dplyr)
    library(nycflights13) # Contains weather data set
    
    weather %>% 
      group_by(origin, year, month, day) %>% 
      summarise(temp = mean(temp), humid = mean(humid))
    

    To answer your question better, we need an example of your data. It's also unclear what you mean by "create a series for 2024" based on the 2015-2023 data.