convert | R Documentation |
convert
converts distance/length or area from specified units to other specified units.
convert(x, from = "km", towhat = "mi")
x |
A number or vector of numbers to be converted. |
from |
A string specifying original units of input parameter. Default is 'km' which is kilometers. Note all must be in the same units. Units can be specified as any of the following: c( 'millimeter', 'millimeters', 'centimeter', 'centimeters', 'meter', 'meters', 'kilometer', 'kilometers', "mm", "cm", "m", "km", "sqmm", "sqcm", "sqm", "sqkm", "mm2", "cm2", "m2", "km2", 'inch', 'inches', 'foot', 'feet', 'yard', 'yards', 'mile', 'miles', "in", "ft", "yd", "mi", "sqin", "sqft", "sqyd", "sqmi", "in2", 'ft2', 'yd2', 'mi2' ) Note that m2 is for square meters not square miles. |
towhat |
A strings specifying new units to convert to. Default is 'mi' which is miles. |
This function takes a number, or vector of numbers, representing distance/length or area
in one type of specified units, such as miles, and returns the corresponding number(s)
converted to some other units, such as kilometers. Units can be specified in various ways.
All inputs must be in the same units. All outputs must be in a single set of units as well.
NOTE: For some purposes, Census Bureau does this: "The ANSI standard for converting square kilometers into square miles was used ( 1 square mile = 2.58998811 square kilometers)."
(see https://www.census.gov/geo/reference/state-area.html)
but the conversions in this function use 2.5899881034 not 2.58998811 sqkm/sqmi.
The difference is only 6.6 per billion (roughly 1 in 152 million), which is less than one tenth of a square kilometer out the entire USA.
Returns a number or vector of numbers then length of the input x, with each element corresponding to an input element converted to new units.
get.distances
which allows you to specify a search radius and
get distances only within that radius, and related functions.
convert(1, 'mi', 'km')
convert(c(1e6, 1), 'sqm', 'sqkm')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.