Converts a list of mixed units to a specific unit, using the units
package.
Arguments
- x
A mixed units object (
units::mixed_units()) to be converted to thetarget_unit- target_unit
A
characterstring 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.
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")
#> Units: [ug/L]
#> [1] 1e+03 1e+06 1e+07 NA
mishmash <- as_unit_ecotox(c("h", "sec", "mi", "dph"))
mixed_to_single_unit(mishmash, "h")
#> Units: [h]
#> [1] 1.000000e+00 2.777778e-04 1.666667e-02 2.400000e+01