Coerces a haven_labelled_defined vector whose underlying type is
Date into a base R Date vector.
This method preserves the underlying date values and, by default, also retains any semantic metadata attached to the variable.
Usage
# S3 method for class 'haven_labelled_defined'
as.Date(x, strip_attributes = FALSE, ...)Arguments
- x
A vector created with
defined()with underlying typeDate.- strip_attributes
Logical; should the semantic metadata attributes (label, unit, definition, namespace) be removed from the returned vector? Defaults to
FALSE.- ...
Additional arguments passed to
base::as.Date().
Details
Use strip_attributes = TRUE when flattening or preparing data for
external pipelines, but keep the default when working with defined
vectors directly.
Base R's as.Date() also works, as it dispatches to this method via
S3. However, using as.Date() on defined vectors is considered safe
because this method ensures metadata is handled predictably.
