This is a conversion function that performs conversions between concentration and pressure units of dissolved oxygen (DO).

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 unit_args() for details.

to

string. The DO unit to convert to. See unit_args() for details.

S

numeric. Salinity (ppt). Defaults to NULL. Required for conversion of some units. See unit_args() for details.

t

numeric. Temperature(°C). Defaults to NULL. Required for conversion of some units. See unit_args() for details.

P

numeric. Pressure (bar). Defaults to 1.013253. Required for conversion of some units. See unit_args() for details.

simplify

logical. Defaults to TRUE in which case the converted values are returned as a numeric vector. if FALSE a list object of class convert_DO is returned.

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/

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 for print() function. See above.

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")
#> [1] 256.5721

# 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: Input or output units require Atmospheric Pressure input (i.e. P = ??). 
#> Default value of P = 1.013253 bar has been used.
#> [1] 7.752073
convert_DO(214, from = "hPa", to = "mL/kg", S = 33, t = 18)
#> convert_DO: Input or output units require Atmospheric Pressure input (i.e. P = ??). 
#> Default value of P = 1.013253 bar has been used.
#> [1] 5.733996

# Convert a vector of values
convert_DO(urchins.rd[[5]], from = "mg/L", to = "umol/L")
#>   [1] 239.0715 240.9465 240.6340 241.2590 239.6965 237.8214 238.1339 238.4464 238.4464 236.5714 238.1339 237.5089 237.5089 235.6338 235.0088 237.5089 236.8839 237.1964 235.6338 236.5714 235.6338 234.0713 234.3838 234.0713 234.3838 235.3213 234.6963 234.0713 234.0713 232.5087 233.4463 233.4463 233.4463 232.8212 232.5087 234.0713 234.0713 232.1962 233.4463 233.4463 231.5712 231.8837 231.5712 231.8837 231.5712 231.2587 230.9462 233.1337 234.0713 231.8837 231.5712 230.6336 230.6336 231.8837 230.6336 230.3211 231.5712 229.3836 230.6336 230.6336 230.0086 230.0086 229.3836 230.6336 229.3836 229.0711 229.3836 228.7586 228.4461 227.8210 228.4461 228.7586 228.1336 228.4461 227.8210 228.7586 228.4461 228.7586 229.0711 228.4461 226.8835 225.9460 226.8835 226.2585 225.6335 226.2585 225.9460 225.6335 223.7584 225.3209 224.6959 224.3834 226.2585 225.0084 225.6335 225.9460 226.2585 224.6959 225.3209 225.9460 225.0084 225.3209 223.4459 222.8209 224.3834 224.6959 224.6959 224.6959 225.3209 225.3209
#> [111] 223.7584 224.0709 222.8209 223.1334 223.4459 222.5083 222.5083 223.1334 222.8209 223.7584 222.1958 221.2583 221.8833 221.2583 222.8209 222.1958 222.1958 221.8833 222.5083 221.8833 221.2583 221.5708 220.3208 219.3832 220.6333 219.6957 220.9458 220.3208 219.0707 220.9458 219.3832 220.3208 220.0083 219.6957 219.6957 220.3208 218.7582 219.6957 219.0707 219.3832 220.9458 220.3208 218.4457 217.5082 217.1956 219.0707 217.8207 218.1332 216.8831 217.1956 218.1332 217.1956 218.7582 217.1956 218.1332 217.8207 217.5082 216.2581 215.3206 215.3206 216.2581 215.3206 216.5706 215.6331 215.6331 216.2581 216.8831 216.8831 215.9456 216.2581 216.5706 215.3206 214.0705 215.3206 215.6331 215.3206 213.4455 215.6331 214.3830 214.0705 215.0081 214.3830 214.0705 213.4455 213.1330 213.4455 211.8829 213.7580 212.8205 212.5080 212.5080 212.1955 212.1955 212.5080 212.1955 211.8829 211.8829 213.1330 213.4455 212.5080 212.8205 212.1955 211.5704 211.8829 210.6329 211.8829 211.2579 211.8829 211.8829 212.8205
#> [221] 212.1955 210.9454 211.2579 210.9454 210.6329 211.8829 210.6329 211.2579 210.3204 210.3204 210.3204 208.4453 209.3829 209.6954 209.6954 208.4453 208.1328 208.1328 209.0703 209.3829 209.3829 207.8203 207.8203 207.8203 207.8203 208.1328 207.1953 206.8828 206.5702 206.2577 207.5078 207.5078 206.8828 206.8828 206.8828 206.2577 205.6327 207.1953 206.8828 206.2577 205.6327 206.5702 206.8828 205.0077 205.9452 205.6327 206.2577 206.2577 205.9452 205.6327 206.5702
convert_DO(c(8.01, 8.03, 8.05), from = "mg per litre", to = "%Air",
  t = 15, S = 35)
