The 'units' attribute of FLQuant objects provides a mechanism for keeping track of the units of measurement of that particular piece of data.
uom(op, u1, u2) uomUnits(unit = missing)
uom
.uom
returns a string with the corresponding units of measurement, or a character vector, showing the operation carried out, when units are not known to uom
or not compatible, e.g. "100 * d".
uomUnits
returns TRUE or FALSE if unit
is given, otherwise a character vector with all units known to uom
.
Arithmetic operators for 'FLQuant' objects are aware of a limited set of units of measurement and will output the right unit when two object are arithmetically combined. For example, the product of object with units of 'kg' and '1000' will output an object with 'units' of 't' (for metric tonnes).
Operations involving combinations of units not defined will issue a warning, and the resulting 'units' attribute will simply keep a string indicating the input units of measurement and the operation carried out, as in '10 * 1000'.
Note that no scaling or modification of the values in the object takes place.
Conversion across units is carried out by the uom()
function
The list of units known to uom
is stored internally but can be queried by calling uomUnits()
with no arguments. If a character vector is provided, a logical is returned telling whether the string is included or not in that table.
#> An object of class "FLQuant" #> , , unit = unique, season = all, area = unique #> #> year #> quant 1 #> all 1000 #> #> units: kg#> An object of class "FLQuant" #> , , unit = unique, season = all, area = unique #> #> year #> quant 1 #> all 0.54 #> #> units: z# Check if units are known uomUnits('kg')#> [1] TRUEuomUnits('kell')#> [1] FALSE