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:
i_labelled(
myData <-x = c(1, 2, 3, NA),
labels = c("A" = 1, "B" = 2, "C" = 3),
label = "my Variable"
)
%in% 1
myData #> [1] TRUE FALSE FALSE FALSE
== 1
myData #> [1] TRUE FALSE FALSE NA
> 1
myData #> [1] FALSE TRUE TRUE NA
Keep in mind, if character values are used for indexation, value labels are alway chosen over underlying values.
%in% c("A", "B")
myData #> [1] TRUE TRUE FALSE FALSE
!= "C"
myData #> [1] TRUE TRUE FALSE NA
> "A"
myData #> [1] FALSE TRUE TRUE NA