These exercises cover the sections of Data wrangling with tidy.

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

 

Exercise 1

 

  1. Create a dataframe with the variables age and IGF for only the Steelhead fish
  2. Create a dataframe with all the variables except the IGF values, for all fish that begin with S

ANSWERS

Answer for Q1

## # A tibble: 38 x 2
##    age_classbylength IGF1_ng_ml
##    <chr>                  <dbl>
##  1 juvenile                42.7
##  2 juvenile                NA  
##  3 juvenile                24.2
##  4 juvenile                NA  
##  5 juvenile                63.5
##  6 juvenile                61.2
##  7 juvenile                30.6
##  8 juvenile                49.4
##  9 juvenile                56.3
## 10 juvenile                55.7
## # … with 28 more rows

Answer for Q2

## # A tibble: 49 x 4
##    salmon_id common_name    age_classbylength length_mm
##        <dbl> <chr>          <chr>                 <dbl>
##  1     35035 Sockeye salmon juvenile                121
##  2     35036 Sockeye salmon juvenile                112
##  3     35037 Steelhead      juvenile                220
##  4     35038 Steelhead      juvenile                152
##  5     35034 Sockeye salmon juvenile                139
##  6     35048 Steelhead      juvenile                288
##  7     35049 Steelhead      juvenile                190
##  8     35050 Steelhead      juvenile                283
##  9     35051 Steelhead      juvenile                279
## 10     35052 Steelhead      juvenile                235
## # … with 39 more rows