create_ctrl_df.Rd
This function takes in a data frame row per observation like OBI data. It then summarize the numerator and denominator of a rate of interest. This function also use control chart principles to calculate CIs and flag alerts.
create_ctrl_df(
df,
date_var,
num_var,
den_var,
date_gran = "month",
nsigmas = 3,
long = F,
increase_is_bad = TRUE,
for_highchart = FALSE
)
A data frame, for example OBI export data
The date variable to be used for grouping; usually infant_dob_dt; Make use this variable is in a date format, for example: lubridate::dmy_hms(infant_dob_dt)
The variable to be summarized as the numerator - should be binary 0 1
The variable to be summarized as the denominator - should be binary 0 1
"month" or "quarter"; The granularity of dates we want to use for our control chart; default is "month".
a numeric value specifying the number of sigmas to use for computing control limits. default to 3.
Whether to pivot the data to long format - default is TRUE as this is the data structure needed for ggplot2
If TRUE, this is a trend that would ideally be decreasing over time; if FALSE, ideally increasing. default is TRUE.
If TRUE, multiplies all rates by 100 for highchart; default is FALSE.
An tibble with the aggridated numerator and denominator by input date variable