Primary exercises
- In the survey dataset add a new column
feet
with heights reported in feet unit (1 foot = 30.48 cm).
mutate(survey, feet=height/30.48)
# A tibble: 233 × 14
name gender span1 span2 hand fold pulse clap exercise smokes height m.i age feet
<chr> <chr> <dbl> <dbl> <chr> <chr> <dbl> <chr> <chr> <chr> <dbl> <chr> <dbl> <dbl>
1 Alyson female 18.5 18 right right 92 left some never 173 metric 18.2 5.68
2 Todd male 19.5 20.5 left right 104 left none regul 178. imperial 17.6 5.83
3 Gerald male 18 13.3 right left 87 neither none occas NA <NA> 16.9 NA
4 Robert male 18.8 18.9 right right NA neither none never 160 metric 20.3 5.25
5 Dustin male 20 20 right neither 35 right some never 165 metric 23.7 5.41
6 Abby female 18 17.7 right left 64 right some never 173. imperial 21 5.67
7 Andre male 17.7 17.7 right left 83 right freq never 183. imperial 18.8 6
8 Michael female 17 17.3 right right 74 right freq never 157 metric 35.8 5.15
9 Edward male 20 19.5 right right 72 right some never 175 metric 19 5.74
10 Carl male 18.5 18.5 right right 90 right some never 167 metric 22.3 5.48
# … with 223 more rows
- In the survey dataset add a new column
diffWritingHandSpan
: the difference of span1 (writing hand) and span2 (non-writing hand).
mutate(survey, diffWritingHandSpan=span1-span2)
# A tibble: 233 × 14
name gender span1 span2 hand fold pulse clap exercise smokes height m.i age diffWritingHandSpan
<chr> <chr> <dbl> <dbl> <chr> <chr> <dbl> <chr> <chr> <chr> <dbl> <chr> <dbl> <dbl>
1 Alyson female 18.5 18 right right 92 left some never 173 metric 18.2 0.5
2 Todd male 19.5 20.5 left right 104 left none regul 178. imperial 17.6 -1
3 Gerald male 18 13.3 right left 87 neither none occas NA <NA> 16.9 4.7
4 Robert male 18.8 18.9 right right NA neither none never 160 metric 20.3 -0.100
5 Dustin male 20 20 right neither 35 right some never 165 metric 23.7 0
6 Abby female 18 17.7 right left 64 right some never 173. imperial 21 0.300
7 Andre male 17.7 17.7 right left 83 right freq never 183. imperial 18.8 0
8 Michael female 17 17.3 right right 74 right freq never 157 metric 35.8 -0.300
9 Edward male 20 19.5 right right 72 right some never 175 metric 19 0.5
10 Carl male 18.5 18.5 right right 90 right some never 167 metric 22.3 0
# … with 223 more rows
- In the pulse dataset add new weight variables
pound
and stone
(1 kg = 2.20462 pound = 0.157473 stone).
mutate(pulse, pound = weight * 2.20462, stone = weight * 0.157473 )
# A tibble: 110 × 15
id name height weight age gender smokes alcohol exercise ran pulse1 pulse2 year pound stone
<chr> <chr> <dbl> <dbl> <dbl> <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1993_A Bonnie 173 57 18 female no yes moderate sat 86 88 1993 126. 8.98
2 1993_B Melanie 179 58 19 female no yes moderate ran 82 150 1993 128. 9.13
3 1993_C Consuelo 167 62 18 female no yes high ran 96 176 1993 137. 9.76
4 1993_D Travis 195 84 18 male no yes high sat 71 73 1993 185. 13.2
5 1993_E Lauri 173 64 18 female no yes low sat 90 88 1993 141. 10.1
6 1993_F George 184 74 22 male no yes low ran 78 141 1993 163. 11.7
7 1993_G Cherry 162 57 20 female no yes moderate sat 68 72 1993 126. 8.98
8 1993_H Francesca 169 55 18 female no yes moderate sat 71 77 1993 121. 8.66
9 1993_I Sonja 164 56 19 female no yes high sat 68 68 1993 123. 8.82
10 1993_J Troy 168 60 23 male no yes moderate ran 88 150 1993 132. 9.45
# … with 100 more rows
- In the survey dataset convert the variables
smokes
from character to factor with levels {“never”,“occas”,“regul”, “heavy”}, in that order.
mutate(survey, smokes = fct_relevel(factor(smokes), "never","occas","regul", "heavy"))
# A tibble: 233 × 13
name gender span1 span2 hand fold pulse clap exercise smokes height m.i age
<chr> <chr> <dbl> <dbl> <chr> <chr> <dbl> <chr> <chr> <fct> <dbl> <chr> <dbl>
1 Alyson female 18.5 18 right right 92 left some never 173 metric 18.2
2 Todd male 19.5 20.5 left right 104 left none regul 178. imperial 17.6
3 Gerald male 18 13.3 right left 87 neither none occas NA <NA> 16.9
4 Robert male 18.8 18.9 right right NA neither none never 160 metric 20.3
5 Dustin male 20 20 right neither 35 right some never 165 metric 23.7
6 Abby female 18 17.7 right left 64 right some never 173. imperial 21
7 Andre male 17.7 17.7 right left 83 right freq never 183. imperial 18.8
8 Michael female 17 17.3 right right 74 right freq never 157 metric 35.8
9 Edward male 20 19.5 right right 72 right some never 175 metric 19
10 Carl male 18.5 18.5 right right 90 right some never 167 metric 22.3
# … with 223 more rows
Copyright © 2022 Biomedical Data Sciences (BDS) | LUMC