[BioC] how split a matrix

Yuan Hao yuan.x.hao at gmail.com
Fri Feb 24 14:36:17 CET 2012


There's a function 'split()' in R
Just set the columns you would like to cluster into as a factor.

 > ?split()
Usage:

      split(x, f, drop = FALSE, ...)
      split(x, f, drop = FALSE, ...) <- value
      unsplit(value, f, drop = FALSE)

Cheers,
Yuan

On 24 Feb 2012, at 13:27, Ali Mohammadian wrote:

> Hi Sirs,
>
> I have a matrix, and I have written  a function to split it by its
> columns, the algorithm works manually, but does not work in R:
>
> A= matrix (rnorm (96),8,12)
> get.replicates = function (A, reps=reps){
> 	temp = array(-999,dim=c(dim (A) [2]/reps,dim(A) [1],reps))
> 	for (replicates.no in 1: (dim (A) [2]/reps)) {
> 	temp [replicates.no, , ] = A [ , reps*(replicates.no-1)+1:
> reps*(replicates.no) ]
> 	}
> temp	
> }
>
> get.replicates (A,3)
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor



More information about the Bioconductor mailing list