If elements of a vector are extracted, the new vector retains label
and class tiny_labelled.
x[1:2]
#> Variable label : A variable label
#> [1] 1 2
str(x)
#> 'tiny_labelled' int [1:4] 1 2 3 4
#> - attr(*, "label")= chr "A variable label"
x[1:2] <- 5:6
str(x)
#> 'tiny_labelled' int [1:4] 5 6 3 4
#> - attr(*, "label")= chr "A variable label"Using double brackets removes label and class
tiny_labelled, similar to how names are handled:
It is still possible top keep variable label and class by setting
keep_label = TRUE:
If a vector is modified (e.g., via mathematical operations), label
and tiny_labelled class are removed.
Vectors of class tiny_labelled keep label and class if
they are modified via as.character(),
as.numeric(), etc.
If keep_label = FALSE, label and class are removed.
as() methods are always strict, i.e. label and class are
removed:
It is possible to assign multiple labels to the columns of a data
frame by passing a named list or a named vector of key-value pairs. Note
that mixing different types of labels (e.g. character and
expression labels) is only possible if the right-hand side
is a list.