Reputation: 91
For simplicity, I have made the following code.
df1 <- data.frame(A=c(1:3), B=c('A', 'A', 'A', 'B', 'B', 'B'))
df2 <- data.frame(C=c('D'), D=c(4, 4, 5, 5, 6, 6))
one <- split(df1, df1$B)
two <- split(df2, df2$D)
goal_df <- data.frame(A=c(1:3), B=c('A', 'A', 'A', 'B', 'B', 'B'),
C=c('D'), D=c(4, 4, 5, 5, 6, 6))
I have two lists like 'one' and 'two'. This lists contain several thousand data frames. I want to combine all of these into one data frame. I tried rbind, but I ran into issues because the dimensions of the data frames in the list vary. The end result should be what I have called goal_df
Upvotes: 0
Views: 352
Reputation: 886948
We can use
library(rowr)
do.call(cbind.fill, c(list(do.call(rbind, one), do.call(rbind, two)), fill = NA))
Upvotes: 1