Learn R Programming

measurements (version 1.2.0)

conv_unit: Convert Units of Measurement

Description

Converts common units of measurement for a variety of dimensions. See conv_unit_options for all options.

Usage

conv_unit(x, from, to)

Arguments

x

a numeric vector giving the measurement value in its original units.

from

the unit in which the measurement was made.

to

the unit to which the measurement is to be converted.

Details

Acceleration

mm_per_sec2, cm_per_sec2, m_per_sec2, km_per_sec2, grav, inch_per_sec2, ft_per_sec2, mi_per_sec2, kph_per_sec, mph_per_sec

Angle

degree, radian, grad, arcmin, arcsec, turn

Area

nm2, um2, mm2, cm2, m2, hectare, km2, inch2, ft2, yd2, acre, mi2, naut_mi2

Coordinate

dec_deg, deg_dec_min, deg_min_sec (see note)

Count

nmol, umol, mmol, mol

Duration

nsec, usec, msec, sec, min, hr, day, wk, mon, yr, dec, cen, mil, Ma

Energy

J, kJ, erg, cal, Cal, Wsec, kWh, MWh, BTU

Flow

ml_per_sec, ml_per_min, ml_per_hr, l_per_sec, l_per_min, l_per_hr, m3_per_sec, m3_per_min, m3_per_hr, gal_per_sec, gal_per_min, gal_per_hr, ft3_per_sec, ft3_per_min, ft3_per_hr, Sv

Length

angstrom, nm, um, mm, cm, dm, m, km, inch, ft, yd, fathom, mi, naut_mi, au, light_yr, parsec, point

Mass

ug, mg, g, kg, Pg, carat, metric_ton, oz, lbs, short_ton, long_ton, stone

Power

uW, mW, W, kW, MW, GW, erg_per_sec, cal_per_sec, cal_per_hr, Cal_per_sec, Cal_per_hr, BTU_per_sec, BTU_per_hr, hp

Pressure

uatm, atm, Pa, hPa, kPa, torr, mmHg, inHg, cmH2O, inH2O, mbar, bar, dbar, psi

Speed

mm_per_sec, cm_per_sec, m_per_sec, km_per_sec, inch_per_sec, ft_per_sec, kph, mph, km_per_day, mi_per_day, knot, mach, light

Temperature

C, F, K, R

Volume

ul, ml, dl, l, cm3, dm3, m3, km3, us_tsp, us_tbsp, us_oz, us_cup, us_pint, us_quart, us_gal, inch3, ft3, mi3, imp_tsp, imp_tbsp, imp_oz, imp_cup, imp_pint, imp_quart, imp_gal

The conversion values have been defined based primarily from international weight and measurement authorities (e.g. General Conference on Weights and Measures, International Committee for Weights and Measures, etc.). While much effort was made to make conversions as accurate as possible, you should check the accuracy of conversions to ensure that conversions are precise enough for your applications.

See Also

conv_unit_options, conv_dim

Examples

Run this code
# NOT RUN {
conv_unit(2.54, "cm", "inch") # Result = 1 inch

conv_unit(seq(1, 10), "kg", "short_ton") # A vector of measurement values can be converted

# Convert 1, 10, and 100 meters to all other length units
sapply(conv_unit_options$length, function(x) conv_unit(c(1, 10, 100), "m", x))

conv_unit("33 1 1", "deg_min_sec", "dec_deg")

conv_unit(c("101 44.32","3 19.453"), "deg_dec_min", "deg_min_sec")

# }

Run the code above in your browser using DataLab