Dplyr penguins data basics select (solution)

NoteExercise

If the file penguins.csv is not already in your working directory then download it into your working directory.

Load the data using read_csv() and use dplyr to complete the following tasks.

  1. Select the data from the species column.
  2. Select the data from the island and year.
  3. Select the data from the species, bill_length_mm, bill_depth_mm, and body_mass_g 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: 344 Columns: 8
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): species, island, sex
dbl (5): bill_length_mm, bill_depth_mm, flipper_length_mm, body_mass_g, year

ℹ 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 species column.
# A tibble: 344 × 1
   species
   <chr>  
 1 Adelie 
 2 Adelie 
 3 Adelie 
 4 Adelie 
 5 Adelie 
 6 Adelie 
 7 Adelie 
 8 Adelie 
 9 Adelie 
10 Adelie 
# ℹ 334 more rows
  1. Select the data from the island and year.
# A tibble: 344 × 2
   island     year
   <chr>     <dbl>
 1 Torgersen  2007
 2 Torgersen  2007
 3 Torgersen  2007
 4 Torgersen  2007
 5 Torgersen  2007
 6 Torgersen  2007
 7 Torgersen  2007
 8 Torgersen  2007
 9 Torgersen  2007
10 Torgersen  2007
# ℹ 334 more rows
  1. Select the data from the species, bill_length_mm, bill_depth_mm, and body_mass_g columns.
# A tibble: 344 × 4
   species bill_length_mm bill_depth_mm body_mass_g
   <chr>            <dbl>         <dbl>       <dbl>
 1 Adelie            39.1          18.7        3750
 2 Adelie            39.5          17.4        3800
 3 Adelie            40.3          18          3250
 4 Adelie            NA            NA            NA
 5 Adelie            36.7          19.3        3450
 6 Adelie            39.3          20.6        3650
 7 Adelie            38.9          17.8        3625
 8 Adelie            39.2          19.6        4675
 9 Adelie            34.1          18.1        3475
10 Adelie            42            20.2        4250
# ℹ 334 more rows