% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/var_labels.R
\name{var_labels}
\alias{var_labels}
\alias{var_labels<-}
\title{Get or set variable labels}
\usage{
var_labels(x)

var_labels(x) <- value
}
\arguments{
\item{x}{A vector or a data frame.}

\item{value}{Character label(s) to assign.}
}
\value{
- If \code{x} is a data frame: a named character vector with one entry per
  column (missing labels are returned as \code{NA_character_}).
- Otherwise: a single character string (or \code{NA_character_}).
}
\description{
Assign labels to describe variables in a data frame.
Can be called on a single variable or full data, to assign or to read existing
labels.
}
\details{
For a vector, this reads/writes a base-R \code{"label"} attribute.
For a data frame, this reads/writes the \code{"label"} attribute of each
column.
}
\examples{
df <- data.frame(x = 1:3, y = 4:6)

# Set labels for all columns
var_labels(df) <- c("this is x", "this is y")
var_labels(df)

# Set a label for a single column
var_labels(df$x) <- "this is x"
var_labels(df$x)

}
