[Analogue-commits] r335 - in pkg: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jul 11 22:32:56 CEST 2013


Author: gsimpson
Date: 2013-07-11 22:32:56 +0200 (Thu, 11 Jul 2013)
New Revision: 335

Modified:
   pkg/R/chooseTaxa.R
   pkg/inst/ChangeLog
   pkg/man/chooseTaxa.Rd
Log:
adds 'na.rm = FALSE' argument to chooseTaxa

Modified: pkg/R/chooseTaxa.R
===================================================================
--- pkg/R/chooseTaxa.R	2013-06-04 03:04:16 UTC (rev 334)
+++ pkg/R/chooseTaxa.R	2013-07-11 20:32:56 UTC (rev 335)
@@ -4,12 +4,15 @@
 
 chooseTaxa.default <- function(object, n.occ = 1, max.abun = 0,
                                type = c("AND","OR"), value = TRUE,
-                               ...) {
+                               na.rm = FALSE, ...) {
     if(missing(type))
         type <- "AND"
     type <- match.arg(type)
-    occ.want <- colSums(object > 0) >= n.occ
-    abun.want <- apply(object, 2, max) >= max.abun
+    ## issue a warning if any values in object are NA
+    if(any(is.na(object)))
+        warning("'NA's present in data; results may not be what you expect.\nConsider using 'na.rm = TRUE'.")
+    occ.want <- colSums(object > 0, na.rm = na.rm) >= n.occ
+    abun.want <- apply(object, 2, max, na.rm = na.rm) >= max.abun
     want <- if(isTRUE(all.equal(type, "AND"))) {
         occ.want & abun.want
     } else {

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2013-06-04 03:04:16 UTC (rev 334)
+++ pkg/inst/ChangeLog	2013-07-11 20:32:56 UTC (rev 335)
@@ -6,6 +6,10 @@
 	the selected species or a logical vector indicating which columns
 	(species) met the selection criteria.
 
+	New argument `na.rm = FALSE` to control whether or not `NA`s are
+	excluded from the calculation of abundance and occurrence. Suggested
+	by Michael Burstert.
+
 	* scores.prcurve: now preserves the rownames on the `lambda`
 	component.
 

Modified: pkg/man/chooseTaxa.Rd
===================================================================
--- pkg/man/chooseTaxa.Rd	2013-06-04 03:04:16 UTC (rev 334)
+++ pkg/man/chooseTaxa.Rd	2013-07-11 20:32:56 UTC (rev 335)
@@ -13,7 +13,8 @@
 chooseTaxa(object, \dots)
 
 \method{chooseTaxa}{default}(object, n.occ = 1, max.abun = 0,
-           type = c("AND","OR"), value = TRUE, \dots)
+           type = c("AND","OR"), value = TRUE, na.rm = FALSE,
+           \dots)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
@@ -38,6 +39,8 @@
     returned? If \code{TRUE}, the default, the data for the chosen taxa
     are returned. If \code{FALSE}, a logical vector is returned,
     indicating which taxa met the selection criteria.}
+  \item{na.rm}{logical; should missing values \code{NA}s be excluded
+    from the calculation of abundances and occurrence?}
   \item{\dots}{arguments passed on to subsequent methods.}
 }
 %\details{



More information about the Analogue-commits mailing list