[Analogue-commits] r214 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Mar 26 20:20:32 CET 2011


Author: gsimpson
Date: 2011-03-26 20:20:32 +0100 (Sat, 26 Mar 2011)
New Revision: 214

Modified:
   pkg/R/waFit.R
Log:
Fixes NA or NaN optima issue

Modified: pkg/R/waFit.R
===================================================================
--- pkg/R/waFit.R	2011-03-26 19:18:54 UTC (rev 213)
+++ pkg/R/waFit.R	2011-03-26 19:20:32 UTC (rev 214)
@@ -1,10 +1,13 @@
-`waFit` <- function(x, y, tol.dw, useN2, deshrink, na.tol, small.tol,
-                     min.tol, f) {
+`waFit` <- function(x, y, tol.dw, useN2, deshrink, na.tol,
+                    small.tol, min.tol, f) {
     ## sample summaries
     n.samp <- nrow(x)
     n.spp <- ncol(x)
     ## calculate WA optima for each species in x
     wa.optima <- w.avg(x, y)
+    ## fix-up NaN or NA optima
+    if(any(miss <- is.na(wa.optima)))
+        wa.optima[miss] <- 0
     ## compute tolerances
     tolerances <- tol <- w.tol(x, y, wa.optima, useN2 = useN2)
     ## fix-up tolerances for use in TF computations



More information about the Analogue-commits mailing list