% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sequence-consensus-groups.R
\name{create_consensus_sequence}
\alias{create_consensus_sequence}
\title{Create an aligned-position consensus sequence}
\usage{
create_consensus_sequence(
  data,
  sequence_id_col = "sequence_id",
  order_col = "sequence_order",
  state_col = "state",
  group_cols = NULL,
  weight_col = NULL,
  missing_state_policy = c("exclude", "state", "error"),
  missing_state_label = "<MISSING>",
  tie_method = c("first", "last", "missing", "all"),
  state_levels = NULL,
  min_support = 1L
)
}
\arguments{
\item{data}{A long-format data frame, a prepared gp3sequences result, or a
data frame containing canonical columns.}

\item{sequence_id_col, order_col, state_col}{Column names defining sequences.}

\item{group_cols}{Optional columns defining independent consensus groups.}

\item{weight_col}{Optional non-negative row-weight column.}

\item{missing_state_policy}{One of \code{"exclude"}, \code{"state"}, or \code{"error"}.}

\item{missing_state_label}{Label used when missing states are retained.}

\item{tie_method}{Deterministic tie policy: \code{"first"}, \code{"last"},
\code{"missing"}, or \code{"all"}.}

\item{state_levels}{Optional preferred state ordering used for ties.}

\item{min_support}{Minimum number of contributing sequences at a position.}
}
\value{
A data frame of class \code{gp3_consensus_sequence} containing group
columns, sequence position, consensus state, support counts and weights,
agreement proportion, tie count, tied states, and total group sequences.
}
\description{
Computes a descriptive consensus state at each observed sequence position.
The function does not treat the consensus as a behavioural norm and does not
infer psychological or causal meaning.
}
\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
)
create_consensus_sequence(sequences, group_cols = "group")

}
