Learn R Programming

aNCA (version 0.1.0)

simplify_unit: Simplify compound unit expressions

Description

This function takes a units object or a character string representing a unit expression and returns a simplified units using the units package simplifications.

Usage

simplify_unit(x, as_character = FALSE)

Value

A simplified units object, or a list of units objects if input is a vector.

Arguments

x

A units object, character string, or vector of either to be simplified.

as_character

Logical. TRUE returns the result as a character, FALSE (default) as a unit object.

Examples

Run this code
# Using a units object
u <- units::set_units(1, "L*g/mg", mode = "standard")
simplify_unit(u)

# Using a character string
simplify_unit("(mg*L)/(mL)")

Run the code above in your browser using DataLab