% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lpr_set_ros.R
\name{lpr_set_ros}
\alias{lpr_set_ros}
\title{Set Response Option (ROS) labels for variables in AmericasBarometer datasets}
\usage{
lpr_set_ros(data, lang_id = "en", attribute_name = "roslabel")
}
\arguments{
\item{data}{A data frame loaded using readstata13 containing label.table attributes.}

\item{lang_id}{Language identifier for the labels ("en" for English,
"es" for Spanish, "pt" for Portuguese). Default is "en" (English).}

\item{attribute_name}{The name of the attribute where the formatted response
options string will be stored. Default is "roslabel".}
}
\value{
The input data frame with response option labels added to variables as attributes
}
\description{
This function extracts formatted response option labels for AmericasBarometer
variables, using label tables stored as attributes. The labels are formatted
with their corresponding numeric codes and can be pulled in multiple languages.
}
\details{
The function looks for label tables stored as attributes of the data frame,
with names following the pattern "VARNAME_lang_id" (e.g., "ing4_en" for English
labels of variable ing4). Each label table should be a named numeric vector where
names are the response labels and values are the corresponding codes.

Special codes (values >= 1000) are excluded from the response options string.
}
\examples{

require(lapop); data(bra23)

# Apply the function
bra23 <- lpr_set_ros(bra23) # Default English
bra23 <- lpr_set_ros(bra23, lang_id = "es", attribute_name = "respuestas") # Spanish
bra23 <- lpr_set_ros(bra23, lang_id = "pt", attribute_name = "ROsLabels_pt") # Portuguese

# View the resulting attribute
attr(bra23$ing4, "roslabel")
attr(bra23$ing4, "respuestas")
attr(bra23$ing4, "ROsLabels_pt")

}
