Consider I have two data.frames:
A<-data.frame(a=c("b","a", "a", "e", "e","a"),Za=c(11,22,33,44,55,66))
B<-data.frame(b=c("a","a", "b", "e", "f","f"),Zb=c(11,22,33,44,55,66))
Now I want to match them based on the columns a and b, but sustain every possible combination. So in the end I want to have :
Anew<-data.frame(a=c("a","a","a","a","a","a","b","e","e","f","f"),Za=c(11,11,11,22,22,22,33,44,44,55,66))
Bnew<-data.frame(b=c("a","a","a","a","a","a","b","e","e",NA,NA),Zb=c(22,33,66,22,33,66,11,44,55,NA,NA))
Anew
a Za
1 a 11
2 a 11
3 a 11
4 a 22
5 a 22
6 a 22
7 b 33
8 e 44
9 e 44
10 f 55
11 f 66
Bnew
b Zb
1 a 22
2 a 33
3 a 66
4 a 22
5 a 33
6 a 66
7 b 11
8 e 44
9 e 55
10 <NA> NA
11 <NA> NA
I dont want to use ncomb if possible as my vector is really really huge and this would kill my memory. A fast running solution would be perfect!
Many thanks for every help!