convert_temperature {weathermetrics}R Documentation

Convert from one temperature metric to another

Description

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

Usage

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

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


[Package weathermetrics version 1.2.2 Index]