Remove variable labels from variables.
remove_label(x, ...)
A vector or data frame.
Optional, unquoted names of variables that should be selected for
further processing. Required, if x
is a data frame (and no
vector) and only selected variables from x
should be processed.
You may also use functions like :
or tidyselect's select-helpers.
See 'Examples'.
x
with removed variable labels
set_label
to manually set variable labels or
get_label
to get variable labels; set_labels
to
add value labels, replacing the existing ones (and removing non-specified
value labels).
data(efc)
x <- efc[, 1:5]
get_label(x)
#> c12hour
#> "average number of hours of care per week"
#> e15relat
#> "relationship to elder"
#> e16sex
#> "elder's gender"
#> e17age
#> "elder' age"
#> e42dep
#> "elder's dependency"
str(x)
#> 'data.frame': 908 obs. of 5 variables:
#> $ c12hour : num 16 148 70 168 168 16 161 110 28 40 ...
#> ..- attr(*, "label")= chr "average number of hours of care per week"
#> $ e15relat: num 2 2 1 1 2 2 1 4 2 2 ...
#> ..- attr(*, "label")= chr "relationship to elder"
#> ..- attr(*, "labels")= Named num [1:8] 1 2 3 4 5 6 7 8
#> .. ..- attr(*, "names")= chr [1:8] "spouse/partner" "child" "sibling" "daughter or son -in-law" ...
#> $ e16sex : num 2 2 2 2 2 2 1 2 2 2 ...
#> ..- attr(*, "label")= chr "elder's gender"
#> ..- attr(*, "labels")= Named num [1:2] 1 2
#> .. ..- attr(*, "names")= chr [1:2] "male" "female"
#> $ e17age : num 83 88 82 67 84 85 74 87 79 83 ...
#> ..- attr(*, "label")= chr "elder' age"
#> $ e42dep : num 3 3 3 4 4 4 4 4 4 4 ...
#> ..- attr(*, "label")= chr "elder's dependency"
#> ..- attr(*, "labels")= Named num [1:4] 1 2 3 4
#> .. ..- attr(*, "names")= chr [1:4] "independent" "slightly dependent" "moderately dependent" "severely dependent"
x <- remove_label(x)
get_label(x)
#> c12hour e15relat e16sex e17age e42dep
#> "" "" "" "" ""
str(x)
#> 'data.frame': 908 obs. of 5 variables:
#> $ c12hour : num 16 148 70 168 168 16 161 110 28 40 ...
#> $ e15relat: num 2 2 1 1 2 2 1 4 2 2 ...
#> ..- attr(*, "labels")= Named num [1:8] 1 2 3 4 5 6 7 8
#> .. ..- attr(*, "names")= chr [1:8] "spouse/partner" "child" "sibling" "daughter or son -in-law" ...
#> $ e16sex : num 2 2 2 2 2 2 1 2 2 2 ...
#> ..- attr(*, "labels")= Named num [1:2] 1 2
#> .. ..- attr(*, "names")= chr [1:2] "male" "female"
#> $ e17age : num 83 88 82 67 84 85 74 87 79 83 ...
#> $ e42dep : num 3 3 3 4 4 4 4 4 4 4 ...
#> ..- attr(*, "labels")= Named num [1:4] 1 2 3 4
#> .. ..- attr(*, "names")= chr [1:4] "independent" "slightly dependent" "moderately dependent" "severely dependent"