mixed_to_single_unit: Convert mixed units to a specific unit

View source: R/process_unit.r

mixed_to_single_unitR Documentation

Convert mixed units to a specific unit

Description

Converts a list of mixed units to a specific unit, using the units package.

Usage

mixed_to_single_unit(x, target_unit)

Arguments

x

A mixed units object (units::mixed_units()) to be converted to the target_unit

target_unit

A character string representing the target unit

Value

Returns a units object (?units::units). Values with units that cannot be converted to the target_unit is returned as NA.

Author(s)

Pepijn de Vries

See Also

Other ecotox-sanitisers: as_date_ecotox(), as_numeric_ecotox(), as_unit_ecotox(), process_ecotox_dates(), process_ecotox_numerics(), process_ecotox_units()

Examples

mishmash <- as_unit_ecotox(c("mg/L", "ppt w/v", "% w/v", "mmol/L"))

## Note that 'mmol/L' cannot be converted to 'ug/L'
## without a molar mass. It is returned as `NA`
mixed_to_single_unit(mishmash, "ug/L")

mishmash <- as_unit_ecotox(c("h", "sec", "mi", "dph"))

mixed_to_single_unit(mishmash, "h")

ECOTOXr documentation built on April 12, 2025, 1:27 a.m.