Get unit id, shortname, symbol or name of a value in accordance with StoX convention.

hasUnit(
  value,
  property = c("id", "shortname", "symbol", "name"),
  unitTable = RstoxData::StoxUnits
)

Arguments

value

value to read unit from

property

the property of the unit that is to be returned (e.g. 'symbol' or 'name')

unitTable

formatted as StoxUnits

Value

TRUE if the value has unit, FALSE if not.

Examples

 dt <- data.table::data.table(weight=c(1000,1200))
 dt$weight <- setUnit(dt$weight, "mass-g")
 print(hasUnit(dt$weight))
#> [1] TRUE
 print(hasUnit(1))
#> [1] FALSE