[Vegan-commits] r2232 - in pkg/vegan: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 13 20:37:52 CEST 2012


Author: psolymos
Date: 2012-07-13 20:37:52 +0200 (Fri, 13 Jul 2012)
New Revision: 2232

Added:
   pkg/vegan/R/hierParseFormula.R
Modified:
   pkg/vegan/man/vegan-internal.Rd
Log:
new internal for parsing formula in adipart+allies

Added: pkg/vegan/R/hierParseFormula.R
===================================================================
--- pkg/vegan/R/hierParseFormula.R	                        (rev 0)
+++ pkg/vegan/R/hierParseFormula.R	2012-07-13 18:37:52 UTC (rev 2232)
@@ -0,0 +1,20 @@
+"hierParseFormula" <-
+function (formula, data)
+{
+    lhs <- formula[[2]]
+    if (any(attr(terms(formula, data = data), "order") > 1)) 
+        stop("interactions are not allowed")
+    lhs <- as.matrix(eval(lhs, data))
+    formula[[2]] <- NULL
+    rhs <- model.frame(formula, data, drop.unused.levels = TRUE)
+    rhs[] <- lapply(rhs, function(u) {
+        if (!is.factor(u)) 
+            u <- factor(u)
+        u
+    })
+    if (length(rhs) < 2)
+        stop("at least 2 hierarchy levels are needed")
+    attr(rhs, "terms") <- NULL
+    list(lhs=lhs, rhs=rhs)
+}
+

Modified: pkg/vegan/man/vegan-internal.Rd
===================================================================
--- pkg/vegan/man/vegan-internal.Rd	2012-07-13 18:10:21 UTC (rev 2231)
+++ pkg/vegan/man/vegan-internal.Rd	2012-07-13 18:37:52 UTC (rev 2232)
@@ -10,6 +10,7 @@
 \alias{ordiArrowMul}
 \alias{ordiArgAbsorber}
 \alias{veganCovEllipse}
+\alias{hierParseFormula}
 
 \title{Internal vegan functions}
 
@@ -31,6 +32,7 @@
 permuted.index(n, strata)
 pasteCall(call, prefix = "Call:")
 veganCovEllipse(cov, center = c(0, 0), scale = 1, npoints = 100)
+hierParseFormula(formula, data)
 }
 
 \details{ The description here is only intended for \pkg{vegan}
@@ -79,6 +81,11 @@
 
   \code{veganCovEllipse} finds the coordinates for drawing a
   covariance ellipse.
+
+  \code{hierParseFormula} returns a list of one matrix (left hand side)
+  and a model frame with factors representing hierarchy levels 
+  to be used in \code{\link{adipart}}, \code{\link{multipart}}
+  and \code{\link{hiersimu}}.
 }
 
 \keyword{internal }



More information about the Vegan-commits mailing list