units (version 0.6-7)

units: Set measurement units on a numeric vector

Description

Set measurement units on a numeric vector

Convert units

retrieve measurement units from units object

Usage

# S3 method for numeric
units(x) <- value

# S3 method for units units(x) <- value

# S3 method for logical units(x) <- value

# S3 method for units units(x)

Arguments

x

numeric vector, or object of class units

value

object of class units or symbolic_units, or in the case of set_units expression with symbols that can be resolved in ud_units (see examples).

Value

object of class units

the units method retrieves the units attribute, which is of class symbolic_units

Details

if value is of class units and has a value unequal to 1, this value is ignored unless units_options("simplifiy") is TRUE. If simplify is TRUE, x is multiplied by this value.

Examples

Run this code
# NOT RUN {
x = 1:3
class(x)
units(x) <- as_units("m/s")
class(x)
y = 2:5
a <- set_units(1:3, m/s)
units(a) <- with(ud_units, km/h)
a
# convert to a mixed_units object:
units(a) = c("m/s", "km/h", "km/h")
a
# }

Run the code above in your browser using DataLab