Dplyr shrub volume data basics select (solution)

NoteExercise

Dr. Morales is interested in studying the factors controlling the size and carbon storage of shrubs. She has conducted an experiment looking at the effect of three different treatments on shrub volume at four different locations. She has placed the data file on the web for you to download:

If the file shrub-volume-data.csv is not already in your working directory (it probably is if you’re taking this class using Posit Cloud) then download it into your working directory.

Get familiar with the data by importing it using read_csv() and use dplyr to complete the following tasks.

  1. Select the data from the length column (using select).
  2. Select the data from the site and experiment columns (using select).
  3. Select the data from the experiment, length, width, and height columns
CautionOutput solution

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
Rows: 15 Columns: 5
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl (5): site, experiment, length, width, height

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
  1. Select the data from the length column (using select).
# A tibble: 15 × 1
   length
    <dbl>
 1    2.2
 2    2.1
 3    2.7
 4    3  
 5    3.1
 6    2.5
 7    1.9
 8    1.1
 9    3.5
10    2.9
11    4.5
12    1.2
13    2.6
14    1.8
15    3.1
  1. Select the data from the site and experiment columns (using select).
# A tibble: 15 × 2
    site experiment
   <dbl>      <dbl>
 1     1          1
 2     1          2
 3     1          3
 4     2          1
 5     2          2
 6     2          3
 7     3          1
 8     3          2
 9     3          3
10     4          1
11     4          2
12     4          3
13     5          1
14     5          2
15     5          3
  1. Select the data from the experiment, length, width, and height columns
# A tibble: 15 × 4
   experiment length width height
        <dbl>  <dbl> <dbl>  <dbl>
 1          1    2.2   1.3    9.6
 2          2    2.1   2.2    7.6
 3          3    2.7   1.5    2.2
 4          1    3     4.5    1.5
 5          2    3.1   3.1    4  
 6          3    2.5   2.8    3  
 7          1    1.9   1.8    4.5
 8          2    1.1   0.5    2.3
 9          3    3.5   2      7.5
10          1    2.9   2.7    3.2
11          2    4.5   4.8    6.5
12          3    1.2   1.8    2.7
13          1    2.6   0.8   NA  
14          2    1.8  NA      5.2
15          3    3.1   2.2   NA