[Vegan-commits] r1656 - in pkg/permute: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jun 26 13:44:44 CEST 2011


Author: gsimpson
Date: 2011-06-26 13:44:43 +0200 (Sun, 26 Jun 2011)
New Revision: 1656

Added:
   pkg/permute/R/nobs-methods.R
   pkg/permute/man/nobs.Rd
Removed:
   pkg/permute/R/getNumObs.R
   pkg/permute/man/getNumObs.Rd
Modified:
   pkg/permute/NAMESPACE
   pkg/permute/R/allPerms.R
   pkg/permute/R/numPerms.R
   pkg/permute/R/permCheck.R
   pkg/permute/man/numPerms.Rd
   pkg/permute/man/shuffle.Rd
Log:
get permute to pass R CMD check, getNumObs() changed to nobs() methods

Modified: pkg/permute/NAMESPACE
===================================================================
--- pkg/permute/NAMESPACE	2011-06-26 10:58:20 UTC (rev 1655)
+++ pkg/permute/NAMESPACE	2011-06-26 11:44:43 UTC (rev 1656)
@@ -1,5 +1,5 @@
 ## Visible functions:
-export(`allPerms`, `Blocks`, `getNumObs`, `numPerms`, `permCheck`,
+export(`allPerms`, `Blocks`, `numPerms`, `permCheck`,
        `permControl`, `permute`, `shuffle`, `Within`)
 
 ## Imports
@@ -15,12 +15,8 @@
 # summary methods
 S3method(`summary`, `allPerms`)
 S3method(`summary`, `permCheck`)
-# getNumObs methods
-S3method(`getNumObs`, `default`)
-S3method(`getNumObs`, `numeric`)
-S3method(`getNumObs`, `integer`)
 ## nobs() methods
 S3method(`nobs`, `numeric`)
 S3method(`nobs`, `integer`)
 S3method(`nobs`, `matrix`)
-S3method(`nobs`, `cca`)
+S3method(`nobs`, `data.frame`)

Modified: pkg/permute/R/allPerms.R
===================================================================
--- pkg/permute/R/allPerms.R	2011-06-26 10:58:20 UTC (rev 1655)
+++ pkg/permute/R/allPerms.R	2011-06-26 11:44:43 UTC (rev 1656)
@@ -18,7 +18,7 @@
     if((is.numeric(n) || is.integer(n)) && (length(n) == 1))
          v <- seq_len(n)
     ## number of observations in data
-    n <- nobs(v) ## getNumObs
+    n <- nobs(v)
     ## check permutation scheme and update control
     pcheck <- permCheck(v, control = control, make.all = FALSE)
     ctrl <- pcheck$control

Deleted: pkg/permute/R/getNumObs.R
===================================================================
--- pkg/permute/R/getNumObs.R	2011-06-26 10:58:20 UTC (rev 1655)
+++ pkg/permute/R/getNumObs.R	2011-06-26 11:44:43 UTC (rev 1656)
@@ -1,33 +0,0 @@
-`getNumObs` <- function(object, ...) UseMethod("getNumObs")
-
-`getNumObs.default` <- function(object, ...)
-{
-    NROW(scores(object, display = "sites"))
-}
-
-`getNumObs.numeric` <- function(object, ...)
-{
-    length(object)
-}
-
-`getNumObs.integer` <- function(object, ...)
-{
-    getNumObs.numeric(object)
-}
-
-## add some nobs() methods - need to be documented
-`nobs.numeric` <- function(object, ...) {
-    length(object)
-}
-
-`nobs.integer` <- function(object, ...) {
-    nobs.numeric(object, ...)
-}
-
-`nobs.matrix` <- function(object, ...) {
-    NROW(object)
-}
-
-`nobs.cca` <- function(object, ...) {
-    NROW(scores(object, display = "sites"))
-}

Copied: pkg/permute/R/nobs-methods.R (from rev 1653, pkg/permute/R/getNumObs.R)
===================================================================
--- pkg/permute/R/nobs-methods.R	                        (rev 0)
+++ pkg/permute/R/nobs-methods.R	2011-06-26 11:44:43 UTC (rev 1656)
@@ -0,0 +1,17 @@
+## add some nobs() methods - need to be documented
+`nobs.numeric` <- function(object, ...) {
+    length(object)
+}
+
+`nobs.integer` <- function(object, ...) {
+    nobs.numeric(object, ...)
+}
+
+`nobs.matrix` <- function(object, ...) {
+    NROW(object)
+}
+
+`nobs.data.frame` <- function(object, ...) {
+    NROW(object)
+}
+

Modified: pkg/permute/R/numPerms.R
===================================================================
--- pkg/permute/R/numPerms.R	2011-06-26 10:58:20 UTC (rev 1655)
+++ pkg/permute/R/numPerms.R	2011-06-26 11:44:43 UTC (rev 1656)
@@ -7,7 +7,7 @@
        (length(object) == 1))
         object <- seq_len(object)
     ## number of observations in data
-    nobs <- getNumObs(object)
+    nobs <- nobs(object)
     ## within perms object
     WITHIN <- control$within
     ## strata perms object

Modified: pkg/permute/R/permCheck.R
===================================================================
--- pkg/permute/R/permCheck.R	2011-06-26 10:58:20 UTC (rev 1655)
+++ pkg/permute/R/permCheck.R	2011-06-26 11:44:43 UTC (rev 1656)
@@ -7,7 +7,7 @@
        (is.integer(object) || is.numeric(object)))
         object <- seq_len(object)
     ## check the number of observations in object
-    nobs <- getNumObs(object)
+    nobs <- nobs(object)
     ## sample permutation type
     type <- control$within$type
     ## if strata, check nobs == length of strata

Deleted: pkg/permute/man/getNumObs.Rd
===================================================================
--- pkg/permute/man/getNumObs.Rd	2011-06-26 10:58:20 UTC (rev 1655)
+++ pkg/permute/man/getNumObs.Rd	2011-06-26 11:44:43 UTC (rev 1656)
@@ -1,54 +0,0 @@
-\name{getNumObs}
-\alias{getNumObs}
-\alias{getNumObs.default}
-\alias{getNumObs.integer}
-\alias{getNumObs.numeric}
-\alias{nobs.numeric}
-\alias{nobs.integer}
-\alias{nobs.matrix}
-\alias{nobs.cca}
-
-\title{Number of observations in a given object}
-\description{
-  \code{getNumObs} is a utility function to return the number of
-  observations for a range of R and ordination objects.
-}
-\usage{
-getNumObs(object, \dots)
-
-\method{getNumObs}{default}(object, \dots)
-
-\method{getNumObs}{numeric}(object, \dots)
-
-\method{getNumObs}{integer}(object, \dots)
-}
-\arguments{
-  \item{object}{any R object handled by \code{\link[vegan]{scores}},
-    data frames, matrices, and numeric and integer vectors.}
-  \item{\dots}{arguments to other methods.}
-}
-\details{
-  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[vegan]{scores}}
-  method exists. This includes matrices and data frames, as well as
-  specific methods for numeric or integer vectors.
-}
-\value{
-  The (numeric) number of observations in \code{object}.
-}
-\author{Gavin Simpson}
-\examples{
-## vector
-len <- sample(1:10, 1)
-v <- numeric(sample(1:100, len))
-len
-obs <- getNumObs(v)
-isTRUE(all.equal(len, obs))
-
-## integer
-len <- sample(1:10, 1)
-obs <- getNumObs(len)
-isTRUE(all.equal(len, obs))
-
-}

Copied: pkg/permute/man/nobs.Rd (from rev 1653, pkg/permute/man/getNumObs.Rd)
===================================================================
--- pkg/permute/man/nobs.Rd	                        (rev 0)
+++ pkg/permute/man/nobs.Rd	2011-06-26 11:44:43 UTC (rev 1656)
@@ -0,0 +1,50 @@
+\name{nobs-methods}
+\alias{nobs-methods}
+\alias{nobs.numeric}
+\alias{nobs.integer}
+\alias{nobs.matrix}
+\alias{nobs.data.frame}
+
+\title{Number of observations in a given object}
+\description{
+  \code{\link{nobs}} is a generic function to return the number of
+  observations from a model. \code{shuffle} provides a few methods for
+  other types of data object in R.
+}
+\usage{
+
+\method{nobs}{numeric}(object, \dots)
+
+\method{nobs}{integer}(object, \dots)
+
+\method{nobs}{matrix}(object, \dots)
+
+\method{nobs}{data.frame}(object, \dots)
+}
+\arguments{
+  \item{object}{a data frame or matrix, or a numeric or integer vector.}
+  \item{\dots}{arguments to other methods.}
+}
+\details{
+  Function \code{nobs} is a simple generic function to return the
+  number of observations in a range of R model objects. Methods are
+  provided to work with a variety of R objects.
+}
+\value{
+  The (numeric) number of observations in \code{object}.
+}
+\author{Gavin Simpson}
+\examples{
+## vector
+len <- sample(1:10, 1)
+v <- numeric(sample(1:100, len))
+len
+obs <- nobs(v)
+isTRUE(all.equal(len, obs))
+
+## integer
+len <- sample(1:10, 1)
+obs <- nobs(len)
+isTRUE(all.equal(len, obs))
+
+}

Modified: pkg/permute/man/numPerms.Rd
===================================================================
--- pkg/permute/man/numPerms.Rd	2011-06-26 10:58:20 UTC (rev 1655)
+++ pkg/permute/man/numPerms.Rd	2011-06-26 11:44:43 UTC (rev 1656)
@@ -10,7 +10,7 @@
 numPerms(object, control = permControl())
 }
 \arguments{
-  \item{object}{any object handled by \code{\link{getNumObs}}.}
+  \item{object}{any object handled by \code{\link{nobs}}.}
   \item{control}{a list of control values describing properties of the
     permutation design, as returned by a call to
     \code{\link{permControl}}.}
@@ -60,19 +60,21 @@
   \emph{grid} is not an issue here.
 }
 \author{Gavin Simpson}
-\seealso{\code{\link{shuffle}} and \code{\link{permControl}}.}
+\seealso{\code{\link{shuffle}} and
+  \code{\link{permControl}}. Additional \code{\link{nobs}} methods are
+  provide, see \code{\link{nobs-methods}}.}
 \examples{
 ## permutation design --- see ?permControl
 ctrl <- permControl() ## defaults to freely exchangeable
 
 ## vector
 v <- 1:10
-(obs <- getNumObs(v))
+(obs <- nobs(v))
 numPerms(v, control = ctrl)
 
 ## integer
 len <- length(v)
-(obs <- getNumObs(len))
+(obs <- nobs(len))
 numPerms(len, control = ctrl)
 
 ## new design, objects are a time series

Modified: pkg/permute/man/shuffle.Rd
===================================================================
--- pkg/permute/man/shuffle.Rd	2011-06-26 10:58:20 UTC (rev 1655)
+++ pkg/permute/man/shuffle.Rd	2011-06-26 11:44:43 UTC (rev 1656)
@@ -241,7 +241,7 @@
     ## check the control object
     control <- permCheck(x, control)$control
     ## number of observations
-    Nobs <- getNumObs(x)
+    Nobs <- nobs(x)
     ## group names
     lev <- names(table(group))
     ## vector to hold results, +1 because of observed t



More information about the Vegan-commits mailing list