Hello,
I recently found out that dplyr is able to merge/join data.
My doubt is how do I need to declare a one to many kind of merge.
I don't know the terminology of inner join, left join, semi join, etc ( I come from the stata world)
Thanks for your time and interest.
This may help!?
Is this the sort of thing you are looking for?
library(dplyr)
DF1 <- data.frame(Name = c("A", "B"), Value = 1:2)
DF1
#> Name Value
#> 1 A 1
#> 2 B 2
DF2 <- data.frame(Name = rep(c("A", "B"), 4), Value2 = 11:18)
DF2
#> Name Value2
#> 1 A 11
#> 2 B 12
#> 3 A 13
#> 4 B 14
#> 5 A 15
#> 6 B 16
#> 7 A 17
#> 8 B 18
NewDF = inner_join(DF1, DF2, by = "Name")
NewDF
#> Name Value Value2
#> 1 A 1 11
#> 2 A 1 13
#> 3 A 1 15
#> 4 A 1 17
#> 5 B 2 12
#> 6 B 2 14
#> 7 B 2 16
#> 8 B 2 18
Created on 2020-01-17 by the reprex package (v0.3.0)
Yes. But it seems that dplyr doesn't do the job completely. I was wrong about that issue.
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.