R/windSpeed.R

Defines functions windSpeed

Documented in windSpeed

#' Wind Speed
#'
#' @description Calculate wind speed in m/s from u & v components
#'
#' @param u first component of wind speed
#' @param v second component of wind speed
#'
#' @return Speed in m/s
#'
#' @export
#'
#' @examples
#' # windSpeed(u, v)
#'

windSpeed <- function(u, v) {

  # Convert u and v to numeric
  # (as.character is necessary to avoid problems when converting from factors)
  uN <- as.numeric(as.character(u))
  vN <- as.numeric(as.character(v))

  ws <- sqrt(uN^2 + vN^2)

  return(ws)

}

Try the kehra package in your browser

Any scripts or data that you put into this service are public.

kehra documentation built on May 2, 2019, 5:16 a.m.