Primary exercises
- Create tibble
Create a tibble
exercise_group
for a group of individuals with names {Sonja, Steven, Ines, Robert, Tim} with their heights {164, 188, 164, 180, 170}, weights {56.0, 87.0, 54.0, 80.0, 58.5} and frequency of exercise {high, high, low, moderate, low}.Update the tibble
exercise_group
withElla
andOscar
, leave their respectiveheight
,weight
andexercise
values as missing (NA
). Avoid copy/paste from (a) with inclusion of new names, instead try to reuse the columns insideexercise_group
.Add the
sex
variable toexercise_group
with valuesmale
andfemale
.
- Create a tibble which keeps track of the smoking habits over the
years of
Julio
age 21 started smoking at 17 and stopped in 2020,Camille
age 20 started smoking in 2021 andTravis
19 started at age 16.
tibble subset
Take the tibble
exercise_group
from the previous exercise and create a new tibbleexercise_group_sub
without theheight
andweight
variables by selection[
.Create a tibble called
exercise_group_sub
with the 1st and 3rd column.
Extract variables as vectors
Given the tibble
favourite_colour
, how old were the subjects by the end of 2021?What is the mean height in
exercise_group
? Use mean function (see ?mean).
Read tibbles from file
Read
pulse.csv
data set into R and inspect its dimensions.Read
survey.csv
data set into R.
Inspect the dimensions.
Show the first 9 and the last 7 rows.
Calculate the mean
age
.Calculate the mean height in survey data.