R/ct.R

Defines functions ct

Documented in ct

#' CONTACT RATE FUNCTION
#'
#' This function measures the ratio of times the batter makes contact with the ball
#' @param x Dataset containing batting statistics
#' @keywords ct
#' @export
#' @examples
#' ct()

ct <- function(x){
  if("K" %in% colnames(x)){
    k <- x$K
  } else{
    k <- x$SO
  }
  CT <- (x$AB - k)/x$AB
}
DevinOrman/mlbstats documentation built on May 14, 2019, 1:58 a.m.