# NOT RUN {
x <- labelled(sample(5, 10, replace = TRUE), c(Bad = 1, Good = 5))
# Default method uses values where available
as_factor(x)
# You can also extract just the labels
as_factor(x, levels = "labels")
# Or just the values
as_factor(x, levels = "values")
# Or combine value and label
as_factor(x, levels = "both")
# }
Run the code above in your browser using DataLab