View source: R/ct_convert_unit.R
| ct_convert_unit | R Documentation |
Convert a numeric value from one unit to another. It supports area, distance (length), and angle units.
ct_convert_unit(x, from, to, show_units = FALSE)
x |
Numeric. Value(s) to convert. |
from |
Character. The unit to convert from. Can be any synonym
e.g. |
to |
Character. The unit to convert to. Can also be any synonym. |
show_units |
Logical. If |
A numeric vector of converted values.
units_table() for supported units and synonyms.
# Distance
ct_convert_unit(1000, "m", "km")
ct_convert_unit(1, "mile", "m")
ct_convert_unit(12, "inches", "ft")
# Area
ct_convert_unit(1, "acre", "m2")
ct_convert_unit(2, "km2", "hectare")
# Angle
ct_convert_unit(180, "deg", "rad")
ct_convert_unit(pi, "rad", "deg")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.