Primary exercises

  1. In the survey dataset add a new column feet with heights reported in feet unit (1 foot = 30.48 cm).

  2. In the survey dataset add a new column diffWritingHandSpan : the difference of span1 (writing hand) and span2 (non-writing hand).

  3. In the pulse dataset add new weight variables pound and stone (1 kg = 2.20462 pound = 0.157473 stone).

  4. In the survey dataset convert the variables smokes from character to factor with levels {“never”,“occas”,“regul”, “heavy”}, in that order.

Extra exercises

In the survey dataset:

  1. Add a new column diffHandSpan : the absolute difference between span1 (writing hand) and span2 (non-writing hand). Hint: use abs function (?abs).

  2. Change height unit from cm to inch (1 cm = 0.393701 inch).

  3. Produce the tibble containing the personal information of only those having height (in foot unit) between and including 6.0 and 6.5 feet.

  4. How many observations are in the following call, please try to reason before running the statement.

filter(mutate(filter(survey, height> 190),feet=height/30.48),height<=190 )
  1. The following table is one of many BMI classifications:
classification bmi
1 underweight <18.5
2 normal 18.5-24.9
3 overweight 25-29.9
4 obese >=30

Add the variable BMI_class to the pulse data set. Note that you will need to round (see ?round an additional argument digits) the BMI calculation to one decimal digit to fit into classification values in the table given above. Use the helper function case_when.

  1. Age classification:
classification age notation
1 adult >19 (19,∞)
2 adolescent >=10 and <=19 [10,19]
3 child >=1 and <=9 [1,9]
4 infant <1 (-∞,1)

Add the variable age_group to the survey dataset.



Copyright © 2024 Biomedical Data Sciences (BDS) | LUMC