Drop units from a dimensionful quantity and retrieve a dimensionless number.
The dimensionless number is defined by the ratio of x
and one unit u(1, unit)
.
Arguments
- x
A dimensionful numeric vector (S3 class "units"), e.g. generated with
u()
or subsequent calculations.- unit
A character indicating the unit. See
units::valid_udunits()
andunits::valid_udunits_prefixes()
for possible units.
Examples
x <- u(1, "km")
# retrieve a dimensionless number
# from x in units of "meter"
du(x, "m")
#> [1] 1000
# drop the unit of a dimensionaless "unit" quantity
du(x / x)
#> [1] 1