[Vegan-commits] r990 - in pkg/vegan: R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 4 08:02:20 CEST 2009


Author: jarioksa
Date: 2009-09-04 08:02:19 +0200 (Fri, 04 Sep 2009)
New Revision: 990

Modified:
   pkg/vegan/R/ordiNAexclude.R
   pkg/vegan/R/weights.cca.R
   pkg/vegan/R/weights.rda.R
   pkg/vegan/inst/ChangeLog
Log:
weights for cca/rda know na.action, and fixes for saving excluded rowsums

Modified: pkg/vegan/R/ordiNAexclude.R
===================================================================
--- pkg/vegan/R/ordiNAexclude.R	2009-09-03 14:48:47 UTC (rev 989)
+++ pkg/vegan/R/ordiNAexclude.R	2009-09-04 06:02:19 UTC (rev 990)
@@ -13,7 +13,7 @@
         return(x)
     ## rowsums for CA (in RDA/PCA rowsum = NA)
     if (!inherits(x, "rda"))
-        x$rowsum.exclude <- rowSums(excluded)/x$grand.total
+        x$rowsum.excluded <- rowSums(excluded)/x$grand.total
     ## Estimate WA scores for NA cases with newdata of excluded
     ## observations
     if (is.null(x$pCCA)) {
@@ -37,7 +37,7 @@
         return(x)
     if (!inherits(x, "rda")) {
         x$rowsum <- napredict(omit, x$rowsum)
-        if (inhertis(omit, "exclude"))
+        if (inherits(omit, "exclude"))
             x$rowsum[omit] <- x$rowsum.excluded
     }
     if (!is.null(x$CCA)) {

Modified: pkg/vegan/R/weights.cca.R
===================================================================
--- pkg/vegan/R/weights.cca.R	2009-09-03 14:48:47 UTC (rev 989)
+++ pkg/vegan/R/weights.cca.R	2009-09-04 06:02:19 UTC (rev 990)
@@ -2,7 +2,13 @@
     function (object, display = "sites", ...) 
 {
     display <- match.arg(display, c("sites", "species", "lc", "wa"))
-    if (display %in% c("sites", "lc", "wa")) 
+    if (display %in% c("sites", "lc", "wa")) {
+        if (!is.null(object$na.action) &&
+            inherits(object$na.action, "exclude")) {
+            object$rowsum <- napredict(object$na.action, object$rowsum)
+            object$rowsum[object$na.action] <- object$rowsum.excluded
+            }
         object$rowsum
+    }
     else object$colsum
 }

Modified: pkg/vegan/R/weights.rda.R
===================================================================
--- pkg/vegan/R/weights.rda.R	2009-09-03 14:48:47 UTC (rev 989)
+++ pkg/vegan/R/weights.rda.R	2009-09-04 06:02:19 UTC (rev 990)
@@ -3,8 +3,12 @@
 {
     display <- match.arg(display, c("sites", "species", "lc", 
                                     "wa"))
-    n <- if (display %in% c("sites", "lc", "wa")) 
-        max(nrow(object$CA$Xbar), nrow(object$CCA$Xbar))
-    else max(ncol(object$CA$Xbar), ncol(object$CCA$Xbar))
+    if (display %in% c("sites", "lc", "wa")) {
+        n <- max(nrow(object$CA$Xbar), nrow(object$CCA$Xbar))
+        if (!is.null(object$na.action) &&
+            inherits(object$na.action, "exclude"))
+            n <- n + length(object$na.action)
+    }
+    else n <- max(ncol(object$CA$Xbar), ncol(object$CCA$Xbar))
     rep(1, n)
 }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-09-03 14:48:47 UTC (rev 989)
+++ pkg/vegan/inst/ChangeLog	2009-09-04 06:02:19 UTC (rev 990)
@@ -10,7 +10,9 @@
 	and scores.rda pads the results with these excluded data. In this
 	way the internal structure of the cca object remains unchanged,
 	but functions accessing the result with scores will get the NA
-	data.  
+	data. 
+
+	* weights.cca and weights.rda know na.action.
 	
 	* plot.cca: works when there are NA values in scores.
 



More information about the Vegan-commits mailing list