Get access to all lessons in this course.
-
RMarkdown
- Why Use RMarkdown?
- RMarkdown Overview
- YAML
- Text
- Code Chunks
- Wrapping Up
-
Data Wrangling and Analysis
- Getting Started
- The Tidyverse
- select
- mutate
- filter
- summarize
- group_by
- count
- arrange
- Create a New Data Frame
- Crosstabs
- Wrapping Up
-
Data Visualization
- An Important Workflow Tip
- The Grammar of Graphics
- Scatterplots
- Histograms
- Bar Charts
- color and fill
- scales
- Text and Labels
- Plot Labels
- Themes
- Facets
- Save Plots
- Wrapping Up
-
Wrapping Up
- You Did It!
Fundamentals of R (v1)
filter
This lesson is locked
This lesson is called filter, part of the Fundamentals of R (v1) course. This lesson is called filter, part of the Fundamentals of R (v1) course.
If the video is not playing correctly, you can watch it in a new window
Transcript
Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.
Your Turn
Complete the filter sections of the data-wrangling-and-analysis-exercises.Rmd file.
Learn More
General Data Wrangling and Analysis Resources
Because most material that discusses data wrangling and analysis with the dplyr packges does so in a way that covers all of the verbs discussed in this course, I have chosen not to separate them by lesson. Instead, here are some helpful resources for learning more about all of the tidyverse verbs discussed in this course:
Chapter 5 of R for Data Science
RStudio Cloud primer on working with data
Tidyverse for Beginners by Danielle Navarro
Learning Statistics with R by Danielle Navarro
Introduction to the Tidyverse by Alison Hill
A gRadual intRoduction to data wRangling by Chester Ismay and Ted Laderas
You need to be signed-in to comment on this post. Login.
Catherine Roller White
March 27, 2021
There is a line in the data-wrangling-and-analysis-exercises.Rmd file that says: "We can use Use
,
for numeric data." I think the placement of the equals sign may need to change for "greater or equal than" (i.e., '=>' should be '>=').Vuk Sekicki
March 27, 2021
returns: Error: Problem with
filter()
input..1
. x no applicable method for 'drop_na' applied to an object of class "c('double', 'numeric')" ℹ Input..1
isdrop_na(days_phys_hlth_bad)
. Runrlang::last_error()
to see where the error occurred.Hana Hanfi
April 7, 2021
I'm getting an error that "drop_na" wasn't found even though I previously loaded "dplyr" into the library. Should I have loaded another function?
Zach Tilton
August 19, 2021
Received an error code on the last exercise:
Error in drop_na(., days_phys_hlth_bad) : could not find function "drop_na"
dplyr is loaded. Not sure what is happening here. Moving forward with !is.na for the time being. Thanks.
Ekerette Udoh
September 30, 2021
nhanes %>% filter(Education == "College Grad") %>% select(Education, MaritalStatus)
When running the code above Education and MaritalStatus displays just fine. But when I add the second filter function as below I get an error message.
nhanes %>% filter(Education == "College Grad") %>% filter(MaritalStatus %n% c("Divorced", "Separated", "Widowed")) %>% select(Education, MaritalStatus)
Nathan Welsch
January 17, 2022
Is there a "rule of thumb" or useful way of remembering what needs quotes?
Josh Gutwill
October 4, 2022
I'm wondering if you know why one needs to concatenate multiple observations in the filter function. For example, here's a correct use of filter: filter(marital_status %in% c("Divorced", "Separated", "Widowed")) From what I understand of the concatenate function (from Excel), wouldn't that basically mean R is looking at each observation in marital_status and seeing if that observation can be found anywhere inside "DivorcedSeparatedWidowed"? But when I try it without concatenating by doing this: filter(marital_status %in% ("DivorcedSeparatedWidowed")) I get an error message. Maybe the answer is "That's just how R works," but I'm trying to build a solid mental model for these functions, so if there's anything more to it, I'd love to better understand. Thanks!
Ellen Wilson
October 6, 2022
I'm puzzled because in your video, it looks like there are code chunks that say "Your code here" (or something like that), but when I go to the file, the code is already complete for all the code chunks. This has actually been the case for the past few sections, and looks like it is for the next one, too.
Julieth Silao
November 6, 2022
A tibble:0 × 2
hello David
when i filter education and marital status , i didnt get any table instead A tibble.0x 2 can i help
Chelsea Ruder
March 29, 2023
I can't seem to get the drop an or !is.na functions to work. oregon_respondents % select_all() %>% filter(!is.na(ip_address))
When I run this code, there are still blanks for ip_address.