Generates a transition table that describes movements and stability between states from one observation to the next. It formats the output as a markdown table, highlighting the number of entities remaining in the same state (diagonal) and those transitioning to different states (off-diagonal).
Usage
transition_table(
trans_df,
state_names = NULL,
wave_info = NULL,
table_name = "transition_table"
)
transition_table(
trans_df,
state_names = NULL,
wave_info = NULL,
table_name = "transition_table"
)
Arguments
- state_names
Optional; a vector of state names to replace the default state labels. If NULL, states will be labeled as "State 1", "State 2", etc., based on the unique values in `from` and `to` columns.
- data
A data frame with columns `from` and `to` indicating the initial and subsequent states of entities, respectively, and a `Freq` column indicating the frequency of transitions.
Value
A list with two elements: `explanation`, a character string explaining the table, and `table`, a markdown-formatted table of transitions. The diagonal entries (in bold) represent the count of entities that remained in their initial state, while the off-diagonal entries show the count of transitions between different states.