🚗 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.

👋 Before you go, leave an anonymous rating & feedback

Average rating 4.5 / 5. Vote count: 23

No votes so far! Be the first to rate this post.

Please share any positive or negative feedback you may have.

Feedback is completely anonymous

3 Comments
Newest
Oldest Most Voted
Jobert Richie

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”))
  }
 }

Sabina

Hi Jobert,

Could you share with us the error message you are receiving?

Jobert Richie

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!

3
0
Questions or comments?x