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 isFALSE
. 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
isTRUE
. Default isFALSE
.
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)
# 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)
# 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)
# 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)