Description Usage Arguments Details Value Examples
These functions set/get/drop value labels. Duplicated values are not allowed.
If argument x
is data.frame or list then labels applied to all
elements of data.frame/list. To drop value labels, use val_lab(var) <-
NULL
or unvl(var)
. For variable labels see var_lab.
val_lab
returns value labels or NULL if labels doesn't
exist.
val_lab<-
set value labels.
set_val_lab
returns variable with value labels.
add_val_lab<-
add value labels to already existing value labels.
unvl
drops value labels.
has.labels
check if value labels exists.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | val_lab(x)
val_lab(x) <- value
set_val_lab(x, value, add = FALSE)
add_val_lab(x, value)
has.labels(x)
add_val_lab(x) <- value
unvl(x)
drop_val_labs(x)
drop_unused_labels(x)
|
x |
Variable(s). Vector/data.frame/list. |
value |
Named vector. Names of vector are labels for the appropriate values of variable x. |
add |
Logical. Should we add value labels to old labels or replace it? Deafult is FALSE - we completely replace old values. If TRUE new value labels will be combined with old value labels. |
Value labels are stored in attribute "labels"
(attr(x,"labels")
). We set variable class to "labelled" for preserving
labels from dropping during some operations (such as c
and `[`
).
val_lab
return value labels (named vector). If labels doesn't
exist it return NULL . val_lab<-
and set_val_lab
return
variable (vector x) of class "labelled" with attribute "labels" which
contains value labels.
1 2 3 4 5 6 7 8 9 10 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.