convertUnits: Produce conversion factor to multiply old.units by to get...

View source: R/unit.conversions.R

convertUnitsR Documentation

Produce conversion factor to multiply old.units by to get new.units

Description

Converts units; units can be arbitrarily complex as long as every dimension of each unit is present in unit.conversions

Usage

convertUnits(old.units, new.units, attach.units = FALSE)

Arguments

old.units

character. The units to convert from.

new.units

character. The units to convert to.

attach.units

logical. Should units be attached to the conversion factor?

Value

a conversion factor that can be multiplied with data in the old.units to achieve data in the new.units

Examples

loadflex:::convertUnits('mg/L', 'kg/m^3')
loadflex:::convertUnits('kg d^-1', 'kg/yr')
loadflex:::convertUnits('kg/yr', 'kg/d', attach.units = TRUE)
## Not run: 
loadflex:::convertUnits('mg/L', 'm^3/d') # error: dimensions must match
loadflex:::convertUnits(unitbundle('ft^3 g L^-1 s^-1'), 'kg/d') # error: too complicated

## End(Not run)

USGS-R/loadflex documentation built on July 26, 2023, 9:54 p.m.