Primary exercises
Apply the following to survey data:
Select personal information {name, age, gender, height} into a new tibble
survey_personal_info
.Select personal information as previous exercise into a new tibble
survey_personal_info
but with variable names initials in uppercase, e.g.Name
,Age
etc.Reorder the variables in survey dataset as such that name,age and gender appear as first, second and the third column followed by the remaining variables.
Deselect variables that relate to hand and/or arm (e.g. span1, span2, hand, etc.). See also description survey data.
Select the top 20 names along with gender.
Reproduce the following tibbles (note that variables are renamed and reshuffled):
6.1 First 5 observations.
# A tibble: 5 × 13 SPAN1 SPAN2 name gender hand fold pulse clap exercise smokes height m.i age <dbl> <dbl> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <dbl> <chr> <dbl> 1 18.5 18 Alyson female right right 92 left some never 173 metric 18.2 2 19.5 20.5 Todd male left right 104 left none regul 178. imperial 17.6 3 18 13.3 Gerald male right left 87 neither none occas NA <NA> 16.9 4 18.8 18.9 Robert male right right NA neither none never 160 metric 20.3 5 20 20 Dustin male right neither 35 right some never 165 metric 23.7
6.1 Last 3 observations.
# A tibble: 3 × 13 Hand Fold Clap name gender span1 span2 pulse exercise smokes height m.i age <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <chr> <chr> <dbl> <chr> <dbl> 1 right right right Tracey female 17.5 16.5 NA some never 170 metric 18.6 2 right right right Keith male 21 21.5 90 some never 183 metric 17.2 3 right right right Celina female 17.6 17.3 85 freq never 168. metric 17.8
Select variables, from survey data, by pattern matching.
7.1 Select variables that end with ‘e’.
7.2 Select variables that start with ‘s’.
7.3 Select hand span variables using a helper function.