unitted-class: A fusion of data and units

Description Details Slots See Also Examples

Description

A unitted object is a data object - a vector, data.frame, array, etc. - and its associated units. These units will be propagated through addition, multiplication, and many other common operations on data. Unitted objects are created by calling unitted() or u(), and the data can be retrieved by calling deunitted() or v(). Units can be extracted as character strings with get_units(). Most of the time, you'll find that unitted objects can do everything that their un-unitted data could do, but with smart units to make your analyses more readable and less vulnerable to typos or omissions.

Details

Every unitted object contains a .Data 'slot', though this is not formally recognized as such in the documentation.

Slots

units

The units. Depending on the .Data type, the units slot may contain a single units bundle (e.g., "kg ha^-1"), a matrix or array of bundles, or a list of bundles. Any of these may be retrieved with get_units.

See Also

unitted for class and subclass construction, deunitted for recovering the data from the unitted object, and unitted_Ops for smart units behaviors.

Examples

1
2
3
4
5
6
7
8
9
# unitted object creation
miles_vec <- unitted(1:5,"mi")
hours_vec <- unitted(7,"hr")

# unitted object manipulation
miles_vec / hours_vec
miles_vec^2
hours_vec + hours_vec
hours_vec == hours_vec

appling/unitted documentation built on May 10, 2019, 12:44 p.m.