#> convert_DO: Input or output units require Atmospheric Pressure input (i.e. P = ??). 
#> Default value of P = 1.013253 bar has been used.
#> [1] 98.59464 98.84082 99.08699
convert_DO(sardine.rd[[2]], from = "%Air", to = "torr",
  t = 15, S = 35)
#> convert_DO: Input or output units require Atmospheric Pressure input (i.e. P = ??). 
#> Default value of P = 1.013253 bar has been used.
#>    [1] 151.6918 151.6918 151.6918 151.6918 151.6918 151.6918 151.6918 151.5331 151.5331 151.5331 151.6918 151.6918 151.5331 151.5331 151.6918 151.6918 151.6918 151.3744 151.6918 151.6918 151.6918 151.6918 151.8504 151.6918 151.6918 151.6918 151.6918 151.5331 151.6918 151.6918 151.3744 151.6918 151.6918 151.5331 151.5331 151.5331 151.6918 151.3744 151.5331 151.5331 151.3744 151.5331 151.6918 151.5331 151.5331 151.5331 151.6918 151.6918 151.6918 151.6918 151.6918 151.6918 151.8504 151.5331 151.6918 151.3744 151.5331 151.6918 151.5331 151.5331 151.6918 151.6918 151.6918 151.3744 151.5331 151.5331 151.6918 151.6918 151.6918 151.6918 151.6918 151.6918 151.5331 151.6918 151.6918 151.6918 151.5331 151.3744 151.6918 151.6918 151.5331 151.3744 151.6918 151.5331 151.5331 151.6918 151.3744 151.6918 151.6918 151.5331 151.6918 151.3744 151.6918 151.6918 151.5331 151.6918 151.6918 151.3744 151.5331 151.5331 151.6918 151.5331 151.3744 151.5331 151.3744 151.5331 151.5331 151.5331 151.2157 151.6918
#>  [111] 151.5331 151.5331 151.5331 151.5331 151.2157 151.3744 151.5331 151.5331 151.2157 151.5331 151.5331 151.6918 151.6918 151.3744 151.3744 151.5331 151.2157 151.3744 151.3744 151.5331 151.6918 151.6918 151.5331 151.5331 151.3744 151.5331 151.3744 151.6918 151.5331 151.2157 151.3744 151.3744 151.5331 151.5331 151.3744 151.3744 151.5331 151.3744 151.3744 151.3744 151.5331 151.2157 151.3744 151.3744 151.5331 151.3744 151.3744 151.3744 151.3744 151.5331 151.3744 151.3744 151.5331 151.3744 151.3744 151.3744 151.3744 151.2157 151.6918 151.3744 151.3744 151.5331 151.5331 151.3744 151.3744 151.3744 151.3744 151.3744 151.6918 151.5331 151.2157 151.2157 151.3744 151.3744 151.5331 151.3744 151.3744 151.5331 151.2157 151.5331 151.5331 151.5331 151.2157 151.3744 151.3744 151.5331 151.3744 151.3744 151.5331 151.2157 151.3744 151.3744 151.3744 151.3744 151.3744 151.3744 151.3744 151.2157 151.2157 151.2157 151.2157 151.5331 151.2157 151.5331 151.5331 151.5331 151.3744 151.2157 151.3744 151.2157
#>  [221] 151.2157 151.2157 151.3744 151.2157 151.3744 151.5331 151.3744 151.0571 151.2157 151.3744 151.3744 151.3744 151.2157 151.3744 151.2157 151.2157 151.3744 151.3744 151.5331 151.3744 151.0571 151.0571 151.2157 151.5331 151.3744 151.3744 151.3744 151.3744 151.3744 151.2157 151.5331 151.2157 151.2157 151.3744 151.2157 151.3744 151.2157 151.3744 151.0571 151.2157 151.3744 151.2157 151.3744 151.2157 151.3744 151.2157 151.2157 151.2157 151.2157 151.0571 151.3744 151.5331 151.0571 151.3744 151.2157 151.5331 151.2157 151.3744 151.2157 151.3744 151.3744 151.0571 151.3744 151.2157 151.2157 151.2157 151.2157 151.2157 151.3744 151.0571 151.0571 151.2157 151.2157 151.0571 151.5331 151.3744 151.0571 151.2157 151.5331 151.0571 151.2157 151.2157 151.2157 151.2157 151.2157 150.8984 151.2157 151.2157 151.2157 151.3744 151.3744 151.2157 151.2157 151.2157 151.2157 151.2157 151.2157 151.0571 151.3744 150.8984 151.2157 151.3744 151.2157 151.2157 151.0571 150.8984 150.8984 151.2157 151.2157 151.2157
#>  [331] 151.2157 151.2157 150.8984 151.2157 150.8984 151.0571 151.0571 151.0571 151.2157 151.2157 151.0571 151.0571 151.0571 151.2157 151.2157 151.3744 151.2157 151.2157 151.2157 151.0571 151.3744 151.0571 150.8984 150.8984 151.2157 151.0571 151.2157 151.0571 151.2157 151.3744 151.2157 151.0571 151.2157 151.0571 151.3744 151.2157 150.8984 150.8984 151.0571 150.8984 151.2157 151.0571 150.8984 151.0571 150.8984 151.2157 151.0571 151.0571 151.0571 151.0571 150.8984 150.8984 150.8984 150.8984 150.8984 151.0571 151.0571 150.8984 150.8984 151.0571 151.2157 151.0571 151.2157 151.0571 151.0571 151.0571 151.0571 151.0571 150.8984 150.8984 150.7397 151.0571 151.0571 151.0571 150.8984 151.0571 151.0571 150.8984 151.0571 151.2157 151.0571 151.2157 151.2157 151.0571 151.0571 151.3744 151.0571 150.8984 151.2157 151.0571 151.2157 151.2157 151.0571 151.0571 151.2157 150.8984 150.8984 151.0571 151.0571 150.8984 151.2157 150.8984 151.0571 150.7397 150.7397 151.0571 151.0571 151.0571 151.2157 150.8984
#>  [441] 150.7397 151.2157 150.8984 150.8984 151.0571 151.0571 150.8984 150.8984 150.8984 151.0571 151.0571 150.8984 151.0571 150.8984 150.7397 150.8984 150.8984 150.8984 150.8984 151.2157 150.8984 151.0571 150.7397 151.0571 150.8984 150.8984 150.8984 150.8984 151.2157 150.8984 151.0571 150.8984 150.8984 150.7397 150.7397 151.0571 150.7397 150.8984 150.8984 150.8984 151.2157 150.8984 150.8984 150.8984 151.0571 150.7397 150.8984 151.0571 151.0571 151.0571 150.8984 151.0571 151.0571 151.0571 151.0571 150.7397 150.8984 150.8984 150.7397 150.7397 150.8984 150.7397 150.7397 150.7397 150.7397 150.8984 150.7397 150.8984 150.8984 150.8984 150.7397 150.8984 151.0571 150.7397 150.7397 151.0571 151.2157 150.8984 150.8984 150.8984 151.2157 150.7397 151.2157 151.0571 151.0571 151.2157 150.7397 150.8984 150.7397 150.7397 150.8984 150.8984 150.8984 150.7397 150.8984 150.7397 150.8984 150.8984 150.7397 150.8984 150.8984 150.7397 150.7397 150.7397 150.7397 150.8984 150.7397 151.0571 151.0571 150.8984
#>  [551] 151.0571 150.7397 150.7397 151.0571 150.7397 150.7397 150.7397 150.7397 150.8984 150.7397 151.0571 150.8984 150.7397 150.8984 150.8984 150.7397 150.7397 150.7397 150.7397 150.7397 150.8984 150.8984 150.8984 151.0571 150.8984 150.7397 150.8984 150.7397 151.0571 150.7397 150.7397 151.0571 150.8984 150.7397 150.7397 150.7397 150.7397 150.7397 150.8984 150.8984 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.5810 150.8984 150.7397 150.7397 150.8984 151.0571 150.7397 150.7397 150.8984 150.7397 150.7397 150.5810 150.7397 150.7397 150.8984 150.7397 150.7397 150.8984 150.5810 150.8984 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.5810 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.8984 150.8984 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.8984 150.8984 150.7397 150.7397 150.7397 150.7397 150.8984 150.7397 150.4224 150.7397 150.5810 150.8984 150.7397 150.7397 150.7397 150.7397 150.7397 150.8984 150.7397 150.7397
#>  [661] 150.7397 150.7397 150.5810 150.8984 150.7397 150.7397 150.8984 150.7397 150.8984 150.7397 150.7397 150.7397 150.7397 150.7397 150.4224 150.7397 150.7397 150.7397 150.7397 150.5810 150.5810 150.7397 150.7397 150.7397 150.7397 150.5810 150.7397 150.7397 150.5810 150.5810 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.5810 150.7397 150.7397 150.8984 150.7397 150.7397 150.5810 150.7397 150.7397 150.7397 150.7397 150.7397 150.5810 150.7397 150.7397 150.7397 150.7397 150.5810 150.5810 150.4224 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.4224 150.7397 150.5810 150.7397 150.5810 150.7397 150.7397 150.5810 150.7397 150.7397 150.7397 150.7397 150.7397 150.7397 150.5810 150.7397 150.5810 150.7397 150.7397 150.5810 150.7397 150.5810 150.5810 150.5810 150.7397 150.5810 150.7397 150.7397 150.7397 150.4224 150.7397 150.7397 150.7397 150.7397 150.7397 150.5810 150.5810 150.7397 150.7397 150.5810 150.5810
#>  [771] 150.5810 150.5810 150.5810 150.7397 150.7397 150.7397 150.7397 150.5810 150.4224 150.5810 150.5810 150.7397 150.7397 150.5810 150.7397 150.5810 150.5810 150.5810 150.5810 150.4224 150.7397 150.7397 150.7397 150.5810 150.5810 150.7397 150.7397 150.7397 150.5810 150.5810 150.7397 150.7397 150.5810 150.7397 150.7397 150.5810 150.5810 150.7397 150.5810 150.5810 150.7397 150.5810 150.5810 150.7397 150.5810 150.5810 150.7397 150.4224 150.7397 150.5810 150.4224 150.7397 150.7397 150.4224 150.7397 150.5810 150.5810 150.5810 150.4224 150.7397 150.7397 150.5810 150.4224 150.7397 150.5810 150.5810 150.7397 150.7397 150.4224 150.5810 150.5810 150.4224 150.5810 150.5810 150.5810 150.2637 150.4224 150.7397 150.7397 150.7397 150.5810 150.4224 150.5810 150.7397 150.7397 150.4224 150.7397 150.7397 150.5810 150.5810 150.7397 150.5810 150.4224 150.7397 150.4224 150.5810 150.5810 150.5810 150.2637 150.4224 150.5810 150.5810 150.5810 150.4224 150.7397 150.4224 150.4224 150.5810 150.4224 150.7397
#>  [881] 150.5810 150.5810 150.7397 150.7397 150.7397 150.5810 150.4224 150.4224 150.5810 150.4224 150.5810 150.7397 150.2637 150.4224 150.4224 150.2637 150.5810 150.5810 150.5810 150.5810 150.2637 150.5810 150.2637 150.4224 150.5810 150.4224 150.2637 150.4224 150.5810 150.5810 150.5810 150.4224 150.7397 150.2637 150.5810 150.4224 150.4224 150.5810 150.2637 150.4224 150.4224 150.4224 150.5810 150.2637 150.5810 150.4224 150.4224 150.4224 150.5810 150.4224 150.4224 150.1050 150.4224 150.2637 150.1050 150.4224 150.1050 150.4224 150.5810 150.4224 150.4224 150.4224 150.5810 150.4224 150.4224 150.2637 150.2637 150.2637 150.1050 150.4224 150.2637 150.4224 150.5810 150.4224 150.4224 150.2637 150.4224 150.5810 150.4224 150.2637 150.4224 150.1050 150.2637 150.4224 150.4224 150.5810 150.7397 150.5810 150.2637 150.5810 150.4224 150.4224 150.1050 150.1050 150.4224 150.2637 150.2637 150.2637 150.2637 150.2637 150.4224 150.4224 150.2637 150.4224 150.2637 150.2637 150.2637 150.1050 150.4224 150.5810
#>  [991] 150.4224 150.2637 150.4224 149.9463 150.2637 150.5810 150.2637 150.2637 150.2637 150.2637
#>  [ reached getOption("max.print") -- omitted 6513 entries ]