convert_ghg_unit: convert_ghg_unit

View source: R/ghg_flux.R

convert_ghg_unitR Documentation

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
)

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.

Value

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

Examples

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

aelab documentation built on Feb. 23, 2026, 5:07 p.m.