Get named vector of factor levels and values
Examples
structure(c(1, 2, 3, 2, 10, 9),
labels = c(Unknown = 9, Refused = 10),
class = "haven_labelled"
) |>
as_factor() |>
named_levels()
#> 1 2 3 Refused Unknown
#> 1 2 3 10 9
structure(c(1, 2, 3, 2, 10, 9),
labels = c(Unknown = 9, Refused = 10),
class = "labelled"
) |>
as_factor() |>
named_levels()
#> 1 2 3 Refused Unknown
#> 1 2 3 10 9