I have two vectors where some elements are common:
v1= c('a', 'b', 'c')
v2 = c('b', 'c', 'd')
I want to combine the vectors into two data.frame
s. In the first I want all elements from both vectors, and non-matching positions in either vector should be replaced by NA
:
v1 v2
a NA
b b
c c
NA d
In the second data frame, I want the elements from from the first vector and the corresponding matches in the second:
v1 v2
a NA
b b
c c
What is the best way to do it?