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

You need to unzip this folder to code along. Or “Extract All” on Windows. See our video explanation of this if you are unsure.

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, please rate your satisfaction with this lesson

Ratings are completely anonymous

Average rating 5 / 5. Vote count: 4

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

Notify of

Oldest Most Voted
Inline Feedbacks
View all comments

Q_prop_women_low_grip_strength <- 
 sarcopenia %>% 
 filter(sex_male_1_female_0 == 0) %>% 
 mutate(low_grip_strength = grip_strength_kg < 20) %>% 
 tabyl(low_grip_strength) %>% 
 .[2,3] * 100

Im not sure i understans the [2,3] in this code and also runninng this code does not show me the percentages despite the tabyl function.



Hi Muna, In this case, the [2,3] is indicating the index we want (row 2 and column 3) and we are multiplying it by 100 to have a percentage. The reason why you are not seeing the percentages is because you need to “call” the object in order to see its value or… Read more »


Thank you, so in this case we are multiplying the number in the row 2 and column 3 of the output from the tabyl which is a table by 100?


Yes, that is correct! 🙂


Very good presentation


for the data quiz, we were advised to use the adorn_pct_formatting() function. the table output shows a new col named “valid_percent”. what does this col refer to (as opposed to n percent)?


Hi Christine, When NA values are present, tabyl() also displays “valid” percentages, i.e., with missing values removed from the denominator.


Got it, that makes sense. Thanks Joy!


yao_bmi %>%   mutate(bmi_integer = as.integer(bmi),  I think there might be something wrong with this part of the code provided in the lesson. We dont define yao_BMI from yao dataset first. I tried to do it in the code with this, but it still didnt work: yao_bmi <- yao %>%   select (bmi) %>%   mutate(bmi_integer… Read more »


Hi Snigdha, yao_bmi is created in section 7, just before the practice question. yao_bmi <- yao %>% select(weight_kg, height_cm) %>% # first obtain the height in meters mutate(height_meters = height_cm/100) %>% # then use the BMI formula mutate(bmi = weight_kg / (height_meters)^2) Please make sure you have run all the code above the code… Read more »

Questions or comments?x