From 428a1dd675bb469413a9e9087500ac808a9c3a77 Mon Sep 17 00:00:00 2001 From: antagomir Date: Sat, 25 Mar 2017 02:07:24 +0100 Subject: [PATCH] Added na.rm option to taxa_sums. This helps to avoid certain errors when desired. FALSE by default. --- R/otuTable-class.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/otuTable-class.R b/R/otuTable-class.R index f202de95..6df7cf6c 100644 --- a/R/otuTable-class.R +++ b/R/otuTable-class.R @@ -92,6 +92,7 @@ setMethod("otu_table", "ANY", function(object, errorIfNULL=TRUE){ #' @usage taxa_sums(x) #' #' @param x \code{\link{otu_table-class}}, or \code{\link{phyloseq-class}}. +#' @param na.rm Ignore NA values in taking the sum. FALSE by default. #' #' @return A \code{\link{numeric-class}} with length equal to the number of species #' in the table, name indicated the taxa ID, and value equal to the sum of @@ -104,12 +105,12 @@ setMethod("otu_table", "ANY", function(object, errorIfNULL=TRUE){ #' taxa_sums(enterotype) #' data(esophagus) #' taxa_sums(esophagus) -taxa_sums <- function(x){ +taxa_sums <- function(x, na.rm = FALSE){ x <- otu_table(x) if( taxa_are_rows(x) ){ - rowSums(x) + rowSums(x, na.rm = na.rm) } else { - colSums(x) + colSums(x, na.rm = na.rm) } } ################################################################################