labelled_to_continuous: Labelled vectors to continuous

View source: R/labelled_to_continuous.R

labelled_to_continuousR Documentation

Labelled vectors to continuous

Description

Convert a vector to the numeric version of its value labels

Usage

labelled_to_continuous(x)

Arguments

x

an atomic numeric vector with the attribute "labels"

Details

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).

Value

a numeric vector

Author(s)

Sven Halvorson (svenpubmail@gmail.com)

Examples

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)


svenhalvorson/SvenR documentation built on Aug. 25, 2023, 1:31 p.m.