% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/core-metadata.R
\name{set_val_labels}
\alias{set_val_labels}
\title{Set Value Labels}
\usage{
set_val_labels(x, ..., variable = NULL, labels = NULL)
}
\arguments{
\item{x}{A survey design object or a data frame.}

\item{...}{Named arguments where the name is the variable and the value is
a fully named vector of value labels. Supports \verb{!!!} list splicing.}

\item{variable}{A character vector of variable names.}

\item{labels}{A list of named vectors, one per element of \code{variable}. When
\code{variable} has length 1, a bare named vector is also accepted.}
}
\value{
The modified object, invisibly.
}
\description{
Sets value labels for one or more variables using one of three conventions.
}
\details{
\strong{Convention 1 (named \code{...})} — recommended:

\if{html}{\out{<div class="sourceCode r">}}\preformatted{set_val_labels(x, sex = c(Male = 1L, Female = 2L))
}\if{html}{\out{</div>}}

\strong{Convention 2 (single named list in \code{...})}:

\if{html}{\out{<div class="sourceCode r">}}\preformatted{set_val_labels(x, list(sex = c(Male = 1L, Female = 2L)))
}\if{html}{\out{</div>}}

\strong{Convention 3 (\code{variable} + \code{labels})}:

\if{html}{\out{<div class="sourceCode r">}}\preformatted{set_val_labels(x, variable = "sex", labels = c(Male = 1L, Female = 2L))
}\if{html}{\out{</div>}}
}
\examples{
d <- as_survey(nhanes_2017, ids = sdmvpsu, weights = wtint2yr,
               strata = sdmvstra, nest = TRUE)
d <- set_val_labels(d, riagendr = c(Male = 1L, Female = 2L))

}
\seealso{
\code{\link[=extract_val_labels]{extract_val_labels()}} to retrieve value labels

Other metadata: 
\code{\link{classify_question_type}()},
\code{\link{extract_metadata}()},
\code{\link{extract_missing_codes}()},
\code{\link{extract_question_preface}()},
\code{\link{extract_sata}()},
\code{\link{extract_universe}()},
\code{\link{extract_val_labels}()},
\code{\link{extract_var_label}()},
\code{\link{extract_var_note}()},
\code{\link{infer_question_prefaces}()},
\code{\link{set_missing_codes}()},
\code{\link{set_question_preface}()},
\code{\link{set_sata}()},
\code{\link{set_universe}()},
\code{\link{set_var_label}()},
\code{\link{set_var_note}()},
\code{\link{survey_metadata}()},
\code{\link{survey_weighting_history}()}
}
\concept{metadata}
