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
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
>
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
> 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
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
5 matches
Mail list logo