Combining data frames with unequal number of columns

r

Solution

There's also `rbind.fill` from `plyr` or `Stack`.

library(plyr)

rbind.fill(Dat1, Dat2)

##   Col1 Col2 Col3 Col4 Col5
## 1   A1   56   89   NA <NA>
## 2   A2   49   NA   84  F11

library(Stack)

Stack(Dat1, Dat2)

##   Col1 Col2 Col3 Col4 Col5
## 1   A1   56   89   NA <NA>
## 2   A2   49   NA   84  F11

Problem

Suppose I have two data frames, Dat1 and Dat2, ``` Dat1 Col1 Col2 Col3 A1 56 89 ``` and ``` Dat2 Col1 Col2 Col4 Col5 A2 49 84 F11 ``` Finally I want to have a combined data frame which looks like ``` Col1 Col2 Col3 Col4 Col5 A1 56 89 NA NA A2 49 NA 84 F11 ``` Is it possible to achieve this in R?

Original source

Related problems