It is increasingly used in education
It is cross-platform, open-source, and freely-available
It is increasingly used in education
It is cross-platform, open-source, and freely-available
It is a programming language and quite flexible
It is increasingly used in education
It is cross-platform, open-source, and freely-available
It is a programming language and quite flexible
It is capable of carrying out basic and complex statistical analyses
It is increasingly used in education
It is cross-platform, open-source, and freely-available
It is a programming language and quite flexible
It is capable of carrying out basic and complex statistical analyses
It is able to work with data small (n = 10) and large (n = 1,000,000+) efficiently
It is increasingly used in education
It is cross-platform, open-source, and freely-available
It is a programming language and quite flexible
It is capable of carrying out basic and complex statistical analyses
It is able to work with data small (n = 10) and large (n = 1,000,000+) efficiently
There is a great, inclusive community of users and developers
Activities:
What do you think this code will do?
starwars %>% filter(sex == "female") %>% select(name, hair_color, skin_color, homeworld)
Let's see!
starwars %>% filter(sex == "female") %>% select(name, hair_color, skin_color, homeworld)
## # A tibble: 16 × 4## name hair_color skin_color homeworld## <chr> <chr> <chr> <chr> ## 1 Leia Organa brown light Alderaan ## 2 Beru Whitesun lars brown light Tatooine ## 3 Mon Mothma auburn fair Chandrila## 4 Shmi Skywalker black fair Tatooine ## 5 Ayla Secura none blue Ryloth ## 6 Adi Gallia none dark Coruscant## 7 Cordé brown light Naboo ## 8 Luminara Unduli black yellow Mirial ## 9 Barriss Offee black yellow Mirial ## 10 Dormé brown light Naboo ## 11 Zam Wesell blonde fair, green, yellow Zolan ## 12 Taun We none grey Kamino ## 13 Jocasta Nu white fair Coruscant## 14 Shaak Ti none red, blue, white Shili ## 15 Rey brown light <NA> ## 16 Padmé Amidala brown light Naboo
What do you think this code will do?
starwars %>% filter(sex %in% c("male", "none"), height <= 150) %>% select(name, sex, height, mass, homeworld) %>% arrange(desc(height))
Let's see!
starwars %>% filter(sex %in% c("male", "none"), height <= 150) %>% arrange(height) %>% select(name, sex, height, mass, homeworld)
## # A tibble: 10 × 5## name sex height mass homeworld ## <chr> <chr> <int> <dbl> <chr> ## 1 Yoda male 66 17 <NA> ## 2 Ratts Tyerell male 79 15 Aleen Minor## 3 Wicket Systri Warrick male 88 20 Endor ## 4 Dud Bolt male 94 45 Vulpter ## 5 R2-D2 none 96 32 Naboo ## 6 R4-P17 none 96 NA <NA> ## 7 R5-D4 none 97 32 Tatooine ## 8 Sebulba male 112 40 Malastare ## 9 Gasgano male 122 NA Troiken ## 10 Watto male 137 NA Toydaria
starwars %>% unnest(starships) %>% select(name, gender, starships) %>% head(10)
## # A tibble: 10 × 3## name gender starships ## <chr> <chr> <chr> ## 1 Luke Skywalker masculine X-wing ## 2 Luke Skywalker masculine Imperial shuttle ## 3 Darth Vader masculine TIE Advanced x1 ## 4 Biggs Darklighter masculine X-wing ## 5 Obi-Wan Kenobi masculine Jedi starfighter ## 6 Obi-Wan Kenobi masculine Trade Federation cruiser## 7 Obi-Wan Kenobi masculine Naboo star skiff ## 8 Obi-Wan Kenobi masculine Jedi Interceptor ## 9 Obi-Wan Kenobi masculine Belbullab-22 starfighter## 10 Anakin Skywalker masculine Trade Federation cruiser
starwars %>% unnest(starships) %>% mutate(vehicles = strsplit(starships, ",")) %>% unnest(starships) %>% select(name, gender, starships) %>% group_by(gender) %>% count()
## # A tibble: 3 × 2## # Groups: gender [3]## gender n## <chr> <int>## 1 feminine 3## 2 masculine 27## 3 <NA> 1
glimpse(starwars)
## Rows: 87## Columns: 14## $ name <chr> "Luke Skywalker", "C-3PO", "R2-D2", "Darth Vader", "Leia Or…## $ height <int> 172, 167, 96, 202, 150, 178, 165, 97, 183, 182, 188, 180, 2…## $ mass <dbl> 77.0, 75.0, 32.0, 136.0, 49.0, 120.0, 75.0, 32.0, 84.0, 77.…## $ hair_color <chr> "blond", NA, NA, "none", "brown", "brown, grey", "brown", N…## $ skin_color <chr> "fair", "gold", "white, blue", "white", "light", "light", "…## $ eye_color <chr> "blue", "yellow", "red", "yellow", "brown", "blue", "blue",…## $ birth_year <dbl> 19.0, 112.0, 33.0, 41.9, 19.0, 52.0, 47.0, NA, 24.0, 57.0, …## $ sex <chr> "male", "none", "none", "male", "female", "male", "female",…## $ gender <chr> "masculine", "masculine", "masculine", "masculine", "femini…## $ homeworld <chr> "Tatooine", "Tatooine", "Naboo", "Tatooine", "Alderaan", "T…## $ species <chr> "Human", "Droid", "Droid", "Human", "Human", "Human", "Huma…## $ films <list> <"The Empire Strikes Back", "Revenge of the Sith", "Return…## $ vehicles <list> <"Snowspeeder", "Imperial Speeder Bike">, <>, <>, <>, "Imp…## $ starships <list> <"X-wing", "Imperial shuttle">, <>, <>, "TIE Advanced x1",…
starwars %>% ggplot() + geom_point(aes(x = mass, y = height, color = gender), alpha = 0.5 ) + theme_bw()
Beginners:
Intermediates:
Experts:
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |