quantity_units: Work with quantity units.

quantity_unitsR Documentation

Work with quantity units.

Description

Work with quantity units.

Usage

get_qty_units(q)

get_qty_units_with_label(q, label = names(q))

Arguments

q

quantities

label

text label to use with the units - single value or vector of the same length as q. By default uses the names of q, which only works if q is a list or data frame.

Functions

  • 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.

See Also

Other quantity functions: check_quantities, make_qty_units_explicit(), metric_scaling, quantities, quantity_data

Examples


# quantity units examples
qty(5000, "g") %>% get_qty_units()
x <- list(a = qty(5000, "g"), b = 42, c = qty(100, "mbar"))
x %>% get_qty_units()
# labels with units
get_qty_units_with_label(qty(0.1, "mM"), "concentration")

# 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)
get_qty_units_with_label(x, "same label")

sebkopf/chemtools documentation built on Aug. 1, 2023, 2:36 a.m.