ConvUnit.Rd
Converts a numerical vector from one measurement system to another. Metric prefixes (as unit prefixes that precede a basic unit of measure to indicate a multiple or fraction of the unit) are respected.
The two functions CmToPts()
and PtsToCm()
convert centimeters to points and vice versa. 1 cm corresponds to 28.35 points.
The units as defined by the International System of Units (SI) (m, g, s, A, K, mol, cd, Hz, rad, sr, N, Pa, J, W, C, V, F, Ohm, S, Wb, T, H, lm, lx, Bq, Gy, Sv, kat, l) can be used to convert between different prefixes. The following non SI-units can be chosen for conversion between different systems. NA
will be returned if a conversion can't be found.
The function is using the conversion factors stored in the dataset d.units
.
Weight and mass | ||
Gram | ||
g | metric | Pound mass (avoirdupois) |
lb | Ounce mass (avoirdupois) | oz |
Metric ton | ton (or tn) | |
Distance | Meter | |
m | metric | Statute mile |
mi | Nautical mile | nmi |
Inch | in | Foot |
ft | Yard | yd |
Angstrom | AA | (accepted) metric |
Astronomical unit | au | |
Time | Year | |
a | Day | d |
Hour | h | Minute |
min | Second | s |
Pressure | ||
Pascal | Pa | Atmosphere |
atm | mm of Mercury | mmHg |
bar | bar | Pound-force per quare inch |
psi | ||
Energy | ||
Joule | J | metric |
IT calorie | cal | (accepted) metric |
Electron volt | eV (or ev) | |
Power | Horsepower (mechanical) | |
hp | Horsepower (metric) | HP |
Watt | W (or w) | metric |
Temperature | Degree Celsius | |
C | Degree Fahrenheit | F |
Kelvin | K | metric |
Liquid measure | ||
Fluid ounce | fl oz | Gallon |
gal | Liter | l (or lt) |
Additional details can be found in the d.units
data.frame.
ConvUnit(c(1.2, 5.4, 6.7), "in", "m")
#> [1] 0.03048 0.13716 0.17018
# from kilometers to pico meters
ConvUnit(1, from="km", to="pm")
#> [1] 1e+15
# from miles to kilometers
ConvUnit(1, from="mi", to="km")
#> [1] 1.609344
# nautical miles
ConvUnit(1, from="nmi", to="km")
#> [1] 1.852
# from kilo Kelvin to Fahrenheit
ConvUnit(10, from="kK", to="F")
#> [1] 18523.67
# from metric to more quirky units
ConvUnit(c(10, 1), from="hl", to="gal")
#> [1] 264.17205 26.41721
ConvUnit(500, from="ml", to="fl oz")
#> [1] 16.90674
# conversion between non-SI units
ConvUnit(1000, "yd", "mi")
#> [1] 0.5679333
# ... must be the same as
ConvUnit(ConvUnit(1000, "yd", "m"), "m", "mi")
#> [1] 0.5679333