Prep Data for Rohani Plot
iidda_prep_rohani.Rd
Prep data for rohani plots. Prep steps include creating additional time unit fields, summarizing the series variable by time unit and grouping variable (the x and y axis variables) ,and optionally normalizing series data to be in the range (0,1). By default, the grouping variable is ranked in order of the summarized series variable. Needs to be generalized more, might need to handle the case where the desired y-axis is a second time unit, as in the seasonal heatmap plot and therefore making use of the year_end_fix function.
Usage
iidda_prep_rohani(
data,
series_variable = "deaths",
time_variable = "period_end_date",
start_time_variable = "period_end_date",
time_unit = c("year"),
grouping_variable = "cause",
ranking_variable = NULL,
normalize = FALSE,
handle_missing_values = HandleMissingValues(na_remove = FALSE, na_replace = NULL),
handle_zero_values = HandleZeroValues(zero_remove = FALSE, zero_replace = NULL),
create_nonexistent = FALSE
)
Arguments
- data
data frame containing time series data
- series_variable
column name of series variable in `data`, default is "deaths"
- time_variable
column name of time variable in `data`, default is "period_end_date"
- start_time_variable
column name of time variable in `data`, default is "period_end_date"
- time_unit
a vector of new time unit fields to create from `start_time_variable` and `end_time_variable`. Defaults to "c("year")". The currently functionality expects that "year" is included, should be made more general to incorporate any of iidda.analysis:::time_units.
- grouping_variable
column name of grouping variable to appear on the y-axis of the heatmap.
- ranking_variable
column name of variable used to rank the grouping variable.
- normalize
boolean flag to normalize `series_variable` data to be between 0 and 1.
- handle_missing_values
function to handle missing values, defaults to HandleMissingValues
- handle_zero_values
function to handle zero values, defaults to HandleZeroValues
- create_nonexistent
boolean flag to create
NA
records for non-existent `time_unit` and `grouping_variable`. This creates all combinations of `time_unit` and `grouping_variable` to ensure there are no missing records.