% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/core-metadata.R
\name{set_var_label}
\alias{set_var_label}
\title{Set Variable Label(s)}
\usage{
set_var_label(x, ..., variable = NULL, label = 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
the label string. Supports \verb{!!!} list splicing.}

\item{variable}{A character vector of variable names. Use with \code{label}.}

\item{label}{A character vector of label strings, one per element of
\code{variable}.}
}
\value{
The modified object, invisibly.
}
\description{
Sets variable labels using one of three conventions.
}
\details{
\strong{Convention 1 (named \code{...})} — recommended for interactive use:

\if{html}{\out{<div class="sourceCode r">}}\preformatted{set_var_label(x, age = "Age in years", income = "Annual income")
set_var_label(x, !!!labels_list)   # list splicing
}\if{html}{\out{</div>}}

\strong{Convention 2 (named vector in \code{...})} — useful for programmatic use:

\if{html}{\out{<div class="sourceCode r">}}\preformatted{set_var_label(x, c(age = "Age in years", income = "Annual income"))
}\if{html}{\out{</div>}}

\strong{Convention 3 (\code{variable} + \code{label} arguments)} — for vector input:

\if{html}{\out{<div class="sourceCode r">}}\preformatted{vars <- c("age", "income")
lbls <- c("Age in years", "Annual income")
set_var_label(x, variable = vars, label = lbls)
}\if{html}{\out{</div>}}
}
\examples{
d <- as_survey(nhanes_2017, ids = sdmvpsu, weights = wtint2yr,
               strata = sdmvstra, nest = TRUE)
d <- set_var_label(d, indfmpir = "Income-to-poverty ratio")

# Multiple variables
d <- set_var_label(d, bpxsy1 = "Systolic BP (1st reading)",
                      bpxdi1 = "Diastolic BP (1st reading)")

}
\seealso{
\code{\link[=extract_var_label]{extract_var_label()}} to retrieve a label

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_val_labels}()},
\code{\link{set_var_note}()},
\code{\link{survey_metadata}()},
\code{\link{survey_weighting_history}()}
}
\concept{metadata}
