Reputation: 154
I created two test datasets:
mymerge1
col1 col2
x 29
y 23
z 66
mymerge2
col1 col2
x black
y red
This command: mymerge3<-merge(mymerge1, mymerge2, by="col1", all.mymerge1=TRUE)
gives me this:
col1 col2.x col2.y
x 29 black
y 23 red
But where is the third row z
of mymerge1
? Why does't all.mymerge1=TRUE
work?
Upvotes: 0
Views: 218
Reputation: 2906
You can use dplyr method:
mymerge3 <- dplyr::inner_join(mymerge1, mymerge2, by = "col1")
inner_join keeps all the rown from both datasets
Upvotes: 0
Reputation: 18420
It's mymerge3<-merge(mymerge1, mymerge2, by="col1", all.x=TRUE)
, the name of the all.x
parameters is not changed.
Upvotes: 1