One of the fundamental features of i_labelled objects is that both underlying values and value labels can be used for logical operations.
The following rules must be observed when indexing i_labelled objects:
myData <- i_labelled(
x = c(1, 2, 3, NA),
labels = c("A" = 1, "B" = 2, "C" = 3),
label = "my Variable"
)
myData %in% 1
#> [1] TRUE FALSE FALSE FALSEmyData == 1
#> [1] TRUE FALSE FALSE NAmyData > 1
#> [1] FALSE TRUE TRUE NAKeep in mind, if character values are used for indexation, value labels are alway chosen over underlying values.
myData %in% c("A", "B")
#> [1] TRUE TRUE FALSE FALSEmyData != "C"
#> [1] TRUE TRUE FALSE NAmyData > "A"
#> [1] FALSE TRUE TRUE NA