[R] Rbind help needed
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Wed Nov 27 21:39:02 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 z a matrix too? A more efficient way would be
dn <- dim(z)
new <- t(matrix(t(z), dn[2], dn[1]*n))
relying on recycling. As the t's show, it works most naturally for cbind.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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