R Units
Units is a package to set units on numeric variables.
Contents
Installation
install.packages('units')
Usage
Variables with a set unit are sometimes more convenient to use in visualization packages like table1.
The following are all effectively equivalent:
library(units)
units(x) <- "m/s"
units(x) <- as_units("m/s")
units(x) <- make_units(m/s)
x <- set_units(x, m/s)In a magrittr pipeline, this is a convenient way to use this package:
x %>% set_units(m/s) %>% ...
Note that make_units can take a bare expression rather than a quoted unit.
