% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/frequencies.R
\name{convert_sequence_format}
\alias{convert_sequence_format}
\title{Convert Sequence Data to Different Formats}
\usage{
convert_sequence_format(
  data,
  seq_cols = NULL,
  id_col = NULL,
  action = NULL,
  time = NULL,
  format = c("frequency", "onehot", "edgelist", "follows")
)
}
\arguments{
\item{data}{Data frame containing sequence data.}

\item{seq_cols}{Character vector. Names of columns containing sequential
states (for wide format input). If NULL, all columns except \code{id_col}
are used. Default: NULL.}

\item{id_col}{Character vector. Name(s) of the ID column(s). For long
format, required. For wide format, optional: if NULL, the first column
is used as the id only when it is a genuine identifier (its values are
disjoint from the states in the remaining columns); for canonical wide
sequence data with no id column (e.g. \code{V1..Vn} / \code{T1..Tn}), a
row-index id is synthesized and every column is treated as a sequence
column. Default: NULL.}

\item{action}{Character or NULL. Name of the column containing actions/states
(for long format input). If provided, data is treated as long format.
Default: NULL.}

\item{time}{Character or NULL. Name of the time column for ordering actions
within sequences (for long format). Default: NULL.}

\item{format}{Character. Output format:
\describe{
\item{"frequency"}{Count of each action per sequence (wide, one column per
state).}
\item{"onehot"}{Binary presence/absence of each action per sequence.}
\item{"edgelist"}{Consecutive transition pairs (from, to) per sequence.}
\item{"follows"}{Each action paired with the action that preceded it.}
}}
}
\value{
A data frame in the requested format:
\describe{
\item{frequency}{ID columns + one integer column per state with counts.}
\item{onehot}{ID columns + one binary column per state (0/1).}
\item{edgelist}{ID columns + \code{from} and \code{to} columns.}
\item{follows}{ID columns + \code{act} and \code{follows} columns.}
}
}
\description{
Convert wide or long sequence data into frequency counts, one-hot encoding,
edge lists, or follows format.
}
\examples{
# Wide format input
seqs <- data.frame(V1 = c("A","B","A"), V2 = c("B","A","C"), V3 = c("A","C","B"))
convert_sequence_format(seqs, format = "frequency")
convert_sequence_format(seqs, format = "edgelist")

}
\seealso{
\code{\link{frequencies}} for building transition frequency matrices.
}
