Re: [R] repeat matrix rows as a whole

2012-04-26 Thread Jessica Streicher
a <- matrix(1:8, 2, 4, byrow=TRUE) b<-t(a) r<-rep(b,5) # can insert anything for 5 matrix(r,ncol=dim(a)[2],byrow=T) [,1] [,2] [,3] [,4] [1,]1234 [2,]5678 [3,]1234 [4,]5678 [5,]1234 [6,]5678

Re: [R] repeat matrix rows as a whole

2012-04-26 Thread Petr PIKAL
Hi what about rbind(a,a) [,1] [,2] [,3] [,4] [1,]1234 [2,]5678 [3,]1234 [4,]5678 Regards Petr > > > a <- matrix(1:8, 2, 4, byrow=TRUE) > > a > [,1] [,2] [,3] [,4] > [1,]1234 > [2,]5678 >

Re: [R] repeat matrix rows as a whole

2012-04-25 Thread Jeff Newmiller
Yes, integer vector indexing. You haven't provided R code to work with so I will just refer you to read the pdf "An Introduction to R" included with most R installations for more details. --- Jeff Newmiller

Re: [R] repeat matrix rows as a whole

2012-04-25 Thread Richard M. Heiberger
> a <- matrix(1:8, 2, 4, byrow=TRUE) > a [,1] [,2] [,3] [,4] [1,]1234 [2,]5678 > a[c(1,2,1,2),] [,1] [,2] [,3] [,4] [1,]1234 [2,]5678 [3,]1234 [4,]5678 > On Wed, Apr 25, 2012 at 8:32 PM, Rebec

[R] repeat matrix rows as a whole

2012-04-25 Thread Rebecca
Hi, If I have a matrix like 1  2  3  4 5  6  7  8, how can I repeat two rows as whole, to be like 1  2  3  4 5  6  7  8 1  2  3  4 5  6  7  8?   Since I have more two rows in a matrix and I need to repeat many times, I wonder whether there is a convenient command to do so.   Thanks! [[alte