Hi, I would like to rbind 2 data frames. They both some common column names, but also some unique column names each, is there any simple function that rbind these 2 data frames with filling NAs for those columns of unique names? thanks
rbind() problem
2 messages · array chip, Tobias Verbeke
Hi array (?),
Hi, I would like to rbind 2 data frames. They both some common column names, but also some unique column names each, is there any simple function that rbind these 2 data frames with filling NAs for those columns of unique names?
You can use the reshape package by Hadley Wickham for this:
df1 <- data.frame(V1 = rnorm(10),
V2 = rnorm(10),
V4 = rnorm(10))
df2 <- data.frame(V1 = rnorm(10),
V3 = rnorm(10),
V4 = rnorm(10))
library(reshape)
rbind.fill(df1, df2)
HTH,
Tobias