I have a list of data frames where some data frames have less columns. See example:
a <- data.frame (x1 = 1, x3 = 2, x4 = 7)
b <- data.frame (x1 = 3, x2 = 4, x3 = 3, x4 = 8)
c <- data.frame (x1 = 9, x2 = 5, x3 = 2, x4 = 9)
myList = list(a, b, c)
data frame a
misses column x2
. I need to have a data frame out of myList, so I do the following:
mydf = do.call(rbind, myList)
But the problem is that I get the following error:
Error in rbind(deparse.level, ...) :
numbers of columns of arguments do not match
How can I get a data frame where column x2
for a
is filled with NA
?