R/normalize_rows.R

Defines functions normalize_rows

Documented in normalize_rows

#' Normalize rows function
#'
#' Normalizes rows for diversity calculations
#' @keywords jost
#' @export
#' @examples
#' normalize_rows()

normalize_rows <- function(com.matrix){

  row.totals <- rowSums(com.matrix)

  com.matrix <- as.matrix(com.matrix)

  for(i in 1:nrow(com.matrix)){
    com.matrix[i, ] <- com.matrix[i, ] / row.totals[i]
  }

  return(com.matrix)
}
ebatzer/JostDiv documentation built on Nov. 4, 2019, 11:28 a.m.