Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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))

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.

Value

An object of class units.

Examples

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

units

Measurement Units for R Vectors

v0.7-1
GPL-2
Authors
Edzer Pebesma [aut, cre] (<https://orcid.org/0000-0001-8049-7069>), Thomas Mailund [aut], Tomasz Kalinowski [aut], James Hiebert [ctb], Iñaki Ucar [aut] (<https://orcid.org/0000-0001-6403-5550>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.