🚗 Video too fast or too slow? Click the gear icon ⚙️ at the bottom-right to change the speed!
Lesson code
Please download the zip folder below to code along with the instructor!
After downloading, unzip the folder, open the RStudio Project file within, then open the “VIDEO_CODE_ALONG” script and type along with the instructor in the video above!
Lesson notes
The written guide below is an accompaniment to the lesson video. You may read through it if you prefer written tutorials to video content.
Hello
I am receiving an error when typing this code. What could be the problem, please?
BMI <- medicaldata::smartpill %>%
as_tibble() %>%
select(Weight, Height) %>%
mutate(BMI = calc_bmi(Weight, Height)) %>%
head(20) %>%
select(BMI)
for (bmi in BMI) {
if (bmi < 18.5) {
print(paste(bmi, “is underweight”))
}
else if (bmi>=18.5 & bmi < 25) {
print(paste(bmi, “is normal BMI”))
}
else if (bmi >= 25 & bmi < 30) {
print(paste(bmi, “is overweight”))
}
else {
print(paste(bmi, “is obese”))
}
}
Hi Jobert,
Could you share with us the error message you are receiving?
Hi Sabina!
Sorry for the late reply. I think it’s due to the fact that I rather used the ifelse syntax and it worked perfectly.
Thank you!