R/strenght_index.R

Defines functions calculate_strenght_index calculate_robi calculate_sinclair wilks_to_text calculate_wilks

Documented in calculate_robi calculate_sinclair calculate_wilks

#' @title Calculate Wilks score
#'
#' @description
#' \lifecycle{stable}
#'
#' Calculate the Wilks score for a lift, or a combination of lifts
#'
#' @param weight weight in kg.
#' @param sex `male` or `female`.
#' @param lift weight of a lift in kg.
#' @param method either `new` or `old`.
#'
#' @return Wilks score
#'
#' @details For more info see:
#' \url{https://en.wikipedia.org/wiki/Wilks_Coefficient}
#' Vanderburgh, Paul M; Batterham, Alan M (1999). "Validation of the Wilks
#' powerlifting formula". Medicine & Science in Sports & Exercise. 31 (12):
#' 1869–75. doi:10.1097/00005768-199912000-00027. PMID 10613442.
#'
#' @examples
#' calculate_wilks(weight = 83, sex = "male", lift = 150)
#' @rdname calculate_wilks
#' @export
calculate_wilks <- function(weight, sex, lift, method = "old") {
  checkmate::assert_number(weight, lower = 0)
  check_sex(sex)
  checkmate::assert_number(lift, lower = 0)
  if (method == "old") {
    if (sex == "male") {
      a <- -216.0475144
      b <- 16.2606339
      c <- -0.002388645
      d <- -0.00113732
      e <- 0.00000701863
      f <- -0.00000001291
    }
    if (sex == "female") {
      a <- 594.31747775582
      b <- -27.23842536447
      c <- 0.82112226871
      d <- -0.00930733913
      e <- 0.00004731582
      f <- -0.00000009054
    }
    wilks <-
      (500 / (a +
                b * weight +
                c * weight ^ 2 +
                d * weight ^ 3 +
                e * weight ^ 4 +
                f * weight ^ 5)) * lift
  } else {
    warning("New wilks has not yet been implemented...")
  }
  return(wilks)
}

wilks_to_text <- function(wilks) {
  # https://wilkscalculator.com/a/what-is-a-good-wilks-score
  .NotYetImplemented()
  wilks_lkp <- data.frame(
    "wilks_points" = c(250, 300, 350, 400, 450, 500, 550, 600),
    "level" = c(
      "Promising beginner",
      "Solid beginner",
      "Regional Hero",
      "National level",
      "World-class",
      "Elite",
      "Super Elite",
      "GOAT material"
    ),
    "remark" = c(
      "You don't walk in off the street without training doing this",
      paste("This could be achieved in 1-2 years of focused effort and",
            "training for most lifters"),
      paste("In smaller countries/states, this might win you a medal at the",
            "nationals"),
      paste("Odds are, that in most countries you will be competing at a",
            "national level with 400+ Wilks"),
      "Congratulations, you are going to the world championships!",
      "You are probably in the top 10 in the world in your weight!",
      paste("Less that 100 people in the world have ever achieved 550+",
      "Wilks points."),
      paste("You are in the running to be the Greatest Of All Time. Only a",
      "handful of lifters have ever achieved 600+ Wilks - none of them in",
      "doping tested federations.")
    )
  )
}

#' @title Calculate Sinclair index
#'
#' @description The Sinclair Coefficients are a method to compare different
#'   weight classes in Olympic weightlifting.
#'
#' @param weight weight in kg
#' @param sex one of `male` or `female`.
#' @param lift_total Total weight (kg) that was lifted.
#'
#' @return Sinclair index
#'
#' @details For more information see:
#'   \url{https://en.wikipedia.org/wiki/Sinclair_Coefficients}
#'
#' @examples
#' calculate_sinclair(61.9, "male", 320)
#' @rdname calculate_sinclair
#' @export
#' @importFrom checkmate assert_number
calculate_sinclair <- function(weight, sex, lift_total) {
  # for the cycle of 2017, 2018, 2019, 2020
  # lift_total = snatch + clean and jerk
  # https://en.wikipedia.org/wiki/Sinclair_Coefficients
  # https://www.bcweightlifting.ca/sinclairformula/
  checkmate::assert_number(weight, lower = 0)
  check_sex(sex)
  checkmate::assert_number(lift_total, lower = 0)
  if (sex == "male") {
    a <- 0.751945030
    b <- 175.508
  }
  if (sex == "female") {
    a <- 0.783497476
    b <- 153.655
  }
  c <- log10(weight / b)
  d <- a * (c ** 2)
  sinclair <- lift_total * (10 ** d)
  return(sinclair)
}

#' @title Calculate Robi index
#'
#' @description Developed by Former IWF Technology Director Robert Nagy, the
#' "Robi Points" is the official IWF calculation method to compare individual
#' athlete Total results across each of the IWF body weight categories at Junior
#' and Senior level.
#'
#' @param weight weight in kg
#' @param sex one of `male` or `female`.
#' @param lift_total Total weight (kg) that was lifted.
#'
#' @return Robi index
#'
#' @details For more information see: \url{https://www.iwf.net/robi-points/}
#'
#' @examples
#' calculate_robi(106, "male", 320)
#' @rdname calculate_robi
#' @export
#' @importFrom utils head
#' @importFrom checkmate assert_number
calculate_robi <- function(weight, sex, lift_total) {
  # https://barbend.com/robi-vs-sinclair-weightlifting/
  checkmate::assert_number(weight, lower = 0)
  check_sex(sex)
  checkmate::assert_number(lift_total, lower = 0)
  b <- 3.3219281
  if (sex == "male") {
    categories <- data.frame(
      weight_kg = c(56, 62, 69, 77, 85, 94, 105, 999),
      record = c(307, 333, 359, 380, 396, 417, 437, 477)
    )
    categories$A <- 1000 / (categories$record ** b)
  }
  if (sex == "female") {
    categories <- data.frame(
      weight_kg = c(48, 53, 58, 63, 69, 75, 90, 999),
      record = c(217, 233, 252, 262, 276, 296, 283, 348)
    )
    categories$A <- 1000 / (categories$record ** b)

  }
  A <- utils::head(categories[categories$weight_kg >= weight, "A"], n = 1)
  robi_points <- A * lift_total ** b
  return(robi_points)
}

calculate_strenght_index <- function(weight, age, sex) {
  # http://www.strongur.io/strength-index/
  .NotYetImplemented()
}
MarijnJABoer/befitteR documentation built on April 24, 2020, 5:43 a.m.