parse_unit: Parse unit from string

Description Usage Arguments Details Examples

View source: R/unit_strings.R

Description

Converts a character string to units. If available, unit names are replaced by the corresponding symbol.

Usage

1
parse_unit(string)

Arguments

string

(character) Unit string to parse.

Details

The string may only contain unit names, numeric exponents, and operators "/", "*", "^", "(", and ")". Spaces between unit names are interpreted as "*". This includes the following standard formats:

Unlike parse_unit:

For a list of supported units and their notation, see the UDUNITS-2 Units Database.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
parse_unit("m/s")
parse_unit("(m)/(s)")
parse_unit("m s-1")
parse_unit("meters/seconds")
parse_unit("meters seconds-1")
parse_unit("kg * (m^2 / s^3)")
parse_unit("kg (m^2 / s^3)")
parse_unit("kg m2 s-3")
parse_unit("in")
parse_unit("in/s")
parse_unit("<c2><b0>")
parse_unit("<c2><b5>m/s")
parse_unit("mm")
parse_unit("H2O+1 m1 s-1")
## Not run: 
parse_unit("unknown")

## End(Not run)

columbia-glacier/units2 documentation built on July 10, 2017, 12:03 a.m.