Learn R Programming

units (version 1.0-0)

udunits2: udunits2 utilities

Description

Some udunits2 utilities are exposed to the user. These functions are useful for checking whether units are convertible or converting between units without having to create units objects. Arguments are recycled if necessary.

Usage

ud_are_convertible(from, to, ...)

ud_convert(x, from, to)

Value

ud_are_convertible

returns TRUE if both units exist and are convertible, FALSE otherwise.

ud_convert

returns a numeric vector with x converted to new unit.

Arguments

from, to

character vector or object of class symbolic_units, for the symbol(s) of the original unit(s) and the unit to convert to respectively.

...

unused.

x

numeric vector

Examples

Run this code
ud_are_convertible(c("m", "mm"), "km")
ud_convert(c(100, 100000), c("m", "mm"), "km")

a <- set_units(1:3, m/s)
ud_are_convertible(units(a), "km/h")
ud_convert(1:3, units(a), "km/h")

ud_are_convertible("degF", "degC")
ud_convert(32, "degF", "degC")

Run the code above in your browser using DataLab