The qty
function makes it easy to keep track of different quantities in chemical calculations. Metric prefixes are fully supported, i.e. any unit can be combined with standard metric_scaling scaling (mL, nmol, kg, etc.). Some quantities can also be used in common arithmetic operations.
qty(x = double(), unit, scale_to_best_metric = TRUE)
x | the numeric value of the quantity, can be a single value or a vector |
---|---|
unit | the unit of the quantity |
scale_to_best_metric | whether to automatically scale to the best metric prefix |
The following types of quantities are supported.
amount (N): base unit mol
but also understands mole
, all metric prefixes allowed
mass (m): base unit g
, all metric prefixes allowed
molecular weight (MW): base unit g/mol
, all metric prefixes allowed in the numerator
molarity concentration (C): base unit M
but also understands mol/L
, all metric prefixes allowed in the numerator
mass concentration (C): base unit g/L
but also understands g/l
, all metric prefixes allowed in the numerator. This is technically a density and sometimes referred to as such in the microbial kitchen documentation.
volume (V): base unit L
but also understands l
, all metric prefixes allowed
pressure (P): base unit bar
but also understands Pa
, all metric prefixes allowed, the common non-metric units atm
, psi
, Torr
, mTorr
, and % SP
(% at standard pressure = % of 1 bar) are also supported and will be automatically converted to bar
.
gas solubility (S): base unit M/bar
, all metric prefixes allowed in the numerator, the common non-metric unit M/atm
is also supported and will be automatically converted to M/bar
. This quantity is used for capturing Henry's law constants.
temperature (T): base unit K
but also understands C
and F
and converts them to Kelvin
qty
: generate a quantity object
Other quantity functions:
check_quantities
,
make_qty_units_explicit()
,
metric_scaling
,
quantity_data
,
quantity_units
qty(0.045, "mmol/L")#> <C (molarity concentration) in 'µM'[1]> #> [1] 45qty(200, "mbar")#> <P (pressure) in 'mbar'[1]> #> [1] 200qty(6, "psi")#> <P (pressure) in 'mbar'[1]> #> [1] 413.6855qty(30, "C")#> <T (temperature) in 'K'[1]> #> [1] 303.15qty(100, "K")#> <T (temperature) in 'K'[1]> #> [1] 100qty(5, "mg/L")#> <C (mass concentration) in 'mg/L'[1]> #> [1] 5qty(1, "mM/bar")#> <S (gas solubility) in 'mM/bar'[1]> #> [1] 1qty(257, "g/mol")#> <MW (molecular weight) in 'g/mol'[1]> #> [1] 257