- Input: \(Height = 180cm\) and \(Weight = 90 kilograms\)
Category <- c("Underweight", "Normal Weight", "Overweight", "Obesity")
get_weight_catory <- function(height, weight){
bmi <- round( weight/ ((height/100) * (height/100)), digit = 1)
if(bmi< 18.5){ category<- Category[1]}
else if (bmi>=18.5 & bmi<= 24.9){category<-Category[2]}
else if( bmi >= 25 & bmi <= 29.9){category<-Category[3]} else{category<-Category[4]}
return (c( "BMI" = bmi, " Weight Catorgary" = category) )
}
- Output: BMI & Weight Catorgary
get_weight_catory(180, 90)
## BMI: Weight Catorgary :
## "27.8" "Overweight"