[R] merging data.frames columnwise (rbind with different variables, lengths)
Stefan Uhmann
stefan.uhmann at mailbox.tu-dresden.de
Thu Dec 11 13:45:42 CET 2008
Dear List,
I have two dataframes with overlapping colnames and want to merge them.
Actually, what I want is more similar to rbind, but the dataframes
differ in their columns. Here are the examples:
df1 <- data.frame(A = c(1,2), B = c("m","f"), C = c("at home", "away"))
df2 <- data.frame(A = c(2), C = c("at home"))
Here the desired result:
A B C
1 1 m at home
2 2 f away
3 2 NA at home
Thanks for any help,
Stefan
More information about the R-help
mailing list