Just a note: looking at
> dat
[,1] [,2] [,3] [,4]
[1,] 2 3 5 4
[2,] 2 7 4 6
[3,] NA NA NA NA
> df
[,1] [,2] [,3] [,4]
[1,] 2 4 4 NA
[2,] 3 2 6 NA
[3,] 5 7 NA NA
I am not surprised by the result that
identical(dat,df)
[1] FALSE
However look
df=matrix(as.numeric(unlist(x)), nrow= 3, byrow = T)
identical(dat,df)
[1] TRUE
Alternatives do.call(rbind, list)
If you are looking for an alternative do.call, check out dplyr::bind_rows(which is powered by data frames and is reasonably efficient). The second option may be Reduceas in:
Reduce(rbind, x)
[,1] [,2] [,3] [,4]
init 2 3 5 4
2 7 4 6
NA NA NA NA
- data.table::rbindlist, (!). , , , . .
library(data.table)
rbindlist(list(x))
V1 V2 V3
1: 2 2 NA
2: 3 7 NA
3: 5 4 NA
4: 4 6 NA
t(), .
, , , -
sapply(x, length)
[1] 4 4 4
, , , ncol , length. , names .