I've been struggling to make this work all day and I can't figure it out. I have two tables x and y that I'd like to combine. The first two columns of y are a subset of x, but y has an extra column. I'd like to combine the two without having duplicates in the first two columns.
x:
A B
------
1 2
3 4
5 6
7 8
9 10
y:
A B C
-------------
1 2 123
3 4 456
9 10 789
I'd like my result to be:
A B C
-------------
1 2 123
3 4 456
5 6 0
7 8 0
9 10 789
How would I go about doing this?
`z <- rbind(x, y[, c("A", "B")])`
`z <- z[!(duplicated(z)|duplicated(z, fromLast = TRUE)),] ` to remove duplicates
`rbind(z, y, fill=TRUE)` – Henk May 07 '18 at 14:39