calculate_ibw: Ideal Body Weight Calculation

calculate_ibwR Documentation

Ideal Body Weight Calculation

Description

Calculates Ideal Body Weight (IBW) by Devine formula (same as Hamwi), with several other available methods. Converts units if needed. Available methods for IBW calculations are described in Peterson et al..

The function is not vectorized, so to perform multiple calculations, first create a vectorized version of the function as in the examples below

This version is only the Devine method, and does not use the 'switch()' function. This did not avoid the vectorization issue, however, and it does not work on dataframes without converting to a vectorized version. Kept only for documentation, since it is no faster than the other version.

Usage

calculate_ibw(
  height,
  gender = NA,
  weight_units = "kg",
  height_units = "in",
  method = "Devine"
)

calculate_ibw_devine(
  height,
  gender = NA,
  weight_units = "kg",
  height_units = "in",
  method = "Devine"
)

Arguments

height

Body Height (m)

weight_units

Desired units for result

height_units

If height is in Units other than m, specifiy here to properly convert for calucations ("m", "cm", or "in")

method

string for IBW formula to use for calculation ("Hamwi", "Devine", "Robinson", "Broca", "Miller", "Hammond")

Value

a numeric vector with Ideal Body Weight (defaults to lbs)

Examples

library(tabletools)
ibw_methods <- c("Hamwi", "Devine", "Robinson", "Broca", "Miller", "Hammond")
names(ibw_methods) <- ibw_methods
sapply(ibw_methods, \(x)calculate_ibw(height = 70, gender="M", method = x))
sapply(ibw_methods, \(x)calculate_ibw(height = 70, gender="F", method = x))
# if gender missing returns NA
sapply(ibw_methods, \(x)calculate_ibw(height = 70,  method = x))
# Change Units for desired IBW result
# if not specified defaults to LBS
sapply(ibw_methods, \(x)calculate_ibw(height = 70, gender="F", method = x))
sapply(ibw_methods, \(x)calculate_ibw(height = 70, gender="F", method = x, weight_units="kg"))
sapply(ibw_methods, \(x)calculate_ibw(height = 70, gender="F", method = x, weight_units="kilograms"))
sapply(ibw_methods, \(x)calculate_ibw(height = 70, gender="F", method = x, weight_units="g"))
sapply(ibw_methods, \(x)calculate_ibw(height = 70, gender="F", method = x, weight_units="lbs"))

# use different input height, indicate using "height_units" argument
calculate_ibw(height = 1.778, gender="F", height_units = "m")
calculate_ibw(height = 177.8, gender="F", height_units = "cm")


dat <- data.frame(id =1:10,
gender = sample(c("M", "F", NA), 10, replace = T),
height = rnorm(10, 1.7, sd=0.2),
weight = rnorm(10, 100, sd=20))
library(dplyr)
dat |>
  mutate(ibw = calculate_ibw(height, gender, height_units = "m"))

JMLuther/tabletools documentation built on April 14, 2025, 3:09 a.m.