This function creates a line plot showing trends over time for each subject, and includes an option to visualize differences between two groups.

visualize_timepoints(
  df,
  subject_col = "Subject",
  time_col = "timepoint",
  value_col,
  group_col = NULL
)

Arguments

df

Data frame containing longitudinal data.

subject_col

Character. Column name for subject identifiers. Default is "Subject".

time_col

Character. Column name for time points. Default is "timepoint".

value_col

Character. Column name for the measurement to be visualized. This parameter is required.

group_col

Character. Optional. Column name for grouping variable (e.g., "Condition"). Default is NULL.

Value

A ggplot object displaying trends over time with optional group comparison.

Examples

# visualize_timepoints(demog[demog$longitudinal, ], value_col = "smri.Label1.VolumeInMillimeters", group_col = "Condition")