unit.from.string: Unit Interpreter

View source: R/units.R

unit.from.stringR Documentation

Unit Interpreter

Description

This 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

Usage

unit.from.string(unit.str)

Arguments

unit.str

a string that contains a human readable unit

verbose

if TRUE, this function prints what it does (to find problems)

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.

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)

Examples

> unit.from.string("m/s")
  scale multiplier exponent   kind
1     0          1        1  metre
2     0          1       -1 second

> unit.from.string("micromolarity")
  scale multiplier exponent  kind
1    -6          1        1  mole
2     0          1       -1 litre

> unit.from.string("µM")
  scale multiplier exponent     kind
1    -6          1        1 molarity

a-kramer/SBtabVFGEN documentation built on Nov. 14, 2024, 8:41 p.m.