This package provides functions to prepare data ready for the SPC Funnel Matrix, and display this using flextable.
The data that feeds into the SPC Funnel Matrix visual requires
preparation using the spc_funnel_matrix_prep_data function.
This takes the following inputs:
indicator - A vector to denote the indicator group.
Used to calculate aggregate SPC and Funnel Plotsgroup - A vector of group names. Used to aggregate and
group points on plotsperiod_end - A date (or character of format
“yyyy-mm-dd”) for the end date of the period.period_start - A date (or character of format
“yyyy-mm-dd”) for the start date of the period.numerator - A vector of the numerator. Used to
calculate the value for SPC and Funnel plotsdenominator - A vector of the denominator Used to
calculate the value for SPC and Funnel plotsmultiplier - Scale relative risk and funnel by this
factor.better_is - A string identifying the direction that is
favourable for the indicator. “Higher” for points below the lower
control limit to be unfavourable, “Lower” for points above the upper
control limit to be unfavourable, and “Neutral” if the direction is not
stated.parent_group_name - A vector of parent group names
which are to be displayed in the tooltip. These are the major categories
for the groups.parent_indicator - A vector used for indicator
grouping. i.e. grouping together maternity related indicators into a
Maternity group.spc_chart_type - A string identifying the type of spc
chart.funnel_chart_type - A string identifying the type of
funnel plot.indicator_name - A vector of descriptive names for
indicator.group_name - A vector of descriptive names for groups
Default group variablefunnel_data_points - A vector of “Yes” or NA, marks
which data points are included in the funnel plot calculation.An example of this is shown below using the
example_spc_data dataset:
head(example_spc_data)
#> indicator group period_end period_start numerator
#> <char> <char> <Date> <Date> <int>
#> 1: Standardised Mortality Ratio A 2021-01-31 2021-01-01 6
#> 2: Standardised Mortality Ratio A 2021-02-28 2021-02-01 4
#> 3: Standardised Mortality Ratio A 2021-03-31 2021-03-01 4
#> 4: Standardised Mortality Ratio A 2021-04-30 2021-04-01 4
#> 5: Standardised Mortality Ratio A 2021-05-31 2021-05-01 8
#> 6: Standardised Mortality Ratio A 2021-06-30 2021-06-01 4
#> denominator multiplier better_is spc_chart_type funnel_chart_type
#> <num> <num> <char> <char> <char>
#> 1: 4.379261 100 Lower i SR
#> 2: 3.778151 100 Lower i SR
#> 3: 4.398701 100 Lower i SR
#> 4: 4.913439 100 Lower i SR
#> 5: 4.950847 100 Lower i SR
#> 6: 3.115129 100 Lower i SRThe dataset is then passed to the
spc_funnel_matrix_prep_data function to prepare the data
for the SPC Funnel Matrix:
spc_funnel_matrix_data <- spc_funnel_matrix_prep_data(
indicator = example_spc_data$indicator,
group = example_spc_data$group,
period_end = example_spc_data$period_end,
period_start = example_spc_data$period_start,
numerator = example_spc_data$numerator,
denominator = example_spc_data$denominator,
multiplier = example_spc_data$multiplier,
better_is = example_spc_data$better_is,
overdispersion = FALSE,
parent_group_name = "All",
parent_indicator = "All",
spc_chart_type = example_spc_data$spc_chart_type,
funnel_chart_type = example_spc_data$funnel_chart_type,
funnel_data_points = "Yes"
)
#> Funnel Patterns Completed
#> SPC Data Validated
#> Start SPC Pattern Detection
#> SPC Patterns Completed
#> Funnel Patterns Completed
#> SPC Data Validated
#> Start SPC Pattern Detection
#> SPC Patterns CompletedThis package provides a function to plot the SPC Funnel Matrix output using flextable. An example of this is as follows:
spc_funnel_matrix_flextable(data = spc_funnel_matrix_data)
#> Warning in `[.data.table`(spans_dataset, runs_types_lst$is_raster == TRUE, :
#> Coercing 'list' RHS to 'character' to match the type of column 17 named 'txt'.
| Better than Expected | Within Expectations | Worse than Expected |
|---|---|---|---|
| character(0) | character(0) | character(0) |
character(0) | Pressure Injury - B (ⓣ) | Caesarean Section - B (ⓣ) | Crude Mortality - I (≒,ⓢ) |
character(0) | Crude Mortality - A | There are 20 indicator and group combinations that have not displayed any SPC patterns or funnel plot outliers in the last twelve months | Crude Mortality - B |
character(0) | Crude Mortality - D (ⓣ) | Caesarean Section - C (ⓢ) | Caesarean Section - F (ⓣ) |