| UnitConv {DescTools} | R Documentation |
Convert a number from one measurement system to another. The function can translate a table of distances in miles to a table of distances in kilometers.
UnitConv(x, from_unit, to_unit) data(d.units) data(d.prefix)
x |
the numeric to be converted. |
from_unit |
a character defining the original unit. |
to_unit |
a character defining the target unit. |
The following units can be chosen. Conversions will work with units within the group. NA wil be returned if a conversion can't be found.
The multipliers can be found in the dataset d.units.
| Weight and mass | ||
| Gram | g | metric |
| Slug | sg | |
| Pound mass (avoirdupois) | lbm | |
| U (atomic mass unit) | u | |
| Ounce mass (avoirdupois) | ozm | |
| Distance | ||
| Meter | m | metric |
| Statute mile | mi | |
| Nautical mile | Nmi | |
| Inch | in | |
| Foot | ft | |
| Yard | yd | |
| Angstrom | ang | metric |
| Pica | pica | |
| Time | ||
| Year | yr | |
| Day | day | |
| Hour | hr | |
| Minute | mn | |
| Second | sec | |
| Pressure | ||
| Pascal | Pa (or p) | |
| Atmosphere | atm (or at) | |
| mm of Mercury | mmHg | |
| Force | ||
| Newton | N | metric |
| Dyne | dyn (or dy) | |
| Pound force | lbf | |
| Energy | ||
| Joule | J | metric |
| Erg | e | |
| Thermodynamic calorie | c | |
| IT calorie | cal | metric |
| Electron volt | eV (or ev) | metric |
| Horsepower-hour | HPh (or hh) | |
| Watt-hour | Wh (or wh) | metric |
| Foot-pound | flb | |
| BTU | BTU (or btu) | |
| Power | ||
| Horsepower | HP (or h) | |
| Watt | W (or w) | metric |
| Magnetism | ||
| Tesla | T | metric |
| Gauss | ga | metric |
| Temperature | ||
| Degree Celsius | C (or cel) | |
| Degree Fahrenheit | F (or fah) | |
| Kelvin | K (or kel) | metric |
| Liquid measure | ||
| Teaspoon | tsp | |
| Tablespoon | tbs | |
| Fluid ounce | oz | |
| Cup | cup | |
| U.S. pint | pt (or us_pt) | |
| U.K. pint | uk_pt | |
| Quart | qt | |
| Gallon | gal | |
| Liter | l (or lt) | metric |
All the details can be found in the d.units data.frame.
Andri Signorell <andri@signorell.net>
UnitConv(c(1.2, 5.4, 6.7), "in", "m")