% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/survey-collection.R
\name{set_collection_id}
\alias{set_collection_id}
\title{Set the Identifier Column on a \code{survey_collection}}
\usage{
set_collection_id(x, id)
}
\arguments{
\item{x}{A \link{survey_collection}.}

\item{id}{Character(1). The new identifier column name. Must be
non-\code{NA} and non-empty.}
}
\value{
The modified \code{survey_collection}, invisibly.
}
\description{
Updates the \verb{@id} property of a \code{survey_collection}. The new value is
the column name \code{.dispatch_over_collection()} injects when an analysis
function (\code{get_means()}, \code{get_freqs()}, etc.) is dispatched across the
collection without an explicit per-call \code{.id}.
}
\details{
Setting the same value as the existing \verb{@id} returns the collection
unchanged (no error, no warning). All other invariants on the
collection (\verb{@surveys}, \verb{@groups}, \verb{@if_missing_var}) are preserved.

Pipes naturally with the rest of the collection API:
\preformatted{coll |> set_collection_id("wave") |> get_means(y1)}
}
\examples{
d1 <- as_survey(gss_2024, ids = vpsu, weights = wtssps,
                strata = vstrat, nest = TRUE)
coll <- as_survey_collection(a = d1)
coll <- set_collection_id(coll, "wave")
coll@id

}
\seealso{
Other collections: 
\code{\link{add_survey}()},
\code{\link{as_survey_collection}()},
\code{\link{remove_survey}()},
\code{\link{set_collection_if_missing_var}()},
\code{\link{survey_collection}()}
}
\concept{collections}
