In the plyr
package there is a function rbind.fill
that will merge data.frames and introduce NA
for empty cells:
library(plyr)
combined <- rbind.fill(mtcars[c("mpg", "wt")], mtcars[c("wt", "cyl")])
combined[25:40, ]
mpg wt cyl
25 19.2 3.845 NA
26 27.3 1.935 NA
27 26.0 2.140 NA
28 30.4 1.513 NA
29 15.8 3.170 NA
30 19.7 2.770 NA
31 15.0 3.570 NA
32 21.4 2.780 NA
33 NA 2.620 6
34 NA 2.875 6
35 NA 2.320 4