Using dplyr's join functions in R to filter and merge data frames (CC164)

Ғылым және технология

The ability to use dplyr's join functions to merge and filter data frames in R has made life so much easier than trying to do the same thing with base R. In this Code Club, Pat will demonstrate how to use and the difference between full_join, inner_join, left_join, right_join, and anti_join. 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.
In this episode, Pat uses #inner_join, #left_join, #right_join, #full_join, and #anti_join from the #dplyr #R package in #Rstudio. The accompanying blog post can be found at www.riffomonas.org/code_club/....
Want more practice on the concepts covered in Code Club? You can sign up for my weekly newsletter at 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 riffomonas.org/workshops/
You can also find complete tutorials for learning R with the tidyverse using...
Microbial ecology data: www.riffomonas.org/minimalR/
General data: www.riffomonas.org/generalR/
0:00 Joining data frames
3:52 full_join: returning all of the data
4:41 inner_join: returning the overlapping data
5:32 left_join and right_join: returning data in the left or right data frame
6:23 anti_join: returning the missing data
7:44 Using joins to filter data
9:50 Different methods of specifying which column to join by
11:07 Putting it all together

Пікірлер: 25

  • @user-no9uy3vo4l
    @user-no9uy3vo4l4 ай бұрын

    I have been trying to join my data for the last 4 days and finally! Thank you! I have been starting from the way beginning of your videos from 3 years ago. Thank you for sharing and being so detailed and adding extra functions and ideas that someone else may need to use.

  • @Riffomonas

    @Riffomonas

    4 ай бұрын

    Im so glad to hear they’ve been helpful!

  • @j.knetsch3413
    @j.knetsch34134 ай бұрын

    omg thank you!

  • @timmytesla9655
    @timmytesla96552 жыл бұрын

    Super useful explanation. The Anti-join function here is easier than that in SQL. Thanks for the video.

  • @Riffomonas

    @Riffomonas

    2 жыл бұрын

    My pleasure! Thanks for watching Timmy

  • @sohilausamarabie9631
    @sohilausamarabie96312 жыл бұрын

    Amazing explanation! Thank you!!

  • @Riffomonas

    @Riffomonas

    2 жыл бұрын

    Thanks for watching Sohila! 🤓

  • @hansmeiser6078
    @hansmeiser60782 жыл бұрын

    Cool.

  • @ieliemielio
    @ieliemielio2 жыл бұрын

    The joins are also the way to mimic Excel’s much-loved VLOOKUP function

  • @Riffomonas

    @Riffomonas

    2 жыл бұрын

    I feel like I need to do a “Pat relearns Excel” series 😂

  • @niceday2015
    @niceday2015 Жыл бұрын

    Always great.

  • @lichaccakaven146
    @lichaccakaven1462 жыл бұрын

    超喜欢你的讲解!!^_^

  • @russtin1
    @russtin12 жыл бұрын

    I remember really struggling to get merge to perform a left_join in my pre-tidyverse days

  • @DanJohanssonJLB
    @DanJohanssonJLB2 жыл бұрын

    pat i love hadley so much for making my hard learned SQL skills relevant again by bringing them into R. As you mentioned, i also like to be explicit and always use the "by" argument, but this is also why i always use left_join. I feel like inner_join hides missing records from me and I want to know things are missing so I can handle those missing entries right away. Obviously you could look for missing data further along in your code but i'd rather just deal with it now. maybe there's a better way that I'm not aware of....

  • @Riffomonas

    @Riffomonas

    2 жыл бұрын

    Hi Daniel - thanks for watching and writing. I *love* the joins. I get a lot out of seeing how other people use them

  • @johnschloss694
    @johnschloss6942 жыл бұрын

    Cool video

  • @Riffomonas

    @Riffomonas

    2 жыл бұрын

    Thanks dude

  • @cristianjaviermena6955
    @cristianjaviermena69556 ай бұрын

    goatttttt

  • @peteralfred7006
    @peteralfred70062 жыл бұрын

    Hey Pat I am lost on the way. I want to know where did you come up with the ipsos dataset? I followed the link, I was totally lost on the way.

  • @Riffomonas

    @Riffomonas

    2 жыл бұрын

    Hi Peter - I'm sorry the link above wasn't working but it is now. You can find it in the original video from this series (kzread.info/dash/bejne/o5Wf1c-KkcWzhaw.html) or on the github repository at raw.githubusercontent.com/riffomonas/vaccination_attitudes/main/august_october_2020.csv

  • @jamesleleji6984
    @jamesleleji6984 Жыл бұрын

    How do you combine two data frames with different column names with the union function

  • @hansmeiser6078
    @hansmeiser60782 жыл бұрын

    What is the difference between merge(all=TRUE) and full_join()?

  • @Riffomonas

    @Riffomonas

    2 жыл бұрын

    The *_join functions are the same functionality as provided by merge, but with a cleaner syntax

  • @haraldurkarlsson1147
    @haraldurkarlsson1147 Жыл бұрын

    Would location %in% c(“Australia”, “Brazil”, …) not have worked here? I guess that is mute since you filter with a join later but still good to know that there is a short-cut.

  • @Riffomonas

    @Riffomonas

    4 ай бұрын

    Both would work

Келесі