Creates a visualization of participant retention/attrition over time using event day_offset values. Requires ggplot2 to be installed.
Arguments
- project
A redcap_project object, or an attrition_over_time data frame
- baseline_event
Character. Name of the baseline event (if project is provided)
- definition
Character. How to define retention (if project is provided)
- form
Character. Form to check if definition = "complete_form" (if project is provided)
- metric
Character. Which metric to plot: "retention_rate" (default), "attrition_rate", "n_retained", or "n_lost"
- show_points
Logical. Whether to show points at each event (default: TRUE)
- show_labels
Logical. Whether to show event labels (default: FALSE)
Examples
if (FALSE) { # \dontrun{
project <- redcap_project()
# Quick plot
plot_attrition_curve(project)
# Customize
plot_attrition_curve(project, metric = "n_retained", show_labels = TRUE)
# Or pass pre-calculated attrition data
attrition <- get_attrition_over_time(project)
plot_attrition_curve(attrition)
} # }
