convertUnits: Convert length or areal units

View source: R/convertUnits.r

convertUnitsR Documentation

Convert length or areal units

Description

This function converts length and area values from one unit to another (e.g., meters to miles, or square yards to acres). Alternatively, it provides the conversion factor for changing one unit to another.

Usage

convertUnits(from = NULL, to = NULL, x = NULL)

Arguments

from, to

Character: Names of the units to convert from/to. Partial matching is used, and case is ignored. Valid values are listed below. The '*2' values represent areas (e.g., 'm2' is "meters-squared").

  • 'm' or 'meters'

  • 'm2' or 'meters2'

  • 'km' or 'kilometers'

  • 'km2' or 'kilometers2'

  • 'mi' or 'miles'

  • 'mi2' or 'miles2'

  • 'ft' or 'feet'

  • 'ft2' or 'feet2'

  • 'yd' or 'yards'

  • 'yd2' or 'yards2'

  • 'ac' or 'acres'

  • 'ha' or 'hectares'

  • 'nmi' or 'nautical miles'

  • 'nmi2' or 'nautical miles2'

x

Numeric or NULL (default). The value(s) to convert in the unit specified by from. If left as NULL, the conversion factor is reported instead.

See Also

expandUnits, conversionFactors

Examples


# conversion
convertUnits(from = 'm', to = 'km', 250)
convertUnits(from = 'm', to = 'mi', 250)
convertUnits(from = 'm2', to = 'km2', 250)

# conversion factors 
convertUnits(from = 'm', to = 'km')
convertUnits(from = 'm')
convertUnits(to = 'm')


adamlilith/omnibus documentation built on April 12, 2024, 8:46 p.m.