R/one_rm.R

Defines functions calculate_rep_max_list calculate_rep_max rep_max_lander rep_max_wendler rep_max_wathan rep_max_oconnor rep_max_lombardi rep_max_mcglothin rep_max_mayhew rep_max_epley rep_max_brzycki calculate_one_rm one_rm_lander one_rm_wendler one_rm_wathan one_rm_oconnor one_rm_lombardi one_rm_mcglothin one_rm_mayhew one_rm_epley one_rm_brzycki

Documented in calculate_one_rm calculate_rep_max calculate_rep_max_list one_rm_brzycki one_rm_epley one_rm_lander one_rm_lombardi one_rm_mayhew one_rm_mcglothin one_rm_oconnor one_rm_wathan one_rm_wendler rep_max_brzycki rep_max_epley rep_max_lander rep_max_lombardi rep_max_mayhew rep_max_mcglothin rep_max_oconnor rep_max_wathan rep_max_wendler

#' @title Calculate one rep max
#'
#' @description
#' \lifecycle{stable}
#'
#' Calculates the one rep maximum. Possible equations are:
#'
#' - Brzycki
#' - Epley
#' - Mayhew
#' - McGlothin
#' - Lombardi
#' - oConnor
#' - Wathan
#' - Wendler
#'
#' @details
#' For more information go to:
#' \url{https://en.wikipedia.org/wiki/One-repetition_maximum}.
#'
#' @name one_rm_formulas
#'
#' @param reps number of reps.
#' @param lift weight.
#'
#' @return One rep max
#'
#' @aliases NULL
NULL

#' @rdname one_rm_formulas
one_rm_brzycki <- function(reps, lift) {
  return(round(lift / (1.0278 - (0.0278 * reps)), 2))
}

#' @rdname one_rm_formulas
one_rm_epley <- function(reps, lift) {
  return(round(lift * (1 + (reps / 30)), 2))
}

#' @rdname one_rm_formulas
one_rm_mayhew <- function(reps, lift) {
  return(round((100 * lift) / (52.2 + (41.9 * (
    exp(-0.055 * reps)
  ))), 2))
}

#' @rdname one_rm_formulas
one_rm_mcglothin <- function(reps, lift) {
  return(round((100 * lift) / (101.3 - (2.67123 * reps)), 2))
}

#' @rdname one_rm_formulas
one_rm_lombardi <- function(reps, lift) {
  return(round(lift * reps ^ 0.10, 2))
}

#' @rdname one_rm_formulas
one_rm_oconnor <- function(reps, lift) {
  return(round(lift * (1 + (reps / 40)), 2))
}

#' @rdname one_rm_formulas
one_rm_wathan <- function(reps, lift) {
  return(round((100 * lift) / (48.8 + (53.8 * (
    exp(-0.075 * reps)
  ))), 2))
}

#' @rdname one_rm_formulas
one_rm_wendler <- function(reps, lift) {
  return(round((lift * reps * 0.0333) + lift, 2))
}

#' @rdname one_rm_formulas
one_rm_lander <- function(reps, lift) {
  return(round(100 * lift / (101.3 - 2.67123 * reps), 2))
}

#' @title Calculate 1 Rep Max
#'
#' @description
#' \lifecycle{stable}
#'
#' This function takes in the number of repetitions and the lifted weight to
#' calculate an estimated one repetition maximum for that lift. Wathan is
#' probably the best equation to estimate strength.
#'
#' @param reps The number of reps. minimum is 2 reps, maximum is 12 reps.
#' @param lift The weight being lifted
#' @param equation The equation for calculating the 1RM.
#'
#' @return Estimated one rep max
#'
#' @details
#' Note that 1RM are estimates and can be very different for all exercises. For
#' more information go to:
#' \url{https://en.wikipedia.org/wiki/One-repetition_maximum}.
#'
#' @references
#' Lesuer, DA, Mccormick, JH, Mayhew, JL et al. (1997). "The accuracy of
#' prediction equations for estimating 1-RM performance in the bench press,
#' squat, and deadlift". J Strength Cond Res 11: 211–213.
#'
#' @examples
#' calculate_one_rm(8, 100)
#' @rdname calculate_one_rm
#' @export
#' @importFrom checkmate assert_number
calculate_one_rm <- function(reps, lift, equation = "wathan") {
  checkmate::assert_number(reps, lower = 2, upper = 12)
  checkmate::assert_number(lift, lower = 1)
  choices <- c(
    "brzycki",
    "epley",
    "mayhew",
    "mcglothin",
    "lombardi",
    "oconnor",
    "wathan",
    "wendler",
    "lander"
  )
  checkmate::assert_choice(equation, choices)
  estimate <- switch(
    equation,
    "brzycki" = one_rm_brzycki(reps, lift),
    "epley" = one_rm_epley(reps, lift),
    "mayhew" = one_rm_mayhew(reps, lift),
    "mcglothin" = one_rm_mcglothin(reps, lift),
    "lombardi" = one_rm_lombardi(reps, lift),
    "oconnor" = one_rm_oconnor(reps, lift),
    "wathan" = one_rm_wathan(reps, lift),
    "wendler" = one_rm_wendler(reps, lift),
    "lander" = one_rm_lander(reps, lift)
  )
  return(estimate)
}

