This function returns people's BMIs. The function the returns the BMIs does what I want but I cannot figure out how to print the WEIGHTS of those people that have a BMI over 25. I feel like I should be subscripting but how do I get that association? Thanks in advance.
heights_in_cms <- c(180, 165, 160, 193)
weights_in_kg <- c(87, 58, 65, 100)
bmi_calc <- function(h, w) {
bmi = w / (h / 100)^2
cat("BMIs are:", bmi, "\n")
for (b in bmi) {
if (b > 25) {
print(b)
}
}
}
bmi_seq <- bmi_calc(heights_in_cms, weights_in_kg)