convert_temperature: Convert from one temperature metric to another

Description Usage Arguments Value Author(s) Examples

Description

This function allows you to convert a vector of temperature values between Fahrenheit, Celsius, and degrees Kelvin.

Usage

1
convert_temperature(temperature, old_metric, new_metric, round = 2)

Arguments

temperature

A numeric vector of temperatures to be converted.

old_metric

The metric from which you want to convert. Possible options are:

  • fahrenheit, f

  • kelvin, k

  • celsius, c

new_metric

The metric to which you want to convert. The same options are possible as for old_metric.

round

An integer indicating the number of decimal places to round the converted value.

Value

A numeric vector with temperature converted to the metric specified by the argument new_metric.

Author(s)

#' Joshua Ferreri joshua.m.ferreri@gmail.com, Brooke Anderson brooke.anderson@colostate.edu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(lyon)
lyon$TemperatureF <- convert_temperature(lyon$TemperatureC,
   old_metric = "c", new_metric = "f")
lyon

data(norfolk)
norfolk$TempC <- convert_temperature(norfolk$TemperatureF,
   old_metric = "f", new_metric = "c")
norfolk

data(angeles)
angeles$TemperatureC <- convert_temperature(angeles$TemperatureK,
   old_metric = "kelvin", new_metric = "celsius")
angeles

weathermetrics documentation built on May 2, 2019, 2:18 a.m.