Using dplyr's filter function to pick rows from a data frame in R (CC161)
Channel: Riffomonas Project
Date: 2021-11-08

R's filter function allows you to create queries to pick rows from a data frame that match your query. It's a tremendously powerful function that we get from the dplyr R package. In this episode we'll see how we can use it to search through a data frame with more than 100000 rows! You can make simple and more sophisticated queries by following a few simple concepts. We'll also see how you can remove NA values using these concepts and using the special drop_na function. I'll demonstrate how to use filter with a massive data frame that we downloaded from Our World in Data that describes COVID-19 vaccination rates by country and day.

In this episode, Pat uses #filter and #drop_na from the #dplyr #R package in #Rstudio. The accompanying blog post can be found at https://www.riffomonas.org/code_club/2021-11-08-filter-function.

Want more practice on the concepts covered in Code Club? You can sign up for my weekly newsletter at https://shop.riffomonas.org/youtube to get practice problems, tips, and insights.

If you're interested in taking an upcoming 3 day R workshop be sure to check out our schedule at https://riffomonas.org/workshops/


You can also find complete tutorials for learning R with the tidyverse using...
Microbial ecology data: https://www.riffomonas.org/minimalR/
General data: https://www.riffomonas.org/generalR/

0:00 Filtering rows from a data frame
1:48 Filtering rows that satisfy a set of criteria
5:19 Combining filter statments with AND & OR
12:17 Filtering rows based on a logical column
15:09 Filtering out rows with NA values
16:47 Cleaning up script