From the course: Learning the R Tidyverse
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Column-wise groups: group_by() and mutate() - R Tutorial
From the course: Learning the R Tidyverse
Column-wise groups: group_by() and mutate()
- [Instructor] We've just met the count function for cross tabulation, but a much more general tool is to combine together, group_by, and mutate for column wise grouping and summarizing of data. Let's look at how we use these two functions together in the 04_03b project. In the mutate.R script, we're going to load the tidyverse on line one, and we've got a little bit of code here, which is selecting some columns of interest from the Star Wars dataset, name, homeworld, species, and we're getting back the numeric columns as well. How about we were interested in the character from each homeworld that was born earliest in the time period of the movies. Well, we could pipe this into the function group_by to group the data by homeworld so that our new take calculations are going to be performed within groups. So if we group_by homeworld, our table tells us it's now grouped, so we can see groups homeworld 49, the 49 unique homeworlds in the dataset. And then we're going to pipe this into…
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)
-
-
-