% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/statistics.R
\name{sig_labels}
\alias{sig_labels}
\title{sig_labels}
\usage{
sig_labels(
  stat_data,
  variable,
  group,
  by = "year",
  plot_data = NULL,
  alpha = 0.05
)
}
\arguments{
\item{stat_data}{Data frame of raw observations used for the statistical
test. Should already be filtered to the relevant subset (e.g. a single
water type).}

\item{variable}{Name of the response variable column (string).}

\item{group}{Name of the grouping column (string).}

\item{by}{Name of the faceting column whose levels are iterated over
(string, default \code{"year"}).}

\item{plot_data}{Data frame used to compute label y-positions via
\code{max(variable)} per group. Defaults to \code{stat_data}. Pass the
aggregated/boxplot data here when it differs from the raw test data.}

\item{alpha}{Significance threshold; facets with KW p-value >=
\code{alpha} are dropped (default \code{0.05}).}
}
\value{
A data frame with columns \code{<group>}, \code{Letter},
  \code{MonoLetter}, \code{y_pos}, and \code{<by>}. Returns an empty data
  frame when no facet reaches significance.
}
\description{
Run \code{\link{ks_test}} separately for each level of a
  faceting variable and return compact letter display (CLD) annotations
  ready for \code{geom_text}. Only facets where the Kruskal-Wallis p-value
  is below \code{alpha} are included in the output.
}
\examples{
set.seed(1)
df <- data.frame(
  year = rep(c("2023", "2024"), each = 20),
  grp  = rep(c("A","B","C","D"), 10),
  val  = c(rnorm(20, mean = rep(c(1,3,2,6), 5)), rnorm(20))
)
sig_labels(df, "val", "grp", by = "year")
}
