Skip to contents

dta_bmicat() categorizes Body Mass Index (BMI) values into specified weight categories.

Usage

dta_bmicat(
  dat,
  .bmi,
  name = "bmi_cat",
  is_extended = FALSE,
  out_of_range = "",
  as_factor = TRUE,
  as_numeric = FALSE
)

Arguments

dat

A data frame or tibble containing the BMI data.

.bmi

The name of the column in dat containing BMI values.

name

A character string specifying the name of the new column to be created with BMI categories. Default is bmi_cat.

is_extended

A logical value indicating whether to use the extended BMI categories. If TRUE, includes Class 1, 2, and 3 obesity. Default is FALSE. See Details section for more information.

out_of_range

A character string specifying the label for out-of-range BMI values. Default is an empty string.

as_factor

A logical value indicating whether to return the BMI categories as a factor. Default is TRUE.

as_numeric

A logical value indicating whether to convert the factor to numeric. Only applicable if as_factor is TRUE. Default is FALSE.

Value

A data frame or tibble with an additional column for BMI categories.

Details

The standard BMI categories are defined as follows:

Underweight

BMI < 18.5

Healthy weight

18.5 ≤ BMI < 25.0

Overweight

25.0 ≤ BMI < 30.0

Obesity

BMI ≥ 30.0

If is_extended is set to TRUE, the extended BMI categories are:

Underweight

BMI < 18.5

Healthy weight

18.5 ≤ BMI < 25.0

Overweight

25.0 ≤ BMI < 30.0

Class I Obesity

30.0 ≤ BMI < 35.0

Class II Obesity

35.0 ≤ BMI < 40.0

Class III Obesity (Severe)

BMI ≥ 40.0

Examples

data("data_bmicat")
dta_gtable(data_bmicat)
id bmi
STM/4921 21.93635
STM/4396 14.53933
STM/7908 22.09073
STM/7243 27.26801
STM/4801 22.75831
STM/5134 24.96495
STM/7138 15.36971
STM/6802 17.85532
STM/4420 39.24707
STM/6351 26.87495
STM/4933 18.36572
STM/4303 30.81854
STM/7465 16.76574
STM/4587 26.78009
STM/5320 33.56599
# Categorize `bmi` into the standard BMI categories df <- dta_bmicat( dat = data_bmicat, .bmi = bmi, name = bmi_cat, is_extended = FALSE, as_factor = TRUE ) dta_gtable(df)
id bmi bmi_cat
STM/4921 21.93635 Healthy weight
STM/4396 14.53933 Underweight
STM/7908 22.09073 Healthy weight
STM/7243 27.26801 Overweight
STM/4801 22.75831 Healthy weight
STM/5134 24.96495 Healthy weight
STM/7138 15.36971 Underweight
STM/6802 17.85532 Underweight
STM/4420 39.24707 Obesity
STM/6351 26.87495 Overweight
STM/4933 18.36572 Underweight
STM/4303 30.81854 Obesity
STM/7465 16.76574 Underweight
STM/4587 26.78009 Overweight
STM/5320 33.56599 Obesity
# Categorize `bmi` into the extended BMI categories df2 <- dta_bmicat( dat = data_bmicat, .bmi = bmi, name = bmi_cat, is_extended = TRUE, as_factor = TRUE ) dta_gtable(df2)
id bmi bmi_cat
STM/4921 21.93635 Healthy weight
STM/4396 14.53933 Underweight
STM/7908 22.09073 Healthy weight
STM/7243 27.26801 Overweight
STM/4801 22.75831 Healthy weight
STM/5134 24.96495 Healthy weight
STM/7138 15.36971 Underweight
STM/6802 17.85532 Underweight
STM/4420 39.24707 Class 2 Obesity
STM/6351 26.87495 Overweight
STM/4933 18.36572 Underweight
STM/4303 30.81854 Class 1 Obesity
STM/7465 16.76574 Underweight
STM/4587 26.78009 Overweight
STM/5320 33.56599 Class 1 Obesity
# Categorize `bmi` into the standard BMI categories and # convert to numeric df3 <- dta_bmicat( dat = data_bmicat, .bmi = bmi, name = bmi_cat, is_extended = TRUE, as_factor = TRUE, as_numeric = TRUE ) dta_gtable(df3)
id bmi bmi_cat
STM/4921 21.93635 2
STM/4396 14.53933 1
STM/7908 22.09073 2
STM/7243 27.26801 3
STM/4801 22.75831 2
STM/5134 24.96495 2
STM/7138 15.36971 1
STM/6802 17.85532 1
STM/4420 39.24707 5
STM/6351 26.87495 3
STM/4933 18.36572 1
STM/4303 30.81854 4
STM/7465 16.76574 1
STM/4587 26.78009 3
STM/5320 33.56599 4