[R] Rbind help needed

Roger Peng rpeng at stat.ucla.edu
Wed Nov 27 20:51:04 CET 2002


If you can somehow get all your matrices in a list, you can use do.call().
For example, 

> matlist <- list(a = matrix(0, 10, 4), b = matrix(1, 5, 4))
> do.call("rbind", matlist)
      [,1] [,2] [,3] [,4]
 [1,]    0    0    0    0
 [2,]    0    0    0    0
 [3,]    0    0    0    0
 [4,]    0    0    0    0
 [5,]    0    0    0    0
 [6,]    0    0    0    0
 [7,]    0    0    0    0
 [8,]    0    0    0    0
 [9,]    0    0    0    0
[10,]    0    0    0    0
[11,]    1    1    1    1
[12,]    1    1    1    1
[13,]    1    1    1    1
[14,]    1    1    1    1
[15,]    1    1    1    1


-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng

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?
> 
> Cheers 
> Mick
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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