[Vegan-commits] r2759 - in pkg/permute: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Nov 26 05:56:33 CET 2013
Author: gsimpson
Date: 2013-11-26 05:56:32 +0100 (Tue, 26 Nov 2013)
New Revision: 2759
Modified:
pkg/permute/NAMESPACE
pkg/permute/R/getFoo-methods.R
pkg/permute/R/setFoo-methods.R
pkg/permute/man/set-methods.Rd
Log:
finish out the range of setFoo functions
Modified: pkg/permute/NAMESPACE
===================================================================
--- pkg/permute/NAMESPACE 2013-11-25 07:56:41 UTC (rev 2758)
+++ pkg/permute/NAMESPACE 2013-11-26 04:56:32 UTC (rev 2759)
@@ -13,7 +13,13 @@
"setComplete<-",
"setMake<-",
"setObserved<-",
- "setAllperms<-"
+ "setAllperms<-",
+ "setPlots<-",
+ "setWithin<-",
+ "setStrata<-",
+ "setRow<-",
+ "setCol<-",
+ "setDim<-"
)
### Imports: nobs() only exists in R 2.13.0 for import. We define the
@@ -103,28 +109,30 @@
S3method("getMake", "how")
S3method("getObserved", "default")
S3method("getObserved", "how")
+
## setFoo methods
S3method("setBlocks<-", "default")
S3method("setBlocks<-", "how")
S3method("setBlocks<-", "permControl")
-## S3method("setPlots", "default")
-## S3method("setPlots", "how")
-## S3method("setPlots", "permControl")
-## S3method("setWithin", "default")
-## S3method("setWithin", "how")
-## S3method("setWithin", "permControl")
-## S3method("setStrata", "default")
-## S3method("setStrata", "how")
-## S3method("setStrata", "permControl")
-## S3method("setType", "default")
-## S3method("setType", "how")
-## S3method("setType", "permControl")
-## S3method("setMirror", "default")
-## S3method("setMirror", "how")
-## S3method("setMirror", "permControl")
-## S3method("setConstant", "default")
-## S3method("setConstant", "how")
-## S3method("setConstant", "permControl")
+S3method("setPlots<-", "default")
+S3method("setPlots<-", "how")
+S3method("setWithin<-", "default")
+S3method("setWithin<-", "how")
+S3method("setStrata<-", "default")
+S3method("setStrata<-", "how")
+S3method("setStrata<-", "Plots")
+S3method("setType<-", "default")
+S3method("setType<-", "how")
+S3method("setType<-", "Within")
+S3method("setType<-", "Plots")
+S3method("setMirror<-", "default")
+S3method("setMirror<-", "how")
+S3method("setMirror<-", "Within")
+S3method("setMirror<-", "Plots")
+S3method("setConstant<-", "default")
+S3method("setConstant<-", "how")
+S3method("setConstant<-", "Within")
+S3method("setConstant<-", "Plots")
S3method("setNperm<-", "default")
S3method("setNperm<-", "how")
S3method("setNperm<-", "permControl")
@@ -137,15 +145,12 @@
S3method("setComplete<-", "default")
S3method("setComplete<-", "how")
S3method("setComplete<-", "permControl")
-## S3method("setRow", "default")
-## S3method("setRow", "how")
-## S3method("setRow", "permControl")
-## S3method("setCol", "default")
-## S3method("setCol", "how")
-## S3method("setCol", "permControl")
-## S3method("setDim", "default")
-## S3method("setDim", "how")
-## S3method("setDim", "permControl")
+S3method("setRow<-", "default")
+S3method("setRow<-", "how")
+S3method("setCol<-", "default")
+S3method("setCol<-", "how")
+S3method("setDim<-", "default")
+S3method("setDim<-", "how")
S3method("setMake<-", "default")
S3method("setMake<-", "how")
S3method("setMake<-", "permControl")
Modified: pkg/permute/R/getFoo-methods.R
===================================================================
--- pkg/permute/R/getFoo-methods.R 2013-11-25 07:56:41 UTC (rev 2758)
+++ pkg/permute/R/getFoo-methods.R 2013-11-26 04:56:32 UTC (rev 2759)
@@ -1,4 +1,5 @@
-## Extractor functions for blocks, plots and within, plus strata
+## Extractor functions for blocks, plots and within, plus strata,
+## etc ...
## Blocks
`getBlocks` <- function(object, ...) {
Modified: pkg/permute/R/setFoo-methods.R
===================================================================
--- pkg/permute/R/setFoo-methods.R 2013-11-25 07:56:41 UTC (rev 2758)
+++ pkg/permute/R/setFoo-methods.R 2013-11-26 04:56:32 UTC (rev 2759)
@@ -1,3 +1,5 @@
+## Replacement functions for blocks, plots and within, plus strata,
+## etc ...
`setNperm<-` <- function(object, value) {
UseMethod("setNperm<-")
}
@@ -179,3 +181,228 @@
object <- fixupCall(object, "observed", value)
object
}
+
+## Plots ##############################################################
+`setPlots<-` <- function(object, value) {
+ UseMethod("setPlots<-")
+}
+
+`setPlots<-.default` <- function(object, value) {
+ stop("No default method for `setPlots`")
+}
+
+`setPlots<-.how` <- function(object, value) {
+ stopifnot(inherits(value, "Plots"))
+ object[["plots"]] <- value
+ object <- fixupCall(object, "plots", getCall(value))
+ object
+}
+
+## Within ##############################################################
+`setWithin<-` <- function(object, value) {
+ UseMethod("setWithin<-")
+}
+
+`setWithin<-.default` <- function(object, value) {
+ stop("No default method for `setWithin`")
+}
+
+`setWithin<-.how` <- function(object, value) {
+ stopifnot(inherits(value, "Within"))
+ object[["within"]] <- value
+ object <- fixupCall(object, "within", getCall(value))
+ object
+}
+
+## Strata #############################################################
+`setStrata<-` <- function(object, value) {
+ UseMethod("setStrata<-")
+}
+
+`setStrata<-.default` <- function(object, value) {
+ stop("No default method for `setStrata`")
+}
+
+`setStrata<-.how` <- function(object, value) {
+ if (!is.null(value))
+ value <- as.factor(value)
+ object[["blocks"]] <- value
+ object <- fixupCall(object, "blocks", getCall(value))
+ object
+}
+
+`setStrata<-.Plots` <- function(object, value) {
+ if (!is.null(value))
+ value <- as.factor(value)
+ object[["strata"]] <- value
+ object <- fixupCall(object, "strata", getCall(value))
+ object
+}
+
+## Grid dimensions ####################################################
+`setRow<-` <- function(object, value) {
+ UseMethod("setRow<-")
+}
+
+`setRow<-.default` <- function(object, value) {
+ stop("No default method for `setRow`")
+}
+
+`setRow<-.how` <- function(object, value) {
+ stop("`setRow` can not be used directly on '\"how\"' objects.")
+}
+
+`setRow<-.Within` <- function(object, value) {
+ value <- as.integer(value)
+ object[["nrow"]] <- value
+ object <- fixupCall(object, "nrow", value)
+ object
+}
+
+`setRow<-.Plots` <- function(object, value) {
+ value <- as.integer(value)
+ object[["nrow"]] <- value
+ object <- fixupCall(object, "nrow", value)
+ object
+}
+
+`setCol<-` <- function(object, value) {
+ UseMethod("setCol<-")
+}
+
+`setCol<-.default` <- function(object, value) {
+ stop("No default method for `setCol`")
+}
+
+`setCol<-.how` <- function(object, value) {
+ stop("`setCol` can not be used directly on '\"how\"' objects.")
+}
+
+`setCol<-.Within` <- function(object, value) {
+ value <- as.integer(value)
+ object[["ncol"]] <- value
+ object <- fixupCall(object, "ncol", value)
+ object
+}
+
+`setCol<-.Plots` <- function(object, value) {
+ value <- as.integer(value)
+ object[["ncol"]] <- value
+ object <- fixupCall(object, "ncol", value)
+ object
+}
+
+`setDim<-` <- function(object, value) {
+ UseMethod("setDim<-")
+}
+
+`setDim<-.default` <- function(object, value) {
+ stop("No default method for `setDim`")
+}
+
+`setDim<-.how` <- function(object, value) {
+ stop("`setDim` can not be used directly on '\"how\"' objects.")
+}
+
+`setDim<-.Within` <- function(object, value) {
+ value <- as.integer(value)
+ stopifnot(all.equal(length(value), 2L))
+ setRow(object) <- value[1]
+ setCol(object) <- value[2]
+ object
+}
+
+`setDim<-.Plots` <- function(object, value) {
+ value <- as.integer(value)
+ stopifnot(all.equal(length(value), 2L))
+ setRow(object) <- value[1]
+ setCol(object) <- value[2]
+ object
+}
+
+## setType ############################################################
+`setType<-` <- function(object, value) {
+ UseMethod("setType<-")
+}
+
+`setType<-.default` <- function(object, value) {
+ stop("No default method for `setType`")
+}
+
+`setType<-.how` <- function(object, value) {
+ stop("`setType` can not be used directly on '\"how\"' objects.")
+}
+
+`setType<-.Within` <- function(object, value) {
+ value <- as.character(value)
+ if (!value %in% c("free","series","grid","none"))
+ stop("Invalid permutation type")
+ value <- rep(value, length.out = 1L)
+ object[["type"]] <- value
+ object <- fixupCall(object, "type", value)
+ object
+}
+
+`setType<-.Plots` <- function(object, value) {
+ value <- as.character(value)
+ if (!value %in% c("free","series","grid","none"))
+ stop("Invalid permutation type")
+ value <- rep(value, length.out = 1L)
+ object[["type"]] <- value
+ object <- fixupCall(object, "type", value)
+ object
+}
+
+## setMirror ############################################################
+`setMirror<-` <- function(object, value) {
+ UseMethod("setMirror<-")
+}
+
+`setMirror<-.default` <- function(object, value) {
+ stop("No default method for `setMirror`")
+}
+
+`setMirror<-.how` <- function(object, value) {
+ stop("`setMirror` can not be used directly on '\"how\"' objects.")
+}
+
+`setMirror<-.Within` <- function(object, value) {
+ if (!is.null(value))
+ value <- rep(as.logical(value), length.out = 1)
+ object[["Mirror"]] <- value
+ object <- fixupCall(object, "Mirror", value)
+ object
+}
+
+`setMirror<-.Plots` <- function(object, value) {
+ if (!is.null(value))
+ value <- rep(as.logical(value), length.out = 1)
+ object[["Mirror"]] <- value
+ object <- fixupCall(object, "Mirror", value)
+ object
+}
+
+## setConstant ############################################################
+`setConstant<-` <- function(object, value) {
+ UseMethod("setConstant<-")
+}
+
+`setConstant<-.default` <- function(object, value) {
+ stop("No default method for `setConstant`")
+}
+
+`setConstant<-.how` <- function(object, value) {
+ stop("`setConstant` can not be used directly on '\"how\"' objects.")
+}
+
+`setConstant<-.Within` <- function(object, value) {
+ if (!is.null(value))
+ value <- rep(as.logical(value), length.out = 1)
+ object[["Constant"]] <- value
+ object <- fixupCall(object, "Constant", value)
+ object
+}
+
+`setConstant<-.Plots` <- function(object, value) {
+ stop("`setConstant` does not apply to '\"Plots\"' objects.")
+}
Modified: pkg/permute/man/set-methods.Rd
===================================================================
--- pkg/permute/man/set-methods.Rd 2013-11-25 07:56:41 UTC (rev 2758)
+++ pkg/permute/man/set-methods.Rd 2013-11-26 04:56:32 UTC (rev 2759)
@@ -4,54 +4,46 @@
\alias{setBlocks<-.default}
\alias{setBlocks<-.how}
\alias{setBlocks<-.permControl}
-%% \alias{getWithin}
-%% \alias{getWithin<-.default}
-%% \alias{getWithin<-.how}
-%% \alias{getWithin<-.permControl}
-%% \alias{getStrata}
-%% \alias{getStrata<-.default}
-%% \alias{getStrata<-.how}
-%% \alias{getStrata<-.permControl}
-%% \alias{getStrata<-.Plots}
-%% \alias{getType}
-%% \alias{getType<-.default}
-%% \alias{getType<-.how}
-%% \alias{getType<-.permControl}
-%% \alias{getType<-.Plots}
-%% \alias{getType<-.Within}
-%% \alias{getMirror}
-%% \alias{getMirror<-.default}
-%% \alias{getMirror<-.how}
-%% \alias{getMirror<-.permControl}
-%% \alias{getMirror<-.Plots}
-%% \alias{getMirror<-.Within}
-%% \alias{getConstant}
-%% \alias{getConstant<-.default}
-%% \alias{getConstant<-.how}
-%% \alias{getConstant<-.permControl}
-%% \alias{getConstant<-.Within}
-%% \alias{getPlots}
-%% \alias{getPlots<-.default}
-%% \alias{getPlots<-.how}
-%% \alias{getPlots<-.permControl}
-%% \alias{getRow}
-%% \alias{getRow<-.default}
-%% \alias{getRow<-.how}
-%% \alias{getRow<-.permControl}
-%% \alias{getRow<-.Plots}
-%% \alias{getRow<-.Within}
-%% \alias{getCol}
-%% \alias{getCol<-.default}
-%% \alias{getCol<-.how}
-%% \alias{getCol<-.permControl}
-%% \alias{getCol<-.Plots}
-%% \alias{getCol<-.Within}
-%% \alias{getDim}
-%% \alias{getDim<-.default}
-%% \alias{getDim<-.how}
-%% \alias{getDim<-.permControl}
-%% \alias{getDim<-.Plots}
-%% \alias{getDim<-.Within}
+\alias{setWithin<-}
+\alias{setWithin<-.default}
+\alias{setWithin<-.how}
+\alias{setStrata<-}
+\alias{setStrata<-.default}
+\alias{setStrata<-.how}
+\alias{setStrata<-.Plots}
+\alias{setType<-}
+\alias{setType<-.default}
+\alias{setType<-.how}
+\alias{setType<-.Plots}
+\alias{setType<-.Within}
+\alias{setMirror<-}
+\alias{setMirror<-.default}
+\alias{setMirror<-.how}
+\alias{setMirror<-.Plots}
+\alias{setMirror<-.Within}
+\alias{setConstant<-}
+\alias{setConstant<-.default}
+\alias{setConstant<-.how}
+\alias{setConstant<-.Plots}
+\alias{setConstant<-.Within}
+\alias{setPlots<-}
+\alias{setPlots<-.default}
+\alias{setPlots<-.how}
+\alias{setRow<-}
+\alias{setRow<-.default}
+\alias{setRow<-.how}
+\alias{setRow<-.Plots}
+\alias{setRow<-.Within}
+\alias{setCol<-}
+\alias{setCol<-.default}
+\alias{setCol<-.how}
+\alias{setCol<-.Plots}
+\alias{setCol<-.Within}
+\alias{setDim<-}
+\alias{setDim<-.default}
+\alias{setDim<-.how}
+\alias{setDim<-.Plots}
+\alias{setDim<-.Within}
\alias{setNperm<-}
\alias{setNperm<-.default}
\alias{setNperm<-.how}
@@ -91,6 +83,9 @@
\usage{
setBlocks(object) <- value
+setPlots(object) <- value
+setWithin(object) <- value
+setStrata(object) <- value
setNperm(object) <- value
setAllperms(object) <- value
setMaxperm(object) <- value
@@ -98,23 +93,12 @@
setComplete(object) <- value
setMake(object) <- value
setObserved(object) <- value
-
-\method{setBlocks}{how}(object) <- value
-
-\method{setNperm}{how}(object) <- value
-
-\method{setAllperms}{how}(object) <- value
-
-\method{setMaxperm}{how}(object) <- value
-
-\method{setMinperm}{how}(object) <- value
-
-\method{setComplete}{how}(object) <- value
-
-\method{setMake}{how}(object) <- value
-
-\method{setObserved}{how}(object) <- value
-
+setRow(object) <- value
+setCol(object) <- value
+setDim(object) <- value
+setType(object) <- value
+setMirror(object) <- value
+setConstant(object) <- value
}
\arguments{
@@ -129,6 +113,19 @@
because the matched call also needs to be updated to facilitate use of
\code{\link{update}} on the \code{\link{how}} object.
}
+\section{Note}{
+ \code{setStrata<-} has methods for objects of class \code{"how"} and
+ \code{"Plots"}. The former sets the \code{blocks} component of the
+ \code{\link{how}} object, whilst the latter sets the \code{strata}
+ component of the \code{\link{Plots}} object.
+
+ \code{setDim<-}, \code{setRow<-}, and \code{setCol<-} cannot be used
+ on an object of class \code{"how"}. Instead, extract the \code{Plots}
+ or \code{Within} components with \code{\link{getPlots}} or
+ \code{\link{getWithin}} and alter those components, then use the
+ resulting object to replace the \code{plots} or \code{within}
+ components using \code{setPlots} or \code{setWithin}.
+}
\value{
These replacement functions return \code{object} suitably modified.
}
More information about the Vegan-commits
mailing list