Skip to contents

Calculates participant retention/attrition across events in a longitudinal study, incorporating the day_offset from event metadata. This provides a time-based view of participant retention for plotting attrition curves.

Usage

get_attrition_over_time(
  project,
  baseline_event = NULL,
  definition = c("any_data", "complete_form"),
  form = NULL
)

Arguments

project

A redcap_project object

baseline_event

Character. Name of the baseline event. If NULL, uses first event by day_offset (default: NULL)

definition

Character. How to define retention: "any_data" (default) or "complete_form"

form

Character. If definition = "complete_form", which form to check (default: NULL)

Value

A data frame with retention statistics by event including day_offset for time-series plotting

Examples

if (FALSE) { # \dontrun{
project <- redcap_project()

# Get attrition over time
attrition <- get_attrition_over_time(project)

# Plot with ggplot2
library(ggplot2)
ggplot(attrition, aes(x = day_offset, y = retention_rate)) +
  geom_line() +
  geom_point() +
  labs(title = "Participant Retention Over Time",
       x = "Days from Baseline",
       y = "Retention Rate (%)")
} # }