compare_sequence_groups: Compare sequence groups descriptively

View source: R/sequence-consensus-groups.R

compare_sequence_groupsR Documentation

Compare sequence groups descriptively

Description

Produces descriptive state, transition and sequence-length comparisons. No hypothesis tests or causal interpretations are produced.

Usage

compare_sequence_groups(
  data,
  group_col,
  sequence_id_col = "sequence_id",
  order_col = "sequence_order",
  state_col = "state",
  reference = NULL,
  metrics = c("state", "transition", "length"),
  include_self = TRUE,
  transition_separator = " -> ",
  zero_policy = c("missing", "infinite")
)

Arguments

data

Long-format sequence data.

group_col

Grouping column that is constant within sequence.

sequence_id_col, order_col, state_col

Sequence columns.

reference

Optional reference group. When supplied, each other group is reported as group_1 and the reference as group_2; differences and ratios are therefore other-minus-reference and other/reference. When omitted, all pairwise group contrasts are returned.

metrics

Any of "state", "transition", and "length".

include_self

Include self-transitions.

transition_separator

Separator used in reported transition labels. It must not occur inside an observed state label.

zero_policy

Ratio policy when the reference value is zero.

Value

A list of class gp3_sequence_group_comparison containing group summaries and pairwise descriptive contrasts.

Examples

sequences <- data.frame(
  sequence_id = rep(c("s1", "s2", "s3", "s4"), each = 4L),
  sequence_order = rep(1:4, times = 4L),
  state = c("A", "B", "C", "D", "A", "B", "C", "C",
            "D", "C", "B", "A", "D", "C", "A", "A"),
  group = rep(c("g1", "g2"), each = 8L),
  stringsAsFactors = FALSE
)
compare_sequence_groups(sequences, group_col = "group")


gp3sequences documentation built on Aug. 23, 2026, 5:10 p.m.