Learn R Programming

datamart (version 0.3.2)

uconv: convert between numerical units

Description

This function converts between numerical units. It works similar to the iconv function: You provide vector x and a from and a to unit name and the function converts. If you omit the from parameter, it is tried to lookup the current unit name by Unit(x).

Arguments

x
numerical vector
from
character, unit to convert from. Default 'Unit(x)'
to
character, unit to convert to
uset
optional, character, unit set to use.

Details

Additionally, you may provide a unitset name. Here, the analogy to iconv ceases. Think of unitset as a dimension of units, or a context for units. Predefined unitsets are "Length", "Mass", "Energy", which are dimensional unitsets and "GaseousFuel", "CrudeOil", which provide the right conversion factors for the given contexts. It is recommened to provide the unitset name. A list of available unitsets and the units defined by them can be obtained with uconvlist(). You may add your own unitset(s) using add_unitsets.

Examples

Run this code
uconv(1, "horse length", "m")
uconv(1:10, "t LNG", "GJ", "GaseousFuel")

Run the code above in your browser using DataLab