[R] rbind with missing columns
klaus.thul@infineon.com
klaus.thul at infineon.com
Fri Apr 30 13:47:35 CEST 2004
Hello,
I have several data sets, which I want to combine column-by-column using
"rbind" (the data sets have ~100 columns). The problem is, that in some
data sets some of the columns are missing.
Simply using rbind gives me:
"Error in match.names(clabs, names(xi)) : names don't match previous
names"
Is there a simple way to make R do the rbind despite the missing columns
and to fill out the missing data with NA's? (I could program this
somehow, but probably there is one very simple solution available)
To make it clear here a simplified example. "unknown.command" is what I
am looking for.
A <- data.frame(a = c(1,2,3), b = c(4,5,6))
B <- data.frame(a = c(1,2,3))
unknown.command(A, B) - should give
A B
1 4
2 5
3 6
4 NA
5 NA
6 NA
Thank you for your help
Klaus
More information about the R-help
mailing list