Skip to contents

Reshapes a long‑format transition frequency data frame into a wide‑format table with totals, and formats it using markdown. Diagonal elements are bolded to highlight state stability.

Usage

margot_transition_table(
  data,
  state_var,
  id_var,
  wave_var,
  waves = NULL,
  state_names = NULL,
  observed_var = NULL,
  observed_val = 1,
  table_name = "transition_table"
)

Arguments

data

a data frame containing your id, state, wave, and (optionally) an observed indicator.

state_var

name of the column indicating the state at each wave.

id_var

name of the column identifying each participant.

wave_var

name of the column indicating the wave (numeric or factor).

waves

optional numeric vector of waves to include (defaults to all present in data).

state_names

optional character vector of labels for each state.

observed_var

optional name of a column marking participants still observed.

observed_val

value in observed_var that denotes “observed” (default 1).

table_name

name for the output object (default "transition_table").

Value

an object of class margot_transitions with tables, explanation, wave_info, and a quarto_code helper.