R/height_to_cm.R

Defines functions height_to_cm

Documented in height_to_cm

#' Height to cm
#' @description convert character string of height e.g. "6-4" to a numerical
#' value in cm.   Note: it will break if the height is above 10feet.
#' @param x height character value
#'
#' @return numerical value in cm
#' @export
#'
#' @examples height_to_cm("6-4")

height_to_cm <- function(x) {
  feet = substr(x, 1, 1) %>% as.numeric()
  inches = substr(x, 3, 4) %>% as.numeric()
  cm = (feet * 30.48) + (inches * 2.54)
  return(cm)
}
becausejustyn/nflhelpR documentation built on March 29, 2022, 10:10 p.m.