labelled(x, labels, is_na = NULL)
x
. Unlike factors, labels don't need to be exhaustive: only a fraction
of the values might be labelled.# labelled vector with multiple types of missing values
x <- labelled(c("M", "M", "F", "X", "N/A"),
c(Male = "M", Female = "F", Refused = "X", "Not applicable" = "N/A"),
c(FALSE, FALSE, TRUE, TRUE))
Run the code above in your browser using DataLab