Align two vector with common elements [duplicate]
问题 This question already has answers here : How to join (merge) data frames (inner, outer, left, right) (13 answers) Closed 8 days ago . 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