View source: R/labelled_to_continuous.R
labelled_to_continuous | R Documentation |
Convert a vector to the numeric version of its value labels
labelled_to_continuous(x)
x |
an atomic numeric vector with the attribute "labels" |
labelled_to_continuous
first converts the values x
to
their associated labels. Then it returns as.numeric(x)
. The intended
use case of this is when a continuos measure was ingested as a categorical data type
and the labels contain the desired values (wrong recodes).
a numeric vector
Sven Halvorson (svenpubmail@gmail.com)
labelled_vector = 1:4
expss::var_lab(labelled_vector) = 'How many times have you read Enuma Elish?'
expss::val_lab(labelled_vector) = c(
'Prefer not to answer' = 1,
'0' = 2,
'1' = 3,
'2' = 4
)
labelled_to_continuous(labelled_vector)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.