intercalate matrices by Rows in R How can I concatenate matrices with unequal rows by intercalating the rows? For example, I want to concatenate A matrix ( dim(A) = 15 20 ) and B matrix (dim(B) = 17 20) and I want the result to be a matrix of 32 rows by 20 columns. I want result matrix with one row from matrix A and the second row from matrix B. Simple rbind just stacks up one matrix on top of other. 

The following function works in case of equal number of rows: 

# drop false ensures that coercion does not change the data structure.
interleave(A, B, drop=FALSE)


But I want the rows to be interleaved and then the remaining rows from B matrix to be added at the end. If the number of rows from one matrix is added and no more are remaining then the remaining rows should get rowbind (normally stacked). 

Is there any way that I can tweak this interleave function from gdata package in R? or is there any other way?
The following approach works perfectly, 

l &lt;- list(a=A,b=B)
dataset &lt;- do.call(rbind, l)[order(sequence(sapply(l, nrow))), ]