Using dplyr's slice and arrange functions in R to order and pick rows from a data frame (CC162)
In this episode of Code Club, Pat uses dplyr
’s slice and arrange functions to show how you can order and grab rows out of a data frame using R. He’ll cover how to do an ascending and descending sort using arrange and desc and the slice_head
, slice_tail
, slice_max
, slice_min
, and slice_sample
functions to grab rows with particular characteristics. We’ll also talk about top_n
. He’ll demonstrate how to use these functions with a massive data frame that we downloaded from Our World in Data that describes COVID-19 vaccination rates by country and day.
Code
You can browse the state of the repository at the