From the course: Learning the R Tidyverse
Unlock the full course today
Join today to access over 24,100 courses taught by industry experts.
Column-wise groups: group_by() and summarize() - R Tutorial
From the course: Learning the R Tidyverse
Column-wise groups: group_by() and summarize()
- [Instructor] In the previous video, we saw how group_by() and mutate() work together. This video is going to look at mutate()'s sibling, summarise(), and how it works with group_by(). Let's do that in the 04_04b project. So in summarise.R script, we're loading the tidyverse on line one, and then we're selecting out three columns in the starwars dataset, species, homeworld, and height. And let's say that we're interested in the tallest individual from each species. We need to start answering that question with group_by() because we want to calculate statistics within the grouped species. So we'll group_by(species), and then we'll pipe this into summarise(), and we're going to create a new column, max_height. We'll use the function max() and the height column, and we're going to add na.rm is equal to TRUE to remove those NA values, and I'm going to run that code. Now, did you notice a difference between how mutate() worked in a previous video and summarise()? Let's copy and paste that…
Contents
-
-
-
-
-
-
(Locked)
Grouping and summarizing data by column or row2m 22s
-
(Locked)
Cross tabulations with count()3m 21s
-
(Locked)
Column-wise groups: group_by() and mutate()3m 38s
-
(Locked)
Column-wise groups: group_by() and summarize()3m 10s
-
(Locked)
Column-wise groups: group_by() and reframe()3m 8s
-
(Locked)
Column-wise groups: Using the .by argument instead of group_by()2m 40s
-
(Locked)
Row-wise groups: rowwise() and c_across()4m 12s
-
(Locked)
Remember to ungroup()1m 50s
-
(Locked)
Challenge: Find maximum penguin dimension by island1m 3s
-
(Locked)
Solution: Find maximum penguin dimension by island3m 40s
-
(Locked)
-
-
-