Forms unit for a column (ycol method) or columns (yspec method). Use purrr::map or purrr::map_chr to simply extract the unit field.

ys_get_unit(x, parens = FALSE, default = "", ...)

Arguments

x

ycol or yspec object

parens

if TRUE, then parens will be added around any unit with one or more character

default

passed to unit

...

passed to unit methods

Examples

spec <- ys_help$spec()

ys_get_unit(spec)
#> $C
#> [1] ""
#> 
#> $NUM
#> [1] ""
#> 
#> $ID
#> [1] ""
#> 
#> $SUBJ
#> [1] ""
#> 
#> $TIME
#> [1] "hour"
#> 
#> $SEQ
#> [1] ""
#> 
#> $CMT
#> [1] ""
#> 
#> $EVID
#> [1] ""
#> 
#> $AMT
#> [1] "mg"
#> 
#> $DV
#> [1] "micrograms/L"
#> 
#> $AGE
#> [1] "years"
#> 
#> $WT
#> [1] "kg"
#> 
#> $CRCL
#> [1] "ml/min"
#> 
#> $ALB
#> [1] "g/dL"
#> 
#> $BMI
#> [1] "m2/kg"
#> 
#> $AAG
#> [1] "mg/dL"
#> 
#> $SCR
#> [1] "mg/dL"
#> 
#> $AST
#> [1] ""
#> 
#> $ALT
#> [1] ""
#> 
#> $HT
#> [1] "cm"
#> 
#> $CP
#> [1] ""
#> 
#> $TAFD
#> [1] "hours"
#> 
#> $TAD
#> [1] "hours"
#> 
#> $LDOS
#> [1] "mg"
#> 
#> $MDV
#> [1] ""
#> 
#> $BLQ
#> [1] ""
#> 
#> $PHASE
#> [1] ""
#> 
#> $STUDY
#> [1] ""
#> 
#> $RF
#> [1] ""
#> 

ys_get_unit(spec$WT)
#> [1] "kg"

if (FALSE) {
purrr:::map(spec,"unit")
}