[R] splitting matrices

MacQueen, Don macqueen1 at llnl.gov
Thu Jan 3 17:56:54 CET 2013

This example illustrates a method that may do what you want.

## split a 20x5 matrix into five 4x5 matrices
xmat <- matrix(1:100, nrow=20, ncol=5, byrow=TRUE)
xsplit <- rep( 1:5, times= rep(4,5))
tmp <- split.data.frame(xmat,xsplit)

You will need to change xsplit to fit your dimensions.


Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550

On 1/3/13 8:40 AM, "eliza botto" <eliza_botto at hotmail.com> wrote:

>Dear useRs,
>i want to split a matrix having 1116rows and 12 columns. i want to split
>that matrix into 36 small matrices each having 12 columns and 31 rows.
>The big matrix should be splitted row wise. which means that the first
>small matrix should copy values which are in first 31 rows and 12 columns
>of the big matrix. similarly 2nd small matrix should contain values from
>32nd to 63rd row of the big matrix and so on. on the whole i want to have
>36 small matrices.i tried
>dim(dd) <- c(31,12,35)
>but the result are not stisfactory...
>thanks in advance
>	[[alternative HTML version deleted]]
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list