#' @title Calculate 2-15 rep max
#'
#' @description
#' \lifecycle{stable}
#'
#' Calculates the 2-15 rep maximum. Possible equations are:
#'
#' - Brzycki
#' - Epley
#' - Mayhew
#' - McGlothin (`.NotYetImplemented()`)
#' - Lombardi
#' - oConnor
#' - Wathan (`.NotYetImplemented()`)
#' - Wendler
#'
#' @details
#' For more information go to:
#' \url{https://en.wikipedia.org/wiki/One-repetition_maximum}.
#'
#' @name rep_max_formulas
#'
#' @param reps number of reps.
#' @param one_rm one rep max.
#'
#' @return One rep max
#'
#' @aliases NULL
NULL

#' @rdname rep_max_formulas
rep_max_brzycki <- function(reps, one_rm) {
  floor((one_rm * (37 - reps)) / 36)
}

#' @rdname rep_max_formulas
rep_max_epley <- function(reps, one_rm) {
  floor(one_rm / ((1 + (reps / 30))))
}

#' @rdname rep_max_formulas
rep_max_mayhew <- function(reps, one_rm) {
  floor((one_rm * (52.2 + (41.9 * exp(
    -1 * (reps * 0.055)
  )))) / 100)
}

#' @rdname rep_max_formulas
rep_max_mcglothin <- function(reps, one_rm) {
  .NotYetImplemented()
}

#' @rdname rep_max_formulas
rep_max_lombardi <- function(reps, one_rm) {
  floor(one_rm / reps ^ (1 / 10))
}

#' @rdname rep_max_formulas
rep_max_oconnor <- function(reps, one_rm) {
  floor(one_rm / (1 + reps * 0.025))
}

#' @rdname rep_max_formulas
rep_max_wathan <- function(reps, one_rm) {
  floor((one_rm * (48.8 + (53.8 * exp(
    -1 * (reps * 0.075)
  )))) / 100)
}

#' @rdname rep_max_formulas
rep_max_wendler <- function(reps, one_rm) {
  .NotYetImplemented()
}

#' @rdname rep_max_formulas
rep_max_lander <- function(reps, one_rm) {
  floor((one_rm * (101.3 - 2.67123 * reps)) / 100)
}

#' @title Maximum weight for a repetition
#'
#' @description Calculate a maximum weight for a given repetition
#'
#' @param reps Number of reps.
#' @param one_rm One rep max.
#' @param equation The equation for calculating the 1RM.
#'
#' @return Weight in kg.
#'
#' @details Maximum weight for n reps.
#'
#' @examples
#' calculate_rep_max(10, 95)
#' @rdname calculate_rep_max
#' @export
#' @importFrom checkmate assert_number assert_choice
calculate_rep_max <- function(reps, one_rm, equation = "wathan") {
  checkmate::assert_number(reps, lower = 1, upper = 15)
  checkmate::assert_number(one_rm, lower = 1)
  choices <- c(
    "brzycki",
    "epley",
    "mayhew",
    "mcglothin",
    "lombardi",
    "oconnor",
    "wathan",
    "wendler",
    "lander"
  )
  checkmate::assert_choice(equation, choices)
  estimate <- switch(
    equation,
    "brzycki" = rep_max_brzycki(reps, one_rm),
    "epley" = rep_max_epley(reps, one_rm),
    "mayhew" = rep_max_mayhew(reps, one_rm),
    "mcglothin" = rep_max_mcglothin(reps, one_rm),
    "lombardi" = rep_max_lombardi(reps, one_rm),
    "oconnor" = rep_max_oconnor(reps, one_rm),
    "wathan" = rep_max_wathan(reps, one_rm),
    "wendler" = rep_max_wendler(reps, one_rm),
    "lander" = rep_max_lander(reps, one_rm)
  )
  return(estimate)
}

#' @title Calculate the weight for 1-12 reps
#'
#' @description For 1 to 12 reps, calculate the weight, based on a (estimated)
#'   one rep max.
#'
#' @param reps Number of reps.
#' @param lift The weight being lifted
#' @param equation The equation for calculating the 1RM.
#'
#' @return List of weights for 1 to 12 reps
#'
#' @details This is based on a given equations.
#'
#' @examples
#' calculate_rep_max_list(10, 95)
#' @rdname calculate_rep_max_list
#' @export
calculate_rep_max_list <- function(reps, lift, equation = "epley") {
  weights <- c()
  if (reps == 1 ) {
    one_rm <- lift
  } else {
    one_rm <- calculate_one_rm(reps, lift, equation = equation)
  }
  i = 2
  while (i <= 12) {
    weight <- calculate_rep_max(i, one_rm, equation = equation)
    weights <- append(weights, weight)
    i = i + 1
  }
  df <- data.frame(cbind(seq(2,12), weights))
  df <- rbind(c(1, one_rm), df)
  colnames(df) <- c("reps", "kilograms")
  return(df)
}
MarijnJABoer/befitteR documentation built on April 24, 2020, 5:43 a.m.