[R] Break Matrix

Jacques VESLOT jacques.veslot at good.ibl.fr
Thu May 11 13:23:54 CEST 2006


mat <- matrix(rnorm(331*12),331,12)

z <- rep(seq(0,331,by=11)+1, each=2)
zz <- z[-c(1,length(z))]

ind <- as.data.frame(matrix(zz, nr=2))

lapply(ind, function(x) mat[x[1]:x[2],])

-------------------------------------------------------------------
Jacques VESLOT

CNRS UMR 8090
I.B.L (2ème étage)
1 rue du Professeur Calmette
B.P. 245
59019 Lille Cedex

Tel : 33 (0)3.20.87.10.44
Fax : 33 (0)3.20.87.10.31

http://www-good.ibl.fr
-------------------------------------------------------------------


SUMANTA BASAK a écrit :
> Hi,
> Thanks for reply. I'm sorry that i forgot to mention that from 2nd 
> matrix the first row values of the second matrix (and so on..) will be 
> the first row (and so on..). Please help me.
> 
> Thanks,
> SB.
> 
> */Jacques VESLOT <jacques.veslot at good.ibl.fr>/* wrote:
> 
>     split(as.data.frame(matrix(rnorm(331*12),331,12)),
>     gl(ceiling(331/12),12,331))
> 
>     -------------------------------------------------------------------
>     Jacques VESLOT
> 
>     CNRS UMR 8090
>     I.B.L (2ème étage)
>     1 rue du Professeur Calmette
>     B.P. 245
>     59019 Lille Cedex
> 
>     Tel : 33 (0)3.20.87.10.44
>     Fax : 33 (0)3.20.87.10.31
> 
>     http://www-good.ibl.fr
>     -------------------------------------------------------------------
> 
> 
>     SUMANTA BASAK a écrit :
>      > Hi All,
>      >
>      > I have a (331*12) matrix. I wan t to braek it into 28 parts each
>     window having 12 rows, so that each matrix become (12*12) matrix.
>     How can i do this.
>      >
>      > Thanks,
>      > Sumanta.
>      >
>      >
>      > ---------------------------------
>      >
>      > Send instant messages to your online friends - NOW
>      > [[alternative HTML version deleted]]
>      >
>      > ______________________________________________
>      > R-help at stat.math.ethz.ch mailing list
>      > https://stat.ethz.ch/mailman/listinfo/r-help
>      > PLEASE do read the posting guide!
>     http://www.R-project.org/posting-guide.html
>      >
> 
> 
> ------------------------------------------------------------------------
> Yahoo! India Answers: Share what you know. Learn something new. Click 
> here 
> <http://us.rd.yahoo.com/mail/in/mailcricket/*http://in.answers.yahoo.com>
> Send instant messages to your online friends - NOW 
> <http://messenger.yahoo.com/download.php;_ylt=Ah5_.LTcbbJtYrNKnfM5e6xwMMIF>




More information about the R-help mailing list