Learn R Programming

aelab (version 1.1.0)

convert_ghg_unit: convert_ghg_unit

Description

Convert a greenhouse gas (GHG) flux value (or a character string containing one or more numeric values, e.g. "0.002 +/- 0.003") to micrograms per square meter per hour.

Usage

convert_ghg_unit(
  input,
  ghg,
  mass = "µg",
  area = "m2",
  time = "hr",
  digits = 2,
  ratio = FALSE
)

Value

A named list with value (converted string) and unit, or "EMPTY" for missing/non-numeric input.

Arguments

input

A single numeric value or a character string containing one or more numbers.

ghg

The molecular formula of the greenhouse gas: "co2", "ch4", or "n2o".

mass

Mass unit of the input flux. One of "mmol", "mg", "g", "ug" (micrograms), "nmol", "Mg", "umol" (micromoles), "mol". Default "ug".

area

Area unit of the input flux. One of "ha", "m2". Default "m2".

time

Time unit of the input flux. One of "yr", "day", "hr", "sec", "min". Default "hr".

digits

Number of decimal places to round to. Default 2.

ratio

Logical. If TRUE, apply an elemental-ratio correction (C-basis for CH4, N-basis for N2O). Default FALSE.

Details

Numeric values embedded in a string (e.g. mean +/- SD notation) are each converted individually and the surrounding text is preserved. Commas are treated as decimal separators.

Examples

Run this code
convert_ghg_unit(97, ghg = "ch4", mass = "mg", area = "m2", time = "hr")

Run the code above in your browser using DataLab