These exercises cover the sections of Data wrangling with tidy.

All files can be found in the “dataset” directory.

 

Exercise 6

 

  • tidy up df2

ANSWERS

Answer

## # A tibble: 97 x 5
##    salmon_id common_name    age_classbylength  length_mm IGF1_ng_ml
##        <dbl> <chr>          <chr>                  <dbl>      <dbl>
##  1     35032 Chinook salmon yearling                 147      41.3 
##  2     35033 Chinook salmon mixed age juvenile       444      62.1 
##  3     35034 Sockeye salmon juvenile                 139      NA   
##  4     35035 Sockeye salmon juvenile                 121      NA   
##  5     35036 Sockeye salmon juvenile                 112      NA   
##  6     35037 Steelhead      juvenile                 220      42.7 
##  7     35038 Steelhead      juvenile                 152      NA   
##  8     35039 Steelhead      juvenile                 201       9.92
##  9     35040 Steelhead      juvenile                 200      38.1 
## 10     35042 Steelhead      juvenile                 247      46.4 
## # … with 87 more rows
## # A tibble: 97 x 5
##    salmon_id common_name    age_classbylength  length_mm IGF1_ng_ml
##        <dbl> <chr>          <chr>                  <dbl>      <dbl>
##  1     35032 Chinook salmon yearling                 147      41.3 
##  2     35033 Chinook salmon mixed age juvenile       444      62.1 
##  3     35034 Sockeye salmon juvenile                 139      NA   
##  4     35035 Sockeye salmon juvenile                 121      NA   
##  5     35036 Sockeye salmon juvenile                 112      NA   
##  6     35037 Steelhead      juvenile                 220      42.7 
##  7     35038 Steelhead      juvenile                 152      NA   
##  8     35039 Steelhead      juvenile                 201       9.92
##  9     35040 Steelhead      juvenile                 200      38.1 
## 10     35042 Steelhead      juvenile                 247      46.4 
## # … with 87 more rows