R/normalizeRows.R

Defines functions normalizeRows

normalizeRows <-
function(dat) {
  if (is.matrix(dat)) {
    norm.abundance <- dat/rowSums(dat)
    norm.abundance[is.nan(norm.abundance)] <- 0
    norm.abundance
  }
  if (is.vector(dat)) {
    norm.abundance <- dat/sum(dat)
    norm.abundance[is.nan(norm.abundance)] <- 0
  }
  return(norm.abundance)
}

Try the hierDiversity package in your browser

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

hierDiversity documentation built on May 2, 2019, 12:39 p.m.