% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/figure-spec.R
\name{hd_spec}
\alias{hd_spec}
\title{Create a Figure Data Specification}
\usage{
hd_spec(data, x, y, group = NULL, n = NULL, colour = NULL)
}
\arguments{
\item{data}{A \code{data.frame} containing all referenced columns.}

\item{x}{Character. Column name for the x-axis variable.}

\item{y}{Character. Column name for the y-axis variable (typically
a percentage or count).}

\item{group}{Character or \code{NULL}. Column used to split data into multiple
series.}

\item{n}{Character or \code{NULL}. Column of raw counts shown in
highcharter tooltips alongside the y value.  Ignored by ggplot2.}

\item{colour}{Character or \code{NULL}. ggplot2 colour aesthetic column.
Defaults to \code{group} when \code{NULL} and \code{group} is set.}
}
\value{
An S3 object of class \code{"hd_spec"}.
}
\description{
Defines the \strong{data mapping} for a figure - which columns map to x, y,
group, and count - independently of any visual presentation choices.
Pass the result to \code{\link[=hd_make]{hd_make()}} together with an optional \code{\link[=hd_opts]{hd_opts()}}
object.
}
\examples{
df <- data.frame(
  age = rep(c("18-24", "25-34", "35-44", "45-54"), each = 2),
  sex = rep(c("Male", "Female"), 4),
  pct = c(42, 38, 55, 61, 48, 52, 60, 57),
  n   = c(120, 115, 200, 210, 180, 175, 160, 155)
)

spec <- hd_spec(df, x = "age", y = "pct", group = "sex", n = "n")
spec

}
\seealso{
\code{\link[=hd_opts]{hd_opts()}}, \code{\link[=hd_make]{hd_make()}}
}
