Compute maximum temperature indicators from grouped data
Source:R/summarise_temp_max.R
summarise_temp_max.Rd
The function computes maximum temperature indicators from grouped data. Expects temperature in celsius degrees.
Arguments
- .x
grouped data, created with
dplyr::group_by()
- value_var
name of the variable with temperature values.
- normals_df
normals data, created with
summarise_normal()
Details
The heat waves indicators are computed based on climatological normals, created with the summarise_normal()
function and passed with the normals_df
argument. Keys to join the normals data must be present (like id, year, and month) and use the same names.
The following indicators are computed for each group.
count
Count of data pointsnormal_mean
Climatological normal mean, fromnormals_df
argumentnormal_p10
Climatological 10th percentile, fromnormals_df
argumentnormal_p90
Climatological 90th percentile, fromnormals_df
argumentmean
Averagemedian
Mediansd
Standard deviationse
Standard errormax
Maximum valuemin
Minimum valuep10
10th percentilep25
25th percentilep75
75th percentilep90
90th percentileheat_waves_3d
Count of heat waves occurences, with 3 or more consecutive days with maximum temperature above the climatological normal value plus 5 celsius degreesheat_waves_5d
Count of heat waves occurences, with 5 or more consecutive days with maximum temperature above the climatological normal value plus 5 celsius degreeshot_days
Count of warm days, when the maximum temperature is above the normal 90th percentilet_25
Count of days with temperatures above or equal to 25 celsius degreest_30
Count of days with temperatures above or equal to 30 celsius degreest_35
Count of days with temperatures above or equal to 35 celsius degreest_40
Count of days with temperatures above or equal to 40 celsius degrees
Examples
# Compute monthly normals
normals <- temp_max_data |>
# Identify month
dplyr::mutate(month = lubridate::month(date)) |>
# Group by id variable and month
dplyr::group_by(code_muni, month) |>
summarise_normal(date_var = date, value_var = value, year_start = 1961, year_end = 1990) |>
dplyr::ungroup()
# Compute indicators
temp_max_data |>
# Identify year
dplyr::mutate(year = lubridate::year(date)) |>
# Identify month
dplyr::mutate(month = lubridate::month(date)) |>
# Group by id variable, year and month
dplyr::group_by(code_muni, year, month) |>
# Compute maximum temperature indicators
summarise_temp_max(value_var = value, normals_df = normals) |>
# Ungroup
dplyr::ungroup()
#> # A tibble: 3,024 × 24
#> code_muni year month count normal_mean normal_p10 normal_p90 mean median
#> <int> <dbl> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 3106200 1961 1 31 27.9 24.0 31.2 25.9 26.1
#> 2 3106200 1961 2 28 28.5 25.5 30.9 28.2 28.7
#> 3 3106200 1961 3 31 28.3 25.4 30.9 28.3 28.9
#> 4 3106200 1961 4 30 27.2 24.6 29.6 28.1 28.1
#> 5 3106200 1961 5 31 25.8 22.8 28.3 25.5 25.5
#> 6 3106200 1961 6 30 24.7 21.9 27.3 24.8 24.9
#> 7 3106200 1961 7 31 24.4 20.9 27.2 25.2 25.1
#> 8 3106200 1961 8 31 26.1 22.2 29.8 27.8 27.7
#> 9 3106200 1961 9 30 27.1 22.6 31.1 31.8 32.7
#> 10 3106200 1961 10 31 27.5 23.0 31.5 28.4 29.3
#> # ℹ 3,014 more rows
#> # ℹ 15 more variables: sd <dbl>, se <dbl>, max <dbl>, min <dbl>, p10 <dbl>,
#> # p25 <dbl>, p75 <dbl>, p90 <dbl>, heat_waves_3d <int>, heat_waves_5d <int>,
#> # hot_days <int>, t_25 <int>, t_30 <int>, t_35 <int>, t_40 <int>