Skip to content

rbind with missing columns

1 message · Michael Dewey

#
At 11:03 01/05/04, you wrote:
Does

A$id <- 1:nrow(A)
B$id <- 1:nrow(B) + nrow(A)
AandB <- merge(A, B, all = TRUE)


 > A
   a b id
1 1 4  1
2 2 5  2
3 3 6  3
 > B
   a id
1 1  4
2 2  5
3 3  6
 > AandB
   a id  b
1 1  1 4
2 1  4 NA
3 2  2 5
4 2  5 NA
5 3  3 6
6 3  6 NA
 >

Give you what you wanted? You can always strip out the "id" column if you 
wish (after sorting on it if you would like the original order back.
Michael Dewey
m.dewey at iop.kcl.ac.uk