as_units.dvec: Coerce Decorated Vector to Units

View source: R/dvec.R

as_units.dvecR Documentation

Coerce Decorated Vector to Units

Description

Coerces dvec to units. If x has a units attribute, it is used to create class 'units'. It is an error if x has no units attribute.

Usage

## S3 method for class 'dvec'
as_units(x, ..., preserve = getOption("yamlet_as_units_preserve", "label"))

Arguments

x

dvec

...

ignored

preserve

attributes to preserve; just label by default (class and units are handled implicitly)

Examples

library(magrittr)
a <- data.frame(id = 1:4, wt = c(70, 80, 70, 80), sex = c(0,1,0,1))
a %<>% decorate('wt: [ body weight, kg ]')
a %<>% decorate('sex: [ sex, [ female: 0, male: 1]]')
a %<>% decorate('id: identifier')
a %<>% resolve
a$wt %>% as_units

yamlet documentation built on Oct. 6, 2023, 9:07 a.m.