| convert_DO {respR} | R Documentation |
Convert between units of dissolved oxygen
Description
This is a conversion function that performs conversions between concentration and pressure units of dissolved oxygen (DO).
Usage
convert_DO(
x,
from = NULL,
to = NULL,
S = NULL,
t = NULL,
P = NULL,
simplify = TRUE
)
Arguments
x |
numeric. The dissolved oxygen (DO) value(s) to be converted. |
from |
string. The DO unit to convert from. See |
to |
string. The DO unit to convert to. See |
S |
numeric. Salinity (ppt). Defaults to NULL. Required for conversion
of some units. See |
t |
numeric. Temperature(°C). Defaults to NULL. Required for conversion
of some units. See |
P |
numeric. Pressure (bar). Defaults to 1.013253. Required for
conversion of some units. See |
simplify |
logical. Defaults to |
Details
The function uses a fuzzy string matching algorithm to accept various unit
formatting styles. For example, "mg/l", "mg/L", "mgL-1", "mg l-1",
"mg.l-1" are all parsed the same. See [unit_args()] for details of
accepted units.
Oxygen concentration units should use SI units (L or kg) for the
denominator.
Some DO units require temperature (t), salinity (S), and atmospheric
pressure (P) to be specified; if this is the case the function will stop
and prompt for them. For the atmospheric pressure input (P), a default value
of 1.013 bar (standard pressure at sea level) is applied if not otherwise
entered. For freshwater experiments, salinity should be set to zero (i.e. S = 0).
S3 Generic Functions
Saved output objects (if simplify = FALSE is used) can be entered in the
generic S3 functions print() and summary().
-
print(): prints input and converted values (up to first 20), plus input and output units. -
summary(): simple wrapper forprint()function. See above.
Value
By default (simplify = TRUE) the output is a numeric vector of
converted values. If simplify = FALSE output is a list object of class
convert_DO containing five elements: $call the function call, $input
values, $output converted values, $input.unit and $output.unit.
More
For additional help, documentation, vignettes, and more visit the respR
website at https://januarharianto.github.io/respR/
Examples
# Convert a numeric value to units which do not require t, S and P
convert_DO(8.21, from = "mg/L", to = "umol/L")
# Convert a numeric value to units which require t, S and P
convert_DO(100, from = "%Air", to = "mg L-1", S = 33, t = 18)
convert_DO(214, from = "hPa", to = "mL/kg", S = 33, t = 18)
# Convert a vector of values
convert_DO(urchins.rd[[5]], from = "mg/L", to = "umol/L")
convert_DO(c(8.01, 8.03, 8.05), from = "mg per litre", to = "%Air",
t = 15, S = 35)
convert_DO(sardine.rd[[2]], from = "%Air", to = "torr",
t = 15, S = 35)