Description Usage Arguments Value See Also Examples
convert_unit()
of a vector or convert_unit_at()
specific columns of a
dataframe.
1 2 3 | convert_unit(x, from, to)
convert_unit_at(x, .at, from, to)
|
x |
A vector or dataframe. |
from |
the unit in which the measurement was made. |
to |
the unit to which the measurement is to be converted. |
.at |
A character vector of names, positive numeric vector of
positions to include, or a negative numeric vector of positions to
exlude. Only those elements corresponding to |
An object with the same structure as x
(vector or dataframe).
measurements::conv_unit()
, purrr::map_at()
.
Other general functions to perform common transforms: standardize_at
1 2 3 4 5 6 7 8 9 10 11 | # For all units see ?measurements::conv_unit()
convert_unit(10, "mm2", "hectare")
convert_unit(1:3, from = "m", to = "mm")
convert_unit(1:3, "mph", "kph")
dfm <- data.frame(dbh = c(10, 100), name = c(10, 100))
convert_unit_at(dfm, .at = "dbh", from = "mm2", to = "hectare")
# All columns
convert_unit_at(dfm, .at = c("dbh", "name"), from = "mm2", to = "hectare")
# Same
convert_unit_at(dfm, .at = names(dfm), from = "mm2", to = "hectare")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.