This will create a list of the matrix subsets:

# create a matrix
x <- cbind(1:40, runif(40))
index <- c(10,15,33,40)  # cut points
# create a matrix with start and end points
slices <- cbind(start=head(c(1,index + 1), -1), end=index)
# create a list with the matrices
matrix.subset <- lapply(seq(nrow(slices)), function(.row){
    x[slices[.row, 1]:slices[.row, 2], ]
})
matrix.subset


On 6/18/07, H. Paul Benton <hpbenton@scripps.edu> wrote:
>
> Dear All,
>
>
>    I have a matrix with data that is not organised. I would like to go
> through this and extract it. Each feature has 2 vectors which express
> the data. I also have an index of the places where the data should be cut.
> eg.
> >class(cc)
> "matrix"
> >cc
>      [,1] [,2]
> [1,]    1   26
> [2,]    2   27
> [3,]    3   28
> [4,]    4   29
> [5,]    5   30
> [6,]    6   31
> [7,]    7   32
> [8,]    8   33
> [9,]    9   34
> [10,]    1   27
> [11,]    1   28
> [12,]    2   30
> [13,]    3   34
> ect......
> > index
> [1] "10" "40"
>
>
> Is there a way to take cc[i:index[i-1],] to another format as to where
> each block could be worked on separately. ie so in one block would be
> rows1:10 the next block would be rows11:40 and so on.
>
> Thanks,
>
> Paul
>
>
>
> --
> Research Technician
> Mass Spectrometry
>   o The
> /
> o Scripps
> \
>   o Research
> /
> o Institute
>
> ______________________________________________
> R-help@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
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

	[[alternative HTML version deleted]]

