How can I add a list of vectors to a preallocated data.frame such that the vectors form the rows of the data.frame?
eg.
ll<-list(c(1,2,3),c(2,3,4))
dd<-data.frame(matrix(nrow=10,ncol=3))
I need dd to look like
1 2 3
2 3 4
do.call(rbind, ll)
To add to an existing data frame
rbind(dd, do.call(rbind, ll)
# OR
do.call(rbind, c(ll, list(dd))
If you're doing this for many data frames, see rbind.fill in the plyr package for a much more efficient approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With