Skip to contents

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).

Usage

du(x, unit = "1")

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() and units::valid_udunits_prefixes() for possible units.

Value

A dimensionless number defined by the ratio of x and one unit u(1, unit).

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