Counts how often each state appears across all trajectories. Returns a
data frame sorted by frequency (descending).
Arguments
- data
A list of character vectors (trajectories) or a data.frame.
Value
A data frame with one row per distinct state, sorted by
count (descending), with columns state, count and
proportion (share of all observations, rounded to 4 decimal
places).
Examples
trajs <- list(c("A","B","C"), c("A","B","A"))
state_frequencies(trajs)
#> state count proportion
#> 1 A 3 0.5000
#> 2 B 2 0.3333
#> 3 C 1 0.1667