Nihar Satsangi
10/22/2017
It is defined as the body mass(kg) divided by the square of the body height(m), and is universally expressed in units of kg/m2.
It is an attempt to quantify the amount of tissue mass in an individual, and then categorize that person as underweight, normal weight, overweight, or obese based on that value.
Commonly accepted BMI ranges are underweight: under 18.5 kg/m2, normal weight: 18.5 to 25, overweight: 25 to 30, obese: over 30.
This BMI calculator computes the BMI of the user and then uses that BMI value to analyse the user's risk category.
Firstly, the user is asked to input the weight(kg) and height(m). When this is done, the server first calculates the BMI through the following function:
bmiValue <- function (w,h) w/h^2
#Let's take an example here, taking w=47(kg) and h=1.5(m)
bmiValue(47,1.5)
[1] 20.88889
Then the server passes the bmi value to the following function to analyse the risk category, the user belongs to:
bmirisk <- function (bmi) {
if (!is.na(bmi)) {
if (bmi < 18.5) "Low Risk category but your weight is in the unhealthy range for your height"
else if (bmi <= 25.0) "Low Risk category"
else if (bmi < 30.0) "Moderate Risk category"
else "High Risk category"
} else ""
}
# Taking the same values as before:
bmirisk(bmiValue(47,1.5))
[1] "Low Risk category"