Skip to content

Commit

Permalink
add warnings if height in cm not m is detected
Browse files Browse the repository at this point in the history
  • Loading branch information
dosgillespie committed Sep 1, 2023
1 parent 065475a commit 180d1b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion R/AlcBinge.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,17 @@ AlcBinge <- function(
#data[sex == "Male", rwatson := 0.55]
#data[sex == "Female", rwatson := 0.68]

# Note that the numbers in the formulae below come from "The Estimation of Blood Alcohol Concentration - Widmark Revisited" - Posey and Mozayani
# height must be in meters and weight in kg

if(max(data$height, na.rm = T) > 100) {
warning("AlcBinge: height in cm not m - correct the input data")
}

data[sex == "Male", rwatson := 0.39834 + ((12.725 * height - 0.11275 * age + 2.8993) / weight)]
data[sex == "Female", rwatson := 0.29218 + ((12.666 * height - 2.4846) / weight)]


data[ , age_temp := NULL]

return(data)
Expand Down
7 changes: 7 additions & 0 deletions R/AlcBinge_stapm.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ AlcBinge_stapm <- function(
by = c("age_cat", "sex", "imd_quintile"),
all.x = T, all.y = F, sort = F)

# Note that the numbers in the formulae below come from "The Estimation of Blood Alcohol Concentration - Widmark Revisited" - Posey and Mozayani
# height must be in meters and weight in kg

if(max(data$height, na.rm = T) > 100) {
warning("AlcBinge: height in cm not m - correct the input data")
}

data[sex == "Male", rwatson := 0.39834 + ((12.725 * height - 0.11275 * age + 2.8993) / weight)]
data[sex == "Female", rwatson := 0.29218 + ((12.666 * height - 2.4846) / weight)]

Expand Down

0 comments on commit 180d1b9

Please sign in to comment.