get_values | R Documentation |
This function retrieves the values associated with value labels
from labelled
vectors. Data is also labelled
when imported from SPSS, SAS or STATA via read_spss
,
read_sas
or read_stata
.
get_values(x, sort.val = TRUE, drop.na = FALSE)
x |
Variable (vector) with value label attributes; or a data frame or list with such variables. |
sort.val |
Logical, if |
drop.na |
Logical, if |
labelled
vectors are numeric by default (when imported with read-functions
like read_spss
) and have variable and value labels attributes.
The value labels are associated with the values from the labelled vector.
This function returns the values associated with the vector's value labels,
which may differ from actual values in the vector (e.g. if not all
values have a related label).
The values associated with value labels from x
,
or NULL
if x
has no label attributes.
get_labels
for getting value labels and get_na
to get values for missing values.
data(efc) str(efc$e42dep) get_values(efc$e42dep) get_labels(efc$e42dep) library(haven) x <- labelled(c(1:3, tagged_na("a", "c", "z"), 4:1), c("Agreement" = 1, "Disagreement" = 4, "First" = tagged_na("c"), "Refused" = tagged_na("a"), "Not home" = tagged_na("z"))) # get all values get_values(x) # drop NA get_values(x, drop.na = TRUE) # data frame as input y <- labelled(c(2:3, 3:1, tagged_na("y"), 4:1), c("Agreement" = 1, "Disagreement" = 4, "Why" = tagged_na("y"))) get_values(data.frame(x, y))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.