[R] Rbind help needed

Thomas Lumley tlumley at u.washington.edu
Wed Nov 27 21:08:33 CET 2002

On Wed, 27 Nov 2002 Bayesianbay at aol.com wrote:

> Dear list
> I have a very simple question which is causing me problems!
> I have a matrix A and simply want to rbind this matrix together n times (n is a large number)
> How can I write this in R?
> I know I could do new<-rbind(z,z,z,...z) with z written n times but this will take forever as n is so large.
> Is there a simple way to write this?

One way is

  t(matrix( rep(t(z), n), nrow=ncol(z)))

There's probably a quicker way using aperm(), as well.


r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list