I have two data.frames, one with only characters and the other with characters and values.
df1 = data.frame(x=c('a', 'b', 'c', 'd', 'e')) df2 = data.frame(x=c('a', 'b', 'c'),y = c(0,1,0)) merge(df1, df2) xy 1 a 0 2 b 1 3 c 0
I want to combine df1 and df2. The characters a, b, and c merge well, and also have 0, 1, 0, but d and e have nothing. I want d and e to also be in the merge table with condition 0 0. Thus, for each missing row in df2 data.frame, the value 0 should be placed in table df1, for example:
xy 1 a 0 2 b 1 3 c 0 4 d 0 5 e 0
merge r dataframe
Lisann May 11 '11 at 14:15 2011-05-11 14:15
source share