Learn R Programming

units (version 0.8-5)

keep_units: Apply a function keeping units

Description

Helper function to apply a function to a units object and then restore the original units.

Usage

keep_units(FUN, x, ..., unit = units(x))

Value

An object of class units.

Arguments

FUN

the function to be applied.

x

first argument of FUN, of class units.

...

optional arguments to FUN.

unit

symbolic unit to restore after FUN.

Details

Provided for incompatible functions that do not preserve units. The user is responsible for ensuring the correctness of the output.

Examples

Run this code
x <- set_units(1:5, m)
keep_units(drop_units, x)

Run the code above in your browser using DataLab