Unit Interpreter
unit.from.string.RdThis function will try its best to interpret strings like "liter/(nmol ms)" rules: 1. only one slash is allowed 2. M can be mega or mol/l: writing M for molarity will treat molarity as it's own unit kind; writing "molarity" will be translated into two SI units (mol and litre) 3. prefixes and units can be words or single letters 4. everything after a slash is the denominator 5. u is an accepted replacement for μ (unicode greek mu or unicode micro symbol) 6. no parentheses (ignored): "(m/s)*kg" will be misinterpreted
Arguments
- unit.str
a string that contains a human readable unit
- verbose
if TRUE, this function prints what it does (to find problems)
Value
data.frame with an interpretation of the unit (multiplier is unused here, but may be used later to deal with units such as hours (kind=second, multiplier=60)
Details
this retruns a data.frame with components as in the sbml standard: kind, multiplier, scale and exponent since there is only one slash,parentheses do nothing everything after a slash is the denominator, so: l/mol s is the same as (l)/(mol s) Remark: not all units are understood.
Examples
print(unit.from.string("m/s"))
#> scale multiplier exponent kind
#> 1 0 1 1 metre
#> 2 0 1 -1 second
print(unit.from.string("micromolarity"))
#> scale multiplier exponent kind
#> 1 -6 1 1 mole
#> 2 0 1 -1 litre
print(unit.from.string("µM"))
#> scale multiplier exponent kind
#> 1 -6 1 1 mole
#> 2 0 1 -1 litre