factor
.to_label(x)
x
was a data frame.to_fac
to convert a numeric variable into a factor (and
retain labels) and to_value
to convert a factor into
a numeric variable.data(efc)
print(get_val_labels(efc)['c161sex'])
head(efc$c161sex)
head(to_label(efc$c161sex))
print(get_val_labels(efc)['e42dep'])
table(efc$e42dep)
table(to_label(efc$e42dep))
# structure of numeric values won't be changed
# by this function, it only applies to labelled vectors
# (typically categorical or factor variables)
str(efc$e17age)
str(to_label(efc$e17age))
Run the code above in your browser using DataLab