tidyverse Package.Install the tidyverse package by running the code.
You only need to install the package ONCE for one workspace.
# run within the CONSOLE!!!!
# install.packages("tidyverse")
However, for using the package, we need to retrieve for EVERY NEW MARKDOWN FILE of the the workspace
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.4.1
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
readr verbs
read.csv() - to load a csv format file.
penguins.raw <- read.csv("penguins_size (1).csv")
View(penguins.raw)
dplyr verb
%>% - pipe - AND THEN - CTRL SHIFT M
str(penguins.raw)
## 'data.frame': 344 obs. of 7 variables:
## $ species : chr "Adelie" "Adelie" "Adelie" "Adelie" ...
## $ island : chr "Torgersen" "Torgersen" "Torgersen" "Torgersen" ...
## $ culmen_length_mm : num 39.1 39.5 40.3 NA 36.7 39.3 38.9 39.2 34.1 42 ...
## $ culmen_depth_mm : num 18.7 17.4 18 NA 19.3 20.6 17.8 19.6 18.1 20.2 ...
## $ flipper_length_mm: int 181 186 195 NA 193 190 181 195 193 190 ...
## $ body_mass_g : int 3750 3800 3250 NA 3450 3650 3625 4675 3475 4250 ...
## $ sex : chr "MALE" "FEMALE" "FEMALE" NA ...
penguins.raw %>% str()
## 'data.frame': 344 obs. of 7 variables:
## $ species : chr "Adelie" "Adelie" "Adelie" "Adelie" ...
## $ island : chr "Torgersen" "Torgersen" "Torgersen" "Torgersen" ...
## $ culmen_length_mm : num 39.1 39.5 40.3 NA 36.7 39.3 38.9 39.2 34.1 42 ...
## $ culmen_depth_mm : num 18.7 17.4 18 NA 19.3 20.6 17.8 19.6 18.1 20.2 ...
## $ flipper_length_mm: int 181 186 195 NA 193 190 181 195 193 190 ...
## $ body_mass_g : int 3750 3800 3250 NA 3450 3650 3625 4675 3475 4250 ...
## $ sex : chr "MALE" "FEMALE" "FEMALE" NA ...
View the first/last 6 rows of the dataset
penguins.raw %>% head()
## species island culmen_length_mm culmen_depth_mm flipper_length_mm
## 1 Adelie Torgersen 39.1 18.7 181
## 2 Adelie Torgersen 39.5 17.4 186
## 3 Adelie Torgersen 40.3 18.0 195
## 4 Adelie Torgersen NA NA NA
## 5 Adelie Torgersen 36.7 19.3 193
## 6 Adelie Torgersen 39.3 20.6 190
## body_mass_g sex
## 1 3750 MALE
## 2 3800 FEMALE
## 3 3250 FEMALE
## 4 NA <NA>
## 5 3450 FEMALE
## 6 3650 MALE
# the first 2 rows
penguins.raw %>% head(n=2)
## species island culmen_length_mm culmen_depth_mm flipper_length_mm
## 1 Adelie Torgersen 39.1 18.7 181
## 2 Adelie Torgersen 39.5 17.4 186
## body_mass_g sex
## 1 3750 MALE
## 2 3800 FEMALE
# last 6 rows
penguins.raw %>% tail()
## species island culmen_length_mm culmen_depth_mm flipper_length_mm
## 339 Gentoo Biscoe 47.2 13.7 214
## 340 Gentoo Biscoe NA NA NA
## 341 Gentoo Biscoe 46.8 14.3 215
## 342 Gentoo Biscoe 50.4 15.7 222
## 343 Gentoo Biscoe 45.2 14.8 212
## 344 Gentoo Biscoe 49.9 16.1 213
## body_mass_g sex
## 339 4925 FEMALE
## 340 NA <NA>
## 341 4850 FEMALE
## 342 5750 MALE
## 343 5200 FEMALE
## 344 5400 MALE
# latst 3 rows
penguins.raw %>% tail(n=3)
## species island culmen_length_mm culmen_depth_mm flipper_length_mm
## 342 Gentoo Biscoe 50.4 15.7 222
## 343 Gentoo Biscoe 45.2 14.8 212
## 344 Gentoo Biscoe 49.9 16.1 213
## body_mass_g sex
## 342 5750 MALE
## 343 5200 FEMALE
## 344 5400 MALE
columns name
penguins.raw %>% colnames()
## [1] "species" "island" "culmen_length_mm"
## [4] "culmen_depth_mm" "flipper_length_mm" "body_mass_g"
## [7] "sex"
renaming columns
rename( new-name = old-name,
new-name2 = old-name1, ... )
penguins.raw <- penguins.raw %>% rename(bill.len = culmen_length_mm,
bill.dep = culmen_depth_mm,
flipper = flipper_length_mm,
mass = body_mass_g,
gender = sex)
unique values for qualitative variables
# unique species available within the dataset
unique(penguins.raw$species)
## [1] "Adelie" "Chinstrap" "Gentoo"
# method 2 with %>%
penguins.raw %>% select(species) %>% unique()
## species
## 1 Adelie
## 153 Chinstrap
## 221 Gentoo
# island
unique(penguins.raw$island)
## [1] "Torgersen" "Biscoe" "Dream"
# gender
unique(penguins.raw$gender)
## [1] "MALE" "FEMALE" NA "."
replace value
penguins.raw$gender[penguins.raw$gender == "."] <- NA
# double check if all dot is replace with missing value
unique(penguins.raw$gender)
## [1] "MALE" "FEMALE" NA
factor qualitative variables
penguins.raw$species <- factor(penguins.raw$species)
penguins.raw$island <- factor(penguins.raw$island)
penguins.raw$gender <- factor(penguins.raw$gender)
# chect str() on the change
penguins.raw %>% str()
## 'data.frame': 344 obs. of 7 variables:
## $ species : Factor w/ 3 levels "Adelie","Chinstrap",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ island : Factor w/ 3 levels "Biscoe","Dream",..: 3 3 3 3 3 3 3 3 3 3 ...
## $ bill.len: num 39.1 39.5 40.3 NA 36.7 39.3 38.9 39.2 34.1 42 ...
## $ bill.dep: num 18.7 17.4 18 NA 19.3 20.6 17.8 19.6 18.1 20.2 ...
## $ flipper : int 181 186 195 NA 193 190 181 195 193 190 ...
## $ mass : int 3750 3800 3250 NA 3450 3650 3625 4675 3475 4250 ...
## $ gender : Factor w/ 2 levels "FEMALE","MALE": 2 1 1 NA 1 2 1 2 NA NA ...
count the number of penguins in each species
penguins.raw %>% count(species)
## species n
## 1 Adelie 152
## 2 Chinstrap 68
## 3 Gentoo 124
count penguins for each species, island, gender
penguins.raw %>% count(species, island, gender)
## species island gender n
## 1 Adelie Biscoe FEMALE 22
## 2 Adelie Biscoe MALE 22
## 3 Adelie Dream FEMALE 27
## 4 Adelie Dream MALE 28
## 5 Adelie Dream <NA> 1
## 6 Adelie Torgersen FEMALE 24
## 7 Adelie Torgersen MALE 23
## 8 Adelie Torgersen <NA> 5
## 9 Chinstrap Dream FEMALE 34
## 10 Chinstrap Dream MALE 34
## 11 Gentoo Biscoe FEMALE 58
## 12 Gentoo Biscoe MALE 61
## 13 Gentoo Biscoe <NA> 5
select() - select the column to work from.
# species and mass
species.mass <- penguins.raw %>% select(species, mass) %>% na.omit()
View(species.mass)
select species, island, bill len
penguin.new <- penguins.raw %>% select(species, island,bill.len) %>% na.omit()
View(penguin.new)
na.omit() drop missing value
penguins <- penguins.raw %>% na.omit()
View(penguins)
dim() - dimension
penguins %>% dim()
## [1] 333 7
count() for qualitative variable to check penguins count after dropping NA
penguins %>% count(species)
## species n
## 1 Adelie 146
## 2 Chinstrap 68
## 3 Gentoo 119
penguins %>% count(island)
## island n
## 1 Biscoe 163
## 2 Dream 123
## 3 Torgersen 47
penguins %>% count(gender)
## gender n
## 1 FEMALE 165
## 2 MALE 168
filter species Chinstrap
Conditional symbol:
== : is matched with.
!= : is NOT / NOT MATCHED with.
> : greater than.
< : less than.
>= : greater than and equal to.
<= : less than and equal to.
&: AND - meaning we need BOTH conditions.
| : OR - meaning we need ONE of the condition.
unique(penguins$species)
## [1] Adelie Chinstrap Gentoo
## Levels: Adelie Chinstrap Gentoo
# filter Chinstrap species
penguins %>% filter(species == "Chinstrap")
## species island bill.len bill.dep flipper mass gender
## 1 Chinstrap Dream 46.5 17.9 192 3500 FEMALE
## 2 Chinstrap Dream 50.0 19.5 196 3900 MALE
## 3 Chinstrap Dream 51.3 19.2 193 3650 MALE
## 4 Chinstrap Dream 45.4 18.7 188 3525 FEMALE
## 5 Chinstrap Dream 52.7 19.8 197 3725 MALE
## 6 Chinstrap Dream 45.2 17.8 198 3950 FEMALE
## 7 Chinstrap Dream 46.1 18.2 178 3250 FEMALE
## 8 Chinstrap Dream 51.3 18.2 197 3750 MALE
## 9 Chinstrap Dream 46.0 18.9 195 4150 FEMALE
## 10 Chinstrap Dream 51.3 19.9 198 3700 MALE
## 11 Chinstrap Dream 46.6 17.8 193 3800 FEMALE
## 12 Chinstrap Dream 51.7 20.3 194 3775 MALE
## 13 Chinstrap Dream 47.0 17.3 185 3700 FEMALE
## 14 Chinstrap Dream 52.0 18.1 201 4050 MALE
## 15 Chinstrap Dream 45.9 17.1 190 3575 FEMALE
## 16 Chinstrap Dream 50.5 19.6 201 4050 MALE
## 17 Chinstrap Dream 50.3 20.0 197 3300 MALE
## 18 Chinstrap Dream 58.0 17.8 181 3700 FEMALE
## 19 Chinstrap Dream 46.4 18.6 190 3450 FEMALE
## 20 Chinstrap Dream 49.2 18.2 195 4400 MALE
## 21 Chinstrap Dream 42.4 17.3 181 3600 FEMALE
## 22 Chinstrap Dream 48.5 17.5 191 3400 MALE
## 23 Chinstrap Dream 43.2 16.6 187 2900 FEMALE
## 24 Chinstrap Dream 50.6 19.4 193 3800 MALE
## 25 Chinstrap Dream 46.7 17.9 195 3300 FEMALE
## 26 Chinstrap Dream 52.0 19.0 197 4150 MALE
## 27 Chinstrap Dream 50.5 18.4 200 3400 FEMALE
## 28 Chinstrap Dream 49.5 19.0 200 3800 MALE
## 29 Chinstrap Dream 46.4 17.8 191 3700 FEMALE
## 30 Chinstrap Dream 52.8 20.0 205 4550 MALE
## 31 Chinstrap Dream 40.9 16.6 187 3200 FEMALE
## 32 Chinstrap Dream 54.2 20.8 201 4300 MALE
## 33 Chinstrap Dream 42.5 16.7 187 3350 FEMALE
## 34 Chinstrap Dream 51.0 18.8 203 4100 MALE
## 35 Chinstrap Dream 49.7 18.6 195 3600 MALE
## 36 Chinstrap Dream 47.5 16.8 199 3900 FEMALE
## 37 Chinstrap Dream 47.6 18.3 195 3850 FEMALE
## 38 Chinstrap Dream 52.0 20.7 210 4800 MALE
## 39 Chinstrap Dream 46.9 16.6 192 2700 FEMALE
## 40 Chinstrap Dream 53.5 19.9 205 4500 MALE
## 41 Chinstrap Dream 49.0 19.5 210 3950 MALE
## 42 Chinstrap Dream 46.2 17.5 187 3650 FEMALE
## 43 Chinstrap Dream 50.9 19.1 196 3550 MALE
## 44 Chinstrap Dream 45.5 17.0 196 3500 FEMALE
## 45 Chinstrap Dream 50.9 17.9 196 3675 FEMALE
## 46 Chinstrap Dream 50.8 18.5 201 4450 MALE
## 47 Chinstrap Dream 50.1 17.9 190 3400 FEMALE
## 48 Chinstrap Dream 49.0 19.6 212 4300 MALE
## 49 Chinstrap Dream 51.5 18.7 187 3250 MALE
## 50 Chinstrap Dream 49.8 17.3 198 3675 FEMALE
## 51 Chinstrap Dream 48.1 16.4 199 3325 FEMALE
## 52 Chinstrap Dream 51.4 19.0 201 3950 MALE
## 53 Chinstrap Dream 45.7 17.3 193 3600 FEMALE
## 54 Chinstrap Dream 50.7 19.7 203 4050 MALE
## 55 Chinstrap Dream 42.5 17.3 187 3350 FEMALE
## 56 Chinstrap Dream 52.2 18.8 197 3450 MALE
## 57 Chinstrap Dream 45.2 16.6 191 3250 FEMALE
## 58 Chinstrap Dream 49.3 19.9 203 4050 MALE
## 59 Chinstrap Dream 50.2 18.8 202 3800 MALE
## 60 Chinstrap Dream 45.6 19.4 194 3525 FEMALE
## 61 Chinstrap Dream 51.9 19.5 206 3950 MALE
## 62 Chinstrap Dream 46.8 16.5 189 3650 FEMALE
## 63 Chinstrap Dream 45.7 17.0 195 3650 FEMALE
## 64 Chinstrap Dream 55.8 19.8 207 4000 MALE
## 65 Chinstrap Dream 43.5 18.1 202 3400 FEMALE
## 66 Chinstrap Dream 49.6 18.2 193 3775 MALE
## 67 Chinstrap Dream 50.8 19.0 210 4100 MALE
## 68 Chinstrap Dream 50.2 18.7 198 3775 FEMALE
# species Chinstrap OR Gentoo
penguins %>% filter(species == "Chinstrap" | species == "Gentoo")
## species island bill.len bill.dep flipper mass gender
## 1 Chinstrap Dream 46.5 17.9 192 3500 FEMALE
## 2 Chinstrap Dream 50.0 19.5 196 3900 MALE
## 3 Chinstrap Dream 51.3 19.2 193 3650 MALE
## 4 Chinstrap Dream 45.4 18.7 188 3525 FEMALE
## 5 Chinstrap Dream 52.7 19.8 197 3725 MALE
## 6 Chinstrap Dream 45.2 17.8 198 3950 FEMALE
## 7 Chinstrap Dream 46.1 18.2 178 3250 FEMALE
## 8 Chinstrap Dream 51.3 18.2 197 3750 MALE
## 9 Chinstrap Dream 46.0 18.9 195 4150 FEMALE
## 10 Chinstrap Dream 51.3 19.9 198 3700 MALE
## 11 Chinstrap Dream 46.6 17.8 193 3800 FEMALE
## 12 Chinstrap Dream 51.7 20.3 194 3775 MALE
## 13 Chinstrap Dream 47.0 17.3 185 3700 FEMALE
## 14 Chinstrap Dream 52.0 18.1 201 4050 MALE
## 15 Chinstrap Dream 45.9 17.1 190 3575 FEMALE
## 16 Chinstrap Dream 50.5 19.6 201 4050 MALE
## 17 Chinstrap Dream 50.3 20.0 197 3300 MALE
## 18 Chinstrap Dream 58.0 17.8 181 3700 FEMALE
## 19 Chinstrap Dream 46.4 18.6 190 3450 FEMALE
## 20 Chinstrap Dream 49.2 18.2 195 4400 MALE
## 21 Chinstrap Dream 42.4 17.3 181 3600 FEMALE
## 22 Chinstrap Dream 48.5 17.5 191 3400 MALE
## 23 Chinstrap Dream 43.2 16.6 187 2900 FEMALE
## 24 Chinstrap Dream 50.6 19.4 193 3800 MALE
## 25 Chinstrap Dream 46.7 17.9 195 3300 FEMALE
## 26 Chinstrap Dream 52.0 19.0 197 4150 MALE
## 27 Chinstrap Dream 50.5 18.4 200 3400 FEMALE
## 28 Chinstrap Dream 49.5 19.0 200 3800 MALE
## 29 Chinstrap Dream 46.4 17.8 191 3700 FEMALE
## 30 Chinstrap Dream 52.8 20.0 205 4550 MALE
## 31 Chinstrap Dream 40.9 16.6 187 3200 FEMALE
## 32 Chinstrap Dream 54.2 20.8 201 4300 MALE
## 33 Chinstrap Dream 42.5 16.7 187 3350 FEMALE
## 34 Chinstrap Dream 51.0 18.8 203 4100 MALE
## 35 Chinstrap Dream 49.7 18.6 195 3600 MALE
## 36 Chinstrap Dream 47.5 16.8 199 3900 FEMALE
## 37 Chinstrap Dream 47.6 18.3 195 3850 FEMALE
## 38 Chinstrap Dream 52.0 20.7 210 4800 MALE
## 39 Chinstrap Dream 46.9 16.6 192 2700 FEMALE
## 40 Chinstrap Dream 53.5 19.9 205 4500 MALE
## 41 Chinstrap Dream 49.0 19.5 210 3950 MALE
## 42 Chinstrap Dream 46.2 17.5 187 3650 FEMALE
## 43 Chinstrap Dream 50.9 19.1 196 3550 MALE
## 44 Chinstrap Dream 45.5 17.0 196 3500 FEMALE
## 45 Chinstrap Dream 50.9 17.9 196 3675 FEMALE
## 46 Chinstrap Dream 50.8 18.5 201 4450 MALE
## 47 Chinstrap Dream 50.1 17.9 190 3400 FEMALE
## 48 Chinstrap Dream 49.0 19.6 212 4300 MALE
## 49 Chinstrap Dream 51.5 18.7 187 3250 MALE
## 50 Chinstrap Dream 49.8 17.3 198 3675 FEMALE
## 51 Chinstrap Dream 48.1 16.4 199 3325 FEMALE
## 52 Chinstrap Dream 51.4 19.0 201 3950 MALE
## 53 Chinstrap Dream 45.7 17.3 193 3600 FEMALE
## 54 Chinstrap Dream 50.7 19.7 203 4050 MALE
## 55 Chinstrap Dream 42.5 17.3 187 3350 FEMALE
## 56 Chinstrap Dream 52.2 18.8 197 3450 MALE
## 57 Chinstrap Dream 45.2 16.6 191 3250 FEMALE
## 58 Chinstrap Dream 49.3 19.9 203 4050 MALE
## 59 Chinstrap Dream 50.2 18.8 202 3800 MALE
## 60 Chinstrap Dream 45.6 19.4 194 3525 FEMALE
## 61 Chinstrap Dream 51.9 19.5 206 3950 MALE
## 62 Chinstrap Dream 46.8 16.5 189 3650 FEMALE
## 63 Chinstrap Dream 45.7 17.0 195 3650 FEMALE
## 64 Chinstrap Dream 55.8 19.8 207 4000 MALE
## 65 Chinstrap Dream 43.5 18.1 202 3400 FEMALE
## 66 Chinstrap Dream 49.6 18.2 193 3775 MALE
## 67 Chinstrap Dream 50.8 19.0 210 4100 MALE
## 68 Chinstrap Dream 50.2 18.7 198 3775 FEMALE
## 69 Gentoo Biscoe 46.1 13.2 211 4500 FEMALE
## 70 Gentoo Biscoe 50.0 16.3 230 5700 MALE
## 71 Gentoo Biscoe 48.7 14.1 210 4450 FEMALE
## 72 Gentoo Biscoe 50.0 15.2 218 5700 MALE
## 73 Gentoo Biscoe 47.6 14.5 215 5400 MALE
## 74 Gentoo Biscoe 46.5 13.5 210 4550 FEMALE
## 75 Gentoo Biscoe 45.4 14.6 211 4800 FEMALE
## 76 Gentoo Biscoe 46.7 15.3 219 5200 MALE
## 77 Gentoo Biscoe 43.3 13.4 209 4400 FEMALE
## 78 Gentoo Biscoe 46.8 15.4 215 5150 MALE
## 79 Gentoo Biscoe 40.9 13.7 214 4650 FEMALE
## 80 Gentoo Biscoe 49.0 16.1 216 5550 MALE
## 81 Gentoo Biscoe 45.5 13.7 214 4650 FEMALE
## 82 Gentoo Biscoe 48.4 14.6 213 5850 MALE
## 83 Gentoo Biscoe 45.8 14.6 210 4200 FEMALE
## 84 Gentoo Biscoe 49.3 15.7 217 5850 MALE
## 85 Gentoo Biscoe 42.0 13.5 210 4150 FEMALE
## 86 Gentoo Biscoe 49.2 15.2 221 6300 MALE
## 87 Gentoo Biscoe 46.2 14.5 209 4800 FEMALE
## 88 Gentoo Biscoe 48.7 15.1 222 5350 MALE
## 89 Gentoo Biscoe 50.2 14.3 218 5700 MALE
## 90 Gentoo Biscoe 45.1 14.5 215 5000 FEMALE
## 91 Gentoo Biscoe 46.5 14.5 213 4400 FEMALE
## 92 Gentoo Biscoe 46.3 15.8 215 5050 MALE
## 93 Gentoo Biscoe 42.9 13.1 215 5000 FEMALE
## 94 Gentoo Biscoe 46.1 15.1 215 5100 MALE
## 95 Gentoo Biscoe 47.8 15.0 215 5650 MALE
## 96 Gentoo Biscoe 48.2 14.3 210 4600 FEMALE
## 97 Gentoo Biscoe 50.0 15.3 220 5550 MALE
## 98 Gentoo Biscoe 47.3 15.3 222 5250 MALE
## 99 Gentoo Biscoe 42.8 14.2 209 4700 FEMALE
## 100 Gentoo Biscoe 45.1 14.5 207 5050 FEMALE
## 101 Gentoo Biscoe 59.6 17.0 230 6050 MALE
## 102 Gentoo Biscoe 49.1 14.8 220 5150 FEMALE
## 103 Gentoo Biscoe 48.4 16.3 220 5400 MALE
## 104 Gentoo Biscoe 42.6 13.7 213 4950 FEMALE
## 105 Gentoo Biscoe 44.4 17.3 219 5250 MALE
## 106 Gentoo Biscoe 44.0 13.6 208 4350 FEMALE
## 107 Gentoo Biscoe 48.7 15.7 208 5350 MALE
## 108 Gentoo Biscoe 42.7 13.7 208 3950 FEMALE
## 109 Gentoo Biscoe 49.6 16.0 225 5700 MALE
## 110 Gentoo Biscoe 45.3 13.7 210 4300 FEMALE
## 111 Gentoo Biscoe 49.6 15.0 216 4750 MALE
## 112 Gentoo Biscoe 50.5 15.9 222 5550 MALE
## 113 Gentoo Biscoe 43.6 13.9 217 4900 FEMALE
## 114 Gentoo Biscoe 45.5 13.9 210 4200 FEMALE
## 115 Gentoo Biscoe 50.5 15.9 225 5400 MALE
## 116 Gentoo Biscoe 44.9 13.3 213 5100 FEMALE
## 117 Gentoo Biscoe 45.2 15.8 215 5300 MALE
## 118 Gentoo Biscoe 46.6 14.2 210 4850 FEMALE
## 119 Gentoo Biscoe 48.5 14.1 220 5300 MALE
## 120 Gentoo Biscoe 45.1 14.4 210 4400 FEMALE
## 121 Gentoo Biscoe 50.1 15.0 225 5000 MALE
## 122 Gentoo Biscoe 46.5 14.4 217 4900 FEMALE
## 123 Gentoo Biscoe 45.0 15.4 220 5050 MALE
## 124 Gentoo Biscoe 43.8 13.9 208 4300 FEMALE
## 125 Gentoo Biscoe 45.5 15.0 220 5000 MALE
## 126 Gentoo Biscoe 43.2 14.5 208 4450 FEMALE
## 127 Gentoo Biscoe 50.4 15.3 224 5550 MALE
## 128 Gentoo Biscoe 45.3 13.8 208 4200 FEMALE
## 129 Gentoo Biscoe 46.2 14.9 221 5300 MALE
## 130 Gentoo Biscoe 45.7 13.9 214 4400 FEMALE
## 131 Gentoo Biscoe 54.3 15.7 231 5650 MALE
## 132 Gentoo Biscoe 45.8 14.2 219 4700 FEMALE
## 133 Gentoo Biscoe 49.8 16.8 230 5700 MALE
## 134 Gentoo Biscoe 49.5 16.2 229 5800 MALE
## 135 Gentoo Biscoe 43.5 14.2 220 4700 FEMALE
## 136 Gentoo Biscoe 50.7 15.0 223 5550 MALE
## 137 Gentoo Biscoe 47.7 15.0 216 4750 FEMALE
## 138 Gentoo Biscoe 46.4 15.6 221 5000 MALE
## 139 Gentoo Biscoe 48.2 15.6 221 5100 MALE
## 140 Gentoo Biscoe 46.5 14.8 217 5200 FEMALE
## 141 Gentoo Biscoe 46.4 15.0 216 4700 FEMALE
## 142 Gentoo Biscoe 48.6 16.0 230 5800 MALE
## 143 Gentoo Biscoe 47.5 14.2 209 4600 FEMALE
## 144 Gentoo Biscoe 51.1 16.3 220 6000 MALE
## 145 Gentoo Biscoe 45.2 13.8 215 4750 FEMALE
## 146 Gentoo Biscoe 45.2 16.4 223 5950 MALE
## 147 Gentoo Biscoe 49.1 14.5 212 4625 FEMALE
## 148 Gentoo Biscoe 52.5 15.6 221 5450 MALE
## 149 Gentoo Biscoe 47.4 14.6 212 4725 FEMALE
## 150 Gentoo Biscoe 50.0 15.9 224 5350 MALE
## 151 Gentoo Biscoe 44.9 13.8 212 4750 FEMALE
## 152 Gentoo Biscoe 50.8 17.3 228 5600 MALE
## 153 Gentoo Biscoe 43.4 14.4 218 4600 FEMALE
## 154 Gentoo Biscoe 51.3 14.2 218 5300 MALE
## 155 Gentoo Biscoe 47.5 14.0 212 4875 FEMALE
## 156 Gentoo Biscoe 52.1 17.0 230 5550 MALE
## 157 Gentoo Biscoe 47.5 15.0 218 4950 FEMALE
## 158 Gentoo Biscoe 52.2 17.1 228 5400 MALE
## 159 Gentoo Biscoe 45.5 14.5 212 4750 FEMALE
## 160 Gentoo Biscoe 49.5 16.1 224 5650 MALE
## 161 Gentoo Biscoe 44.5 14.7 214 4850 FEMALE
## 162 Gentoo Biscoe 50.8 15.7 226 5200 MALE
## 163 Gentoo Biscoe 49.4 15.8 216 4925 MALE
## 164 Gentoo Biscoe 46.9 14.6 222 4875 FEMALE
## 165 Gentoo Biscoe 48.4 14.4 203 4625 FEMALE
## 166 Gentoo Biscoe 51.1 16.5 225 5250 MALE
## 167 Gentoo Biscoe 48.5 15.0 219 4850 FEMALE
## 168 Gentoo Biscoe 55.9 17.0 228 5600 MALE
## 169 Gentoo Biscoe 47.2 15.5 215 4975 FEMALE
## 170 Gentoo Biscoe 49.1 15.0 228 5500 MALE
## 171 Gentoo Biscoe 46.8 16.1 215 5500 MALE
## 172 Gentoo Biscoe 41.7 14.7 210 4700 FEMALE
## 173 Gentoo Biscoe 53.4 15.8 219 5500 MALE
## 174 Gentoo Biscoe 43.3 14.0 208 4575 FEMALE
## 175 Gentoo Biscoe 48.1 15.1 209 5500 MALE
## 176 Gentoo Biscoe 50.5 15.2 216 5000 FEMALE
## 177 Gentoo Biscoe 49.8 15.9 229 5950 MALE
## 178 Gentoo Biscoe 43.5 15.2 213 4650 FEMALE
## 179 Gentoo Biscoe 51.5 16.3 230 5500 MALE
## 180 Gentoo Biscoe 46.2 14.1 217 4375 FEMALE
## 181 Gentoo Biscoe 55.1 16.0 230 5850 MALE
## 182 Gentoo Biscoe 48.8 16.2 222 6000 MALE
## 183 Gentoo Biscoe 47.2 13.7 214 4925 FEMALE
## 184 Gentoo Biscoe 46.8 14.3 215 4850 FEMALE
## 185 Gentoo Biscoe 50.4 15.7 222 5750 MALE
## 186 Gentoo Biscoe 45.2 14.8 212 5200 FEMALE
## 187 Gentoo Biscoe 49.9 16.1 213 5400 MALE
# species Chinstrap from Dream Island
penguins %>% filter(species == "Chinstrap" & island == "Dream")
## species island bill.len bill.dep flipper mass gender
## 1 Chinstrap Dream 46.5 17.9 192 3500 FEMALE
## 2 Chinstrap Dream 50.0 19.5 196 3900 MALE
## 3 Chinstrap Dream 51.3 19.2 193 3650 MALE
## 4 Chinstrap Dream 45.4 18.7 188 3525 FEMALE
## 5 Chinstrap Dream 52.7 19.8 197 3725 MALE
## 6 Chinstrap Dream 45.2 17.8 198 3950 FEMALE
## 7 Chinstrap Dream 46.1 18.2 178 3250 FEMALE
## 8 Chinstrap Dream 51.3 18.2 197 3750 MALE
## 9 Chinstrap Dream 46.0 18.9 195 4150 FEMALE
## 10 Chinstrap Dream 51.3 19.9 198 3700 MALE
## 11 Chinstrap Dream 46.6 17.8 193 3800 FEMALE
## 12 Chinstrap Dream 51.7 20.3 194 3775 MALE
## 13 Chinstrap Dream 47.0 17.3 185 3700 FEMALE
## 14 Chinstrap Dream 52.0 18.1 201 4050 MALE
## 15 Chinstrap Dream 45.9 17.1 190 3575 FEMALE
## 16 Chinstrap Dream 50.5 19.6 201 4050 MALE
## 17 Chinstrap Dream 50.3 20.0 197 3300 MALE
## 18 Chinstrap Dream 58.0 17.8 181 3700 FEMALE
## 19 Chinstrap Dream 46.4 18.6 190 3450 FEMALE
## 20 Chinstrap Dream 49.2 18.2 195 4400 MALE
## 21 Chinstrap Dream 42.4 17.3 181 3600 FEMALE
## 22 Chinstrap Dream 48.5 17.5 191 3400 MALE
## 23 Chinstrap Dream 43.2 16.6 187 2900 FEMALE
## 24 Chinstrap Dream 50.6 19.4 193 3800 MALE
## 25 Chinstrap Dream 46.7 17.9 195 3300 FEMALE
## 26 Chinstrap Dream 52.0 19.0 197 4150 MALE
## 27 Chinstrap Dream 50.5 18.4 200 3400 FEMALE
## 28 Chinstrap Dream 49.5 19.0 200 3800 MALE
## 29 Chinstrap Dream 46.4 17.8 191 3700 FEMALE
## 30 Chinstrap Dream 52.8 20.0 205 4550 MALE
## 31 Chinstrap Dream 40.9 16.6 187 3200 FEMALE
## 32 Chinstrap Dream 54.2 20.8 201 4300 MALE
## 33 Chinstrap Dream 42.5 16.7 187 3350 FEMALE
## 34 Chinstrap Dream 51.0 18.8 203 4100 MALE
## 35 Chinstrap Dream 49.7 18.6 195 3600 MALE
## 36 Chinstrap Dream 47.5 16.8 199 3900 FEMALE
## 37 Chinstrap Dream 47.6 18.3 195 3850 FEMALE
## 38 Chinstrap Dream 52.0 20.7 210 4800 MALE
## 39 Chinstrap Dream 46.9 16.6 192 2700 FEMALE
## 40 Chinstrap Dream 53.5 19.9 205 4500 MALE
## 41 Chinstrap Dream 49.0 19.5 210 3950 MALE
## 42 Chinstrap Dream 46.2 17.5 187 3650 FEMALE
## 43 Chinstrap Dream 50.9 19.1 196 3550 MALE
## 44 Chinstrap Dream 45.5 17.0 196 3500 FEMALE
## 45 Chinstrap Dream 50.9 17.9 196 3675 FEMALE
## 46 Chinstrap Dream 50.8 18.5 201 4450 MALE
## 47 Chinstrap Dream 50.1 17.9 190 3400 FEMALE
## 48 Chinstrap Dream 49.0 19.6 212 4300 MALE
## 49 Chinstrap Dream 51.5 18.7 187 3250 MALE
## 50 Chinstrap Dream 49.8 17.3 198 3675 FEMALE
## 51 Chinstrap Dream 48.1 16.4 199 3325 FEMALE
## 52 Chinstrap Dream 51.4 19.0 201 3950 MALE
## 53 Chinstrap Dream 45.7 17.3 193 3600 FEMALE
## 54 Chinstrap Dream 50.7 19.7 203 4050 MALE
## 55 Chinstrap Dream 42.5 17.3 187 3350 FEMALE
## 56 Chinstrap Dream 52.2 18.8 197 3450 MALE
## 57 Chinstrap Dream 45.2 16.6 191 3250 FEMALE
## 58 Chinstrap Dream 49.3 19.9 203 4050 MALE
## 59 Chinstrap Dream 50.2 18.8 202 3800 MALE
## 60 Chinstrap Dream 45.6 19.4 194 3525 FEMALE
## 61 Chinstrap Dream 51.9 19.5 206 3950 MALE
## 62 Chinstrap Dream 46.8 16.5 189 3650 FEMALE
## 63 Chinstrap Dream 45.7 17.0 195 3650 FEMALE
## 64 Chinstrap Dream 55.8 19.8 207 4000 MALE
## 65 Chinstrap Dream 43.5 18.1 202 3400 FEMALE
## 66 Chinstrap Dream 49.6 18.2 193 3775 MALE
## 67 Chinstrap Dream 50.8 19.0 210 4100 MALE
## 68 Chinstrap Dream 50.2 18.7 198 3775 FEMALE
# filter out just penguins of body mass <= 2900
penguins %>% filter(mass <= 2900)
## species island bill.len bill.dep flipper mass gender
## 1 Adelie Biscoe 34.5 18.1 187 2900 FEMALE
## 2 Adelie Biscoe 36.5 16.6 181 2850 FEMALE
## 3 Adelie Biscoe 36.4 17.1 184 2850 FEMALE
## 4 Adelie Dream 33.1 16.1 178 2900 FEMALE
## 5 Adelie Torgersen 38.6 17.0 188 2900 FEMALE
## 6 Chinstrap Dream 43.2 16.6 187 2900 FEMALE
## 7 Chinstrap Dream 46.9 16.6 192 2700 FEMALE