rr-formula

why is the formular i created in my r-code not working


Help pls! I ve trying to create this BMI formular to run as code. Not sure what I am doing wrong. Still a newbie in this world of coding. Here's what I attempted

weight= 79
height= 179
BMI<= as.formula((weight/(height)^2)*703)
print BMI

Solution

  • Is this what you're trying to do?

    weight <- 79
    height <- 179
    BMI <- (weight/(height)^2) * 703
    print(BMI)
    [1] 1.73331
    

    Why is the number "703" in there?

    Shouldn't it be:

    weight <- 79
    height <- 179
    BMI <- (weight/(height/100)^2)
    print(BMI)
    [1] 24.65591