restore_units: Restore units to vector or tabular data

restore_unitsR Documentation

Restore units to vector or tabular data

Description

Operations on tabular data or geodata can result in unit-aware columns being returned to a naive state. This function easily restores them.

Usage

restore_units(to, from)

## Default S3 method:
restore_units(to, from)

## S3 method for class 'data.frame'
restore_units(to, from)

Arguments

to

numeric vector, tabular data or geodata

from

same class as to

Value

same value(s) as from, but with units set as they were in to

Examples

## Not run: 
library(dplyr)
library(units)
df <- mutate(mtcars, mpg = as_units(mpg, "mi/gal"))
grouped <- group_by(df, cyl)
summarised <- summarise_at(grouped, vars(mpg), mean)
restore_units(summarised, from = df)

## End(Not run)


BAAQMD/unittools documentation built on Jan. 28, 2024, 9:14 p.m.