2024-11-20 12:09:13 +01:00
|
|
|
% Generated by roxygen2: do not edit by hand
|
|
|
|
% Please edit documentation in R/as_factor.R
|
|
|
|
\name{named_levels}
|
|
|
|
\alias{named_levels}
|
|
|
|
\title{Get named vector of factor levels and values}
|
|
|
|
\usage{
|
|
|
|
named_levels(data, label = "labels", na.label = NULL, na.value = 99)
|
|
|
|
}
|
|
|
|
\arguments{
|
|
|
|
\item{data}{factor}
|
|
|
|
|
|
|
|
\item{label}{character string of attribute with named vector of factor labels}
|
2024-11-20 12:40:29 +01:00
|
|
|
|
|
|
|
\item{na.label}{character string to refactor NA values. Default is NULL.}
|
|
|
|
|
|
|
|
\item{na.value}{new value for NA strings. Ignored if na.label is NULL.
|
|
|
|
Default is 99.}
|
2024-11-20 12:09:13 +01:00
|
|
|
}
|
|
|
|
\value{
|
|
|
|
named vector
|
|
|
|
}
|
|
|
|
\description{
|
|
|
|
Get named vector of factor levels and values
|
|
|
|
}
|
|
|
|
\examples{
|
2024-11-20 12:40:29 +01:00
|
|
|
\dontrun{
|
2024-11-20 12:09:13 +01:00
|
|
|
structure(c(1, 2, 3, 2, 10, 9),
|
|
|
|
labels = c(Unknown = 9, Refused = 10),
|
|
|
|
class = "haven_labelled"
|
2024-11-20 14:31:01 +01:00
|
|
|
) |>
|
|
|
|
as_factor() |>
|
|
|
|
named_levels()
|
2024-11-20 12:09:13 +01:00
|
|
|
}
|
2024-11-20 12:40:29 +01:00
|
|
|
}
|