Work with quantity units.
get_qty_units(q) get_qty_units_with_label(q, label = names(q))
q | quantities |
---|---|
label | text label to use with the units - single value or vector of the same length as |
get_qty_units
: get units from a quantity, list of quantities or data frame (returns NA for objects/columns that are not quantities)
get_qty_units_with_label
: get units from a quantity, list of quantities or data frame, with a custom label in the format label [units]
. Objects/columns that are not quantities simply return the label with out the [units] part.
Other quantity functions:
check_quantities
,
make_qty_units_explicit()
,
metric_scaling
,
quantities
,
quantity_data
#> [1] "kg"#> a b c #> "kg" NA "mbar"#> [1] "concentration [µM]"# make labels with units for data frame columns x <- data.frame(a = qty(1, "mg"), b = 2, c = qty(100, "mbar")) get_qty_units_with_label(x)#> a b c #> "a [mg]" "b" "c [mbar]"get_qty_units_with_label(x, "same label")#> a b c #> "same label [mg]" "same label" "same label [mbar]"