How to Filter Rows Which Contain Specific String in R / dplyr

12,159
0
Published 2020-07-16
Video showing how to filter rows which contain a given string in R using dplyr. We show how to filter the rows of a dataframe in R that contains a string that is given by the user. We also show how to filter rows based on a regular expression. The function that we use to do this is the grepl function. If you ask me, this function is absolutely necessary if you want to become a good data scientist.

If you enjoyed this video please leave a like! Subscribe for more of the best R content on YouTube!

All Comments (9)
  • @grantwaters2128
    This a money video. Thank you for not making it super long and complicated.
  • @HominidPetro
    But how do you filter when you want a specific string ONLY. Like, what if I only want "apple" but not "apple 1", "apple 2", "apple 3", etc. If I did filter(grepl('apple', df)) I would get all the apples. But I only want the original.
  • I'm trying to filter for two specific variables Democrat and Republican. How would I go about that this works just fine for isolating one but I don't know how to make it filter for everything except two things.