Description Usage Arguments Value See Also Examples
Unlike measurements::conv_unit()
this function doesn't fail if it can't
convert a unit – instead it outputs NA.
1 | convert_units(x, from, to, quietly = FALSE)
|
x |
a numeric vector giving the measurement value in its original units. |
from |
the unit in which the measurement was made. |
to |
the unit to which the measurement is to be converted. |
quietly |
|
As in measurements::conv_unit()
if possible, or NA.
Other helpers: valid_units
1 2 3 4 5 6 7 8 9 | convert_units(c(1, NA), from = "cm", to = "m")
# Same
measurements::conv_unit(c(1, NA), from = "cm", to = "m")
# Passes
convert_units(c(1, 10), from = "cm", to = c("m", "bad"))
convert_units(c(1, 10), from = "cm", to = c("m", "bad"), quietly = TRUE)
# Errs
try(measurements::conv_unit(c(1, 10), from = "cm", to = c("m", "bad")))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.