Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Compare 2 columns of one dataframe with the same 2 columns of another dataframe and find the common combination of values

How can I find the common combination of values in same columns of 2 dataframes? Basically same name and same artistName

dat1<-structure(list(artistName = c("Adele", "Mariah Carey", "D-Block Europe", 
"Wham!", "Ed Sheeran", "Adele", "Adele", "Elton John & Dua Lipa", 
"ArrDee", "GAYLE", "Ed Sheeran", "The Pogues", "Ed Sheeran", 
"Shakin' Stevens", "Leona Lewis", "Sam Fender", "Acraze", "Kelly Clarkson", 
"Joel Corry", "SwitchOTR"), name = c("Easy On Me", "All I Want For Christmas Is You", 
"Overseas (feat. Central Cee)", "Last Christmas", "Shivers", 
"Oh My God", "I Drink Wine", "Cold Heart (PNAU Remix)", "Flowers (Say My Name)", 
"abcdefu", "Bad Habits", "Fairytale of New York", "Overpass Graffiti", 
"Merry Christmas Everyone", "One More Sleep", "Seventeen Going Under", 
"Do It To It (feat. Cherish)", "Underneath the Tree", "I Wish (feat. Mabel)", 
"Coming for You (feat. A1 x J1)")), row.names = c(NA, 20L), class = "data.frame")

dat2<-structure(list(artistName = c("Adele", "Rod Wave", "Kodak Black", 
"Drake", "Nardo Wick", "Drake", "Adele", "Bruno Mars, Anderson .Paak & Silk Sonic", 
"Adele", "Summer Walker & SZA", "Mariah Carey", "GAYLE", "Drake", 
"Doja Cat", "Lil Nas X & Jack Harlow", "Taylor Swift", "The Kid LAROI & Justin Bieber", 
"Adele", "Summer Walker", "Drake"), name = c("Easy On Me", "By Your Side", 
"Super Gremlin", "Knife Talk (feat. 21 Savage & Project Pat)", 
"Who Want Smoke?? (feat. G Herbo, Lil Durk & 21 Savage)", "Way 2 Sexy (feat. Future & Young Thug)", 
"Oh My God", "Smokin Out The Window", "My Little Love", "No Love", 
"All I Want For Christmas Is You", "abcdefu", "Girls Want Girls (feat. Lil Baby)", 
"Need To Know", "INDUSTRY BABY", "All Too Well (10 Minute Version) (Taylor's Version) (From The Vault)", 
"STAY", "I Drink Wine", "Insane", "Fair Trade (feat. Travis Scott)"
)), row.names = c(NA, 20L), class = "data.frame")

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is the following you are looking for?

dplyr::inner_join(dat1, dat2)

#> Joining, by = c("artistName", "name")
#>     artistName                            name
#> 1        Adele                      Easy On Me
#> 2 Mariah Carey All I Want For Christmas Is You
#> 3        Adele                       Oh My God
#> 4        Adele                    I Drink Wine
#> 5        GAYLE                         abcdefu
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading