% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/set_survey.R
\name{set_survey}
\alias{set_survey}
\title{Specify the survey to analyze}
\usage{
set_survey(design, aa_vr = NULL, aa_pop = NULL, ...)
}
\arguments{
\item{design}{a survey object, created with \code{\link[survey:svydesign]{survey::svydesign()}} or
\code{\link[survey:svrepdesign]{survey::svrepdesign()}}. For an unweighted survey, a \code{data.frame} or similar.}

\item{aa_vr}{used to produce age-adjusted estimates only. The name of a
categorical age variable located in \code{design}.}

\item{aa_pop}{used to produce age-adjusted estimates only. A \code{data.frame} with
columns named \code{Level} and \code{Population}. \code{Level} must exactly match the levels
of \code{aa_vr}. \code{Population} is the population count or proportion/weight for
that level of \code{aa_vr}.}

\item{...}{arguments to \code{\link[=set_opts]{set_opts()}}.}
}
\value{
info about the survey
}
\description{
You must specify a survey before the other functions, such as \code{\link[=tab]{tab()}},
will work. To convert a \code{data.frame} or similar to a survey object, see \code{\link[survey:svydesign]{survey::svydesign()}}
or \code{\link[survey:svrepdesign]{survey::svrepdesign()}}.
}
\details{
Optionally, the survey can have an attribute called \code{label}, which is the
long name of the survey. Optionally, each variable in the survey can have an
attribute called \code{label}, which is the variable's long name.

For age-adjustment, \code{aa_pop$Population} can contain either population counts
or proportions/weights for each level. Values are normalized internally, so
counts and proportions produce the same age-adjusted estimates when they
describe the same standard population distribution.
}
\examples{
set_survey(namcs2019sv)
set_survey(namcs2019sv, mode = "NCHS")

## Age-adjusted estimation
set_survey(nhis2024a, aa_vr = "age_group_std", aa_pop = uspop_example$age_group_std)
}
\seealso{
Other options: 
\code{\link{set_opts}()},
\code{\link{show_options}()},
\code{\link{surveytable-options}}
}
\concept{options}
