
Last chance! 50% off unlimited learning
Sale ends in
read_spss
,
read_sas
or read_stata
) and
x
is a data frame or a list of variables, returns the all variable labels as names character vector of lengthncol(x)
.x
is a vector, returns the variable label as string.get_label(x, def.value = NULL)
x
has no label attribute. By default, NULL
is returned.x
is a variable.
If x
is a single vector and has no label attribute, the value
of def.value
will be returned (which is by default NULL
).get_labels
.set_label
to manually set variable labels or get_labels
to get value labels.# import SPSS data set
# mydat <- read_spss("my_spss_data.sav", enc="UTF-8")
# retrieve variable labels
# mydat.var <- get_label(mydat)
# retrieve value labels
# mydat.val <- get_labels(mydat)
data(efc)
# get variable lable
get_label(efc$e42dep)
# alternative way
get_label(efc)["e42dep"]
# simple barplot
barplot(table(efc$e42dep))
# get value labels to annotate barplot
barplot(table(efc$e42dep),
names.arg = get_labels(efc$e42dep),
main = get_label(efc$e42dep))
# get labels from multiple variables
get_label(list(efc$e42dep,
efc$e16sex,
efc$e15relat))
Run the code above in your browser using DataLab