Convert distance (and area) values between different units
Source:R/convert_dist_units.R
convert_dist_units.Rd
Convert distance (and area) values between different units
Arguments
- dist
Numeric or units object
- from
Existing unit for dist, Default:
NULL
. If dist is a units object, the numerator is used as "from"- to
Unit to convert distance to, Default: 'meter'
- drop
If
TRUE
, return numeric. IfFALSE
, return class units object.- digits
Number of digits to include in result; defaults to
NULL
.
Value
Object created by units::set_units()
See also
Other dist:
convert_dist_scale()
,
is_dist_units()
Examples
convert_dist_units(1, from = "mile", to = "km")
#> 1.609344 [km]
convert_dist_units(3, from = "ft", to = "yard")
#> 1 [yard]
mile <- units::set_units(1, "mi")
convert_dist_units(mile, to = "feet")
#> 5280 [feet]
is_same_units(mile, "mile")
#> [1] TRUE