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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Mar 21 15:35:41 CET 2008


Author: gsimpson
Date: 2008-03-21 15:35:41 +0100 (Fri, 21 Mar 2008)
New Revision: 276

Modified:
   pkg/R/numPerms.R
   pkg/inst/ChangeLog
   pkg/man/permCheck.Rd
Log:
numPerms now works if you tell it the number of observations

Modified: pkg/R/numPerms.R
===================================================================
--- pkg/R/numPerms.R	2008-03-21 11:12:23 UTC (rev 275)
+++ pkg/R/numPerms.R	2008-03-21 14:35:41 UTC (rev 276)
@@ -1,5 +1,8 @@
 `numPerms` <- function(object, control = permControl())
 {
+    ## expand object if a numeric or integer vector of length 1
+    if((is.numeric(object) || is.integer(object)) && (length(object) == 1))
+         object <- seq_len(object)
     ## number of observations in data
     nobs <- getNumObs(object)
     ## are strata present?

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2008-03-21 11:12:23 UTC (rev 275)
+++ pkg/inst/ChangeLog	2008-03-21 14:35:41 UTC (rev 276)
@@ -6,7 +6,14 @@
 
 	* allPerms: New function to enumerate all possible permutations
 	for a given permutation scheme and number of samples. Has 'print'
-	and 'summary' methods
+	and 'summary' methods.
+
+	* numPerms: Now accepts a numeric or integer vector of length 1
+	as the first argument 'object'. If supplied it is expanded to
+	seq(from = 1, to = object). This change allows you to state the
+	number of observations rather than pass an object from which the 
+	number of observations is deduced. Updated and clarified 
+	documentation in this regard.
 	
 Version 1.12-4 (closed Mar 20, 2008)
 	

Modified: pkg/man/permCheck.Rd
===================================================================
--- pkg/man/permCheck.Rd	2008-03-21 11:12:23 UTC (rev 275)
+++ pkg/man/permCheck.Rd	2008-03-21 14:35:41 UTC (rev 276)
@@ -44,10 +44,13 @@
 }
 
 \arguments{
-  \item{object}{an R object. Specifically, any object handled by
-    \code{\link{scores}}, data frames, matrices, and numeric and
-    integer  vectors. For \code{\link{summary.permCheck}} an object of
-    class \code{"permCheck"}.}
+  \item{object}{an R object. Specifically, for \code{getNumObs} any
+    object handled by \code{\link{scores}}, data frames, matrices, and
+    numeric and integer  vectors. See Details for a complete
+    description, especially for \code{numPerms}. For
+    \code{\link{summary.permCheck}} an object of class
+    \code{"permCheck"}. For \code{\link{summary.allPerms}} an object of
+    class \code{"allPerms"}.} 
   \item{control}{a list of control values describing properties of the
     permutation design, as returned by a call to
     \code{\link{permControl}}.}
@@ -83,6 +86,16 @@
   permutations, and as such complete enumeration of all permutations is
   turned  on (\code{control$complete} is set to \code{TRUE}).
 
+  Function \code{numPerms} returns the number of permutations for the
+  passed \code{object} and the selected permutation
+  scheme. \code{object} can be one of a data frame, matrix, an object
+  for which a scores method exists, or a numeric or integer vector. In
+  the case of a numeric or integer vector, a vector of length 1 can be
+  used and it will be expanded to a vector of length \code{object}
+  (i.e., \code{1:object}) before computing the number of
+  permutations. As such, \code{object} can be the number of observations
+  not just the object containing the observations.
+
   Function \code{allPerms} enumerates all possible permutations for the
   number of observations and the selected permutation scheme. It has
   \code{\link{print}} and \code{\link{summary}} methods. \code{allPerms}
@@ -99,6 +112,12 @@
   control this and guard against trying to evaluate too large a number
   of permutations, if the number of possible permutations is larger than
   \code{max}, \code{allPerms} exits with an error.
+
+  Function \code{getNumObs} is a simple generic function to return the
+  number of observations in a range of R objects. The default method
+  will work for any object for which a \code{\link{scores}} method
+  exists. This includes matrices and data frames, as well as specific
+  methods for numeric or integer vectors.
 }
 \value{
   For \code{permCheck} a list containing the maximum number of



More information about the Vegan-commits mailing list