R/calcMeans.R

Defines functions calcMeans

Documented in calcMeans

calcMeans<-function(x,cls) {
  ucls <- unique(cls) 
  v <- matrix(,nrow=nrow(x),ncol=length(ucls))
  for(i in 1:length(ucls)) {
    ind<-which(cls==ucls[i])
    if( length(ind) > 1 ) {
	  #xx <- matrix(x[,ind],nc=length(ind))
	  xx <- as.matrix(x[,ind])
      #v[,i] <- rowMeans(xx/sqrt(length(ind)))
      v[,i] <- rowSums(xx)/sqrt(length(ind))
    } else {
      v[,i] <- x[,ind]
    }
  }
  colnames(v) <- ucls
  v
}

Try the FIRMAGene package in your browser

Any scripts or data that you put into this service are public.

FIRMAGene documentation built on May 2, 2019, 5:55 p.m.