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)
the numeric value of the quantity, can be a single value or a vector
the unit of the quantity
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")
#> <mk_molarity_concentration[1]>
#> [1] 45
qty(200, "mbar")
#> <mk_pressure[1]>
#> [1] 200
qty(6, "psi")
#> <mk_pressure[1]>
#> [1] 413.6855
qty(30, "C")
#> <mk_temperature[1]>
#> [1] 303.15
qty(100, "K")
#> <mk_temperature[1]>
#> [1] 100
qty(5, "mg/L")
#> <mk_mass_concentration[1]>
#> [1] 5
qty(1, "mM/bar")
#> <mk_gas_solubility[1]>
#> [1] 1
qty(257, "g/mol")
#> <mk_molecular_weight[1]>
#> [1] 257