Find the unit identifier given quantity and either symbol, shortname or name

findUnit(
  quantity,
  shortname = NULL,
  symbol = NULL,
  name = NULL,
  unitTable = RstoxData::StoxUnits
)

Arguments

quantity

The quantity to look up units for

shortname

shortname of the desired unit

symbol

Symbol of the desired unit

name

name of the desired unit

unitTable

formatted as StoxUnits

Value

valid id in unitTable

Details

This is useful for looking up correct unit identifiers from user input. Provide either symbol, shortname or name, do not provide more than one.

The argument 'conversionTable' defines valid units and their symbols. This defaults to StoxUnits.

See also

getUnitOptions for listing all valid options for a quantity.

Examples

 findUnit("mass", getUnitOptions("mass")[1])
#> [1] "mass-g"
 findUnit("length", "m")
#> [1] "length-m"