as_numeric() converts a defined() vector to a numeric vector.
It validates that the underlying data are numeric, and optionally preserves
or strips semantic metadata.
Usage
as_numeric(x, ...)
# S3 method for haven_labelled_defined
as_numeric(x, strip_attributes = TRUE, ...)
Value
A numeric vector with or without preserved attributes.
Arguments
x
A vector created with defined().
...
Reserved for future use.
strip_attributes
Logical; whether to remove semantic metadata
(label, unit, concept, namespace). Defaults to TRUE.
Details
Use strip_attributes = TRUE when flattening or preparing data for
external pipelines, but keep the default when working with defined
vectors directly.
as.numeric() drops all metadata and returns only the numeric values in
a vector.