R/functions.R

Defines functions calculate_ds calculate_ks calculate_kp calculate_kda

#' @export
calculate_kda <- function(kills, deaths, assists){
  if(deaths == 0){
    res <- kills + assists
  } else {
    res <- round((kills + assists)/deaths, 2)
  }
  res
}

#' @export
calculate_kp <- function(kills, assists, teamkills){
  if(teamkills == 0){
    res <- 0
  } else {
    res <- round(100*(kills + assists)/teamkills, 2)
  }
  res
}

#' @export
calculate_ks <- function(kills, teamkills){
  if(teamkills == 0){
    res <- 0
  } else {
    res <- round(100*kills/teamkills, 2)
  }
  res
}

#' @export
calculate_ds <- function(deaths, teamdeaths){
  if(teamdeaths == 0){
    res <- 0
  } else {
    res <- round(100*deaths/teamdeaths, 2)
  }
  res
}
LopezJehan/League documentation built on Dec. 17, 2021, 1:11 a.m.