[Vegan-commits] r738 - pkg/vegan/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Mar 13 02:52:13 CET 2009


Author: psolymos
Date: 2009-03-13 02:52:12 +0100 (Fri, 13 Mar 2009)
New Revision: 738

Modified:
   pkg/vegan/R/adipart.R
   pkg/vegan/R/print.adipart.R
Log:
call attribute and some stop() message added


Modified: pkg/vegan/R/adipart.R
===================================================================
--- pkg/vegan/R/adipart.R	2009-03-11 17:24:00 UTC (rev 737)
+++ pkg/vegan/R/adipart.R	2009-03-13 01:52:12 UTC (rev 738)
@@ -26,9 +26,13 @@
     rval[[1]] <- as.factor(rhs[,nlevs])
     rval[[1]] <- rval[[1]][drop = TRUE]
     nCol <- nlevs - 1
-    for (i in 2:nlevs) {
-        rval[[i]] <- interaction(rhs[,nCol], rval[[(i-1)]], drop=TRUE)
-        nCol <- nCol - 1
+    if (nlevs == 0)
+        stop("too few levels in the hierarchy")
+    if (nlevs > 1) {
+        for (i in 2:nlevs) {
+            rval[[i]] <- interaction(rhs[,nCol], rval[[(i-1)]], drop=TRUE)
+            nCol <- nCol - 1
+        }
     }
     rval <- as.data.frame(rval[rev(1:length(rval))])
     l2 <- sapply(rval, function(z) length(unique(z)))
@@ -80,6 +84,7 @@
     nam <- c(paste("alpha", 1:(nlevs-1), sep="."), "gamma",
         paste("beta", 1:(nlevs-1), sep="."))
     names(sim$statistic) <- attr(sim$oecosimu$statistic, "names") <- nam
+    attr(sim, "call") <- match.call()
     attr(sim, "index") <- index
     attr(sim, "weights") <- weights
     attr(sim, "n.levels") <- nlevs
@@ -88,3 +93,4 @@
     class(sim) <- c("adipart", "list")
     sim
 }
+

Modified: pkg/vegan/R/print.adipart.R
===================================================================
--- pkg/vegan/R/print.adipart.R	2009-03-11 17:24:00 UTC (rev 737)
+++ pkg/vegan/R/print.adipart.R	2009-03-13 01:52:12 UTC (rev 738)
@@ -3,7 +3,7 @@
 {
     cat("adipart with", ncol(x$oecosimu$simulated), "simulations\n")
     att <- attributes(x)
-    att$names <- att$class <- att$n.levels <- att$terms <- att$model <- NULL
+    att$names <- att$call <- att$class <- att$n.levels <- att$terms <- att$model <- NULL
     cat("with", paste(names(att), att, collapse=", "))
 
     cat("\n\n")



More information about the Vegan-commits mailing list