These functions generate values with units that work well within data frames and tibbles and implement safety checks on operations that combine values with different units. To retrieve the value without units, use iso_strip_units (works for single variables and data frames/tibbles). To retrieve the unit use iso_get_units. Note that to correctly combine data frames / tibbles that have values with units in them, use vec_rbind instead of rbind or bind_rows. vec_rbind will combine columns that have values with units if they have the same unit and otherwise convert back to plain values without units with a warning. The other functions will either fail or reduce the unit values to plain values with a cryptic warning message about not preserving attributes.

iso_with_units(x, units = "undefined units")

iso_double_with_units(x = double(), units = "undefined units")

Arguments

x

the values (single value or vector)

units

the units for the value, by default "undefined units" but this parameter should always be supplied when working with real data that has units

Details

iso_with_units is the primary function to generate values with units. At present, only numeric values are supported so this function is just a shorter alias for the number-specific iso_double_with_units. It is not clear yet whether any non-numeric values with units make sense to be supported at a later point or whether integer and decimal numbers should be treated differently when they have units.