uc: Unit conversion function

Description Usage Arguments Value References Examples

View source: R/Units.R

Description

Unit conversion function "from"-"to"

Usage

1
uc(x, from, to)

Arguments

x

A quantity to be conversed (atomic vector or list)

from

Valid unit name (character)

to

Valid unit name (character)

Value

Converted quantity (atomic vector or list as per input)

References

  1. http://en.wikipedia.org/wiki/Systems_of_measurement

  2. http://en.wikipedia.org/wiki/Conversion_of_units

  3. http://en.wikipedia.org/wiki/Api_gravity

  4. http://cran.r-project.org/web/packages/marelac/

  5. http://petrowiki.org

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 uc(1, "mkm2", "D")
 uc(1, "mkm2", "mD")
 uc(u(1:5, "kg"), "kg", "lb")
 uc(u(list(1, 2), "ton"), "ton", "lb")
 uc(u(data.frame(x1 = 1:3, x2 = 4:6), "ft3"), "ft3", "cm3")
 uc(1, "ft3", "l")
 uc(1, "ft3", "cm3")
 uc(1, "bbl", "l")
 uc(150, "m", "km") + u(c(1.0, 2.0, 3.5), "km")
 uc(1.5, "cP", "Pa*s")
 # Example below with correct units
 uc(1, "kg/m3", "lb/ft3")
 # Example below with incorrect units causes an error
 ## Not run: uc(1, "kg/m3", "lbft3")

R-kicker/unitconv documentation built on Feb. 12, 2021, 12:33 a.m.