Learn R Programming

udunits2 (version 0.13.2.2)

ud.are.convertible: Determine whether two units may be converted between each other

Description

This function takes udunits compatible strings and determines whether or not it is possible to convert between them.

Usage

ud.are.convertible(u1, u2)

Value

Returns a logical: True if the units can be converted between each other, False if either of the arguments is not parseable by udunits, or if no conversion is possible.

Arguments

u1

A character string which is parseable into a udunits compatible unit.

u2

Another character string which is also parseable into a udunits compatible unit.

Author

James Hiebert hiebert@uvic.ca

Details

Even if two units are parseable and recognized by the udunits library, it may or may not be possible to convert from one to another. For example, it makes sense to convert from celsius to kelvin, however not from celsius to kilograms. This function allows the user to check if two units are of the same system and if there exists a defined conversion between the two.

References

See the udunits function ut_are_convertible: https://docs.unidata.ucar.edu/udunits/current/udunits2lib.html#ut_are_convertible and the main uninits webpage: https://www.unidata.ucar.edu/software/udunits/

See Also

ud.is.parseable

Examples

Run this code
ud.are.convertible("miles", "km")        # TRUE
ud.are.convertible("grams", "kilograms") # TRUE
ud.are.convertible("celsius", "grams")   # FALSE
ud.are.convertible("not", "parseable")   # FALSE

Run the code above in your browser using DataLab