Skip to content

Instantly share code, notes, and snippets.

@damianooldoni
Last active October 7, 2018 14:13
Show Gist options
  • Save damianooldoni/169af1d9f1699896c47b865389a46a58 to your computer and use it in GitHub Desktop.
Save damianooldoni/169af1d9f1699896c47b865389a46a58 to your computer and use it in GitHub Desktop.
Function to calculate the theoretical maximum Heart Rate (HRmax)
#' Function to caclulate the theoretical maximum Heart Rate (HRmax)
#'
#' @param sex (character) "M" or "F"
#' @param age (numeric) Age in years
#' @param weight (numeric) Weight in kilograms
#'
#' @return theoretical maximum Heart Rate
#' @examples
#' get_HRmax(sex = "M", age = 35, weight = 61)
#'
get_HRmax <- function(sex, age, weight) {
HRmax <- 210
if (sex == "M") {
HRmax <- HRmax + 4
}
HRmax <- HRmax - weight/11 - age/2
return(HRmax)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment