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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 13 20:41:12 CEST 2012


Author: psolymos
Date: 2012-07-13 20:41:12 +0200 (Fri, 13 Jul 2012)
New Revision: 2233

Modified:
   pkg/vegan/R/adipart.formula.R
   pkg/vegan/R/hiersimu.formula.R
   pkg/vegan/R/multipart.formula.R
   pkg/vegan/inst/ChangeLog
Log:
applying hierParseFormula

Modified: pkg/vegan/R/adipart.formula.R
===================================================================
--- pkg/vegan/R/adipart.formula.R	2012-07-13 18:37:52 UTC (rev 2232)
+++ pkg/vegan/R/adipart.formula.R	2012-07-13 18:41:12 UTC (rev 2233)
@@ -3,20 +3,13 @@
              weights=c("unif", "prop"), relative = FALSE, nsimul=99, ...)
 {
     ## evaluate formula
-    lhs <- formula[[2]]
     if (missing(data))
         data <- parent.frame()
-    lhs <- as.matrix(eval(lhs, data))
-    formula[[2]] <- NULL
-    rhs <- model.frame(formula, data, drop.unused.levels = TRUE)
+    tmp <- hierParseFormula(formula, data)
+    lhs <- tmp$lhs
+    rhs <- tmp$rhs
 
-    ## check proper design of the model frame
-    noint <- attr(attr(attr(rhs, "terms"), "factors"), "dimnames")[[1]]
-    int <- attr(attr(attr(rhs, "terms"), "factors"), "dimnames")[[2]]
-    if (!identical(noint, int))
-        stop("interactions are not allowed in formula")
-    if (!all(attr(attr(rhs, "terms"), "dataClasses") == "factor"))
-        stop("all right hand side variables in formula must be factors")
+    ## run simulations
     sim <- adipart.default(lhs, rhs, index = index, weights = weights,
                            relative = relative, nsimul = nsimul, ...)
     call <- match.call()

Modified: pkg/vegan/R/hiersimu.formula.R
===================================================================
--- pkg/vegan/R/hiersimu.formula.R	2012-07-13 18:37:52 UTC (rev 2232)
+++ pkg/vegan/R/hiersimu.formula.R	2012-07-13 18:41:12 UTC (rev 2233)
@@ -3,20 +3,13 @@
              relative = FALSE, drop.highest = FALSE, nsimul=99, ...)
 {
     ## evaluate formula
-    lhs <- formula[[2]]
     if (missing(data))
         data <- parent.frame()
-    lhs <- as.matrix(eval(lhs, data))
-    formula[[2]] <- NULL
-    rhs <- model.frame(formula, data, drop.unused.levels = TRUE)
+    tmp <- hierParseFormula(formula, data)
+    lhs <- tmp$lhs
+    rhs <- tmp$rhs
 
-    ## check proper design of the model frame
-    noint <- attr(attr(attr(rhs, "terms"), "factors"), "dimnames")[[1]]
-    int <- attr(attr(attr(rhs, "terms"), "factors"), "dimnames")[[2]]
-    if (!identical(noint, int))
-        stop("interactions are not allowed in formula")
-    if (!all(attr(attr(rhs, "terms"), "dataClasses") == "factor"))
-        stop("all right hand side variables in formula must be factors")
+    ## run simulations
     sim <- hiersimu.default(lhs, rhs, FUN = FUN, location = location,
                             relative = relative, drop.highest = drop.highest,
                             nsimul = nsimul, ...)
@@ -25,3 +18,4 @@
     attr(sim, "call") <- call
     sim
 }
+

Modified: pkg/vegan/R/multipart.formula.R
===================================================================
--- pkg/vegan/R/multipart.formula.R	2012-07-13 18:37:52 UTC (rev 2232)
+++ pkg/vegan/R/multipart.formula.R	2012-07-13 18:41:12 UTC (rev 2233)
@@ -3,20 +3,13 @@
              global = FALSE, relative = FALSE, nsimul=99, ...)
 {
     ## evaluate formula
-    lhs <- formula[[2]]
     if (missing(data))
         data <- parent.frame()
-    lhs <- as.matrix(eval(lhs, data))
-    formula[[2]] <- NULL
-    rhs <- model.frame(formula, data, drop.unused.levels = TRUE)
+    tmp <- hierParseFormula(formula, data)
+    lhs <- tmp$lhs
+    rhs <- tmp$rhs
 
-    ## check proper design of the model frame
-    noint <- attr(attr(attr(rhs, "terms"), "factors"), "dimnames")[[1]]
-    int <- attr(attr(attr(rhs, "terms"), "factors"), "dimnames")[[2]]
-    if (!identical(noint, int))
-        stop("interactions are not allowed in formula")
-    if (!all(attr(attr(rhs, "terms"), "dataClasses") == "factor"))
-        stop("all right hand side variables in formula must be factors")
+    ## run simulations
     sim <- multipart.default(lhs, rhs, index = index, scales = scales,
                              global = global, relative = relative,
                              nsimul = nsimul, ...)

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2012-07-13 18:37:52 UTC (rev 2232)
+++ pkg/vegan/inst/ChangeLog	2012-07-13 18:41:12 UTC (rev 2233)
@@ -28,7 +28,10 @@
 	and shows the call. print.oecosimu() is able to display adipart(),
 	hiersimu() and multipart() results, but does not show all
 	informations that those dedicated functions showed about options. 
-	
+
+	* Formula methods for adipart/multipart/hiersimu functions
+	use a new internal (hierParseFormula) to interpret the formula.
+
 Version 2.1-16 (closed June 18, 2012)
 
 	* envfit: plot() gained new argument 'bg' that triggers labelling



More information about the Vegan-commits mailing list