% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geoms-layout.R
\name{geom_alluvial}
\alias{geom_alluvial}
\title{Alluvial diagram (ordered, repeated-measures categorical flow)}
\usage{
geom_alluvial(
  mapping = NULL,
  data = NULL,
  alpha = NULL,
  node_width = NULL,
  label = TRUE
)
}
\arguments{
\item{mapping, data}{Standard layer overrides. Map the stage to \code{x}
(an ordered factor keeps its declared stage order), the category at
that stage to \code{y}, and the subject id to \code{group}.}

\item{alpha}{Ribbon opacity.}

\item{node_width}{Node bar width as a fraction of the panel.}

\item{label}{Draw node labels.}
}
\value{
A \link{Layer} to add with \code{+}.
}
\description{
Tracks the same subjects through an ordered sequence of stages (e.g.
visit 1 category -> visit 2 category -> visit 3 category), unlike
\code{\link[=geom_sankey]{geom_sankey()}}, which draws a general directed flow graph from an
edge list. Internally it tallies every consecutive-stage transition
and reuses \code{geom_sankey()}'s node-stacking and ribbon-path layout.
}
\examples{
d <- data.frame(
  subject = rep(1:8, each = 3),
  visit = rep(c("Baseline", "Week 4", "Week 8"), 8),
  response = c(
    "SD", "SD", "PR", "SD", "PR", "PR", "SD", "SD", "SD",
    "PR", "PR", "CR", "SD", "PR", "PR", "SD", "SD", "PD",
    "PR", "CR", "CR", "SD", "PD", "PD"
  )
)
d$visit <- factor(d$visit, levels = c("Baseline", "Week 4", "Week 8"))
ggnext(d, aes(x = visit, y = response, group = subject)) +
  geom_alluvial() +
  theme_void()
}
