parse_units: Turn a units string into an internal units representation

Description Usage Arguments Details Value See Also

Description

This function creates parsed units. Unlike unparsed character strings, parsed units are unambiguous and can be used for arithmetic operations.

Usage

1
parse_units(ustrs, delimiter = "|")

Arguments

ustrs

character vector of unit strings, one string per set of units

delimiter

single character. The delimiter can be used to identify complex units - for example, with "|" as the delimiter, you might specify units of "|g SO_4^2-| m^-2 hr^-1". Then "g SO_4^2-" would be considered a single unit with power of 1. "m" and "hr" would also be recognized as units because they are separated by spaces and contain no internal special characters (such as spaces or "^").

Details

Units strings are potentially ambiguous; a delimiter may be used to indicate where the text part of a unit begins and ends. For example, "g soil^-1" will be incorrectly parsed into "g" and "soil^-1", but this can be avoided by wrapping the two-word unit in the delimiter: "|g soil|^-1" will be parsed such that "g soil" is a single unit term.

Definitions

This is a unit: "kg". This is another unit: "kgC_organic^2". This is a unit string: "kgC ha^-1 yr^-1". This is a vector of unit strings: c("kgC ha^-1 yr^-1", "PgN", "ft^3 s^-1").

Implementation

This function is vectorized so that N unit strings will be turned into N internal representations.

Value

list of data.frames, one per unit string passed in

See Also

Other unit-parsing functions: prepare_delimiter, simplify_units, sort_units


appling/unitted documentation built on May 10, 2019, 12:44 p.m.