Skip to contents

Filters and prepares data for plotting by selecting relevant records based on indicator, variant, and year. Also creates a control limit function for the filtered dataset.

Usage

prepare_plot_data(dta, ind, varant, yr)

Arguments

dta

data.table containing the full dataset

ind

String, indicator name to filter by (e.g., "antipsychotics")

varant

String, variant name to filter by (e.g., "overall", "dementia")

yr

The year to plot

Value

A list containing:

plotdta

Filtered data.table for plotting

calc_cl

Function to calculate control limits for the filtered data

Examples

if (FALSE) { # \dontrun{
# Prepare data for antipsychotic usage plot
plot_data <- prepare_plot_data(
  dta = my_data,
  config = list(dates = list(report = list(year = 2024))),
  ind = "antipsychotics",
  varant = "overall"
)

# Access the filtered data
plot_data$plotdta

# Use the control limit function
plot_data$calc_cl(100, 0.975)} # }