[Vegan-commits] r308 - in pkg: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Apr 8 23:44:36 CEST 2008


Author: gsimpson
Date: 2008-04-08 23:44:36 +0200 (Tue, 08 Apr 2008)
New Revision: 308

Modified:
   pkg/R/allPerms.R
   pkg/inst/ChangeLog
   pkg/man/permCheck.Rd
Log:
allPerms now accepts a vector from which number of observations can be deduced. This was the intended behaviour but it failed in such case.

Modified: pkg/R/allPerms.R
===================================================================
--- pkg/R/allPerms.R	2008-04-08 08:32:12 UTC (rev 307)
+++ pkg/R/allPerms.R	2008-04-08 21:44:36 UTC (rev 308)
@@ -85,7 +85,12 @@
         do.call(rbind, res)
     }
     ## start
-    v <- seq_len(n)
+    v <- n
+    ## expand n if a numeric or integer vector of length 1
+    if((is.numeric(n) || is.integer(n)) && (length(n) == 1))
+         v <- seq_len(n)
+    ## number of observations in data
+    n <- getNumObs(v)
     ## check permutation scheme and update control
     pcheck <- permCheck(v, control = control, make.all = FALSE)
     control <- pcheck$control
@@ -107,7 +112,7 @@
         ## see permuted.index2 for how to do this
         if(control$constant) {
             ## same permutation in each block
-            v <- seq_len(n)
+            #v <- seq_len(n)
             pg <- unique(table(control$strata))
             control.wi <- permControl(type = control$type,
                                       mirror = control$mirror,

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2008-04-08 08:32:12 UTC (rev 307)
+++ pkg/inst/ChangeLog	2008-04-08 21:44:36 UTC (rev 308)
@@ -17,6 +17,10 @@
 	* summary.cca: contributions of eigenvalues accumulated for
 	constrained and unconstrained axes, and separately (new) for
 	constrained axes. 
+
+	* allPerms: Now accepts a vector from which number of observations 
+	can be deduced. This was the intended behaviour but allPerms failed
+	in such cases.
 	
 Version 1.12-8 (closed April 6, 2008)
 

Modified: pkg/man/permCheck.Rd
===================================================================
--- pkg/man/permCheck.Rd	2008-04-08 08:32:12 UTC (rev 307)
+++ pkg/man/permCheck.Rd	2008-04-08 21:44:36 UTC (rev 308)
@@ -65,7 +65,8 @@
   \item{make.all}{logical; should \code{permCheck} generate all
     possible permutations? Useful if want to check permutation design
     but not produce the matrix of all permutations.}
-  \item{n}{the number of observations.}
+  \item{n}{the number of observations or an 'object' from which the
+    number of observations can be determined via \code{getNumObs}.}
   \item{max}{the maximum number of permutations, below which complete
     enumeration will be attempted. See Details.}
   \item{observed}{logical, should the observed ordering of samples be
@@ -289,6 +290,10 @@
 numPerms(7, permControl(type = "series", strata = fac))
 allPerms(7, permControl(type = "series", strata = fac))
 
+## allPerms can work with a vector
+vec <- c(3,4,5)
+allPerms(vec)
+
 ## Tests for permuplot
 n <- 25
 ## standard permutation designs



More information about the Vegan-commits mailing list