Apply a function across heat waves from all projections

Description

This function will take a user-specified function and apply it across all the heat wave files created by gen_hw_set. It will generate either a single value for every ensemble member within every climate model, if city_specific is set to FALSE, or a value for every city for every ensemble member, if city_specific is set to TRUE.

Usage

1
apply_all_models(out, FUN, city_specific = FALSE, ...)

Arguments

out

Character string with pathname to which heat wave files were written by gen_hw_set. Typically, this will be the same pathname as that specified with out when running gen_hw_set.

FUN

A character string with the name of a function to apply to the heat wave dataframes located in the directory specified by out. This function must take the argument, hw_datafr, a dataframe of identified and characterized heat waves, as generated by gen_hw_set. For an example of one of these dataframes, load the hw_datafr data. The function should output a single value when applied to the full heat wave dataframe. The function can also have other arguments, which are passed through the ... argument of apply_all_models.

city_specific

TRUE or FALSE, specifying whether the function should be applied separately for each study location.

...

Optional arguments to FUN.

Value

A dataframe with the value output by the FUN function, as applied to all the heat wave dataframes generated by gen_hw_set.

Note

The function input as FUN must follow a very specific structure. It most have as an argument a dataframe with characterized heat waves, as generated by the gen_hw_set function. See the futureheatwaves vignette for more guidance on creating and applying a custom function to explore the heat waves identified and characterized by gen_hw_set.

Examples

1
2
3
4
5
ex_results <- system.file("extdata/example_results",
                          package = "futureheatwaves")
apply_all_models(ex_results, FUN = average_mean_temp)
apply_all_models(ex_results, FUN = average_mean_temp,
                 city_specific = TRUE)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.