From noreply at r-forge.r-project.org Sun Nov 3 15:34:21 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 3 Nov 2013 15:34:21 +0100 (CET) Subject: [Vegan-commits] r2642 - in pkg/vegan: R inst vignettes Message-ID: <20131103143421.141E1185DD0@r-forge.r-project.org> Author: jarioksa Date: 2013-11-03 15:34:20 +0100 (Sun, 03 Nov 2013) New Revision: 2642 Modified: pkg/vegan/R/adonis.R pkg/vegan/R/anosim.R pkg/vegan/R/bioenv.default.R pkg/vegan/R/mantel.R pkg/vegan/R/mantel.partial.R pkg/vegan/R/metaMDSiter.R pkg/vegan/R/mrpp.R pkg/vegan/R/oecosimu.R pkg/vegan/R/permutest.cca.R pkg/vegan/R/simper.R pkg/vegan/inst/ChangeLog pkg/vegan/vignettes/decision-vegan.Rnw Log: do not use setDefaultCluster() clusters in parallel processing Modified: pkg/vegan/R/adonis.R =================================================================== --- pkg/vegan/R/adonis.R 2013-10-31 20:24:59 UTC (rev 2641) +++ pkg/vegan/R/adonis.R 2013-11-03 14:34:20 UTC (rev 2642) @@ -107,8 +107,6 @@ ## Apply permutations for each term ## This is the new f.test (2011-06-15) that uses fewer arguments ## Set first parallel processing for all terms - if (is.null(parallel) && getRversion() >= "2.15.0") - parallel <- get("default", envir = parallel:::.reg) if (is.null(parallel) || getRversion() < "2.14.0") parallel <- 1 hasClus <- inherits(parallel, "cluster") Modified: pkg/vegan/R/anosim.R =================================================================== --- pkg/vegan/R/anosim.R 2013-10-31 20:24:59 UTC (rev 2641) +++ pkg/vegan/R/anosim.R 2013-11-03 14:34:20 UTC (rev 2642) @@ -48,8 +48,6 @@ permutations <- nrow(permat) } ## Parallel processing - if (is.null(parallel) && getRversion() >= "2.15.0") - parallel <- get("default", envir = parallel:::.reg) if (is.null(parallel) || getRversion() < "2.14.0") parallel <- 1 hasClus <- inherits(parallel, "cluster") Modified: pkg/vegan/R/bioenv.default.R =================================================================== --- pkg/vegan/R/bioenv.default.R 2013-10-31 20:24:59 UTC (rev 2641) +++ pkg/vegan/R/bioenv.default.R 2013-11-03 14:34:20 UTC (rev 2642) @@ -71,8 +71,6 @@ comdis <- vegdist(comm, method = index) } ## Prepare for parallel processing - if (is.null(parallel) && getRversion() >= "2.15.0") - parallel <- get("default", envir = parallel:::.reg) if (is.null(parallel) || getRversion() < "2.14.0") parallel <- 1 hasClus <- inherits(parallel, "cluster") Modified: pkg/vegan/R/mantel.R =================================================================== --- pkg/vegan/R/mantel.R 2013-10-31 20:24:59 UTC (rev 2641) +++ pkg/vegan/R/mantel.R 2013-11-03 14:34:20 UTC (rev 2642) @@ -41,8 +41,6 @@ drop(cor(permvec, ydis, method = method, use = use)) } ## Parallel processing - if (is.null(parallel) && getRversion() >= "2.15.0") - parallel <- get("default", envir = parallel:::.reg) if (is.null(parallel) || getRversion() < "2.14.0") parallel <- 1 hasClus <- inherits(parallel, "cluster") Modified: pkg/vegan/R/mantel.partial.R =================================================================== --- pkg/vegan/R/mantel.partial.R 2013-10-31 20:24:59 UTC (rev 2641) +++ pkg/vegan/R/mantel.partial.R 2013-11-03 14:34:20 UTC (rev 2642) @@ -49,8 +49,6 @@ part.cor(rxy, rxz, ryz) } ## parallel processing - if (is.null(parallel) && getRversion() >= "2.15.0") - parallel <- get("default", envir = parallel:::.reg) if (is.null(parallel) || getRversion() < "2.14.0") parallel <- 1 hasClus <- inherits(parallel, "cluster") Modified: pkg/vegan/R/metaMDSiter.R =================================================================== --- pkg/vegan/R/metaMDSiter.R 2013-10-31 20:24:59 UTC (rev 2641) +++ pkg/vegan/R/metaMDSiter.R 2013-11-03 14:34:20 UTC (rev 2642) @@ -73,8 +73,6 @@ monostop(s0) tries <- 0 ## Prepare for parallel processing - if (is.null(parallel) && getRversion() >= "2.15.0") - parallel <- get("default", envir = parallel:::.reg) if (is.null(parallel) || getRversion() < "2.14.0") parallel <- 1 hasClus <- inherits(parallel, "cluster") Modified: pkg/vegan/R/mrpp.R =================================================================== --- pkg/vegan/R/mrpp.R 2013-10-31 20:24:59 UTC (rev 2641) +++ pkg/vegan/R/mrpp.R 2013-11-03 14:34:20 UTC (rev 2642) @@ -50,8 +50,6 @@ ncol(perms), N)) } ## Parallel processing - if (is.null(parallel) && getRversion() >= "2.15.0") - parallel <- get("default", envir = parallel:::.reg) if (is.null(parallel) || getRversion() < "2.14.0") parallel <- 1 hasClus <- inherits(parallel, "cluster") Modified: pkg/vegan/R/oecosimu.R =================================================================== --- pkg/vegan/R/oecosimu.R 2013-10-31 20:24:59 UTC (rev 2641) +++ pkg/vegan/R/oecosimu.R 2013-11-03 14:34:20 UTC (rev 2642) @@ -86,11 +86,7 @@ ## start with empty simind simind <- NULL ## Go to parallel processing if 'parallel > 1' or 'parallel' could - ## be a pre-defined socket cluster or 'parallel = NULL' in which - ## case it could be setDefaultCluster (or a user error) - if (is.null(parallel) && getRversion() >= "2.15.0") - parallel <- get("default", envir = parallel:::.reg) - ## still NULL? was not a defaultCluster, so make to non-parallel + ## be a pre-defined socket cluster or 'parallel = NULL'. if (is.null(parallel) || getRversion() < "2.14.0") parallel <- 1 hasClus <- inherits(parallel, "cluster") Modified: pkg/vegan/R/permutest.cca.R =================================================================== --- pkg/vegan/R/permutest.cca.R 2013-10-31 20:24:59 UTC (rev 2641) +++ pkg/vegan/R/permutest.cca.R 2013-11-03 14:34:20 UTC (rev 2642) @@ -124,8 +124,6 @@ } nperm <- nrow(permutations) ## Parallel processing (similar as in oecosimu) - if (is.null(parallel) && getRversion() >= "2.15.0") - parallel <- get("default", envir = parallel:::.reg) if (is.null(parallel) || getRversion() < "2.14.0") parallel <- 1 hasClus <- inherits(parallel, "cluster") Modified: pkg/vegan/R/simper.R =================================================================== --- pkg/vegan/R/simper.R 2013-10-31 20:24:59 UTC (rev 2641) +++ pkg/vegan/R/simper.R 2013-11-03 14:34:20 UTC (rev 2642) @@ -38,8 +38,6 @@ if (nperm > 0) perm.contr <- matrix(nrow=P, ncol=nperm) ## Parallel processing ? - if (is.null(parallel) && getRversion() >= "2.15.0") - parallel <- get("default", envir = parallel:::.reg) if (is.null(parallel) || getRversion() < "2.14.0") parallel <- 1 hasClus <- inherits(parallel, "cluster") Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-10-31 20:24:59 UTC (rev 2641) +++ pkg/vegan/inst/ChangeLog 2013-11-03 14:34:20 UTC (rev 2642) @@ -25,6 +25,11 @@ (testing theory requires nesting, but this is commonly violated by users: here nesting is necessary). + * parellel: default cluster defined by setDefaultCluster() is no + longer used in functions with parallel processing. Using default + cluster would need querying an unexported environment + parellel:::.reg, and this gives a NOTE in R CMD check. + * specaccum, renyiaccum, tsallisaccum: gained argument to select a 'subset' of sites (looks like my student would need them). Modified: pkg/vegan/vignettes/decision-vegan.Rnw =================================================================== --- pkg/vegan/vignettes/decision-vegan.Rnw 2013-10-31 20:24:59 UTC (rev 2641) +++ pkg/vegan/vignettes/decision-vegan.Rnw 2013-11-03 14:34:20 UTC (rev 2642) @@ -92,10 +92,8 @@ package is loaded. \R{} allows\footnote{Since \R{} version 2.15.0.} -setting up a default socket cluster (\code{setDefaultCluster}). In -that case \pkg{vegan} will perform parallel processing with that -default cluster. If the \code{mc.cores} is also set, it takes -precedence. +setting up a default socket cluster (\code{setDefaultCluster}), but +this will not be used in \pkg{vegan}. \subsubsection{Setting up socket clusters} \label{sec:parallel:socket} @@ -201,31 +199,7 @@ \begin{enumerate} \item \code{NULL}: The function is called with argument \code{parallel = getOption("mc.cores")}. The option \code{mc.cores} is normally - unset and then the default is \code{parallel = NULL}. This is - interpreted as \code{parallel = 1} in \R-2.14.x. In \R-2.15.x the - function inspects if a default socket cluster is defined. \R-2.15.0 - has a non-exported environment \code{parallel:::.reg} with variable - \code{default} that is either \code{NULL} (default) or a socket - cluster. Querying this environment is an error in \R-2.14.x so that - we also need to test the \R{} version. In the following - \code{oecosimu} code we first see if the default cluster is set when - \code{parallel = NULL}, and if it is unset, the \code{parallel} will - still be \code{NULL} and will be changed to \code{1}. After this, - the value of \code{parallel} will be either an integer or a socket - cluster, and information on the type is saved in variable - \code{hasClus}: -\begin{Schunk} -\begin{Soutput} -if(is.null(parallel) && - getRversion() >= "2.15.0") - parallel <- get("default", - envir = parallel:::.reg) -if (is.null(parallel) || - getRversion() < "2.14.0") - parallel <- 1 -hasClus <- inherits(parallel, "cluster") -\end{Soutput} -\end{Schunk} + unset and then the default is \code{parallel = NULL}. \item Integer: An integer value is taken as the number of created parallel processes. In unix-like systems this is the number of forked multicore processes, and in Windows this is the number of @@ -244,16 +218,12 @@ \item Explicitly given argument value of \code{parallel} will always be used. \item If \code{mc.cores} is set, it will be used. In Windows this - means creating and stopping socket clusters even when a default - cluster is set if \code{mc.cores} is not \code{NULL}. Please note + means creating and stopping socket clusters. Please note that the \code{mc.cores} is only set from the environmental variable \code{MC_CORES} when you load the \pkg{parallel} package, and it is always unset before first - \code{require(parallel)}.\footnote{The behaviour of - \code{mc.cores} option is untested in Windows.} - \item The default socket cluster will be used if - set.\footnote{Default cluster is available since \R{} 2.15.0.} - \item The fall back behaviour is no parallel processing. + \code{require(parallel)}. + \item The fall back behaviour is no parallel processing. \end{enumerate} \section{Nestedness and Null models} From noreply at r-forge.r-project.org Mon Nov 4 23:46:58 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 4 Nov 2013 23:46:58 +0100 (CET) Subject: [Vegan-commits] r2643 - pkg/permute/vignettes Message-ID: <20131104224658.A480F18641B@r-forge.r-project.org> Author: gsimpson Date: 2013-11-04 23:46:58 +0100 (Mon, 04 Nov 2013) New Revision: 2643 Modified: pkg/permute/vignettes/permutations.Rnw Log: updates to vignette Modified: pkg/permute/vignettes/permutations.Rnw =================================================================== --- pkg/permute/vignettes/permutations.Rnw 2013-11-03 14:34:20 UTC (rev 2642) +++ pkg/permute/vignettes/permutations.Rnw 2013-11-04 22:46:58 UTC (rev 2643) @@ -9,13 +9,13 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% almost as usual -\author{Gavin L. Simpson\\Environmental Change Research Centre --- UCL} +\author{Gavin L. Simpson\\University of Regina} \title{Restricted permutations; using the \pkg{permute} Package} %% for pretty printing and a nice hypersummary also set: \Plainauthor{Gavin L. Simpson} %% comma-separated -\Plaintitle{Using the permute Package} %% without formatting -\Shorttitle{Using the permuet Package} %% a short title (if necessary) +\Plaintitle{Restricted permutations; using the permute Package} %% without formatting +\Shorttitle{Using the permute Package} %% a short title (if necessary) %% an abstract and keywords \Abstract{ @@ -72,8 +72,9 @@ The interest is whether there is a difference in the mean mandible length between male and female golden jackals. The null hypothesis is that there is zero difference in mandible length between the two sexes or that females have larger mandible. The alternative hypothesis is that males have larger mandibles. The usual statistical test of this hypothesis is a one-sided $t$ test, which can be applied using \code{t.test()} -<>= -jack.t <-t.test(Length ~ Sex, data = jackal, var.equal = TRUE, alternative = "greater") +<>= +jack.t <- t.test(Length ~ Sex, data = jackal, var.equal = TRUE, + alternative = "greater") jack.t @ @@ -152,7 +153,7 @@ <<>>= args(shuffle) @ -A series of convenience functions are provided that allow the user to set-up even quite complex permutation designs with little effort. The user only needs to specify the aspects of the design they require and the convenience functions ensure all configuration choices are set and passed on to \code{shuffle()}. The main convenience function is \code{how()}, which return a list specifying all the options available for controlling the sorts of permutations returned by \code{shuffle()} +A series of convenience functions are provided that allow the user to set-up even quite complex permutation designs with little effort. The user only needs to specify the aspects of the design they require and the convenience functions ensure all configuration choices are set and passed on to \code{shuffle()}. The main convenience function is \code{how()}, which returns a list specifying all the options available for controlling the sorts of permutations returned by \code{shuffle()} <<>>= str(how()) @ @@ -173,11 +174,12 @@ \item Time series or line transect designs, where the temporal or spatial ordering is preserved. \item Spatial grid designs, where the spatial ordering is preserved in both coordinate directions \item Permutation of plots or groups of samples. + \item Blocking factors which restrict permutations to within blocks. The preceding designs can be nested within blocks. \end{itemize} -The first three of these can be nested within the levels of a factor or to the levels of that factor, or to both. Such flexibility allows the analysis of split-plot designs using permutation tests. +The first three of these can be nested within the levels of a factor or to the levels of that factor, or to both. Such flexibility allows the analysis of split-plot designs using permutation tests, especially when combined with blocks. -\code{how()} is used to set up the design from which \code{shuffle()} will draw a permutation. \code{how()} has two main arguments that specify how samples are permuted \emph{within} plots of samples or at the plot level itself. These are \code{within} and \code{plots}. Two convenience functions, \code{Within()} and \code{Plots()} can be used to set the various options for permutation. +\code{how()} is used to set up the design from which \code{shuffle()} will draw a permutation. \code{how()} has two main arguments that specify how samples are permuted \emph{within} plots of samples or at the plot level itself. These are \code{within} and \code{plots}. Two convenience functions, \code{Within()} and \code{Plots()} can be used to set the various options for permutation. Blocks operate at the uppermost level of this hierarchy; blocks define groups of plots, each of which contain groups of samples. For example, to permute the observations \code{1:10} assuming a time series design for the entire set of observations, the following control object would be used @@ -198,7 +200,7 @@ set.seed(4) plt <- gl(3, 9) CTRL <- how(within = Within(type = "grid", ncol = 3, nrow = 3), - plots = Plots(strata = plt)) + plots = Plots(strata = plt)) perm <- shuffle(length(plt), control = CTRL) perm @ @@ -218,8 +220,8 @@ <>= set.seed(4) CTRL <- how(within = Within(type = "grid", ncol = 3, nrow = 3, - constant = TRUE), - plots = Plots(strata = plt)) + constant = TRUE), + plots = Plots(strata = plt)) perm2 <- shuffle(length(plt), control = CTRL) lapply(split(perm2, plt), matrix, ncol = 3) @ @@ -227,8 +229,14 @@ \subsection{Generating sets of permutations with shuffleSet()} There are several reasons why one might wish to generate a set of $n$ permutations instead of repeatedly generating permutations one at a time. Interpreting the permutation design happens each time \code{shuffle()} is called. This is an unnecessary computational burden, especially if you want to perform tests with large numbers of permutations. Furthermore, having the set of permutations available allows for expedited use with other functions, they can be iterated over using \code{for} loops or the \code{apply} family of functions, and the set of permutations can be exported for use outside of R. -The \code{shuffleSet()} function allows the generation of sets of permutations from any of the designs available in \pkg{permute}. \code{shuffleSet()} takes an additional argument to that of \code{shuffle()}, \code{nset}, which is the number of permutations required for the set. Internally, \code{shuffle()} and \code{shuffleSet()} are very similar, with the major difference being that \code{shuffleSet()} arranges repeated calls to the workhorse permutation-generating functions with only the overhead associated with interpreting the permutation design once. \code{shuffleSet()} returns a matrix where the rows represent different permutations in the set. +The \code{shuffleSet()} function allows the generation of sets of permutations from any of the designs available in \pkg{permute}. \code{shuffleSet()} takes an additional argument to that of \code{shuffle()}, \code{nset}, which is the number of permutations required for the set. \code{nset} can be missing, in which case the number of permutations in the set is looked for in the object passed to \code{control}; using this, the desired number of permutation can be set at the time the design is created via the \code{nperm} argument of \code{how()}. For example, +<>= +how(nperm = 10, within = Within(type = "series")) +@ + +Internally, \code{shuffle()} and \code{shuffleSet()} are very similar, with the major difference being that \code{shuffleSet()} arranges repeated calls to the workhorse permutation-generating functions with only the overhead associated with interpreting the permutation design once. \code{shuffleSet()} returns a matrix where the rows represent different permutations in the set. + As an illustration, consider again the simple time series example from earlier. Here I generate a set of 5 permutations from the design, with the results returned as a matrix <>= @@ -238,7 +246,21 @@ pset @ +\section{Defining permutation designs} +In this section examples are given of how various permutation designs can be specified using \code{how()}. It is not the intention to provide exhaustive coverage of all possible designs that can be produced; such a list would be tedious to both write \emph{and} read. Instead, the main features and options will be described through a series of examples. The reader should then be able to put together the various options to create the exact structure required. +\subsection{Set the number of permutations} +It may be useful to specify the number of permutations required in a permutation test alongside the permutation design. This is done via the \code{nperm} argument, as seen earlier. If nothing else is specified +<>= +how(nperm = 999) +@ +would indicate 999 random permutations where the samples are all freely exchangeable. + +One advantage of using \code{nperm} is that \code{shuffleSet()} will use this if the \code{nset} argument is not specified. Additionally, \code{shuffleSet()} will check to see if the desired number of permutations is possible given the data and the requested design. This is done via the function \code{check()}, which is discussed later. + +\subsection{Permuting samples at the lowest level} +At the lowest level of a permutation design in \pkg{permute} + \section*{Computational details} <>= toLatex(sessionInfo()) From noreply at r-forge.r-project.org Mon Nov 4 23:48:22 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 4 Nov 2013 23:48:22 +0100 (CET) Subject: [Vegan-commits] r2644 - in pkg/permute: . R inst man Message-ID: <20131104224823.7ACE718641B@r-forge.r-project.org> Author: gsimpson Date: 2013-11-04 23:48:21 +0100 (Mon, 04 Nov 2013) New Revision: 2644 Modified: pkg/permute/DESCRIPTION pkg/permute/R/how.R pkg/permute/inst/ChangeLog pkg/permute/inst/TODO.md pkg/permute/man/how.Rd Log: adds matched call to object returned by 'how' which allows the use of 'update' to update the permutation design. Added an example to the help page. Bump to 0.7-5. Modified: pkg/permute/DESCRIPTION =================================================================== --- pkg/permute/DESCRIPTION 2013-11-04 22:46:58 UTC (rev 2643) +++ pkg/permute/DESCRIPTION 2013-11-04 22:48:21 UTC (rev 2644) @@ -1,6 +1,6 @@ Package: permute Title: Functions for generating restricted permutations of data -Version: 0.7-4 +Version: 0.7-5 Date: $Date$ Author: Gavin L. Simpson Maintainer: Gavin L. Simpson Modified: pkg/permute/R/how.R =================================================================== --- pkg/permute/R/how.R 2013-11-04 22:46:58 UTC (rev 2643) +++ pkg/permute/R/how.R 2013-11-04 22:48:21 UTC (rev 2644) @@ -12,7 +12,8 @@ nperm = nperm, complete = complete, maxperm = maxperm, minperm = minperm, all.perms = all.perms, observed = observed, - blocks.name = deparse(substitute(blocks))) + blocks.name = deparse(substitute(blocks)), + call = match.call()) class(out) <- "how" out } Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-04 22:46:58 UTC (rev 2643) +++ pkg/permute/inst/ChangeLog 2013-11-04 22:48:21 UTC (rev 2644) @@ -2,6 +2,11 @@ permute ChangeLog +Version 0.7-5 + + * how: the matched call is now returned permitting the use of + `update()` to update elements of a stored permutation design object. + Version 0.7-4 * Deprecated functions: Completed the deprecation of `permCheck()` Modified: pkg/permute/inst/TODO.md =================================================================== --- pkg/permute/inst/TODO.md 2013-11-04 22:46:58 UTC (rev 2643) +++ pkg/permute/inst/TODO.md 2013-11-04 22:48:21 UTC (rev 2644) @@ -11,12 +11,33 @@ object already exists and want to tweak it. Example is in `?allPerms` where I turn mirroring on via - ctrl$within$mirror <- TRUE + ctrl$within$mirror <- TRUE - But how? Best idea currently is an `update.permControl` method. The - generic is in namespace `stats`. Or a `modify()` function, perhaps - coupled with specific replacement functions for certain components. + But how? Best idea currently is an `update.permControl` method. The + generic is in namespace `stats`. Or a `modify()` function, perhaps + coupled with specific replacement functions for certain components. + + *DONE, in part, in 0.7-5* The matched call is now returned by `how()` + and this allows `update()` to do its work with no further effort from + me. What isn't so neat is that currently this means you need to type + out in full any specification of `within` and `plots` as these take + the results of function calls. Hence we have, from `./man/how.Rd` + + plts <- gl(4,10) + blks <- gl(2,20) + h1 <- how(within = Within(type = "series", mirror = TRUE), + plots = Plots(strata = plts, type = "series"), + blocks = blks) + ## The design can be updated... + ## ... remove the blocking: + update(h1, blocks = NULL) + ## ... or switch the type of shuffling at a level: + update(h1, plots = Plots(strata = plts, type = "none")) + + Where in the second `update()` the entire `Plots()` call needs to + repeated to change just one part, the `type`. + * `permControl` - deprecate this in favour of `how` as in "how to permute"? *DONE Completed in 0.7-4* @@ -26,4 +47,4 @@ easy without a lot of work to visualise all possible schemes. * `check` insists on returning all permutations *without* the observed - on. \ No newline at end of file + one. Modified: pkg/permute/man/how.Rd =================================================================== --- pkg/permute/man/how.Rd 2013-11-04 22:46:58 UTC (rev 2643) +++ pkg/permute/man/how.Rd 2013-11-04 22:48:21 UTC (rev 2644) @@ -104,8 +104,14 @@ \examples{ plts <- gl(4,10) blks <- gl(2,20) -how(within = Within(type = "series", mirror = TRUE), - plots = Plots(strata = plts, type = "series"), - blocks = blks) +h1 <- how(within = Within(type = "series", mirror = TRUE), + plots = Plots(strata = plts, type = "series"), + blocks = blks) + +## The design can be updated... +## ... remove the blocking: +update(h1, blocks = NULL) +## ... or switch the type of shuffling at a level: +update(h1, plots = Plots(strata = plts, type = "none")) } \keyword{ utils } \ No newline at end of file From noreply at r-forge.r-project.org Mon Nov 4 23:50:42 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 4 Nov 2013 23:50:42 +0100 (CET) Subject: [Vegan-commits] r2645 - pkg/permute/inst Message-ID: <20131104225042.6434F185A3A@r-forge.r-project.org> Author: gsimpson Date: 2013-11-04 23:50:42 +0100 (Mon, 04 Nov 2013) New Revision: 2645 Modified: pkg/permute/inst/ChangeLog Log: Forgot to attribute the matched call / update idea to Jari. Now corrected. Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-04 22:48:21 UTC (rev 2644) +++ pkg/permute/inst/ChangeLog 2013-11-04 22:50:42 UTC (rev 2645) @@ -6,6 +6,7 @@ * how: the matched call is now returned permitting the use of `update()` to update elements of a stored permutation design object. + Suggested by Jari Oksanen. Version 0.7-4 From noreply at r-forge.r-project.org Tue Nov 5 05:23:55 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Nov 2013 05:23:55 +0100 (CET) Subject: [Vegan-commits] r2646 - pkg/permute/R Message-ID: <20131105042355.EC42A185F67@r-forge.r-project.org> Author: gsimpson Date: 2013-11-05 05:23:55 +0100 (Tue, 05 Nov 2013) New Revision: 2646 Modified: pkg/permute/R/shuffle2.R Log: clears blocks component for within-block permuting Modified: pkg/permute/R/shuffle2.R =================================================================== --- pkg/permute/R/shuffle2.R 2013-11-04 22:50:42 UTC (rev 2645) +++ pkg/permute/R/shuffle2.R 2013-11-05 04:23:55 UTC (rev 2646) @@ -1,113 +1,120 @@ ## new version of shuffle() that allows for blocking `shuffle` <- function(n, control = how()) { - ## get blocking, if any - Block <- getStrata(control, which = "blocks") - if(is.null(Block)) - Block <- factor(rep(1, n)) + ## get blocking, if any + Block <- getStrata(control, which = "blocks") + ## If no blocking, put all samples in same block + if(is.null(Block)) { + Block <- factor(rep(1, n)) + } else { + ## There was blocking so update control to remove it + ## as we don't need it in control at the within-block + ## permutations performed in the loop + control <- update(control, blocks = NULL) + } - sn <- seq_len(n) ## sequence of samples in order of input + sn <- seq_len(n) ## sequence of samples in order of input - ## split sn on basis of Block - spln <- split(sn, Block) - nb <- length(spln) ## number of blocks + ## split sn on basis of Block + spln <- split(sn, Block) + nb <- length(spln) ## number of blocks - ## result list - out <- vector(mode = "list", length = nb) + ## result list + out <- vector(mode = "list", length = nb) - ## loop over spln and shuffle in each split - for(i in seq_len(nb)) { - out[[i]] <- doShuffle(spln[[i]], control) - } - out <- unsplit(out, Block) ## undo the original splitting - out + ## loop over spln and shuffle in each split + for(i in seq_len(nb)) { + out[[i]] <- doShuffle(spln[[i]], control) + } + out <- unsplit(out, Block) ## undo the original splitting + out } `doShuffle` <- function(ind, control) { - ## collect strata at Plot level - Pstrata <- getStrata(control, which = "plots", drop = TRUE) - plotCTRL <- getPlots(control) + ## collect strata at Plot level + Pstrata <- getStrata(control, which = "plots", drop = TRUE) + plotCTRL <- getPlots(control) - n <- length(ind) - sn <- seq_len(n) + n <- length(ind) + sn <- seq_len(n) - ## if no strata at Plot level permute all samples using stated scheme - if(is.null(Pstrata)) { - perm <- shuffleNoStrata(n, control) - } else { - typeP <- getType(control, which = "plots") - typeW <- getType(control, which = "within") + ## if no strata at Plot level permute all samples using stated scheme + if(is.null(Pstrata)) { + perm <- shuffleNoStrata(n, control) + } else { + typeP <- getType(control, which = "plots") + typeW <- getType(control, which = "within") - ## permute Plot strata? - if(isTRUE(all.equal(typeP, "none"))) { ## NO - perm <- sn - } else { ## YES - flip <- runif(1L) < 0.5 ## logical, passed on & used only if mirroring - perm <- shuffleStrata(Pstrata[ind], ## take only the ind values - type = typeP, - mirror = plotCTRL$mirror, - flip = flip, - nrow = plotCTRL$nrow, - ncol = plotCTRL$ncol) - } - - ## permute the samples within Plot strata - if(!isTRUE(all.equal(typeW, "none"))) { ## NOTE the `!` - ## house keeping to track permuted strata - used later - tab <- table(Pstrata[ind][perm]) - levs <- names(tab) ## levels of Plot strata in this split - - ## use same permutation within each level of strata? - withinCTRL <- getWithin(control) - CONSTANT <- withinCTRL$constant - if(isTRUE(CONSTANT)) { - if(isTRUE(all.equal(typeW, "free"))) { - N <- unique(tab)[1L] - same.rand <- shuffleFree(N, N) - } else if(isTRUE(all.equal(typeW, "series"))) { - start <- shuffleFree(n / length(levs), 1L) - flip <- runif(1L) < 0.5 - } else if(isTRUE(all.equal(typeW, "grid"))) { - start.row <- shuffleFree(withinCTRL$nrow, 1L) - start.col <- shuffleFree(withinCTRL$ncol, 1L) - flip <- runif(2L) < 0.5 + ## permute Plot strata? + if(isTRUE(all.equal(typeP, "none"))) { ## NO + perm <- sn + } else { ## YES + flip <- runif(1L) < 0.5 ## logical, passed on & used only if mirroring + perm <- shuffleStrata(Pstrata[ind], ## take only the ind values + type = typeP, + mirror = plotCTRL$mirror, + flip = flip, + nrow = plotCTRL$nrow, + ncol = plotCTRL$ncol) } - } else { - start <- start.row <- start.col <- flip <- NULL - } - ## copy perm at this stage - tmp <- perm + ## permute the samples within Plot strata + if(!isTRUE(all.equal(typeW, "none"))) { ## NOTE the `!` + ## house keeping to track permuted strata - used later + tab <- table(Pstrata[ind][perm]) + levs <- names(tab) ## levels of Plot strata in this split - ## for each level of strata in this split, shuffle - for(lv in levs) { - ## must re-order strata here on basis of out as they - ## may have been permuted above - MATCH <- Pstrata[ind][perm] == lv - gr <- perm[MATCH] - if((n.gr <- length(gr)) > 1) { - tmp[which(MATCH)] <- - switch(typeW, - "free" = if(isTRUE(CONSTANT)) { - gr[same.rand] - } else { - perm[gr][shuffleFree(n.gr, n.gr)] - }, - "series" = - gr[shuffleSeries(seq_len(n.gr), - mirror = withinCTRL$mirror, - start = start, flip = flip)], - "grid" = - gr[shuffleGrid(nrow = withinCTRL$nrow, - ncol = withinCTRL$ncol, - mirror = withinCTRL$mirror, - start.row = start.row, - start.col = start.col, - flip = flip)] - ) + ## use same permutation within each level of strata? + withinCTRL <- getWithin(control) + CONSTANT <- withinCTRL$constant + if(isTRUE(CONSTANT)) { + if(isTRUE(all.equal(typeW, "free"))) { + N <- unique(tab)[1L] + same.rand <- shuffleFree(N, N) + } else if(isTRUE(all.equal(typeW, "series"))) { + start <- shuffleFree(n / length(levs), 1L) + flip <- runif(1L) < 0.5 + } else if(isTRUE(all.equal(typeW, "grid"))) { + start.row <- shuffleFree(withinCTRL$nrow, 1L) + start.col <- shuffleFree(withinCTRL$ncol, 1L) + flip <- runif(2L) < 0.5 + } + } else { + start <- start.row <- start.col <- flip <- NULL + } + + ## copy perm at this stage + tmp <- perm + + ## for each level of strata in this split, shuffle + for(lv in levs) { + ## must re-order strata here on basis of out as they + ## may have been permuted above + MATCH <- Pstrata[ind][perm] == lv + gr <- perm[MATCH] + if((n.gr <- length(gr)) > 1) { + tmp[which(MATCH)] <- + switch(typeW, + "free" = if(isTRUE(CONSTANT)) { + gr[same.rand] + } else { + perm[gr][shuffleFree(n.gr, n.gr)] + }, + "series" = + gr[shuffleSeries(seq_len(n.gr), + mirror = withinCTRL$mirror, + start = start, flip = flip)], + "grid" = + gr[shuffleGrid(nrow = withinCTRL$nrow, + ncol = withinCTRL$ncol, + mirror = withinCTRL$mirror, + start.row = start.row, + start.col = start.col, + flip = flip)] + ) + } + } + perm <- tmp } - } - perm <- tmp } - } - ind[perm] + ind[perm] } From noreply at r-forge.r-project.org Tue Nov 5 05:27:07 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Nov 2013 05:27:07 +0100 (CET) Subject: [Vegan-commits] r2647 - pkg/permute/R Message-ID: <20131105042707.AF4C0185F67@r-forge.r-project.org> Author: gsimpson Date: 2013-11-05 05:27:07 +0100 (Tue, 05 Nov 2013) New Revision: 2647 Modified: pkg/permute/R/shuffle2.R Log: reduce control components to within-block samples only Modified: pkg/permute/R/shuffle2.R =================================================================== --- pkg/permute/R/shuffle2.R 2013-11-05 04:23:55 UTC (rev 2646) +++ pkg/permute/R/shuffle2.R 2013-11-05 04:27:07 UTC (rev 2647) @@ -33,6 +33,9 @@ ## collect strata at Plot level Pstrata <- getStrata(control, which = "plots", drop = TRUE) plotCTRL <- getPlots(control) + ## ...which need to be reduced to only those for `ind` + Pstrata <- Pstrata[ind] + plotCTRL <- plotCTRL[ind] n <- length(ind) sn <- seq_len(n) From noreply at r-forge.r-project.org Tue Nov 5 05:33:01 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Nov 2013 05:33:01 +0100 (CET) Subject: [Vegan-commits] r2648 - pkg/permute/R Message-ID: <20131105043301.8C3B0185F67@r-forge.r-project.org> Author: gsimpson Date: 2013-11-05 05:33:01 +0100 (Tue, 05 Nov 2013) New Revision: 2648 Modified: pkg/permute/R/shuffle2.R Log: revised version of r2647 Modified: pkg/permute/R/shuffle2.R =================================================================== --- pkg/permute/R/shuffle2.R 2013-11-05 04:27:07 UTC (rev 2647) +++ pkg/permute/R/shuffle2.R 2013-11-05 04:33:01 UTC (rev 2648) @@ -35,7 +35,6 @@ plotCTRL <- getPlots(control) ## ...which need to be reduced to only those for `ind` Pstrata <- Pstrata[ind] - plotCTRL <- plotCTRL[ind] n <- length(ind) sn <- seq_len(n) @@ -52,7 +51,7 @@ perm <- sn } else { ## YES flip <- runif(1L) < 0.5 ## logical, passed on & used only if mirroring - perm <- shuffleStrata(Pstrata[ind], ## take only the ind values + perm <- shuffleStrata(Pstrata, type = typeP, mirror = plotCTRL$mirror, flip = flip, From noreply at r-forge.r-project.org Tue Nov 5 05:48:34 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Nov 2013 05:48:34 +0100 (CET) Subject: [Vegan-commits] r2649 - pkg/permute/R Message-ID: <20131105044835.0196418592D@r-forge.r-project.org> Author: gsimpson Date: 2013-11-05 05:48:34 +0100 (Tue, 05 Nov 2013) New Revision: 2649 Modified: pkg/permute/R/shuffle2.R Log: simplify subsetting to only the within-block indices Modified: pkg/permute/R/shuffle2.R =================================================================== --- pkg/permute/R/shuffle2.R 2013-11-05 04:33:01 UTC (rev 2648) +++ pkg/permute/R/shuffle2.R 2013-11-05 04:48:34 UTC (rev 2649) @@ -62,7 +62,7 @@ ## permute the samples within Plot strata if(!isTRUE(all.equal(typeW, "none"))) { ## NOTE the `!` ## house keeping to track permuted strata - used later - tab <- table(Pstrata[ind][perm]) + tab <- table(Pstrata[perm]) levs <- names(tab) ## levels of Plot strata in this split ## use same permutation within each level of strata? @@ -91,7 +91,7 @@ for(lv in levs) { ## must re-order strata here on basis of out as they ## may have been permuted above - MATCH <- Pstrata[ind][perm] == lv + MATCH <- Pstrata[perm] == lv gr <- perm[MATCH] if((n.gr <- length(gr)) > 1) { tmp[which(MATCH)] <- From noreply at r-forge.r-project.org Tue Nov 5 16:12:11 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Nov 2013 16:12:11 +0100 (CET) Subject: [Vegan-commits] r2650 - in pkg/vegan: . R inst man Message-ID: <20131105151211.BE036185AC9@r-forge.r-project.org> Author: jarioksa Date: 2013-11-05 16:12:11 +0100 (Tue, 05 Nov 2013) New Revision: 2650 Modified: pkg/vegan/DESCRIPTION pkg/vegan/R/permutest.cca.R pkg/vegan/inst/ChangeLog pkg/vegan/man/anova.cca.Rd Log: permutest.cca uses permute package Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2013-11-05 04:48:34 UTC (rev 2649) +++ pkg/vegan/DESCRIPTION 2013-11-05 15:12:11 UTC (rev 2650) @@ -1,12 +1,12 @@ Package: vegan Title: Community Ecology Package -Version: 2.1-37 -Date: October 14, 2013 +Version: 2.1-38 +Date: November 5, 2013 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, Helene Wagner Maintainer: Jari Oksanen -Depends: permute (>= 0.7-4), lattice, R (>= 2.14.0) +Depends: permute (>= 0.7-5), lattice, R (>= 2.14.0) Suggests: MASS, mgcv, cluster, parallel, scatterplot3d, rgl, tcltk Description: Ordination methods, diversity analysis and other functions for community and vegetation ecologists. Modified: pkg/vegan/R/permutest.cca.R =================================================================== --- pkg/vegan/R/permutest.cca.R 2013-11-05 04:48:34 UTC (rev 2649) +++ pkg/vegan/R/permutest.cca.R 2013-11-05 15:12:11 UTC (rev 2650) @@ -5,7 +5,7 @@ stop("No default permutation test defined") `permutest.cca` <- - function (x, permutations = 99, + function (x, permutations = how(nperm=99), model = c("reduced", "direct", "full"), first = FALSE, strata = NULL, parallel = getOption("mc.cores") , ...) { @@ -113,15 +113,23 @@ if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) runif(1) seed <- get(".Random.seed", envir = .GlobalEnv, inherits = FALSE) - ## permutations + ## permutations is either a single number, a how() structure or a + ## permutation matrix if (length(permutations) == 1) { - if (is.null(strata)) - permutations <- shuffleSet(N, permutations) - else - permutations <- - t(sapply(1:permutations, - function(x) permuted.index(N, strata=strata))) + nperm <- permutations + permutations <- how(nperm = nperm) } + if (!is.null(strata)) { + if (!inherits(permutations, "how")) + stop("'strata' can be used only with simple permutation or with 'how()'") + if (!is.null(permutations$block)) + stop("'strata' cannot be applied when 'blocks' are defined in 'how()'") + permutations <- update(permutations, blocks = strata) + } + ## now permutations is either a how() structure or a permutation + ## matrix. Make it to a matrix if it is "how" + if (inherits(permutations, "how")) + permutations <- shuffleSet(N, control = permutations) nperm <- nrow(permutations) ## Parallel processing (similar as in oecosimu) if (is.null(parallel) || getRversion() < "2.14.0") Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-11-05 04:48:34 UTC (rev 2649) +++ pkg/vegan/inst/ChangeLog 2013-11-05 15:12:11 UTC (rev 2650) @@ -2,8 +2,20 @@ VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/ -Version 2.1-37 (opened October 14, 2013) +Version 2.1-38 (opened November 5, 2013) + * DESCRIPTION: depends on permute >= 0.7-5. + + * permutest.cca: permutation test uses 'permute' package. The old + interface was retained, and 'permutations' can be a single number + or a permutation matrix (as previously), but now it can also be a + how() object of the 'permute' package. The argument 'strata' was + also retained, but it is planned to be deprecated in the future, + and it is recommended that users switch to defining 'blocks' in + how(). + +Version 2.1-37 (closed November 5, 2013) + * anova.cca: added new function anova.ccalist() to compare a sequence of models. The function is still experimental ("proof of the concept") and unexported. If this stays in vegan, it should Modified: pkg/vegan/man/anova.cca.Rd =================================================================== --- pkg/vegan/man/anova.cca.Rd 2013-11-05 04:48:34 UTC (rev 2649) +++ pkg/vegan/man/anova.cca.Rd 2013-11-05 15:12:11 UTC (rev 2650) @@ -23,7 +23,7 @@ permutest(x, ...) -\method{permutest}{cca}(x, permutations = 99, +\method{permutest}{cca}(x, permutations = how(nperm=99), model = c("reduced", "direct", "full"), first = FALSE, strata = NULL, parallel = getOption("mc.cores") , ...) @@ -46,14 +46,23 @@ \code{permutest.cca}. In \code{anova} with \code{by = "axis"} you can use argument \code{cutoff} (defaults \code{1}) which stops permutations after exceeding the given level. } - \item{permutations}{Number of permutations for assessing significance - of constraints.} + + \item{permutations}{Either a \code{\link[permute]{how}} result + defining permutations, or a permutation matrix with each row giving + the permutation indices, or the number of permutations for simple + permutations. See \code{\link{permutations}} for details.} + \item{model}{Permutation model (partial match).} \item{first}{Assess only the significance of the first constrained eigenvalue; will be passed from \code{anova.cca}. } + \item{strata}{An integer vector or factor specifying the strata for permutation. If supplied, observations are permuted only within the - specified strata.} + specified strata. It is an error to use this when + \code{permutations} is a matrix, or a \code{\link[permute]{how}} + defines \code{blocks}. This is a legacy argument that will be + deprecated in the future: use \code{permutations = how(\dots, blocks)} + instead. } \item{parallel}{Number of parallel processes or a predefined socket cluster. With \code{parallel = 1} uses ordinary, non-parallel From noreply at r-forge.r-project.org Tue Nov 5 22:03:54 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Nov 2013 22:03:54 +0100 (CET) Subject: [Vegan-commits] r2651 - in pkg/permute: R inst Message-ID: <20131105210354.2491C185AC9@r-forge.r-project.org> Author: gsimpson Date: 2013-11-05 22:03:53 +0100 (Tue, 05 Nov 2013) New Revision: 2651 Modified: pkg/permute/R/numPerms.R pkg/permute/inst/ChangeLog Log: fixes a bug whereby numPerms ignored the Blocking structure when computing the total number of permutations for the specified design Modified: pkg/permute/R/numPerms.R =================================================================== --- pkg/permute/R/numPerms.R 2013-11-05 15:12:11 UTC (rev 2650) +++ pkg/permute/R/numPerms.R 2013-11-05 21:03:53 UTC (rev 2651) @@ -91,22 +91,27 @@ spl <- split(indv, BLOCKS) ## loop over the components of spl & apply doNumPerms - np <- lapply(spl, doNumPerms, mult.p, mult.wi, typeP, typeW, PSTRATA, + np <- sapply(spl, doNumPerms, mult.p, mult.wi, typeP, typeW, PSTRATA, mirrorP, mirrorW, constantW) ## multiply up n perms per block - do.call(prod, np) + prod(np) } `doNumPerms` <- function(obs, mult.p, mult.wi, typeP, typeW, PSTRATA, mirrorP, mirrorW, constantW) { n <- nobs(obs) ## obs is index vector for object, split by blocks - ## need only those strata for the current block. As obs is the index - ## vector, split by block, this now gives nobs per plot strata - tab <- table(PSTRATA)#[obs] # table(PSTRATA[obs]) - same.n <- length(unitab <- unique(tab)) + if(!is.null(PSTRATA)) { + ## take only the PSTRATA needed for this block, drop unused levels + PSTRATA <- droplevels(PSTRATA[obs]) + ## need only those strata for the current block. As obs is the index + ## vector, split by block, this now gives nobs per plot strata + tab <- table(PSTRATA) + same.n <- length(unitab <- unique(tab)) + } + ## plots num.p <- if(isTRUE(all.equal(typeP, "free"))) { exp(lfactorial(length(levels(PSTRATA)))) Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-05 15:12:11 UTC (rev 2650) +++ pkg/permute/inst/ChangeLog 2013-11-05 21:03:53 UTC (rev 2651) @@ -8,6 +8,9 @@ `update()` to update elements of a stored permutation design object. Suggested by Jari Oksanen. + * numPerms: fixed a bug where `numPerms()` was ignoring Blocks when + computing the number of possible permutations. + Version 0.7-4 * Deprecated functions: Completed the deprecation of `permCheck()` From noreply at r-forge.r-project.org Tue Nov 5 23:44:43 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Nov 2013 23:44:43 +0100 (CET) Subject: [Vegan-commits] r2652 - in pkg/permute: R inst Message-ID: <20131105224444.01F0318612B@r-forge.r-project.org> Author: gsimpson Date: 2013-11-05 23:44:43 +0100 (Tue, 05 Nov 2013) New Revision: 2652 Modified: pkg/permute/R/print.how.R pkg/permute/inst/ChangeLog Log: wasn't printing details of mirroring or constant settings for within-plot components Modified: pkg/permute/R/print.how.R =================================================================== --- pkg/permute/R/print.how.R 2013-11-05 21:03:53 UTC (rev 2651) +++ pkg/permute/R/print.how.R 2013-11-05 22:44:43 UTC (rev 2652) @@ -4,12 +4,12 @@ stopifnot(class(x) == "how") ## prefix to add to sub-elements - pfix <- " " + pfix <- " " cat("\n") writeLines(strwrap("Permutation Design:")) cat("\n") - + ## Blocks writeLines("Blocks:") blocks <- getBlocks(x) @@ -19,9 +19,9 @@ writeLines(strwrap(paste("Blocks:", x$blocks.name), prefix = pfix)) } - + cat("\n") - + ## Plots writeLines("Plots:") plotStr <- getStrata(x, which = "plots") @@ -47,9 +47,9 @@ prefix = pfix)) } } - + cat("\n") - + ## Within plots writeLines("Within Plots:") wtype <- getType(x, which = "within") @@ -57,7 +57,7 @@ mirrorW <- getMirror(x, which = "within") constantW <- getConstant(x) txt <- "Different permutation within each Plot?:" - if(isTRUE(ptype %in% c("series", "grid"))) { + if(isTRUE(wtype %in% c("series", "grid"))) { writeLines(strwrap(paste("Mirrored?:", if(mirrorW) "Yes" else "No"), prefix = pfix)) writeLines(strwrap(paste(txt, if(constantW) "No" else "Yes"), @@ -72,9 +72,9 @@ nc, nc.t), prefix = pfix)) } - + cat("\n") - + ## Meta data writeLines("Permutation details:") writeLines(strwrap(paste("Number of permutations requested:", @@ -86,5 +86,5 @@ if(complete$complete) "Yes." else "No.", " Activation limit:", complete$minperm) writeLines(strwrap(txt, prefix = pfix)) - + } Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-05 21:03:53 UTC (rev 2651) +++ pkg/permute/inst/ChangeLog 2013-11-05 22:44:43 UTC (rev 2652) @@ -8,6 +8,9 @@ `update()` to update elements of a stored permutation design object. Suggested by Jari Oksanen. + The `print` method for class "how" wasn't printing details of + mirroring or constant settings for within-plot components. + * numPerms: fixed a bug where `numPerms()` was ignoring Blocks when computing the number of possible permutations. From noreply at r-forge.r-project.org Tue Nov 5 23:46:35 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Nov 2013 23:46:35 +0100 (CET) Subject: [Vegan-commits] r2653 - in pkg/permute: R inst Message-ID: <20131105224635.12BE5185DD1@r-forge.r-project.org> Author: gsimpson Date: 2013-11-05 23:46:34 +0100 (Tue, 05 Nov 2013) New Revision: 2653 Modified: pkg/permute/R/Plots.R pkg/permute/R/Within.R pkg/permute/inst/ChangeLog Log: add matched call to returned objects Modified: pkg/permute/R/Plots.R =================================================================== --- pkg/permute/R/Plots.R 2013-11-05 22:44:43 UTC (rev 2652) +++ pkg/permute/R/Plots.R 2013-11-05 22:46:34 UTC (rev 2653) @@ -3,7 +3,7 @@ type <- match.arg(type) out <- list(strata = strata, type = type, mirror = mirror, ncol = ncol, nrow = nrow, - plots.name = deparse(substitute(strata))) + plots.name = deparse(substitute(strata)), call = match.call()) ## keep as list for now ##class(out) <- "Plots" out Modified: pkg/permute/R/Within.R =================================================================== --- pkg/permute/R/Within.R 2013-11-05 22:44:43 UTC (rev 2652) +++ pkg/permute/R/Within.R 2013-11-05 22:46:34 UTC (rev 2653) @@ -7,8 +7,8 @@ else type <- match.arg(type) out <- list(type = type, constant = constant, mirror = mirror, - ncol = ncol, nrow = nrow) + ncol = ncol, nrow = nrow, call = match.call()) ## keep as default list for now ##class(out) <- "Within" - return(out) + out } Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-05 22:44:43 UTC (rev 2652) +++ pkg/permute/inst/ChangeLog 2013-11-05 22:46:34 UTC (rev 2653) @@ -14,6 +14,9 @@ * numPerms: fixed a bug where `numPerms()` was ignoring Blocks when computing the number of possible permutations. + * Within, Plots: as with `how()`, the matched call is now returned + as part of the list object, allowing desirable `update()` behaviour. + Version 0.7-4 * Deprecated functions: Completed the deprecation of `permCheck()` From noreply at r-forge.r-project.org Tue Nov 5 23:47:44 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Nov 2013 23:47:44 +0100 (CET) Subject: [Vegan-commits] r2654 - pkg/permute/vignettes Message-ID: <20131105224744.C13A4184FD6@r-forge.r-project.org> Author: gsimpson Date: 2013-11-05 23:47:44 +0100 (Tue, 05 Nov 2013) New Revision: 2654 Modified: pkg/permute/vignettes/permutations.Rnw Log: name some more code chunks Modified: pkg/permute/vignettes/permutations.Rnw =================================================================== --- pkg/permute/vignettes/permutations.Rnw 2013-11-05 22:46:34 UTC (rev 2653) +++ pkg/permute/vignettes/permutations.Rnw 2013-11-05 22:47:44 UTC (rev 2654) @@ -150,15 +150,15 @@ In the previous section I introduced the \code{shuffle()} function to generate permutation indices for use in a randomisation test. Now we will take a closer look at \code{shuffle()} and explore the various restricted permutation designs from which it can generate permutation indices. \code{shuffle()} has two arguments: i) \code{n}, the number of observations in the data set to be permuted, and ii) \code{control}, a list that defines the permutation design describing how the samples should be permuted. -<<>>= +<>= args(shuffle) @ A series of convenience functions are provided that allow the user to set-up even quite complex permutation designs with little effort. The user only needs to specify the aspects of the design they require and the convenience functions ensure all configuration choices are set and passed on to \code{shuffle()}. The main convenience function is \code{how()}, which returns a list specifying all the options available for controlling the sorts of permutations returned by \code{shuffle()} -<<>>= +<>= str(how()) @ The defaults describe a random permutation design where all objects are freely exchangeable. Using these defaults, \code{shuffle(10)} amounts to \code{sample(1:10, 10, replace = FALSE)}: -<<>>= +<>= set.seed(2) (r1 <- shuffle(10)) set.seed(2) @@ -183,7 +183,7 @@ For example, to permute the observations \code{1:10} assuming a time series design for the entire set of observations, the following control object would be used -<>= +<>= set.seed(4) x <- 1:10 CTRL <- how(within = Within(type = "series")) @@ -196,7 +196,7 @@ A more complex design, with three plots, and a 3 by 3 spatial grid arrangement within each plot can be created as follows -<>= +<>= set.seed(4) plt <- gl(3, 9) CTRL <- how(within = Within(type = "grid", ncol = 3, nrow = 3), @@ -207,7 +207,7 @@ Visualising the permutation as the 3 matrices may help illustrate how the data have been shuffled -<>= +<>= ## Original lapply(split(seq_along(plt), plt), matrix, ncol = 3) ## Shuffled @@ -217,7 +217,7 @@ In the first grid, the lower-left corner of the grid was set to row 2 and column 2 of the original, to row 1 and column 2 in the second grid, and to row 3 column 2 in the third grid. To have the same permutation within each level of \code{plt}, use the \code{constant} argument of the \code{Within()} function, setting it to \code{TRUE} -<>= +<>= set.seed(4) CTRL <- how(within = Within(type = "grid", ncol = 3, nrow = 3, constant = TRUE), @@ -231,7 +231,7 @@ The \code{shuffleSet()} function allows the generation of sets of permutations from any of the designs available in \pkg{permute}. \code{shuffleSet()} takes an additional argument to that of \code{shuffle()}, \code{nset}, which is the number of permutations required for the set. \code{nset} can be missing, in which case the number of permutations in the set is looked for in the object passed to \code{control}; using this, the desired number of permutation can be set at the time the design is created via the \code{nperm} argument of \code{how()}. For example, -<>= +<>= how(nperm = 10, within = Within(type = "series")) @ @@ -239,7 +239,7 @@ As an illustration, consider again the simple time series example from earlier. Here I generate a set of 5 permutations from the design, with the results returned as a matrix -<>= +<>= set.seed(4) CTRL <- how(within = Within(type = "series")) pset <- shuffleSet(10, nset = 5, control = CTRL) From noreply at r-forge.r-project.org Tue Nov 5 23:50:08 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Nov 2013 23:50:08 +0100 (CET) Subject: [Vegan-commits] r2655 - in pkg/permute: R inst Message-ID: <20131105225008.C8498184FD6@r-forge.r-project.org> Author: gsimpson Date: 2013-11-05 23:50:08 +0100 (Tue, 05 Nov 2013) New Revision: 2655 Modified: pkg/permute/R/allPerms.R pkg/permute/inst/ChangeLog Log: fixes several bugs handling the blocking structures (correctly subsets plot strata now) and deals with no plot strata in design Modified: pkg/permute/R/allPerms.R =================================================================== --- pkg/permute/R/allPerms.R 2013-11-05 22:47:44 UTC (rev 2654) +++ pkg/permute/R/allPerms.R 2013-11-05 22:50:08 UTC (rev 2655) @@ -35,17 +35,20 @@ BLOCKS <- factor(rep(1, n)) ## split v by blocks - spl <- split(v, BLOCKS) + spl <- split(seq_len(n), BLOCKS) nb <- length(spl) # number of blocks ## result object out <- vector(mode = "list", length = nb) + ## null-out Blocks in control + control2 <- update(control, blocks = NULL) + ## loop over blocks and return allPerms on each block for (i in seq_along(spl)) { out[[i]] <- doAllPerms(spl[[i]], strataP, typeW, typeP, mirrorW, - mirrorP, constantW, dimW, dimP, control, + mirrorP, constantW, dimW, dimP, control2, nperms = nperms) } @@ -65,6 +68,7 @@ out } + `doAllPerms` <- function(obs, strataP, typeW, typeP, mirrorW, mirrorP, constantW, dimW, dimP, control, nperms) { ## replicate a matrix by going via a list and bind together @@ -75,6 +79,17 @@ n <- length(obs) + ## subset strataP to take only the obs indices and drop the unused + ## levels + if (!is.null(strataP)) { + strataP <- droplevels(strataP[obs]) + } + + ## also need to update the $strata component of control + ## FIXME: this really should have a toplevel function to set/update + ## sub-components of control + control$plots$strata <- strataP + ## permuting within? if (typeW != "none") { if(is.null(strataP)) { @@ -108,7 +123,7 @@ } else { ## different permutations within blocks nperms <- numPerms(sum(tab), control) - + ng <- length(tab) ##pg <- unique(tab) if(length(pg) > 1) { Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-05 22:47:44 UTC (rev 2654) +++ pkg/permute/inst/ChangeLog 2013-11-05 22:50:08 UTC (rev 2655) @@ -17,6 +17,9 @@ * Within, Plots: as with `how()`, the matched call is now returned as part of the list object, allowing desirable `update()` behaviour. + * allPerms, doAllPerms: now correctly work in presence of blocks, + and where there are no plots. + Version 0.7-4 * Deprecated functions: Completed the deprecation of `permCheck()` From noreply at r-forge.r-project.org Tue Nov 5 23:51:25 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 5 Nov 2013 23:51:25 +0100 (CET) Subject: [Vegan-commits] r2656 - in pkg/permute: inst man Message-ID: <20131105225125.C7743184FD6@r-forge.r-project.org> Author: gsimpson Date: 2013-11-05 23:51:25 +0100 (Tue, 05 Nov 2013) New Revision: 2656 Modified: pkg/permute/inst/ChangeLog pkg/permute/man/allPerms.Rd pkg/permute/man/check.Rd Log: Documentation fixes in examples of 'allPerms' and 'check' Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-05 22:50:08 UTC (rev 2655) +++ pkg/permute/inst/ChangeLog 2013-11-05 22:51:25 UTC (rev 2656) @@ -20,6 +20,8 @@ * allPerms, doAllPerms: now correctly work in presence of blocks, and where there are no plots. + * Documentation fixes in examples of `allPerms` and `check`. + Version 0.7-4 * Deprecated functions: Completed the deprecation of `permCheck()` Modified: pkg/permute/man/allPerms.Rd =================================================================== --- pkg/permute/man/allPerms.Rd 2013-11-05 22:50:08 UTC (rev 2655) +++ pkg/permute/man/allPerms.Rd 2013-11-05 22:51:25 UTC (rev 2656) @@ -84,7 +84,8 @@ (tmp2 <- allPerms(Nobs, control = ctrl)) ## turn on mirroring -ctrl$within$mirror <- TRUE +##ctrl$within$mirror <- TRUE +ctrl <- update(ctrl, within = update(getWithin(ctrl), mirror = TRUE)) numPerms(seq_len(Nobs), control = ctrl) (tmp3 <- allPerms(Nobs, control = ctrl, observed = TRUE)) (tmp4 <- allPerms(Nobs, control = ctrl)) Modified: pkg/permute/man/check.Rd =================================================================== --- pkg/permute/man/check.Rd 2013-11-05 22:50:08 UTC (rev 2655) +++ pkg/permute/man/check.Rd 2013-11-05 22:51:25 UTC (rev 2656) @@ -168,7 +168,8 @@ (tmp2 <- allPerms(12, control = ctrl)) ## turn on mirroring %%FIXME needs a proper method to do this -ctrl$within$mirror <- TRUE +##ctrl$within$mirror <- TRUE +ctrl <- update(ctrl, within = update(getWithin(ctrl), mirror = TRUE)) numPerms(1:12, control = ctrl) (tmp3 <- allPerms(12, control = ctrl, observed = TRUE)) (tmp4 <- allPerms(12, control = ctrl)) From noreply at r-forge.r-project.org Wed Nov 6 12:00:34 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 6 Nov 2013 12:00:34 +0100 (CET) Subject: [Vegan-commits] r2657 - in pkg/vegan: . R inst man Message-ID: <20131106110036.ACB1E185C6C@r-forge.r-project.org> Author: jarioksa Date: 2013-11-06 12:00:27 +0100 (Wed, 06 Nov 2013) New Revision: 2657 Modified: pkg/vegan/NAMESPACE pkg/vegan/R/bioenv.default.R pkg/vegan/inst/ChangeLog pkg/vegan/man/bioenv.Rd Log: add bioenvdist() to extract environmental distances used within bioenv Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2013-11-05 22:51:25 UTC (rev 2656) +++ pkg/vegan/NAMESPACE 2013-11-06 11:00:27 UTC (rev 2657) @@ -5,8 +5,8 @@ export(CCorA, MOStest, RsquareAdj, SSarrhenius, SSgitay, SSgleason, SSlomolino, adipart, adonis, anosim, beals, betadisper, betadiver, -bgdispersal, bioenv, bstick, cIndexKM, calibrate, capscale, cascadeKM, -cca, commsimulator, contribdiv, clamtest, commsim, decorana, +bgdispersal, bioenv, bioenvdist, bstick, cIndexKM, calibrate, capscale, +cascadeKM, cca, commsimulator, contribdiv, clamtest, commsim, decorana, decostand, designdist, coverscale, dispweight, dispindmorisita, distconnected, diversity, downweight, drarefy, eigengrad, eigenvals, envfit, estaccumR, estimateR, eventstar, factorfit, fisherfit, fitspecaccum, Modified: pkg/vegan/R/bioenv.default.R =================================================================== --- pkg/vegan/R/bioenv.default.R 2013-11-05 22:51:25 UTC (rev 2656) +++ pkg/vegan/R/bioenv.default.R 2013-11-06 11:00:27 UTC (rev 2657) @@ -121,11 +121,31 @@ flush.console() } } + whichbest <- which.max(lapply(best, function(tmp) tmp$est)) out <- list(names = colnames(env), method = method, index = index, metric = metric, upto = upto, models = best, - partial = partpart) + whichbest = whichbest, + partial = partpart, x = x, distfun = distfun) out$call <- match.call() out$call[[1]] <- as.name("bioenv") class(out) <- "bioenv" out } + +## Function to extract the environmental distances used within +## bioenv. The default is to take the best model, but any model can be +## specified by its number. + +`bioenvdist` <- + function(x, which = "best") +{ + ## any non-numeric argument is regarded as "best" + if(!is.numeric(which)) + which <- x$whichbest + if (x$metric == "gower") + require(cluster) || + stop("requires package 'cluster' for 'gower' metric") + x$distfun(x$x[, x$models[[which]]$best, drop = FALSE]) +} + + Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-11-05 22:51:25 UTC (rev 2656) +++ pkg/vegan/inst/ChangeLog 2013-11-06 11:00:27 UTC (rev 2657) @@ -4,8 +4,16 @@ Version 2.1-38 (opened November 5, 2013) - * DESCRIPTION: depends on permute >= 0.7-5. + * DESCRIPTION: depends on permute >= 0.7-5, where the + permute::how() result object can be updated. + * bioenv: returns now the number of the best model ('whichbest'), + the standardized environmental data ('x') and the distance + function used for the environmental data ('distfun'). New function + bioenvdist() uses these to re-calculate the environmental + distances for the best model, or any other model selected by its + number. + * permutest.cca: permutation test uses 'permute' package. The old interface was retained, and 'permutations' can be a single number or a permutation matrix (as previously), but now it can also be a Modified: pkg/vegan/man/bioenv.Rd =================================================================== --- pkg/vegan/man/bioenv.Rd 2013-11-05 22:51:25 UTC (rev 2656) +++ pkg/vegan/man/bioenv.Rd 2013-11-06 11:00:27 UTC (rev 2657) @@ -3,6 +3,7 @@ \alias{bioenv.default} \alias{bioenv.formula} \alias{summary.bioenv} +\alias{bioenvdist} \title{Best Subset of Environmental Variables with Maximum (Rank) Correlation with Community Dissimilarities } @@ -17,6 +18,7 @@ metric = c("euclidean", "mahalanobis", "manhattan", "gower"), parallel = getOption("mc.cores"), ...) \method{bioenv}{formula}(formula, data, ...) +bioenvdist(x, which = "best") } \arguments{ @@ -37,6 +39,9 @@ cluster. With \code{parallel = 1} uses ordinary, non-parallel processing. The parallel processing is done with \pkg{parallel} package which is available only for \R 2.14.0 and later.} + \item{x}{\code{bioenv} result object.} + \item{which}{The number of the model for which the environmental + distances are evaluated, or the \code{"best"} model.} \item{...}{Other arguments passed to \code{\link{cor}}.} } \details{ @@ -77,6 +82,10 @@ class \code{\link{dist}}. The \code{partial} item can be used with any correlation \code{method}, but it is strictly correct only for Pearson. + + Function \code{bioenvdist} recalculates the environmental distances + used within the function. The default is to calculate distances for + the best model, but the number of any model can be given. Clarke & Ainsworth (1993) suggested this method to be used for selecting the best subset of environmental variables in interpreting @@ -92,10 +101,12 @@ Windows). In addition, Clarke & Ainsworth suggested a novel method of rank correlation which is not available in the current function. } + \value{ The function returns an object of class \code{bioenv} with a \code{summary} method. } + \references{ Clarke, K. R & Ainsworth, M. 1993. A method of linking multivariate community structure to environmental variables. \emph{Marine Ecology @@ -103,17 +114,17 @@ } \author{ Jari Oksanen } -\note{ - If you want to study the \sQuote{significance} of \code{bioenv} +\note{ If you want to study the \sQuote{significance} of \code{bioenv} results, you can use function \code{\link{mantel}} or \code{\link{mantel.partial}} which use the same definition of - correlation. - However, \code{bioenv} standardizes environmental variables to unit standard - deviation using function \code{\link{scale}} and you must do the same - in \code{\link{mantel}} for comparable results. Further, \code{bioenv} - selects variables to maximize the Mantel correlation, and significance - tests based on \emph{a priori} selection of variables are biased. - } + correlation. However, \code{bioenv} standardizes environmental + variables depending on the used metric, and you must do the same in + \code{\link{mantel}} for comparable results (the standardized data are + returned as item \code{x} in the result object). It is safest to use + \code{bioenvdist} to extract the environmental distances that really + were used within \code{bioenv}. NB., \code{bioenv} selects variables + to maximize the Mantel correlation, and significance tests based on + \emph{a priori} selection of variables are biased. } \seealso{\code{\link{vegdist}}, \code{\link{dist}}, \code{\link{cor}} for underlying routines, \code{\link{monoMDS}} and From noreply at r-forge.r-project.org Wed Nov 6 14:09:59 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 6 Nov 2013 14:09:59 +0100 (CET) Subject: [Vegan-commits] r2658 - pkg/vegan/R Message-ID: <20131106130959.B4C6618622D@r-forge.r-project.org> Author: jarioksa Date: 2013-11-06 14:09:51 +0100 (Wed, 06 Nov 2013) New Revision: 2658 Modified: pkg/vegan/R/permutest.cca.R Log: define 'strata' via plots in permutations Modified: pkg/vegan/R/permutest.cca.R =================================================================== --- pkg/vegan/R/permutest.cca.R 2013-11-06 11:00:27 UTC (rev 2657) +++ pkg/vegan/R/permutest.cca.R 2013-11-06 13:09:51 UTC (rev 2658) @@ -124,7 +124,7 @@ stop("'strata' can be used only with simple permutation or with 'how()'") if (!is.null(permutations$block)) stop("'strata' cannot be applied when 'blocks' are defined in 'how()'") - permutations <- update(permutations, blocks = strata) + permutations <- update(permutations, plots = Plots(factor(strata))) } ## now permutations is either a how() structure or a permutation ## matrix. Make it to a matrix if it is "how" From noreply at r-forge.r-project.org Wed Nov 6 14:18:20 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 6 Nov 2013 14:18:20 +0100 (CET) Subject: [Vegan-commits] r2659 - pkg/vegan/R Message-ID: <20131106131820.70107184BAE@r-forge.r-project.org> Author: jarioksa Date: 2013-11-06 14:18:19 +0100 (Wed, 06 Nov 2013) New Revision: 2659 Modified: pkg/vegan/R/permutest.cca.R Log: revert r2658: tried to fix an issue that was fixed already in r2655 in permute Modified: pkg/vegan/R/permutest.cca.R =================================================================== --- pkg/vegan/R/permutest.cca.R 2013-11-06 13:09:51 UTC (rev 2658) +++ pkg/vegan/R/permutest.cca.R 2013-11-06 13:18:19 UTC (rev 2659) @@ -124,7 +124,7 @@ stop("'strata' can be used only with simple permutation or with 'how()'") if (!is.null(permutations$block)) stop("'strata' cannot be applied when 'blocks' are defined in 'how()'") - permutations <- update(permutations, plots = Plots(factor(strata))) + permutations <- update(permutations, blocks = strata) } ## now permutations is either a how() structure or a permutation ## matrix. Make it to a matrix if it is "how" From noreply at r-forge.r-project.org Wed Nov 6 18:14:29 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 6 Nov 2013 18:14:29 +0100 (CET) Subject: [Vegan-commits] r2660 - in pkg/permute: R inst Message-ID: <20131106171429.92C66185686@r-forge.r-project.org> Author: gsimpson Date: 2013-11-06 18:14:29 +0100 (Wed, 06 Nov 2013) New Revision: 2660 Modified: pkg/permute/R/shuffleSet2.R pkg/permute/inst/ChangeLog Log: fix issue in unsplitting block-level permutations into a single whole set Modified: pkg/permute/R/shuffleSet2.R =================================================================== --- pkg/permute/R/shuffleSet2.R 2013-11-06 13:18:19 UTC (rev 2659) +++ pkg/permute/R/shuffleSet2.R 2013-11-06 17:14:29 UTC (rev 2660) @@ -8,7 +8,7 @@ else nset <- np } - + sn <- seq_len(n) ## sequence of samples in order of input ## need to check number of permutations won't blow up @@ -21,19 +21,20 @@ Block <- getStrata(control, which = "blocks") if(is.null(Block)) Block <- factor(rep(1, n)) - + ## split sn on basis of Block spln <- split(sn, Block) nb <- length(spln) ## number of blocks - + ## result list out <- vector(mode = "list", length = nb) - + ## loop over spln and shuffle in each split for(i in seq_len(nb)) { out[[i]] <- doShuffleSet(spln[[i]], nset = nset, control) } - out <- do.call(cbind, out) ## undo the original splitting + ##out <- do.call(cbind, out) ## undo the original splitting + out <- unsplit(out, Block) ## undo the original splitting } else { ## if we have all.perms now then we must have generated it ## during checking or user passed it with control @@ -48,17 +49,17 @@ Pstrata <- getStrata(control, which = "plots", drop = TRUE) plotCTRL <- getPlots(control) typeP <- getType(control, which = "plots") - + ## collect the within control object withinCTRL <- getWithin(control) typeW <- getType(control, which = "within") - + n <- length(ind) sn <- seq_len(n) - + ## result object Set <- matrix(nrow = nset, ncol = n) - + ## if no strata at Plot level permute all samples using stated scheme if(is.null(Pstrata)) { ## If no strata at plot then permute all samples using stated scheme @@ -82,7 +83,7 @@ } } else { ## If strata at Plot level present, either permute samples, Plots or both - + ## permute strata at Plot level? if(isTRUE(all.equal(typeP, "none"))) { Set[] <- rep(sn, each = nset) @@ -97,16 +98,16 @@ ncol = plotCTRL$ncol)) } } - + tmp <- Set - + ## permute the samples within Plot strata if(!isTRUE(all.equal(typeW, "none"))) { for(i in seq_len(nset)) { tab <- table(Pstrata[ind][Set[i,]]) ## the levels of the Plot strata levs <- names(tab) - + ## same permutation within each level of the Plot strata? if(withinCTRL$constant) { if(isTRUE(all.equal(typeW, "free"))) { @@ -123,7 +124,7 @@ } else { start <- start.row <- start.col <- flip <- NULL } - + ## for each level of strata, permute for(lv in levs) { ## must re-order strata here on basis of Ser as they Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-06 13:18:19 UTC (rev 2659) +++ pkg/permute/inst/ChangeLog 2013-11-06 17:14:29 UTC (rev 2660) @@ -11,6 +11,10 @@ The `print` method for class "how" wasn't printing details of mirroring or constant settings for within-plot components. + * shuffleSet: was incorrectly recombining individual block-level + permutations. + Reported by Jari Oksanen. + * numPerms: fixed a bug where `numPerms()` was ignoring Blocks when computing the number of possible permutations. From noreply at r-forge.r-project.org Thu Nov 7 05:11:03 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Nov 2013 05:11:03 +0100 (CET) Subject: [Vegan-commits] r2661 - pkg/permute/R Message-ID: <20131107041103.B9AEB183263@r-forge.r-project.org> Author: gsimpson Date: 2013-11-07 05:11:03 +0100 (Thu, 07 Nov 2013) New Revision: 2661 Modified: pkg/permute/R/shuffleSet2.R Log: can't use unsplit as each element is a matrix of permutations in shuffleSet Modified: pkg/permute/R/shuffleSet2.R =================================================================== --- pkg/permute/R/shuffleSet2.R 2013-11-06 17:14:29 UTC (rev 2660) +++ pkg/permute/R/shuffleSet2.R 2013-11-07 04:11:03 UTC (rev 2661) @@ -33,8 +33,10 @@ for(i in seq_len(nb)) { out[[i]] <- doShuffleSet(spln[[i]], nset = nset, control) } - ##out <- do.call(cbind, out) ## undo the original splitting - out <- unsplit(out, Block) ## undo the original splitting + ## undo the original splitting. Can't use unsplit() here as the + ## elements of out are matrices + out <- do.call(cbind, out) + out[, unlist(spln)] <- out ## reorders according to spln } else { ## if we have all.perms now then we must have generated it ## during checking or user passed it with control From noreply at r-forge.r-project.org Thu Nov 7 05:21:12 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Nov 2013 05:21:12 +0100 (CET) Subject: [Vegan-commits] r2662 - pkg/permute/inst/tests Message-ID: <20131107042112.62BD1184B1D@r-forge.r-project.org> Author: gsimpson Date: 2013-11-07 05:21:11 +0100 (Thu, 07 Nov 2013) New Revision: 2662 Modified: pkg/permute/inst/tests/test-shuffle.R Log: minor fiddling Modified: pkg/permute/inst/tests/test-shuffle.R =================================================================== --- pkg/permute/inst/tests/test-shuffle.R 2013-11-07 04:11:03 UTC (rev 2661) +++ pkg/permute/inst/tests/test-shuffle.R 2013-11-07 04:21:11 UTC (rev 2662) @@ -5,7 +5,7 @@ ## test no permutation test_that("shuffle(n) returns seq_len(n) when not permuting", { - ctrl <- permControl(within = Within(type = "none")) + ctrl <- how(within = Within(type = "none")) expect_that(shuffle(3, control = ctrl), is_identical_to(seq_len(3))) expect_that(shuffle(1, control = ctrl), is_identical_to(1L)) @@ -13,7 +13,7 @@ ## test shuffle returns integers test_that("shuffle() returns integers", { - ctrl <- permControl(within = Within(type = "none")) + ctrl <- how(within = Within(type = "none")) expect_that(shuffle(4), is_a("integer")) expect_that(shuffle(100), is_a("integer")) @@ -26,9 +26,9 @@ test_that("shuffle() works for non-contigous blocks of samples", { ## permuting levels of Plots instead of observations ## non-contiguous blocks - checks that r1972 continues to work - Plot <- factor(rep(1:4, 5)) - CTRL <- permControl(plots = Plots(strata = Plot, type = "free"), - within = Within(type = "none")) + Plot <- factor(rep(1:4, 5)) + CTRL <- how(plots = Plots(strata = Plot, type = "free"), + within = Within(type = "none")) n <- 20 set.seed(2) result <- shuffle(n, CTRL) From noreply at r-forge.r-project.org Thu Nov 7 05:21:56 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Nov 2013 05:21:56 +0100 (CET) Subject: [Vegan-commits] r2663 - pkg/permute/inst/tests Message-ID: <20131107042157.09EE9184B1D@r-forge.r-project.org> Author: gsimpson Date: 2013-11-07 05:21:56 +0100 (Thu, 07 Nov 2013) New Revision: 2663 Added: pkg/permute/inst/tests/test-shuffleSet.R Log: adds initial unit test for shuffleSet Added: pkg/permute/inst/tests/test-shuffleSet.R =================================================================== --- pkg/permute/inst/tests/test-shuffleSet.R (rev 0) +++ pkg/permute/inst/tests/test-shuffleSet.R 2013-11-07 04:21:56 UTC (rev 2663) @@ -0,0 +1,20 @@ +library(testthat) +library_if_available(permute) + +context("Testing shuffleSet()") + +## test that shuffleSet interleves the separate block-level +## permutations correctly back into the original ordering +## This always generates odd, even, odd, ..., numbered vector +## of observations, hence when we take the modulus 2 we get +## a vector of 1,0,1,0,1,... +test_that("shuffleSet interleves block-level perms correctly", { + gr <- factor(rep(1:2, length=20)) + ctrl <- how(nperm=5, blocks=gr) + p <- shuffleSet(20, control = ctrl) %% 2 + y <- rep_len(c(1L, 0L), ncol(p)) + nc <- ncol(p) + for (i in seq_len(nrow(p))) { + expect_that(p[i, ], equals(y)) + } +}) From noreply at r-forge.r-project.org Thu Nov 7 22:15:06 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Nov 2013 22:15:06 +0100 (CET) Subject: [Vegan-commits] r2664 - in pkg/permute: R inst man vignettes Message-ID: <20131107211506.397361849A4@r-forge.r-project.org> Author: gsimpson Date: 2013-11-07 22:15:05 +0100 (Thu, 07 Nov 2013) New Revision: 2664 Modified: pkg/permute/R/shuffleSet2.R pkg/permute/inst/ChangeLog pkg/permute/man/shuffleSet.Rd pkg/permute/vignettes/permutations.Rnw Log: allow checking in shuffleSet to be controlled via the user; adds argument check defaulting to TRUE. Modified: pkg/permute/R/shuffleSet2.R =================================================================== --- pkg/permute/R/shuffleSet2.R 2013-11-07 04:21:56 UTC (rev 2663) +++ pkg/permute/R/shuffleSet2.R 2013-11-07 21:15:05 UTC (rev 2664) @@ -1,5 +1,5 @@ ## new version of shuffleSet() that allows for blocking -`shuffleSet` <- function(n, nset, control = how()) { +`shuffleSet` <- function(n, nset, control = how(), check = TRUE) { ## handle missing nset - take from control if can if(missing(nset)) { np <- getNperm(control) @@ -11,10 +11,17 @@ sn <- seq_len(n) ## sequence of samples in order of input - ## need to check number of permutations won't blow up - pcheck <- check(sn, control = control, make.all = TRUE) - ## control possibly now updated - control <- pcheck$control + ## if checking permutation design, may end up with more perms + ## than requested in nset, depending upon what user specified + ## in `control`. The `check` argument can turn this step off + ## so you always get `nset` permutations and, yes, you can shoot + ## yourself in the foot with this, hence the dfeualt is to check! + if (isTRUE(check)) { + ## need to check number of permutations won't blow up + pcheck <- check(sn, control = control, make.all = TRUE) + ## control possibly now updated + control <- pcheck$control + } if(is.null(control$all.perms)) { ## get blocking, if any Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-07 04:21:56 UTC (rev 2663) +++ pkg/permute/inst/ChangeLog 2013-11-07 21:15:05 UTC (rev 2664) @@ -15,6 +15,14 @@ permutations. Reported by Jari Oksanen. + Gains an argument, `check`, which allows the user to control whether + the permutation design should be checked. In small data sets or where + there are very few permutations, `shuffleSet` could generate more + permutations (i.e. all possible ones) than requested. Turning off this + checking with `check = FALSE` will result in exactly `nset` + permutations being returned, but without a gaurantee that they will + be unique. + * numPerms: fixed a bug where `numPerms()` was ignoring Blocks when computing the number of possible permutations. Modified: pkg/permute/man/shuffleSet.Rd =================================================================== --- pkg/permute/man/shuffleSet.Rd 2013-11-07 04:21:56 UTC (rev 2663) +++ pkg/permute/man/shuffleSet.Rd 2013-11-07 21:15:05 UTC (rev 2664) @@ -11,7 +11,7 @@ set of permutations. } \usage{ -shuffleSet(n, nset, control = how()) +shuffleSet(n, nset, control = how(), check = TRUE) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -24,12 +24,43 @@ \code{control}. } \item{control}{ - an object of class \code{"how"} describing a valid - permutation design. + an object of class \code{"how"} describing a valid permutation + design. } + \item{check}{ + logical; should the design be checked for various problems via + function \code{\link{check}}? The default is to check the design for + the stated number of observations and update \code{control} + accordingly. See Details. + } } \details{ - TODO + \code{shuffleSet} is designed to generate a set of \code{nset} + permutation indices over which a function can iterate as part of a + permutation test. It is only slightly more efficient than calling + \code{\link{shuffle}} \code{nset} times, but it is far more practical + than the simpler function because a set of permutations can be worked + on by applying a function to the rows of the returned object. This + simplifies the function applied, and facilitates the use of parallel + processing functions, thus enabling a larger number of permutations to + be evaluated in reasonable time. + + By default, \code{shuffleSet} will check the permutations design + following a few simple heuristics. See \code{\link{check}} for details + of these. Whether some of the heuristics are activiated or not can be + controlled via \code{\link{how}}, essentialy via its argument + \code{minperm}. In particular, if there are fewer than \code{minperm} + permutations, \code{shuffleSet} will generate and return \strong{all + possible permutations}, which may differ from the number requested via + argument \code{nset}. + + The \code{check} argument to \code{shuffleSet} controls whether + checking is performed in the permutation design. If you set + \code{check = FALSE} then exactly \code{nset} permutations will be + returned. However, do be aware that there is no guarantee that the set + of permutations returned will be unique, especially so for designs and + data sets where there are few possible permutations relative to the + number requested. } \value{ Returns a matrix of permutations, where each row is a separate @@ -46,7 +77,7 @@ %% ~Make other sections like Warning with \section{Warning }{....} ~ \references{ - \code{shuffle()} is modelled after the permutation schemes of Canoco + \code{shuffleSet()} is modelled after the permutation schemes of Canoco 3.1 (ter Braak, 1990); see also Besag & Clifford (1989). Besag, J. and Clifford, P. (1989) Generalized Monte Carlo significance @@ -61,10 +92,11 @@ } \examples{ ## simple random permutations, 5 permutations in set -shuffleSet(n = 10, nset = 10) +shuffleSet(n = 10, nset = 5) -## series random permutations, 10 permutations in set -shuffleSet(10, 10, how(within = Within(type = "series"))) +## series random permutations, 5 permutations in set +shuffleSet(10, 5, how(within = Within(type = "series")), + check = FALSE) ## series random permutations, 10 permutations in set, ## with possible mirroring @@ -94,7 +126,7 @@ ## as above, but with same permutation for each Plot-level stratum CTRL <- how(plots = plotStrata, within = Within(type = "series", constant = TRUE)) -shuffleSet(20, 10, CTRL) +shuffleSet(20, 10, CTRL, check = FALSE) } % Add one or more standard keywords, see file 'KEYWORDS' in the % R documentation directory. Modified: pkg/permute/vignettes/permutations.Rnw =================================================================== --- pkg/permute/vignettes/permutations.Rnw 2013-11-07 04:21:56 UTC (rev 2663) +++ pkg/permute/vignettes/permutations.Rnw 2013-11-07 21:15:05 UTC (rev 2664) @@ -242,9 +242,10 @@ <>= set.seed(4) CTRL <- how(within = Within(type = "series")) -pset <- shuffleSet(10, nset = 5, control = CTRL) +pset <- shuffleSet(10, nset = 5, control = CTRL, check = FALSE) pset @ +Note that we set \code{check = FALSE} in the call. As there are only 10 permutations of these data (including the observed one), by default \code{shuffleSet()} will check the permutation design and, following a few heuristics\footnote{Values used in these heuristics can be set when you create the permutation design with \code{how()}. See \code{?how} for further details and \code{?check} for the function that does the checking.}, will in this case generate all ten permutations. Setting \code{check = FALSE} turns this checking off, enabling exactly \code{nset} permutations to be returned. The downside of this is that you need to be aware of the implications of not checking the design; with a limited number of possible permutations, there is no guarantee that \code{shuffleSet()} will generate a set of \code{nset} unique permutations. \section{Defining permutation designs} In this section examples are given of how various permutation designs can be specified using \code{how()}. It is not the intention to provide exhaustive coverage of all possible designs that can be produced; such a list would be tedious to both write \emph{and} read. Instead, the main features and options will be described through a series of examples. The reader should then be able to put together the various options to create the exact structure required. From noreply at r-forge.r-project.org Thu Nov 7 23:16:20 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Nov 2013 23:16:20 +0100 (CET) Subject: [Vegan-commits] r2665 - pkg/permute/R Message-ID: <20131107221620.D4640186182@r-forge.r-project.org> Author: gsimpson Date: 2013-11-07 23:16:20 +0100 (Thu, 07 Nov 2013) New Revision: 2665 Modified: pkg/permute/R/allPerms.R pkg/permute/R/print.summary.allPerms.R Log: summary.allperms print method now prints the permutation design; all perms returns this design as an attribute 'control' Modified: pkg/permute/R/allPerms.R =================================================================== --- pkg/permute/R/allPerms.R 2013-11-07 21:15:05 UTC (rev 2664) +++ pkg/permute/R/allPerms.R 2013-11-07 22:16:20 UTC (rev 2665) @@ -64,6 +64,7 @@ control$nperm <- control$nperm - 1 } class(out) <- "allPerms" + attr(out, "control") <- control attr(out, "observed") <- observed out } Modified: pkg/permute/R/print.summary.allPerms.R =================================================================== --- pkg/permute/R/print.summary.allPerms.R 2013-11-07 21:15:05 UTC (rev 2664) +++ pkg/permute/R/print.summary.allPerms.R 2013-11-07 22:16:20 UTC (rev 2665) @@ -9,9 +9,9 @@ prefix = "\t")) cat("\nPermutation Scheme:\n") print(control) - cat(paste("Contains observed ordering?:", ifelse(observed, "Yes", "No"), + cat("\nAll permutations:\n") + writeLines(paste("Contains observed ordering?:", ifelse(observed, "Yes", "No"), "\n")) - cat("\nAll permutations:\n") print(x) return(invisible(x)) } From noreply at r-forge.r-project.org Thu Nov 7 23:22:51 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Nov 2013 23:22:51 +0100 (CET) Subject: [Vegan-commits] r2666 - pkg/permute/inst Message-ID: <20131107222251.84A10186182@r-forge.r-project.org> Author: gsimpson Date: 2013-11-07 23:22:51 +0100 (Thu, 07 Nov 2013) New Revision: 2666 Modified: pkg/permute/inst/ChangeLog Log: document r2665 Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-07 22:16:20 UTC (rev 2665) +++ pkg/permute/inst/ChangeLog 2013-11-07 22:22:51 UTC (rev 2666) @@ -32,6 +32,13 @@ * allPerms, doAllPerms: now correctly work in presence of blocks, and where there are no plots. + `allPerms` now includes the permutation design (its `control` + argument) as an attribute, `"control"`, on the returned matrix of + permutations. + + `summary.allPerms` (its `print` method, more correctly) now prints + the permutation design alongside the set of permutations. + * Documentation fixes in examples of `allPerms` and `check`. Version 0.7-4 From noreply at r-forge.r-project.org Thu Nov 7 23:26:54 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Nov 2013 23:26:54 +0100 (CET) Subject: [Vegan-commits] r2667 - pkg/permute/inst Message-ID: <20131107222654.A0332186182@r-forge.r-project.org> Author: gsimpson Date: 2013-11-07 23:26:54 +0100 (Thu, 07 Nov 2013) New Revision: 2667 Modified: pkg/permute/inst/TODO.md Log: Update the TODO list Modified: pkg/permute/inst/TODO.md =================================================================== --- pkg/permute/inst/TODO.md 2013-11-07 22:22:51 UTC (rev 2666) +++ pkg/permute/inst/TODO.md 2013-11-07 22:26:54 UTC (rev 2667) @@ -2,7 +2,8 @@ A TODO list for **permute** - or things I know are broken or needed. - * `summary.allPerms` - is not printing the permutation scheme + * `summary.allPerms` - is not printing the permutation scheme. + *Done in 0.7-5* * `print.permControl` - this needs to be updated to new API, and I don't like the `*** Foo ***` headings I used before. *Done in 0.7-3* @@ -37,6 +38,14 @@ Where in the second `update()` the entire `Plots()` call needs to repeated to change just one part, the `type`. + + This has been tweaked a bit. The second example can now be done via: + + update(h1, plots = update(getPlots(h1), type = "none")) + + Here `getPlots(h1)` returns the `plots` component, which too has + a `call` component and hence can be `update()`ed, hence the nested + calls to `update()`. * `permControl` - deprecate this in favour of `how` as in "how to permute"? *DONE Completed in 0.7-4* From noreply at r-forge.r-project.org Thu Nov 7 23:31:48 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Nov 2013 23:31:48 +0100 (CET) Subject: [Vegan-commits] r2668 - pkg/permute/R Message-ID: <20131107223148.9DB91186182@r-forge.r-project.org> Author: gsimpson Date: 2013-11-07 23:31:48 +0100 (Thu, 07 Nov 2013) New Revision: 2668 Modified: pkg/permute/R/permuplot.R Log: permuplot now prints a message about not working and exits without attempting to plot anything Modified: pkg/permute/R/permuplot.R =================================================================== --- pkg/permute/R/permuplot.R 2013-11-07 22:26:54 UTC (rev 2667) +++ pkg/permute/R/permuplot.R 2013-11-07 22:31:48 UTC (rev 2668) @@ -10,6 +10,10 @@ ann = par("ann"), cex = par("cex"), ...) { + ## This should just bail with an message + message("permuplot does not work with the new permutation designs.\nNo plot will be generated!") + invisible() + xy.series <- function(n) { angle <- seq(0, 2*pi, length = n+1)[-(n+1)] x <- rev(cos(angle)) From noreply at r-forge.r-project.org Thu Nov 7 23:34:48 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Nov 2013 23:34:48 +0100 (CET) Subject: [Vegan-commits] r2669 - pkg/permute/inst Message-ID: <20131107223448.D465F186182@r-forge.r-project.org> Author: gsimpson Date: 2013-11-07 23:34:48 +0100 (Thu, 07 Nov 2013) New Revision: 2669 Modified: pkg/permute/inst/ChangeLog Log: document r2668 Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-07 22:31:48 UTC (rev 2668) +++ pkg/permute/inst/ChangeLog 2013-11-07 22:34:48 UTC (rev 2669) @@ -41,6 +41,14 @@ * Documentation fixes in examples of `allPerms` and `check`. + * permuplot: This is horribly broken and I'm not sure if it will ever + return. In the meantime, this function now prints a warning message if + used and returns nothing, invisibly. + + I'm not convinced that the plot can adequately convery the breadth of + designs now possible. Hence I am minded to deprecate this in 0.8-0 + when released to CRAN and to make it defunct some thereafter. + Version 0.7-4 * Deprecated functions: Completed the deprecation of `permCheck()` From noreply at r-forge.r-project.org Thu Nov 7 23:35:46 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Nov 2013 23:35:46 +0100 (CET) Subject: [Vegan-commits] r2670 - pkg/permute/man Message-ID: <20131107223546.E15291864F8@r-forge.r-project.org> Author: gsimpson Date: 2013-11-07 23:35:46 +0100 (Thu, 07 Nov 2013) New Revision: 2670 Modified: pkg/permute/man/check.Rd Log: fix a formatting issue of the markup layout. Purely cosmetic for editing purposes. Modified: pkg/permute/man/check.Rd =================================================================== --- pkg/permute/man/check.Rd 2013-11-07 22:34:48 UTC (rev 2669) +++ pkg/permute/man/check.Rd 2013-11-07 22:35:46 UTC (rev 2670) @@ -95,8 +95,9 @@ permutations possible and an object of class \code{"\link{how}"}. } \author{Gavin L. Simpson} -\seealso{\code{\link{shuffle}} and \code{\link{how}}.}\examples{ +\seealso{\code{\link{shuffle}} and \code{\link{how}}.} +\examples{ ## use example data from ?pyrifos in package vegan require(vegan) example(pyrifos) From noreply at r-forge.r-project.org Thu Nov 7 23:37:05 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Nov 2013 23:37:05 +0100 (CET) Subject: [Vegan-commits] r2671 - pkg/permute/man Message-ID: <20131107223705.B2CAF1864F8@r-forge.r-project.org> Author: gsimpson Date: 2013-11-07 23:37:05 +0100 (Thu, 07 Nov 2013) New Revision: 2671 Modified: pkg/permute/man/how.Rd Log: change the example to use the nested update() idiom for manipulating permutation designs. Modified: pkg/permute/man/how.Rd =================================================================== --- pkg/permute/man/how.Rd 2013-11-07 22:35:46 UTC (rev 2670) +++ pkg/permute/man/how.Rd 2013-11-07 22:37:05 UTC (rev 2671) @@ -112,6 +112,6 @@ ## ... remove the blocking: update(h1, blocks = NULL) ## ... or switch the type of shuffling at a level: -update(h1, plots = Plots(strata = plts, type = "none")) +update(h1, plots = update(getPlots(h1), type = "none")) } \keyword{ utils } \ No newline at end of file From noreply at r-forge.r-project.org Thu Nov 7 23:56:34 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 7 Nov 2013 23:56:34 +0100 (CET) Subject: [Vegan-commits] r2672 - pkg/permute/tests/Examples Message-ID: <20131107225634.647671864D7@r-forge.r-project.org> Author: gsimpson Date: 2013-11-07 23:56:34 +0100 (Thu, 07 Nov 2013) New Revision: 2672 Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save Log: update the reference check material Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save =================================================================== --- pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-07 22:37:05 UTC (rev 2671) +++ pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-07 22:56:34 UTC (rev 2672) @@ -1,7 +1,7 @@ -R version 3.0.1 (2013-05-16) -- "Good Sport" +R version 3.0.2 Patched (2013-10-07 r64035) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing -Platform: x86_64-pc-linux-gnu (64-bit) +Platform: x86_64-unknown-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -73,7 +73,8 @@ [5,] 6 1 2 3 4 5 12 7 8 9 10 11 > > ## turn on mirroring -> ctrl$within$mirror <- TRUE +> ##ctrl$within$mirror <- TRUE +> ctrl <- update(ctrl, within = update(getWithin(ctrl), mirror = TRUE)) > numPerms(seq_len(Nobs), control = ctrl) [1] 12 > (tmp3 <- allPerms(Nobs, control = ctrl, observed = TRUE)) @@ -111,10 +112,31 @@ Complete enumeration of permutations Permutation Scheme: -NULL + +Permutation Design: + +Blocks: + Defined by: none + +Plots: + Plots: fac + Permutation type: none + Mirrored?: No + +Within Plots: + Permutation type: grid + Mirrored?: Yes + Different permutation within each Plot?: No + Grid dimensions: 3 rows 2 cols + +Permutation details: + Number of permutations requested: 199 + Max. number of permutations allowed: 9999 + Evaluate all permutations?: No. Activation limit: 99 + +All permutations: Contains observed ordering?: Yes -All permutations: [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 2 3 4 5 6 1 8 9 10 11 12 7 [2,] 3 4 5 6 1 2 9 10 11 12 7 8 @@ -133,10 +155,31 @@ Complete enumeration of permutations Permutation Scheme: -NULL + +Permutation Design: + +Blocks: + Defined by: none + +Plots: + Plots: fac + Permutation type: none + Mirrored?: No + +Within Plots: + Permutation type: grid + Mirrored?: Yes + Different permutation within each Plot?: No + Grid dimensions: 3 rows 2 cols + +Permutation details: + Number of permutations requested: 198 + Max. number of permutations allowed: 9999 + Evaluate all permutations?: No. Activation limit: 99 + +All permutations: Contains observed ordering?: No -All permutations: [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 2 3 4 5 6 1 8 9 10 11 12 7 [2,] 3 4 5 6 1 2 9 10 11 12 7 8 @@ -153,6 +196,292 @@ > > > cleanEx() +> nameEx("check") +> ### * check +> +> flush(stderr()); flush(stdout()) +> +> ### Name: check +> ### Title: Utility functions for permutation schemes +> ### Aliases: check print.check print.summary.check summary.check permuplot +> ### Keywords: utilities design methods +> +> ### ** Examples +> +> ## use example data from ?pyrifos in package vegan +> require(vegan) +Loading required package: vegan +Loading required package: lattice +This is vegan 2.1-33 +> example(pyrifos) + +pyrifs> data(pyrifos) + +pyrifs> ditch <- gl(12, 1, length=132) + +pyrifs> week <- gl(11, 12, labels=c(-4, -1, 0.1, 1, 2, 4, 8, 12, 15, 19, 24)) + +pyrifs> dose <- factor(rep(c(0.1, 0, 0, 0.9, 0, 44, 6, 0.1, 44, 0.9, 0, 6), 11)) +> +> ## Demonstrate the maximum number of permutations for the pyrifos data +> ## under a series of permutation schemes +> +> ## no restrictions - lots of perms +> CONTROL <- how(within = Within(type = "free")) +> (check1 <- check(pyrifos, CONTROL)) +[1] 1.118249e+224 +> ##summary(check1) +> +> ## no strata but data are series with no mirroring, so 132 permutations +> CONTROL <- how(within = Within(type = "series", mirror = FALSE)) +> check(pyrifos, CONTROL) +[1] 132 +> +> ## no strata but data are series with mirroring, so 264 permutations +> CONTROL <- how(within = Within(type = "series", mirror = TRUE)) +> check(pyrifos, control = CONTROL) +[1] 264 +> +> ## unrestricted within strata +> check(pyrifos, control = how(plots = Plots(strata = ditch), ++ within = Within(type = "free"))) +[1] 1.636321e+91 +> +> ## time series within strata, no mirroring +> check(pyrifos, ++ control = how(plots = Plots(strata = ditch), ++ within = Within(type = "series", mirror = FALSE))) +[1] 3.138428e+12 +> +> ## time series within strata, with mirroring +> check(pyrifos, ++ control = how(plots = Plots(strata = ditch), ++ within = Within(type = "series", mirror = TRUE))) +[1] 1.2855e+16 +> +> ## time series within strata, no mirroring, same permutation +> ## within strata +> check(pyrifos, ++ control = how(plots = Plots(strata = ditch), ++ within = Within(type = "series", constant = TRUE))) +[1] 11 +> +> ## time series within strata, with mirroring, same permutation +> ## within strata +> check(pyrifos, ++ control = how(plots = Plots(strata = ditch), ++ within = Within(type = "series", mirror = TRUE, ++ constant = TRUE))) +[1] 22 +> ## permute strata +> check(pyrifos, how(plots = Plots(strata = ditch, type = "free"), ++ within = Within(type = "none"))) +[1] 479001600 +> +> ## this should also also for arbitrary vectors +> vec1 <- check(1:100) +> vec2 <- check(1:100, how()) +> all.equal(vec1, vec2) +[1] TRUE +> vec3 <- check(1:100, how(within = Within(type = "series"))) +> all.equal(100, vec3$n) +[1] TRUE +> vec4 <- check(1:100, how(within = Within(type= "series", mirror = TRUE))) +> all.equal(vec4$n, 200) +[1] TRUE +> +> ## enumerate all possible permutations +> fac <- gl(2,6) +> ctrl <- how(plots = Plots(strata = fac), ++ within = Within(type = "grid", mirror = FALSE, ++ constant = TRUE, nrow = 3, ncol = 2)) +> check(1:12, ctrl) +[1] 6 +> +> numPerms(1:12, control = ctrl) +[1] 6 +> (tmp <- allPerms(12, control = ctrl, observed = TRUE)) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] +[1,] 2 3 4 5 6 1 8 9 10 11 12 7 +[2,] 3 4 5 6 1 2 9 10 11 12 7 8 +[3,] 4 5 6 1 2 3 10 11 12 7 8 9 +[4,] 5 6 1 2 3 4 11 12 7 8 9 10 +[5,] 6 1 2 3 4 5 12 7 8 9 10 11 +[6,] 1 2 3 4 5 6 7 8 9 10 11 12 +> (tmp2 <- allPerms(12, control = ctrl)) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] +[1,] 2 3 4 5 6 1 8 9 10 11 12 7 +[2,] 3 4 5 6 1 2 9 10 11 12 7 8 +[3,] 4 5 6 1 2 3 10 11 12 7 8 9 +[4,] 5 6 1 2 3 4 11 12 7 8 9 10 +[5,] 6 1 2 3 4 5 12 7 8 9 10 11 +> +> ## turn on mirroring %%FIXME needs a proper method to do this +> ##ctrl$within$mirror <- TRUE +> ctrl <- update(ctrl, within = update(getWithin(ctrl), mirror = TRUE)) +> numPerms(1:12, control = ctrl) +[1] 12 +> (tmp3 <- allPerms(12, control = ctrl, observed = TRUE)) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] + [1,] 2 3 4 5 6 1 8 9 10 11 12 7 + [2,] 3 4 5 6 1 2 9 10 11 12 7 8 + [3,] 4 5 6 1 2 3 10 11 12 7 8 9 + [4,] 5 6 1 2 3 4 11 12 7 8 9 10 + [5,] 6 1 2 3 4 5 12 7 8 9 10 11 + [6,] 1 2 3 4 5 6 7 8 9 10 11 12 + [7,] 1 6 5 4 3 2 7 12 11 10 9 8 + [8,] 2 1 6 5 4 3 8 7 12 11 10 9 + [9,] 3 2 1 6 5 4 9 8 7 12 11 10 +[10,] 4 3 2 1 6 5 10 9 8 7 12 11 +[11,] 5 4 3 2 1 6 11 10 9 8 7 12 +[12,] 6 5 4 3 2 1 12 11 10 9 8 7 +> (tmp4 <- allPerms(12, control = ctrl)) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] + [1,] 2 3 4 5 6 1 8 9 10 11 12 7 + [2,] 3 4 5 6 1 2 9 10 11 12 7 8 + [3,] 4 5 6 1 2 3 10 11 12 7 8 9 + [4,] 5 6 1 2 3 4 11 12 7 8 9 10 + [5,] 6 1 2 3 4 5 12 7 8 9 10 11 + [6,] 1 6 5 4 3 2 7 12 11 10 9 8 + [7,] 2 1 6 5 4 3 8 7 12 11 10 9 + [8,] 3 2 1 6 5 4 9 8 7 12 11 10 + [9,] 4 3 2 1 6 5 10 9 8 7 12 11 +[10,] 5 4 3 2 1 6 11 10 9 8 7 12 +[11,] 6 5 4 3 2 1 12 11 10 9 8 7 +> ## prints out details of the permutation scheme as +> ## well as the matrix of permutations +> summary(tmp) + + Complete enumeration of permutations + +Permutation Scheme: + +Permutation Design: + +Blocks: + Defined by: none + +Plots: + Plots: fac + Permutation type: none + Mirrored?: No + +Within Plots: + Permutation type: grid + Mirrored?: No + Different permutation within each Plot?: No + Grid dimensions: 3 rows 2 cols + +Permutation details: + Number of permutations requested: 199 + Max. number of permutations allowed: 9999 + Evaluate all permutations?: No. Activation limit: 99 + +All permutations: +Contains observed ordering?: Yes + + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] +[1,] 2 3 4 5 6 1 8 9 10 11 12 7 +[2,] 3 4 5 6 1 2 9 10 11 12 7 8 +[3,] 4 5 6 1 2 3 10 11 12 7 8 9 +[4,] 5 6 1 2 3 4 11 12 7 8 9 10 +[5,] 6 1 2 3 4 5 12 7 8 9 10 11 +[6,] 1 2 3 4 5 6 7 8 9 10 11 12 +> summary(tmp2) + + Complete enumeration of permutations + +Permutation Scheme: + +Permutation Design: + +Blocks: + Defined by: none + +Plots: + Plots: fac + Permutation type: none + Mirrored?: No + +Within Plots: + Permutation type: grid + Mirrored?: No + Different permutation within each Plot?: No + Grid dimensions: 3 rows 2 cols + +Permutation details: + Number of permutations requested: 198 + Max. number of permutations allowed: 9999 + Evaluate all permutations?: No. Activation limit: 99 + +All permutations: +Contains observed ordering?: No + + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] +[1,] 2 3 4 5 6 1 8 9 10 11 12 7 +[2,] 3 4 5 6 1 2 9 10 11 12 7 8 +[3,] 4 5 6 1 2 3 10 11 12 7 8 9 +[4,] 5 6 1 2 3 4 11 12 7 8 9 10 +[5,] 6 1 2 3 4 5 12 7 8 9 10 11 +> +> ## different numbers of observations per level of strata +> fac <- factor(rep(1:3, times = c(3,2,2))) +> ## free permutations in levels of strata +> numPerms(7, how(within = Within(type = "free"), ++ plots = Plots(strata = fac, type = "none"))) +[1] 24 +> allPerms(7, how(within = Within(type = "free"), ++ plots = Plots(strata = fac))) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] + [1,] 1 2 3 4 5 7 6 + [2,] 1 2 3 5 4 6 7 + [3,] 1 2 3 5 4 7 6 + [4,] 1 3 2 4 5 6 7 + [5,] 1 3 2 4 5 7 6 + [6,] 1 3 2 5 4 6 7 + [7,] 1 3 2 5 4 7 6 + [8,] 2 1 3 4 5 6 7 + [9,] 2 1 3 4 5 7 6 +[10,] 2 1 3 5 4 6 7 +[11,] 2 1 3 5 4 7 6 +[12,] 2 3 1 4 5 6 7 +[13,] 2 3 1 4 5 7 6 +[14,] 2 3 1 5 4 6 7 +[15,] 2 3 1 5 4 7 6 +[16,] 3 1 2 4 5 6 7 +[17,] 3 1 2 4 5 7 6 +[18,] 3 1 2 5 4 6 7 +[19,] 3 1 2 5 4 7 6 +[20,] 3 2 1 4 5 6 7 +[21,] 3 2 1 4 5 7 6 +[22,] 3 2 1 5 4 6 7 +[23,] 3 2 1 5 4 7 6 +> ## series permutations in levels of strata +> ctrl <- how(within = Within(type = "series"), plots = Plots(strata = fac)) +> numPerms(7, control = ctrl) +[1] 12 +> allPerms(7, control = ctrl) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] + [1,] 2 3 1 5 4 7 6 + [2,] 2 3 1 5 4 6 7 + [3,] 2 3 1 4 5 7 6 + [4,] 2 3 1 4 5 6 7 + [5,] 3 1 2 5 4 7 6 + [6,] 3 1 2 5 4 6 7 + [7,] 3 1 2 4 5 7 6 + [8,] 3 1 2 4 5 6 7 + [9,] 1 2 3 5 4 7 6 +[10,] 1 2 3 5 4 6 7 +[11,] 1 2 3 4 5 7 6 +> +> +> +> +> +> cleanEx() + +detaching ?package:vegan?, ?package:lattice? + > nameEx("get-methods") > ### * get-methods > @@ -172,7 +501,8 @@ > ### getCol.permControl getDim getDim.default getDim.how > ### getDim.permControl getNperm getNperm.default getNperm.how > ### getNperm.permControl getMaxperm getMaxperm.default getMaxperm.how -> ### getMaxperm.permControl getComplete getComplete.default +> ### getMaxperm.permControl getMinperm getMinperm.default getMinperm.how +> ### getMinperm.permControl getComplete getComplete.default > ### getComplete.how getComplete.permControl > ### Keywords: methods utils > @@ -184,6 +514,73 @@ > > > cleanEx() +> nameEx("how") +> ### * how +> +> flush(stderr()); flush(stdout()) +> +> ### Name: how +> ### Title: How to define a permutation design? +> ### Aliases: how print.how Blocks Within Plots +> ### Keywords: utils +> +> ### ** Examples +> +> plts <- gl(4,10) +> blks <- gl(2,20) +> h1 <- how(within = Within(type = "series", mirror = TRUE), ++ plots = Plots(strata = plts, type = "series"), ++ blocks = blks) +> +> ## The design can be updated... +> ## ... remove the blocking: +> update(h1, blocks = NULL) + +Permutation Design: + +Blocks: + Defined by: none + +Plots: + Plots: plts + Permutation type: series + Mirrored?: No + +Within Plots: + Permutation type: series + Mirrored?: Yes + Different permutation within each Plot?: Yes + +Permutation details: + Number of permutations requested: 199 + Max. number of permutations allowed: 9999 + Evaluate all permutations?: No. Activation limit: 99 +> ## ... or switch the type of shuffling at a level: +> update(h1, plots = update(getPlots(h1), type = "none")) + +Permutation Design: + +Blocks: + Blocks: blks + +Plots: + Plots: plts + Permutation type: none + Mirrored?: No + +Within Plots: + Permutation type: series + Mirrored?: Yes + Different permutation within each Plot?: Yes + +Permutation details: + Number of permutations requested: 199 + Max. number of permutations allowed: 9999 + Evaluate all permutations?: No. Activation limit: 99 +> +> +> +> cleanEx() > nameEx("jackal") > ### * jackal > @@ -291,188 +688,6 @@ > > > cleanEx() -> nameEx("permCheck") -> ### * permCheck -> -> flush(stderr()); flush(stdout()) -> -> ### Name: check -> ### Title: Utility functions for permutation schemes -> ### Aliases: check permCheck print.check print.summary.check summary.check -> ### permuplot -> ### Keywords: utilities design methods -> -> ### ** Examples -> -> -> ## Not run: -> ##D ##D -> ##D ## use example data from ?pyrifos in package vegan -> ##D require(vegan) -> ##D example(pyrifos) -> ##D -> ##D ## Demonstrate the maximum number of permutations for the pyrifos data -> ##D ## under a series of permutation schemes -> ##D -> ##D ## no restrictions - lots of perms -> ##D CONTROL <- how(within = Within(type = "free")) -> ##D (check1 <- check(pyrifos, CONTROL)) -> ##D ##summary(check1) -> ##D -> ##D ## no strata but data are series with no mirroring, so 132 permutations -> ##D CONTROL <- how(within = Within(type = "series", -> ##D mirror = FALSE)) -> ##D check(pyrifos, CONTROL) -> ##D -> ##D ## no strata but data are series with mirroring, so 264 permutations -> ##D CONTROL <- how(within = Within(type = "series", -> ##D mirror = TRUE)) -> ##D check(pyrifos, control = CONTROL) -> ##D -> ##D ## unrestricted within strata -> ##D check(pyrifos, control = how(strata = ditch, -> ##D within = Within(type = "free"))) -> ##D -> ##D ## time series within strata, no mirroring -> ##D check(pyrifos, control = how(strata = ditch, -> ##D within = Within(type = "series", -> ##D mirror = FALSE))) -> ##D -> ##D ## time series within strata, with mirroring -> ##D check(pyrifos, control = how(strata = ditch, -> ##D within = Within(type = "series", -> ##D mirror = TRUE))) -> ##D -> ##D ## time series within strata, no mirroring, same permutation -> ##D ## within strata -> ##D check(pyrifos, control = how(strata = ditch, -> ##D within = Within(type = "series", -> ##D constant = TRUE))) -> ##D -> ##D ## time series within strata, with mirroring, same permutation -> ##D ## within strata -> ##D check(pyrifos, control = how(strata = ditch, -> ##D within = Within(type = "series", -> ##D mirror = TRUE, -> ##D constant = TRUE))) -> ##D -> ##D ## permute strata -> ##D check(pyrifos, how(strata = ditch, -> ##D within = Within(type = "none"), -> ##D blocks = Blocks(type = "free"))) -> ## End(Not run) -> -> ## Not run: -> ##D ##D -> ##D ## this should also also for arbitrary vectors -> ##D vec1 <- check(1:100) -> ##D vec2 <- check(1:100, how()) -> ##D all.equal(vec1, vec2) -> ##D vec3 <- check(1:100, how(within = Within(type = "series"))) -> ##D all.equal(100, vec3$n) -> ##D vec4 <- check(1:100, how(within = -> ##D Within(type= "series", -> ##D mirror = TRUE))) -> ##D all.equal(vec4$n, 200) -> ##D -> ##D ## enumerate all possible permutations -> ##D fac <- gl(2,6) -> ##D ctrl <- how(strata = fac, -> ##D within = Within(type = "grid", mirror = FALSE, -> ##D constant = TRUE, nrow = 3, -> ##D ncol = 2)) -> ##D check(1:12, ctrl) -> ##D -> ##D numPerms(1:12, control = ctrl) -> ##D (tmp <- allPerms(12, control = ctrl, observed = TRUE)) -> ##D (tmp2 <- allPerms(12, control = ctrl)) -> ##D -> ##D ## turn on mirroring ##D -> ##D ctrl$within$mirror <- TRUE -> ##D numPerms(1:12, control = ctrl) -> ##D (tmp3 <- allPerms(12, control = ctrl, observed = TRUE)) -> ##D (tmp4 <- allPerms(12, control = ctrl)) -> ##D ## prints out details of the permutation scheme as -> ##D ## well as the matrix of permutations -> ##D ##summary(tmp) ##D -> ##D ##summary(tmp2) -> ## End(Not run) -> -> ## Not run: -> ##D ## different numbers of observations per level of strata -> ##D fac <- factor(rep(1:3, times = c(3,2,2))) -> ##D ## free permutations in levels of strata -> ##D numPerms(7, how(type = "free", strata = fac)) -> ##D allPerms(7, how(type = "free", strata = fac)) -> ##D ## series permutations in levels of strata -> ##D numPerms(7, how(type = "series", strata = fac)) -> ##D allPerms(7, how(type = "series", strata = fac)) -> ##D -> ##D ## allPerms can work with a vector -> ##D vec <- c(3,4,5) -> ##D allPerms(vec) -> ##D -> ##D ## Tests for permuplot -> ##D n <- 25 -> ##D ## standard permutation designs -> ##D permuplot(n, how(type = "free")) -> ##D permuplot(n, how(type = "series")) -> ##D permuplot(n, how(type = "grid", nrow = 5, ncol = 5)) -> ##D -> ##D ## restricted perms with mirroring -> ##D permuplot(n, how(type = "series", mirror = TRUE)) -> ##D permuplot(n, how(type = "grid", nrow = 5, ncol = 5, -> ##D mirror = TRUE)) -> ##D -> ##D ## perms within strata -> ##D fac <- gl(6, 20) -> ##D control <- how(type = "free", strata = fac) -> ##D permuplot(120, control = control, cex = 0.8) -> ##D control <- how(type = "series", strata = fac) -> ##D permuplot(120, control = control, cex = 0.8) -> ##D fac <- gl(6, 25) -> ##D control <- how(type = "grid", strata = fac, -> ##D nrow = 5, ncol = 5) -> ##D permuplot(150, control = control, cex = 0.8) -> ##D -> ##D ## perms within strata with mirroring -> ##D fac <- gl(6, 20) -> ##D control <- how(type = "series", strata = fac, -> ##D mirror = TRUE) -> ##D permuplot(120, control = control, cex = 0.8) -> ##D fac <- gl(6, 25) -> ##D control <- how(type = "grid", strata = fac, -> ##D nrow = 5, ncol = 5, mirror = TRUE) -> ##D permuplot(150, control = control, cex = 0.8) -> ##D -> ##D ## same perms within strata -> ##D fac <- gl(6, 20) -> ##D control <- how(type = "free", strata = fac, -> ##D constant = TRUE) -> ##D permuplot(120, control = control, cex = 0.8) -> ##D control <- how(type = "series", strata = fac, -> ##D constant = TRUE) -> ##D permuplot(120, control = control, cex = 0.8) -> ##D fac <- gl(6, 25) -> ##D control <- how(type = "grid", strata = fac, -> ##D nrow = 5, ncol = 5, constant = TRUE) -> ##D permuplot(150, control = control, cex = 0.8) -> ##D -> ##D ## same perms within strata with mirroring -> ##D fac <- gl(6, 20) -> ##D control <- how(type = "series", strata = fac, -> ##D mirror = TRUE, constant = TRUE) -> ##D permuplot(120, control = control, cex = 0.8) -> ##D fac <- gl(6, 25) -> ##D control <- how(type = "grid", strata = fac, -> ##D nrow = 5, ncol = 5, mirror = TRUE, -> ##D constant = TRUE) -> ##D permuplot(150, control = control, cex = 0.8) -> ## End(Not run) -> -> -> -> cleanEx() > nameEx("shuffle-utils") > ### * shuffle-utils > @@ -563,22 +778,22 @@ > plots <- Plots(strata = gl(4, 5)) > CTRL <- how(plots = plots, within = Within(type = "free")) > shuffle(20, CTRL) - [1] 8 10 6 7 9 3 5 2 1 4 19 16 20 17 18 13 12 11 14 15 + [1] 5 3 4 2 1 8 7 6 9 10 14 11 15 12 13 18 20 16 17 19 > ## as above but same random permutation within strata > CTRL <- how(plots = plots, within = Within(type = "free", + constant = TRUE)) > shuffle(20, CTRL) - [1] 8 7 10 6 9 13 12 15 11 14 18 17 20 16 19 3 2 5 1 4 + [1] 3 5 2 1 4 8 10 7 6 9 13 15 12 11 14 18 20 17 16 19 > > ## time series within each level of block > CTRL <- how(plots = plots, within = Within(type = "series")) > shuffle(20, CTRL) - [1] 5 1 2 3 4 17 18 19 20 16 14 15 11 12 13 8 9 10 6 7 + [1] 2 3 4 5 1 8 9 10 6 7 15 11 12 13 14 19 20 16 17 18 > ## as above, but with same permutation for each level > CTRL <- how(plots = plots, within = Within(type = "series", + constant = TRUE)) > shuffle(20, CTRL) - [1] 2 3 4 5 1 12 13 14 15 11 17 18 19 20 16 7 8 9 10 6 + [1] 2 3 4 5 1 7 8 9 10 6 12 13 14 15 11 17 18 19 20 16 > > ## spatial grids within each level of block, 4 x (5r x 5c) > nr <- 5 @@ -588,23 +803,23 @@ > CTRL <- how(plots = plots, + within = Within(type = "grid", ncol = nc, nrow = nr)) > shuffle(100, CTRL) - [1] 9 10 6 7 8 14 15 11 12 13 19 20 16 17 18 24 25 21 - [19] 22 23 4 5 1 2 3 83 84 85 81 82 88 89 90 86 87 93 - [37] 94 95 91 92 98 99 100 96 97 78 79 80 76 77 34 35 31 32 - [55] 33 39 40 36 37 38 44 45 41 42 43 49 50 46 47 48 29 30 - [73] 26 27 28 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 - [91] 51 52 53 54 55 56 57 58 59 60 + [1] 24 25 21 22 23 4 5 1 2 3 9 10 6 7 8 14 15 11 + [19] 12 13 19 20 16 17 18 27 28 29 30 26 32 33 34 35 31 37 + [37] 38 39 40 36 42 43 44 45 41 47 48 49 50 46 56 57 58 59 + [55] 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 51 52 + [73] 53 54 55 83 84 85 81 82 88 89 90 86 87 93 94 95 91 92 + [91] 98 99 100 96 97 78 79 80 76 77 > ## as above, but with same permutation for each level > CTRL <- how(plots = plots, + within = Within(type = "grid", ncol = nc, nrow = nr, + constant = TRUE)) > shuffle(100, CTRL) - [1] 17 18 19 20 16 22 23 24 25 21 2 3 4 5 1 7 8 9 - [19] 10 6 12 13 14 15 11 67 68 69 70 66 72 73 74 75 71 52 - [37] 53 54 55 51 57 58 59 60 56 62 63 64 65 61 92 93 94 95 - [55] 91 97 98 99 100 96 77 78 79 80 76 82 83 84 85 81 87 88 - [73] 89 90 86 42 43 44 45 41 47 48 49 50 46 27 28 29 30 26 - [91] 32 33 34 35 31 37 38 39 40 36 + [1] 23 24 25 21 22 3 4 5 1 2 8 9 10 6 7 13 14 15 + [19] 11 12 18 19 20 16 17 48 49 50 46 47 28 29 30 26 27 33 + [37] 34 35 31 32 38 39 40 36 37 43 44 45 41 42 73 74 75 71 + [55] 72 53 54 55 51 52 58 59 60 56 57 63 64 65 61 62 68 69 + [73] 70 66 67 98 99 100 96 97 78 79 80 76 77 83 84 85 81 82 + [91] 88 89 90 86 87 93 94 95 91 92 > > ## permuting levels of plots instead of observations > CTRL <- how(plots = Plots(gl(4, 5), type = "free"), @@ -623,13 +838,13 @@ > CTRL <- how(plots = Plots(gl(4, 5), type = "series"), + within = Within(type = "free")) > shuffle(20, CTRL) - [1] 15 11 14 12 13 17 16 18 20 19 5 4 2 1 3 6 7 10 9 8 + [1] 2 1 3 4 5 6 10 9 7 8 11 12 13 14 15 16 18 20 17 19 > > ## permuting within blocks > grp <- gl(2, 10) # 2 groups of 10 samples each > CTRL <- how(blocks = grp) > shuffle(length(grp), control = CTRL) - [1] 6 5 3 7 4 1 2 8 9 10 16 20 17 14 19 12 15 18 13 11 + [1] 1 3 6 10 4 2 7 8 9 5 12 14 11 15 18 17 16 19 20 13 > > ## Simple function using permute() to assess significance > ## of a t.test @@ -720,48 +935,48 @@ > ### ** Examples > > ## simple random permutations, 5 permutations in set -> shuffleSet(n = 10, nset = 10) - [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] - [1,] 3 4 5 7 2 8 9 6 10 1 - [2,] 3 2 6 10 5 7 8 4 1 9 - [3,] 10 2 6 1 9 8 7 5 3 4 - [4,] 5 6 4 2 10 8 9 1 7 3 - [5,] 9 6 7 4 8 10 1 2 3 5 - [6,] 5 8 4 2 1 6 7 9 3 10 - [7,] 10 3 4 9 8 2 5 7 1 6 - [8,] 4 8 3 9 7 5 10 2 6 1 - [9,] 5 7 4 3 10 2 9 1 8 6 -[10,] 3 1 6 7 5 4 2 8 10 9 +> shuffleSet(n = 10, nset = 5) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] +[1,] 3 4 5 7 2 8 9 6 10 1 +[2,] 3 2 6 10 5 7 8 4 1 9 +[3,] 10 2 6 1 9 8 7 5 3 4 +[4,] 5 6 4 2 10 8 9 1 7 3 +[5,] 9 6 7 4 8 10 1 2 3 5 > -> ## series random permutations, 10 permutations in set -> shuffleSet(10, 10, how(within = Within(type = "series"))) - [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] - [1,] 8 9 10 1 2 3 4 5 6 7 - [2,] 5 6 7 8 9 10 1 2 3 4 - [3,] 4 5 6 7 8 9 10 1 2 3 - [4,] 1 2 3 4 5 6 7 8 9 10 - [5,] 8 9 10 1 2 3 4 5 6 7 - [6,] 4 5 6 7 8 9 10 1 2 3 - [7,] 3 4 5 6 7 8 9 10 1 2 - [8,] 6 7 8 9 10 1 2 3 4 5 - [9,] 1 2 3 4 5 6 7 8 9 10 -[10,] 7 8 9 10 1 2 3 4 5 6 +> ## series random permutations, 5 permutations in set +> shuffleSet(10, 5, how(within = Within(type = "series")), ++ check = FALSE) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] +[1,] 6 7 8 9 10 1 2 3 4 5 +[2,] 10 1 2 3 4 5 6 7 8 9 +[3,] 6 7 8 9 10 1 2 3 4 5 +[4,] 4 5 6 7 8 9 10 1 2 3 +[5,] 2 3 4 5 6 7 8 9 10 1 > > ## series random permutations, 10 permutations in set, > ## with possible mirroring > CTRL <- how(within = Within(type = "series", mirror = TRUE)) > shuffleSet(10, 10, CTRL) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] - [1,] 1 2 3 4 5 6 7 8 9 10 - [2,] 4 3 2 1 10 9 8 7 6 5 - [3,] 2 1 10 9 8 7 6 5 4 3 - [4,] 8 7 6 5 4 3 2 1 10 9 + [1,] 2 3 4 5 6 7 8 9 10 1 + [2,] 3 4 5 6 7 8 9 10 1 2 + [3,] 4 5 6 7 8 9 10 1 2 3 + [4,] 5 6 7 8 9 10 1 2 3 4 [5,] 6 7 8 9 10 1 2 3 4 5 - [6,] 10 9 8 7 6 5 4 3 2 1 - [7,] 5 4 3 2 1 10 9 8 7 6 - [8,] 8 7 6 5 4 3 2 1 10 9 - [9,] 6 5 4 3 2 1 10 9 8 7 -[10,] 4 5 6 7 8 9 10 1 2 3 + [6,] 7 8 9 10 1 2 3 4 5 6 + [7,] 8 9 10 1 2 3 4 5 6 7 + [8,] 9 10 1 2 3 4 5 6 7 8 + [9,] 10 1 2 3 4 5 6 7 8 9 +[10,] 1 10 9 8 7 6 5 4 3 2 +[11,] 2 1 10 9 8 7 6 5 4 3 +[12,] 3 2 1 10 9 8 7 6 5 4 +[13,] 4 3 2 1 10 9 8 7 6 5 +[14,] 5 4 3 2 1 10 9 8 7 6 +[15,] 6 5 4 3 2 1 10 9 8 7 +[16,] 7 6 5 4 3 2 1 10 9 8 +[17,] 8 7 6 5 4 3 2 1 10 9 +[18,] 9 8 7 6 5 4 3 2 1 10 +[19,] 10 9 8 7 6 5 4 3 2 1 > > ## Permuting strata > ## 4 groups of 5 observations @@ -769,27 +984,53 @@ + plots = Plots(strata = gl(4,5), type = "free")) > shuffleSet(20, 10, control = CTRL) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] - [1,] 11 12 13 14 15 1 2 3 4 5 16 17 18 - [2,] 16 17 18 19 20 6 7 8 9 10 11 12 13 - [3,] 16 17 18 19 20 6 7 8 9 10 11 12 13 + [1,] 1 2 3 4 5 6 7 8 9 10 16 17 18 + [2,] 1 2 3 4 5 11 12 13 14 15 6 7 8 + [3,] 1 2 3 4 5 11 12 13 14 15 16 17 18 [4,] 1 2 3 4 5 16 17 18 19 20 6 7 8 - [5,] 1 2 3 4 5 11 12 13 14 15 16 17 18 - [6,] 11 12 13 14 15 6 7 8 9 10 1 2 3 - [7,] 11 12 13 14 15 1 2 3 4 5 6 7 8 - [8,] 6 7 8 9 10 1 2 3 4 5 11 12 13 + [5,] 1 2 3 4 5 16 17 18 19 20 11 12 13 + [6,] 6 7 8 9 10 1 2 3 4 5 11 12 13 + [7,] 6 7 8 9 10 1 2 3 4 5 16 17 18 + [8,] 6 7 8 9 10 11 12 13 14 15 1 2 3 [9,] 6 7 8 9 10 11 12 13 14 15 16 17 18 -[10,] 1 2 3 4 5 6 7 8 9 10 11 12 13 +[10,] 6 7 8 9 10 16 17 18 19 20 1 2 3 +[11,] 6 7 8 9 10 16 17 18 19 20 11 12 13 +[12,] 11 12 13 14 15 1 2 3 4 5 6 7 8 +[13,] 11 12 13 14 15 1 2 3 4 5 16 17 18 +[14,] 11 12 13 14 15 6 7 8 9 10 1 2 3 +[15,] 11 12 13 14 15 6 7 8 9 10 16 17 18 +[16,] 11 12 13 14 15 16 17 18 19 20 1 2 3 +[17,] 11 12 13 14 15 16 17 18 19 20 6 7 8 +[18,] 16 17 18 19 20 1 2 3 4 5 6 7 8 +[19,] 16 17 18 19 20 1 2 3 4 5 11 12 13 +[20,] 16 17 18 19 20 6 7 8 9 10 1 2 3 +[21,] 16 17 18 19 20 6 7 8 9 10 11 12 13 [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/vegan -r 2672 From noreply at r-forge.r-project.org Fri Nov 8 04:01:46 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 8 Nov 2013 04:01:46 +0100 (CET) Subject: [Vegan-commits] r2673 - in pkg/permute: . man Message-ID: <20131108030148.375A9186486@r-forge.r-project.org> Author: gsimpson Date: 2013-11-08 04:01:42 +0100 (Fri, 08 Nov 2013) New Revision: 2673 Modified: pkg/permute/NAMESPACE pkg/permute/man/check.Rd Log: don't export and un-document permuplot Modified: pkg/permute/NAMESPACE =================================================================== --- pkg/permute/NAMESPACE 2013-11-07 22:56:34 UTC (rev 2672) +++ pkg/permute/NAMESPACE 2013-11-08 03:01:42 UTC (rev 2673) @@ -5,7 +5,7 @@ `getBlocks`, `getWithin`, `getStrata`, `getType`, `getMirror`, `getConstant`, `getPlots`, `getRow`, `getCol`, `getDim`, `getNperm`,`getMaxperm`, `getMinperm`, `getComplete`, `shuffleSet`, - `permuplot`,`how`) + `how`) ### Imports: nobs() only exists in R 2.13.0 for import. We define the ### same nobs() generic in permute for export in older R. Modified: pkg/permute/man/check.Rd =================================================================== --- pkg/permute/man/check.Rd 2013-11-07 22:56:34 UTC (rev 2672) +++ pkg/permute/man/check.Rd 2013-11-08 03:01:42 UTC (rev 2673) @@ -3,7 +3,6 @@ \alias{print.check} \alias{print.summary.check} \alias{summary.check} -\alias{permuplot} \title{Utility functions for permutation schemes} \description{ @@ -15,44 +14,24 @@ check(object, control = how(), make.all = TRUE, observed = FALSE) \method{summary}{check}(object, \dots) - -permuplot(n, control = how(), col = par("col"), - hcol = "red", shade = "lightgrey", xlim = NULL, ylim = NULL, - inset = 0.1, main = NULL, sub = NULL, ann = par("ann"), - cex = par("cex"), \dots) } \arguments{ - \item{object}{an R object. See Details for a - complete description, especially for \code{numPerms}. For - \code{\link{summary.check}} an object of class - \code{"check"}.} + \item{object}{an R object. See Details for a complete description, + especially for \code{\link{numPerms}}. For + \code{\link{summary.check}} an object of class \code{"check"}.} \item{control}{a list of control values describing properties of the - permutation design, as returned by a call to - \code{\link{how}}.} - \item{make.all}{logical; should \code{permCheck} generate all + permutation design, as returned by a call to \code{\link{how}}.} + \item{make.all}{logical; should \code{check} generate all possible permutations? Useful if want to check permutation design but not produce the matrix of all permutations.} \item{observed}{logical; if making all possible permutations, should the set include the observed permutation too?} - \item{n}{the number of observations or an 'object' from which the - number of observations can be determined via \code{getNumObs}.} - \item{col, xlim, ylim, main, sub, ann, cex}{Graphical parameters.} - \item{hcol}{Colour to use for highlighting observations and the border - colour of the polygons drawn when \code{type = "strata"}.} - \item{shade}{The polygon shading colour (passed to argument \code{col} - of function \code{\link{polygon}}) when \code{type = "strata"}.} - \item{inset}{Proportion of range of x and y coordinates to add to the - plot x and y limits. Used to create a bit of extra space around the - margin of each plot.} - \item{\dots}{arguments to other methods. For \code{permuplot} - graphical parameters can be passed to plotting functions, though - note that not all parameters will be accepted gracefully at the - moment.} + \item{\dots}{arguments to other methods.} } \details{ - \code{check} and \code{permuplot} are utility functions for working - with the new permutation schemes available in \code{\link{shuffle}}. + \code{check} is a utility functions for working with the new + permutation schemes available in \code{\link{shuffle}}. \code{check} is used to check the current permutation schemes against the object to which it will be applied. It calculates the @@ -62,7 +41,7 @@ an object of class \code{"how"} suitably modified if \code{check} identifies a problem. - The main problem is requesting more permutations than possible with + The main problem is requesting more permutations than is possible with the number of observations and the permutation design. In such cases, \code{nperm} is reduced to equal the number of possible permutations, and complete enumeration of all permutations is turned on @@ -72,23 +51,6 @@ than \code{control$minperm}, it is better to enumerate all possible permutations, and as such complete enumeration of all permutations is turned on (\code{control$complete} is set to \code{TRUE}). - - \code{permuplot} is a graphical utility function, which produces a - graphical representation of a permutation design. It takes the number - of observations and an object returned by \code{\link{how}} as - arguments and produces a plot on the currently active device. If - strata are present in the design, the plotting region is split into - sufficient plotting regions (one for each stratum), and the design in - each stratum plotted. - - Free permutation designs are represented by plotting the observation - number at random x and y coordinates. Series designs (time series or - line transects) are represented by plotting the observation numbers - comprising the series in a circle and the start of the permuted series - is highlighted using colour \code{hcol}. Grid designs are drawn on a - regular grid and the top left observation in the original grid is - highlighted using colour \code{hcol}. Note the ordering used is R's - standard ordering for matrices - columns are filled first. } \value{ For \code{check} a list containing the maximum number of @@ -168,15 +130,14 @@ (tmp <- allPerms(12, control = ctrl, observed = TRUE)) (tmp2 <- allPerms(12, control = ctrl)) -## turn on mirroring %%FIXME needs a proper method to do this -##ctrl$within$mirror <- TRUE +## turn on mirroring ctrl <- update(ctrl, within = update(getWithin(ctrl), mirror = TRUE)) numPerms(1:12, control = ctrl) (tmp3 <- allPerms(12, control = ctrl, observed = TRUE)) (tmp4 <- allPerms(12, control = ctrl)) ## prints out details of the permutation scheme as ## well as the matrix of permutations -summary(tmp) %% FIXME these don't print the scheme +summary(tmp) summary(tmp2) ## different numbers of observations per level of strata @@ -190,11 +151,6 @@ ctrl <- how(within = Within(type = "series"), plots = Plots(strata = fac)) numPerms(7, control = ctrl) allPerms(7, control = ctrl) - -%% FIXME - need all these updating to new API in how... -%% moved permuplot examples out of package until I can fix it -%% properly - } \keyword{ utilities } \keyword{ design } From noreply at r-forge.r-project.org Fri Nov 8 04:03:00 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 8 Nov 2013 04:03:00 +0100 (CET) Subject: [Vegan-commits] r2674 - pkg/permute/inst Message-ID: <20131108030300.982EC186486@r-forge.r-project.org> Author: gsimpson Date: 2013-11-08 04:02:56 +0100 (Fri, 08 Nov 2013) New Revision: 2674 Modified: pkg/permute/inst/ChangeLog Log: document r2673 Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-08 03:01:42 UTC (rev 2673) +++ pkg/permute/inst/ChangeLog 2013-11-08 03:02:56 UTC (rev 2674) @@ -41,10 +41,13 @@ * Documentation fixes in examples of `allPerms` and `check`. - * permuplot: This is horribly broken and I'm not sure if it will ever - return. In the meantime, this function now prints a warning message if - used and returns nothing, invisibly. + * permuplot: This is horribly broken and I'm not sure if it will + ever return. In the meantime, this function now prints a warning + message if used and returns nothing, invisibly. + The function is no longer exported from the package namespace, and + not documented. + I'm not convinced that the plot can adequately convery the breadth of designs now possible. Hence I am minded to deprecate this in 0.8-0 when released to CRAN and to make it defunct some thereafter. From noreply at r-forge.r-project.org Fri Nov 8 04:06:26 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 8 Nov 2013 04:06:26 +0100 (CET) Subject: [Vegan-commits] r2675 - pkg/permute/R Message-ID: <20131108030626.482C3186042@r-forge.r-project.org> Author: gsimpson Date: 2013-11-08 04:06:24 +0100 (Fri, 08 Nov 2013) New Revision: 2675 Modified: pkg/permute/R/permute.R Log: remove explicit call of return() Modified: pkg/permute/R/permute.R =================================================================== --- pkg/permute/R/permute.R 2013-11-08 03:02:56 UTC (rev 2674) +++ pkg/permute/R/permute.R 2013-11-08 03:06:24 UTC (rev 2675) @@ -6,5 +6,5 @@ warning("'$all.perms' is NULL, yet '$complete = TRUE'.\nReturning a random permutation.") perm <- shuffle(n, control) } - return(perm) + perm } From noreply at r-forge.r-project.org Fri Nov 8 04:10:12 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 8 Nov 2013 04:10:12 +0100 (CET) Subject: [Vegan-commits] r2676 - pkg/permute/man Message-ID: <20131108031012.D4F7C186506@r-forge.r-project.org> Author: gsimpson Date: 2013-11-08 04:10:12 +0100 (Fri, 08 Nov 2013) New Revision: 2676 Modified: pkg/permute/man/allPerms.Rd pkg/permute/man/get-methods.Rd pkg/permute/man/how.Rd pkg/permute/man/numPerms.Rd pkg/permute/man/shuffle.Rd Log: minor documentation updates, tweaks, edit, corrections Modified: pkg/permute/man/allPerms.Rd =================================================================== --- pkg/permute/man/allPerms.Rd 2013-11-08 03:06:24 UTC (rev 2675) +++ pkg/permute/man/allPerms.Rd 2013-11-08 03:10:12 UTC (rev 2676) @@ -75,9 +75,8 @@ ## design fac <- gl(2,6) ctrl <- how(within = Within(type = "grid", mirror = FALSE, - constant = TRUE, - nrow = 3, ncol = 2), - plots = Plots(strata = fac)) + constant = TRUE, nrow = 3, ncol = 2), + plots = Plots(strata = fac)) Nobs <- length(fac) numPerms(seq_len(Nobs), control = ctrl) ## 6 (tmp <- allPerms(Nobs, control = ctrl, observed = TRUE)) Modified: pkg/permute/man/get-methods.Rd =================================================================== --- pkg/permute/man/get-methods.Rd 2013-11-08 03:06:24 UTC (rev 2675) +++ pkg/permute/man/get-methods.Rd 2013-11-08 03:10:12 UTC (rev 2676) @@ -91,7 +91,7 @@ \method{getBlocks}{how}(object, ...) \method{getStrata}{how}(object, which = c("plots", "blocks"), - drop = TRUE, ...) + drop = TRUE, ...) \method{getType}{how}(object, which = c("plots", "within"), ...) @@ -123,10 +123,14 @@ \item{\dots}{Arguments passed on to other methods.} } \details{ - TODO + These are extractor functions for working with permutation design + objects created by \code{\link{how}}. They should be used in + preference to directly subsetting the permutation design in case the + internal structure of object changes as \pkg{permute} is developed. } \value{ - TODO + These are simple extractor functions and return the contents of the + corresponding components of \code{object}. } \author{Gavin Simpson} \seealso{\code{\link{check}}, a utility function for checking @@ -134,8 +138,10 @@ } \examples{ -set.seed(1234) - +## extract components from a "how" object +hh <- how() +getWithin(hh) +getNperm(hh) } \keyword{ methods } \keyword{ utils } \ No newline at end of file Modified: pkg/permute/man/how.Rd =================================================================== --- pkg/permute/man/how.Rd 2013-11-08 03:06:24 UTC (rev 2675) +++ pkg/permute/man/how.Rd 2013-11-08 03:10:12 UTC (rev 2676) @@ -34,16 +34,17 @@ \code{plots} each require a named list as produced by \code{Within} and \code{Plots} respectively. \code{blocks} takes a factor, the levels of which define the blocking structure.} - \item{nperm}{the number of permutations.} + \item{nperm}{numeric; the number of permutations.} \item{complete}{logical; should complete enumeration of all permutations be performed?} - \item{type}{the type of permutations required. One of \code{"free"}, - \code{"series"}, \code{"grid"} or \code{"none"}. See Details.} - \item{maxperm}{the maximum number of permutations to - perform. Currently unused.} - \item{minperm}{the lower limit to the number of possible permutations - at which complete enumeration is performed. See argument - \code{complete} and Details, below.} + \item{type}{character; the type of permutations required. One of + \code{"free"}, \code{"series"}, \code{"grid"} or \code{"none"}. See + Details.} + \item{maxperm}{numeric; the maximum number of permutations to + perform. Currently unused.} + \item{minperm}{numeric; the lower limit to the number of possible + permutations at which complete enumeration is performed. See argument + \code{complete} and Details, below.} \item{all.perms}{an object of class \code{allPerms}, the result of a call to \code{\link{allPerms}}.} \item{observed}{logical; should the observed permutation be returned @@ -69,8 +70,7 @@ experimental design, mirrored permutations can be considered part of the Null model, and as such increase the number of possible permutations. The default is to not use mirroring so you must - explicitly turn this on using \code{mirror = TRUE} in - \code{how}. + explicitly turn this on using \code{mirror = TRUE} in \code{how}. To permute plots rather than the observations within plots (the levels of \code{strata}), use \code{Within(type = "none")} and @@ -98,12 +98,15 @@ 3.1}. Wageningen: Agricultural Mathematics Group. (UR). } \author{Gavin Simpson} -\seealso{\code{\link{shuffle}} for permuting from a design, - \code{\link{check}}, a utility function for checking permutation - design described by \code{how}.} +\seealso{\code{\link{shuffle}} and \code{\link{shuffleSet}} for + permuting from a design, and \code{\link{check}}, a utility function + for checking permutation design described by \code{how}.} \examples{ -plts <- gl(4,10) -blks <- gl(2,20) +## Set up factors for the Plots and Blocks +plts <- gl(4, 10) ## 4 Plots of 10 samples each +blks <- gl(2, 20) ## 2 Blocks of 20 samples each + +## permutation design h1 <- how(within = Within(type = "series", mirror = TRUE), plots = Plots(strata = plts, type = "series"), blocks = blks) @@ -111,6 +114,7 @@ ## The design can be updated... ## ... remove the blocking: update(h1, blocks = NULL) + ## ... or switch the type of shuffling at a level: update(h1, plots = update(getPlots(h1), type = "none")) } Modified: pkg/permute/man/numPerms.Rd =================================================================== --- pkg/permute/man/numPerms.Rd 2013-11-08 03:06:24 UTC (rev 2675) +++ pkg/permute/man/numPerms.Rd 2013-11-08 03:10:12 UTC (rev 2676) @@ -27,7 +27,7 @@ not just the object containing the observations. } \value{ - The (numeric) number of possible permutaytions of observations in + The (numeric) number of possible permutations of observations in \code{object}. } \note{ @@ -67,12 +67,12 @@ ## permutation design --- see ?how ctrl <- how() ## defaults to freely exchangeable -## vector +## vector input v <- 1:10 (obs <- nobs(v)) numPerms(v, control = ctrl) -## integer +## integer input len <- length(v) (obs <- nobs(len)) numPerms(len, control = ctrl) @@ -85,7 +85,7 @@ ctrl <- how(within = Within(type = "series", mirror = TRUE)) numPerms(v, control = ctrl) -## Try blocking - 2 groups of 5 +## Try blocking --- 2 groups of 5 bl <- numPerms(v, control = how(blocks = gl(2,5))) bl Modified: pkg/permute/man/shuffle.Rd =================================================================== --- pkg/permute/man/shuffle.Rd 2013-11-08 03:06:24 UTC (rev 2675) +++ pkg/permute/man/shuffle.Rd 2013-11-08 03:10:12 UTC (rev 2676) @@ -37,8 +37,8 @@ permutation of the observations 1, \ldots, n using the permutation scheme described by argument \code{control}. - For \code{how} a list with components for each of the possible - arguments. + For \code{permute} the \code{i}th permutation from the set of all + permutations, or a random permutation from the design. } %\note{ % \code{shuffle} is currently used in one Vegan function; From noreply at r-forge.r-project.org Fri Nov 8 04:11:50 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 8 Nov 2013 04:11:50 +0100 (CET) Subject: [Vegan-commits] r2677 - pkg/permute/tests/Examples Message-ID: <20131108031150.9E0A7185349@r-forge.r-project.org> Author: gsimpson Date: 2013-11-08 04:11:50 +0100 (Fri, 08 Nov 2013) New Revision: 2677 Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save Log: update reference output for Examples Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save =================================================================== --- pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-08 03:10:12 UTC (rev 2676) +++ pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-08 03:11:50 UTC (rev 2677) @@ -1,5 +1,5 @@ -R version 3.0.2 Patched (2013-10-07 r64035) -- "Frisbee Sailing" +R version 3.0.2 Patched (2013-09-26 r64005) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -50,9 +50,8 @@ > ## design > fac <- gl(2,6) > ctrl <- how(within = Within(type = "grid", mirror = FALSE, -+ constant = TRUE, -+ nrow = 3, ncol = 2), -+ plots = Plots(strata = fac)) ++ constant = TRUE, nrow = 3, ncol = 2), ++ plots = Plots(strata = fac)) > Nobs <- length(fac) > numPerms(seq_len(Nobs), control = ctrl) ## 6 [1] 6 @@ -203,7 +202,7 @@ > > ### Name: check > ### Title: Utility functions for permutation schemes -> ### Aliases: check print.check print.summary.check summary.check permuplot +> ### Aliases: check print.check print.summary.check summary.check > ### Keywords: utilities design methods > > ### ** Examples @@ -212,7 +211,7 @@ > require(vegan) Loading required package: vegan Loading required package: lattice -This is vegan 2.1-33 +This is vegan 2.1-37 > example(pyrifos) pyrifs> data(pyrifos) @@ -316,8 +315,7 @@ [4,] 5 6 1 2 3 4 11 12 7 8 9 10 [5,] 6 1 2 3 4 5 12 7 8 9 10 11 > -> ## turn on mirroring %%FIXME needs a proper method to do this -> ##ctrl$within$mirror <- TRUE +> ## turn on mirroring > ctrl <- update(ctrl, within = update(getWithin(ctrl), mirror = TRUE)) > numPerms(1:12, control = ctrl) [1] 12 @@ -350,7 +348,7 @@ [11,] 6 5 4 3 2 1 12 11 10 9 8 7 > ## prints out details of the permutation scheme as > ## well as the matrix of permutations -> summary(tmp) +> summary(tmp) Complete enumeration of permutations @@ -476,8 +474,6 @@ > > > -> -> > cleanEx() detaching ?package:vegan?, ?package:lattice? @@ -508,11 +504,32 @@ > > ### ** Examples > -> set.seed(1234) +> ## extract components from a "how" object +> hh <- how() +> getWithin(hh) +$type +[1] "free" + +$constant +[1] FALSE + +$mirror +[1] FALSE + +$ncol +NULL + +$nrow +NULL + +$call +Within() + +> getNperm(hh) +[1] 199 > > > -> > cleanEx() > nameEx("how") > ### * how @@ -526,8 +543,11 @@ > > ### ** Examples > -> plts <- gl(4,10) -> blks <- gl(2,20) +> ## Set up factors for the Plots and Blocks +> plts <- gl(4, 10) ## 4 Plots of 10 samples each +> blks <- gl(2, 20) ## 2 Blocks of 20 samples each +> +> ## permutation design > h1 <- how(within = Within(type = "series", mirror = TRUE), + plots = Plots(strata = plts, type = "series"), + blocks = blks) @@ -555,6 +575,7 @@ Number of permutations requested: 199 Max. number of permutations allowed: 9999 Evaluate all permutations?: No. Activation limit: 99 +> > ## ... or switch the type of shuffling at a level: > update(h1, plots = update(getPlots(h1), type = "none")) @@ -650,14 +671,14 @@ > ## permutation design --- see ?how > ctrl <- how() ## defaults to freely exchangeable > -> ## vector +> ## vector input > v <- 1:10 > (obs <- nobs(v)) [1] 10 > numPerms(v, control = ctrl) [1] 3628800 > -> ## integer +> ## integer input > len <- length(v) > (obs <- nobs(len)) [1] 1 @@ -674,7 +695,7 @@ > numPerms(v, control = ctrl) [1] 20 > -> ## Try blocking - 2 groups of 5 +> ## Try blocking --- 2 groups of 5 > bl <- numPerms(v, control = how(blocks = gl(2,5))) > bl [1] 14400 @@ -1145,7 +1166,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 1.564 0.032 1.604 0 0 +Time elapsed: 2.065 0.041 2.124 0 0 > grDevices::dev.off() null device 1 From noreply at r-forge.r-project.org Fri Nov 8 11:40:12 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 8 Nov 2013 11:40:12 +0100 (CET) Subject: [Vegan-commits] r2678 - in pkg/vegan: R inst Message-ID: <20131108104012.D4C32185F5B@r-forge.r-project.org> Author: jarioksa Date: 2013-11-08 11:40:12 +0100 (Fri, 08 Nov 2013) New Revision: 2678 Modified: pkg/vegan/R/plot.renyiaccum.R pkg/vegan/inst/ChangeLog Log: fix plotting renyiaccum when only one index was used Modified: pkg/vegan/R/plot.renyiaccum.R =================================================================== --- pkg/vegan/R/plot.renyiaccum.R 2013-11-08 03:11:50 UTC (rev 2677) +++ pkg/vegan/R/plot.renyiaccum.R 2013-11-08 10:40:12 UTC (rev 2678) @@ -2,11 +2,12 @@ function (x, what=c("mean", "Qnt 0.025", "Qnt 0.975"), type = "l", ...) { if (any(what %in% colnames(x[,1,]))) - x <- x[,,what] + x <- x[,,what, drop = FALSE] dm <- dim(x) - lin <- rep(colnames(x[,1,]), each=dm[1]*dm[2]) + dnam <- dimnames(x) + lin <- rep(dnam[[3]], each=dm[1]*dm[2]) Sites <- rep(1:dm[1], len=prod(dm)) - alp <- factor(rownames(x[1,,]), levels=rownames(x[1,,])) + alp <- factor(dnam[[2]], levels=dnam[[2]]) alpha <- rep(rep(alp, each=dm[1]), len=prod(dm)) Diversity <- as.vector(x) xyplot(Diversity ~ Sites | alpha, groups=lin, type=type, ...) Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-11-08 03:11:50 UTC (rev 2677) +++ pkg/vegan/inst/ChangeLog 2013-11-08 10:40:12 UTC (rev 2678) @@ -21,6 +21,9 @@ also retained, but it is planned to be deprecated in the future, and it is recommended that users switch to defining 'blocks' in how(). + + * renyiaccum: plot() works also when only one index ('scales') was + used. Version 2.1-37 (closed November 5, 2013) From noreply at r-forge.r-project.org Fri Nov 8 14:22:06 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 8 Nov 2013 14:22:06 +0100 (CET) Subject: [Vegan-commits] r2679 - in pkg/vegan: R inst man Message-ID: <20131108132206.C4AB0183DE7@r-forge.r-project.org> Author: jarioksa Date: 2013-11-08 14:22:06 +0100 (Fri, 08 Nov 2013) New Revision: 2679 Modified: pkg/vegan/R/plot.renyiaccum.R pkg/vegan/R/renyiaccum.R pkg/vegan/inst/ChangeLog pkg/vegan/man/renyi.Rd Log: renyiaccum gained a collector curve to be used with summary of permutations Modified: pkg/vegan/R/plot.renyiaccum.R =================================================================== --- pkg/vegan/R/plot.renyiaccum.R 2013-11-08 10:40:12 UTC (rev 2678) +++ pkg/vegan/R/plot.renyiaccum.R 2013-11-08 13:22:06 UTC (rev 2679) @@ -1,7 +1,9 @@ `plot.renyiaccum` <- -function (x, what=c("mean", "Qnt 0.025", "Qnt 0.975"), type = "l", ...) +function (x, what=c("Collector", "mean", "Qnt 0.025", "Qnt 0.975"), + type = "l", ...) { - if (any(what %in% colnames(x[,1,]))) + what <- what[what %in% dimnames(x)[[3]]] + if (any(what %in% dimnames(x)[[3]])) x <- x[,,what, drop = FALSE] dm <- dim(x) dnam <- dimnames(x) Modified: pkg/vegan/R/renyiaccum.R =================================================================== --- pkg/vegan/R/renyiaccum.R 2013-11-08 10:40:12 UTC (rev 2678) +++ pkg/vegan/R/renyiaccum.R 2013-11-08 13:22:06 UTC (rev 2679) @@ -1,6 +1,6 @@ `renyiaccum` <- function(x, scales=c(0, 0.5, 1, 2, 4, Inf), permutations = 100, - raw = FALSE, subset, ...) + raw = FALSE, collector = FALSE, subset, ...) { if (!missing(subset)) x <- subset(x, subset) @@ -20,12 +20,16 @@ result[,,k] <- as.matrix(renyi((apply(x[sample(n),],2,cumsum)), scales=scales, ...)) } + if (raw) + collector <- FALSE + if (collector) + ref <- as.matrix(renyi(apply(x, 2, cumsum), scales = scales, ...)) if (raw) { if (m==1) { result <- result[,1,] } }else{ - tmp <- array(dim=c(n,m,6)) + tmp <- array(dim=c(n,m,6 + as.numeric(collector))) for (i in 1:n) { for (j in 1:m) { tmp[i,j,1] <- mean(result[i,j,1:permutations]) @@ -34,12 +38,14 @@ tmp[i,j,4] <- max(result[i,j,1:permutations]) tmp[i,j,5] <- quantile(result[i,j,1:permutations],0.025) tmp[i,j,6] <- quantile(result[i,j,1:permutations],0.975) + if (collector) + tmp[i,j,7] <- ref[i,j] } } result <- tmp dimnames(result) <- list(pooled.sites=c(1:n), scale=scales, - c("mean", "stdev", "min", "max", "Qnt 0.025", "Qnt 0.975")) + c("mean", "stdev", "min", "max", "Qnt 0.025", "Qnt 0.975", if (collector) "Collector")) } class(result) <- c("renyiaccum", class(result)) result Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-11-08 10:40:12 UTC (rev 2678) +++ pkg/vegan/inst/ChangeLog 2013-11-08 13:22:06 UTC (rev 2679) @@ -23,7 +23,11 @@ how(). * renyiaccum: plot() works also when only one index ('scales') was - used. + used. The function gained new argument 'collector = FALSE' to + accumulate sites in the order they are in the data set in addition + to the summary statistics of permutations. This can be used to + analyse the randomness of the particular order of sites (looks + like my student would need this). Version 2.1-37 (closed November 5, 2013) Modified: pkg/vegan/man/renyi.Rd =================================================================== --- pkg/vegan/man/renyi.Rd 2013-11-08 10:40:12 UTC (rev 2678) +++ pkg/vegan/man/renyi.Rd 2013-11-08 13:22:06 UTC (rev 2679) @@ -18,8 +18,9 @@ hill = FALSE) \method{plot}{renyi}(x, ...) renyiaccum(x, scales = c(0, 0.5, 1, 2, 4, Inf), permutations = 100, - raw = FALSE, subset, ...) -\method{plot}{renyiaccum}(x, what = c("mean", "Qnt 0.025", "Qnt 0.975"), type = "l", + raw = FALSE, collector = FALSE, subset, ...) +\method{plot}{renyiaccum}(x, what = c("Collector", "mean", "Qnt 0.025", "Qnt 0.975"), + type = "l", ...) \method{persp}{renyiaccum}(x, theta = 220, col = heat.colors(100), zlim, ...) rgl.renyiaccum(x, rgl.height = 0.2, ...) @@ -34,6 +35,10 @@ \item{raw}{if \code{FALSE} then return summary statistics of permutations, and if \code{TRUE} then returns the individual permutations.} + \item{collector}{Accumulate the diversities in the order the sites are + in the data set, and the collector curve can be plotted against + summary of permutations. The argument is ignored if \code{raw = TRUE}. + } \item{subset}{logical expression indicating sites (rows) to keep: missing values are taken as \code{FALSE}.} \item{what}{Items to be plotted.} From noreply at r-forge.r-project.org Sat Nov 9 01:32:37 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 01:32:37 +0100 (CET) Subject: [Vegan-commits] r2680 - in pkg/permute: . R inst Message-ID: <20131109003237.40008186555@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 01:32:36 +0100 (Sat, 09 Nov 2013) New Revision: 2680 Modified: pkg/permute/NAMESPACE pkg/permute/R/getFoo-methods.R pkg/permute/inst/ChangeLog Log: adds new methods for extracting make and observed components Modified: pkg/permute/NAMESPACE =================================================================== --- pkg/permute/NAMESPACE 2013-11-08 13:22:06 UTC (rev 2679) +++ pkg/permute/NAMESPACE 2013-11-09 00:32:36 UTC (rev 2680) @@ -4,8 +4,8 @@ `shuffleFree`, `shuffleSeries`, `shuffleGrid`, `shuffleStrata`, `getBlocks`, `getWithin`, `getStrata`, `getType`, `getMirror`, `getConstant`, `getPlots`, `getRow`, `getCol`, `getDim`, - `getNperm`,`getMaxperm`, `getMinperm`, `getComplete`, `shuffleSet`, - `how`) + `getNperm`,`getMaxperm`, `getMinperm`, `getComplete`, `getMake`, + `getObserved`, `shuffleSet`, `how`) ### Imports: nobs() only exists in R 2.13.0 for import. We define the ### same nobs() generic in permute for export in older R. @@ -74,3 +74,7 @@ S3method(`getDim`, `default`) S3method(`getDim`, `how`) S3method(`getDim`, `permControl`) +S3method(`getMake`, `default`) +S3method(`getMake`, `how`) +S3method(`getObserved`, `default`) +S3method(`getObserved`, `how`) Modified: pkg/permute/R/getFoo-methods.R =================================================================== --- pkg/permute/R/getFoo-methods.R 2013-11-08 13:22:06 UTC (rev 2679) +++ pkg/permute/R/getFoo-methods.R 2013-11-09 00:32:36 UTC (rev 2680) @@ -343,11 +343,36 @@ } `getComplete.permControl` <- function(object, ...) { - list(complete = object$complete, - minperm = object$minperm) + object$complete } `getComplete.how` <- function(object, ...) { - list(complete = object$complete, - minperm = object$minperm) + object$complete } + +## Returns whether all permutation should/should not be made +`getMake` <- function(object, ...) { + UseMethod("getMake") +} + +`getMake.default` <- function(object, ...) { + stop("No default method for `getMake`") +} + +`getMake.how` <- function(object, ...) { + object$make +} + +## Returns whether the observed permutation should be in +## the set of permutations +`getObserved` <- function(object, ...) { + UseMethod("getObserved") +} + +`getObserved.default` <- function(object, ...) { + stop("No default method for `getObserved`") +} + +`getObserved.how` <- function(object, ...) { + object$observed +} Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-08 13:22:06 UTC (rev 2679) +++ pkg/permute/inst/ChangeLog 2013-11-09 00:32:36 UTC (rev 2680) @@ -39,6 +39,14 @@ `summary.allPerms` (its `print` method, more correctly) now prints the permutation design alongside the set of permutations. + * get-methods: new extractor functions `getObserved()` and + `getMake()` return the `observed` and `make` components of object + created by `how()`. + + * getComplete: This now only returns the `complete` component of + the `"how"` object. Use `getMinperm()` to extract the component + no-longer returned by `getComplete()`. + * Documentation fixes in examples of `allPerms` and `check`. * permuplot: This is horribly broken and I'm not sure if it will From noreply at r-forge.r-project.org Sat Nov 9 02:51:12 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 02:51:12 +0100 (CET) Subject: [Vegan-commits] r2681 - pkg/permute/man Message-ID: <20131109015112.7EF01185DE2@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 02:51:12 +0100 (Sat, 09 Nov 2013) New Revision: 2681 Modified: pkg/permute/man/get-methods.Rd Log: forgot to include the Rd file in r2680 Modified: pkg/permute/man/get-methods.Rd =================================================================== --- pkg/permute/man/get-methods.Rd 2013-11-09 00:32:36 UTC (rev 2680) +++ pkg/permute/man/get-methods.Rd 2013-11-09 01:51:12 UTC (rev 2681) @@ -56,6 +56,12 @@ \alias{getComplete.default} \alias{getComplete.how} \alias{getComplete.permControl} +\alias{getMake} +\alias{getMake.default} +\alias{getMake.how} +\alias{getObserved} +\alias{getObserved.default} +\alias{getObserved.how} \title{Extractor functions to access components of a permutation design} \description{ @@ -83,6 +89,8 @@ getMaxperm(object, ...) getMinperm(object, ...) getComplete(object, ...) +getMake(object, ...) +getObserved(object, ...) \method{getWithin}{how}(object, ...) @@ -113,6 +121,10 @@ \method{getComplete}{how}(object, ...) +\method{getMake}{how}(object, ...) + +\method{getObserved}{how}(object, ...) + } \arguments{ From noreply at r-forge.r-project.org Sat Nov 9 02:56:28 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 02:56:28 +0100 (CET) Subject: [Vegan-commits] r2682 - in pkg/permute: R man Message-ID: <20131109015628.7FBD4185DE2@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 02:56:28 +0100 (Sat, 09 Nov 2013) New Revision: 2682 Modified: pkg/permute/R/allPerms.R pkg/permute/man/allPerms.Rd Log: remove args that are in how() object Modified: pkg/permute/R/allPerms.R =================================================================== --- pkg/permute/R/allPerms.R 2013-11-09 01:51:12 UTC (rev 2681) +++ pkg/permute/R/allPerms.R 2013-11-09 01:56:28 UTC (rev 2682) @@ -1,5 +1,4 @@ -`allPerms` <- function(n, control = how(), max = 9999, - observed = FALSE) { +`allPerms` <- function(n, control = how()) { ## start v <- n ## expand n if a numeric or integer vector of length 1 @@ -8,16 +7,20 @@ ## number of observations in data n <- nobs(v) ## check permutation scheme and update control - pcheck <- check(v, control = control, make.all = FALSE) + make <- getMake(control) + pcheck <- check(v, control = update(control, make = FALSE)) ## ctrl <- pcheck$control + ## if we do copy the new updated control, we need to update to + ## reset make + ## ctrl <- update(ctrl, make = make) ## get max number of permutations nperms <- numPerms(v, control = control) ## sanity check - don't let this run away to infinity ## esp with type = "free" - if(nperms > max) - stop("Number of possible permutations too large (> 'max')") + if(nperms > getMaxperm(control)) + stop("Number of possible permutations too large (> 'maxperm')") WI <- getWithin(control) strataP <- getStrata(control, which = "plots") @@ -55,13 +58,14 @@ ## bind all the blocks together out <- do.call(rbind, out) ## hmm are any of these the same shape? - if(!observed) { + if(!(observed <- getObserved(control))) { obs.v <- seq_len(n) obs.row <- apply(out, 1, function(x, obs.v) all(x == obs.v), obs.v) out <- out[!obs.row, ] ## reduce the number of permutations to get rid of the ## observed ordering - control$nperm <- control$nperm - 1 + ##control$nperm <- control$nperm - 1 + control <- update(control, nperm = getNperm(control) - 1) } class(out) <- "allPerms" attr(out, "control") <- control Modified: pkg/permute/man/allPerms.Rd =================================================================== --- pkg/permute/man/allPerms.Rd 2013-11-09 01:51:12 UTC (rev 2681) +++ pkg/permute/man/allPerms.Rd 2013-11-09 01:56:28 UTC (rev 2682) @@ -10,8 +10,7 @@ permutations for a given R object and a specified permutation design. } \usage{ -allPerms(n, control = how(), max = 9999, - observed = FALSE) +allPerms(n, control = how()) \method{summary}{allPerms}(object, \dots) } @@ -21,11 +20,6 @@ \item{control}{a list of control values describing properties of the permutation design, as returned by a call to \code{\link{how}}.} - \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 - returned as part of the complete enumeration? Default is - \code{FALSE} to facilitate usage in higher level functions.} \item{object}{an object of class \code{"allPerms"}.} \item{\dots}{arguments to other methods.} } @@ -45,7 +39,7 @@ possible permutations would also become problematic in such cases. To 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. + \code{getMaxperm(control)}, \code{allPerms} exits with an error. } \value{ For \code{allPerms}, and object of class \code{"allPerms"}, a matrix @@ -79,14 +73,14 @@ plots = Plots(strata = fac)) Nobs <- length(fac) numPerms(seq_len(Nobs), control = ctrl) ## 6 -(tmp <- allPerms(Nobs, control = ctrl, observed = TRUE)) +(tmp <- allPerms(Nobs, control = update(ctrl, observed = TRUE))) (tmp2 <- allPerms(Nobs, control = ctrl)) ## turn on mirroring ##ctrl$within$mirror <- TRUE ctrl <- update(ctrl, within = update(getWithin(ctrl), mirror = TRUE)) numPerms(seq_len(Nobs), control = ctrl) -(tmp3 <- allPerms(Nobs, control = ctrl, observed = TRUE)) +(tmp3 <- allPerms(Nobs, control = update(ctrl, observed = TRUE))) (tmp4 <- allPerms(Nobs, control = ctrl)) ## prints out details of the permutation scheme as From noreply at r-forge.r-project.org Sat Nov 9 02:57:05 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 02:57:05 +0100 (CET) Subject: [Vegan-commits] r2683 - pkg/permute/inst Message-ID: <20131109015705.42868185DE2@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 02:57:05 +0100 (Sat, 09 Nov 2013) New Revision: 2683 Modified: pkg/permute/inst/ChangeLog Log: forgot to include changelog updates in r2862 Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-09 01:56:28 UTC (rev 2682) +++ pkg/permute/inst/ChangeLog 2013-11-09 01:57:05 UTC (rev 2683) @@ -36,6 +36,9 @@ argument) as an attribute, `"control"`, on the returned matrix of permutations. + `allPerms` looses arguments `max` and `observed` as these are + supposed to be in the control object created by `how()`. + `summary.allPerms` (its `print` method, more correctly) now prints the permutation design alongside the set of permutations. From noreply at r-forge.r-project.org Sat Nov 9 03:00:20 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 03:00:20 +0100 (CET) Subject: [Vegan-commits] r2684 - in pkg/permute: R inst man Message-ID: <20131109020020.72EB5185DE2@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 03:00:19 +0100 (Sat, 09 Nov 2013) New Revision: 2684 Modified: pkg/permute/R/check.R pkg/permute/R/permCheck.R pkg/permute/inst/ChangeLog pkg/permute/man/check.Rd pkg/permute/man/permCheck-deprecated.Rd Log: remove make.all and observed arguments Modified: pkg/permute/R/check.R =================================================================== --- pkg/permute/R/check.R 2013-11-09 01:57:05 UTC (rev 2683) +++ pkg/permute/R/check.R 2013-11-09 02:00:19 UTC (rev 2684) @@ -1,5 +1,4 @@ -`check` <- function(object, control = how(), make.all = TRUE, - observed = FALSE) +`check` <- function(object, control = how()) { ## if object is numeric or integer and of length 1, ## extend the object @@ -68,21 +67,25 @@ ## check if number requested permutations exceeds max possible if(getNperm(control) > num.pos) { - control$nperm <- control$maxperm <- num.pos - control$complete <- TRUE + control <- update(control, nperm = num.pos, maxperm = num.pos, + complete = TRUE) + control$call[["nperm"]] <- eval(control$call[["nperm"]]) + control$call[["maxperm"]] <- eval(control$call[["maxperm"]]) } - + ## if number of possible perms < minperm turn on complete enumeration - if(num.pos < getMinperm(control)) { - control$nperm <- control$maxperm <- num.pos - control$complete <- TRUE + if((num.pos < getMinperm(control))) { + control <- update(control, nperm = num.pos, maxperm = num.pos, + complete = TRUE) + control$call[["nperm"]] <- eval(control$call[["nperm"]]) + control$call[["maxperm"]] <- eval(control$call[["maxperm"]]) } ## if complete enumeration, generate all permutations - if(getComplete(control)$complete && make.all) { - control$all.perms <- allPerms(N, control = control, - max = getMaxperm(control), - observed = observed) + if(getComplete(control) && getMake(control)) { + ap <- allPerms(N, control = control) + control <- update(control, all.perms = ap) + control$call[["all.perms"]] <- eval(control$call[["all.perms"]]) } retval <- list(n = num.pos, control = control) class(retval) <- "check" Modified: pkg/permute/R/permCheck.R =================================================================== --- pkg/permute/R/permCheck.R 2013-11-09 01:57:05 UTC (rev 2683) +++ pkg/permute/R/permCheck.R 2013-11-09 02:00:19 UTC (rev 2684) @@ -1,6 +1,5 @@ ## deprecate check -`permCheck` <- function(object, control = how(), - make.all = TRUE) { +`permCheck` <- function(object, control = how()) { .Deprecated(new = "check", "permute") - check(object = object, control = control, make.all = make.all) + check(object = object, control = control) } Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-09 01:57:05 UTC (rev 2683) +++ pkg/permute/inst/ChangeLog 2013-11-09 02:00:19 UTC (rev 2684) @@ -50,6 +50,11 @@ the `"how"` object. Use `getMinperm()` to extract the component no-longer returned by `getComplete()`. + * check: function looses arguments `make.all` and `observed` as + these are in the control object returned by `how()`. + + The logic of some of the checks has been tweaked slightly. + * Documentation fixes in examples of `allPerms` and `check`. * permuplot: This is horribly broken and I'm not sure if it will Modified: pkg/permute/man/check.Rd =================================================================== --- pkg/permute/man/check.Rd 2013-11-09 01:57:05 UTC (rev 2683) +++ pkg/permute/man/check.Rd 2013-11-09 02:00:19 UTC (rev 2684) @@ -11,7 +11,7 @@ selected permutation design. } \usage{ -check(object, control = how(), make.all = TRUE, observed = FALSE) +check(object, control = how()) \method{summary}{check}(object, \dots) } @@ -22,11 +22,6 @@ \code{\link{summary.check}} an object of class \code{"check"}.} \item{control}{a list of control values describing properties of the permutation design, as returned by a call to \code{\link{how}}.} - \item{make.all}{logical; should \code{check} generate all - possible permutations? Useful if want to check permutation design - but not produce the matrix of all permutations.} - \item{observed}{logical; if making all possible permutations, should - the set include the observed permutation too?} \item{\dots}{arguments to other methods.} } \details{ @@ -127,13 +122,13 @@ check(1:12, ctrl) numPerms(1:12, control = ctrl) -(tmp <- allPerms(12, control = ctrl, observed = TRUE)) +(tmp <- allPerms(12, control = update(ctrl, observed = TRUE))) (tmp2 <- allPerms(12, control = ctrl)) ## turn on mirroring ctrl <- update(ctrl, within = update(getWithin(ctrl), mirror = TRUE)) numPerms(1:12, control = ctrl) -(tmp3 <- allPerms(12, control = ctrl, observed = TRUE)) +(tmp3 <- allPerms(12, control = update(ctrl, observed = TRUE))) (tmp4 <- allPerms(12, control = ctrl)) ## prints out details of the permutation scheme as ## well as the matrix of permutations Modified: pkg/permute/man/permCheck-deprecated.Rd =================================================================== --- pkg/permute/man/permCheck-deprecated.Rd 2013-11-09 01:57:05 UTC (rev 2683) +++ pkg/permute/man/permCheck-deprecated.Rd 2013-11-09 02:00:19 UTC (rev 2684) @@ -12,7 +12,7 @@ selected permutation design. } \usage{ -permCheck(object, control = how(), make.all = TRUE) +permCheck(object, control = how()) \method{summary}{permCheck}(object, \dots) } @@ -25,9 +25,6 @@ \item{control}{a list of control values describing properties of the permutation design, as returned by a call to \code{\link{how}}.} - \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{\dots}{arguments to other methods. For \code{permuplot} graphical parameters can be passed to plotting functions, though note that not all parameters will be accepted gracefully at the From noreply at r-forge.r-project.org Sat Nov 9 03:02:55 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 03:02:55 +0100 (CET) Subject: [Vegan-commits] r2685 - in pkg/permute: R inst man Message-ID: <20131109020255.49237185DE2@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 03:02:54 +0100 (Sat, 09 Nov 2013) New Revision: 2685 Modified: pkg/permute/R/how.R pkg/permute/inst/ChangeLog pkg/permute/man/how.Rd Log: how gets a make argument Modified: pkg/permute/R/how.R =================================================================== --- pkg/permute/R/how.R 2013-11-09 02:00:19 UTC (rev 2684) +++ pkg/permute/R/how.R 2013-11-09 02:02:54 UTC (rev 2685) @@ -6,12 +6,13 @@ maxperm = 9999, minperm = 99, all.perms = NULL, - observed = FALSE) -{ + make = TRUE, + observed = FALSE) { out <- list(within = within, plots = plots, blocks = blocks, nperm = nperm, complete = complete, maxperm = maxperm, minperm = minperm, - all.perms = all.perms, observed = observed, + all.perms = all.perms, make = make, + observed = observed, blocks.name = deparse(substitute(blocks)), call = match.call()) class(out) <- "how" Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-09 02:00:19 UTC (rev 2684) +++ pkg/permute/inst/ChangeLog 2013-11-09 02:02:54 UTC (rev 2685) @@ -8,6 +8,10 @@ `update()` to update elements of a stored permutation design object. Suggested by Jari Oksanen. + `how` also gains an argument `make` which is the user-level way + to control whether all possible permutations are actually + created should the heuristics in `check()` decide they should be. + The `print` method for class "how" wasn't printing details of mirroring or constant settings for within-plot components. Modified: pkg/permute/man/how.Rd =================================================================== --- pkg/permute/man/how.Rd 2013-11-09 02:00:19 UTC (rev 2684) +++ pkg/permute/man/how.Rd 2013-11-09 02:02:54 UTC (rev 2685) @@ -16,7 +16,8 @@ \usage{ how(within = Within(), plots = Plots(), blocks = NULL, nperm = 199, complete = FALSE, maxperm = 9999, - minperm = 99, all.perms = NULL, observed = FALSE) + minperm = 99, all.perms = NULL, make = TRUE, + observed = FALSE) Within(type = c("free","series","grid","none"), constant = FALSE, mirror = FALSE, @@ -47,8 +48,13 @@ \code{complete} and Details, below.} \item{all.perms}{an object of class \code{allPerms}, the result of a call to \code{\link{allPerms}}.} + \item{make}{logical; should \code{check} generate all possible + permutations? Useful if want to check permutation design but not + produce the matrix of all permutations, or to circumvent the + heuristics governing when complete enumeration is activated.} \item{observed}{logical; should the observed permutation be returned - as part of the set of all permutations?} + as part of the set of all permutations? Default is \code{FALSE} to + facilitate usage in higher level functions.} \item{constant}{logical; should the same permutation be used within each level of strata? If \code{FALSE} a separate, possibly restricted, permutation is produced for each level of \code{strata}.} From noreply at r-forge.r-project.org Sat Nov 9 03:04:21 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 03:04:21 +0100 (CET) Subject: [Vegan-commits] r2686 - pkg/permute/R Message-ID: <20131109020421.5E13E185DE2@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 03:04:20 +0100 (Sat, 09 Nov 2013) New Revision: 2686 Modified: pkg/permute/R/shuffleSet2.R Log: update shuffleSet() so it calls check() correctly Modified: pkg/permute/R/shuffleSet2.R =================================================================== --- pkg/permute/R/shuffleSet2.R 2013-11-09 02:02:54 UTC (rev 2685) +++ pkg/permute/R/shuffleSet2.R 2013-11-09 02:04:20 UTC (rev 2686) @@ -15,10 +15,10 @@ ## than requested in nset, depending upon what user specified ## in `control`. The `check` argument can turn this step off ## so you always get `nset` permutations and, yes, you can shoot - ## yourself in the foot with this, hence the dfeualt is to check! + ## yourself in the foot with this, hence the default is to check! if (isTRUE(check)) { ## need to check number of permutations won't blow up - pcheck <- check(sn, control = control, make.all = TRUE) + pcheck <- check(sn, control = control) ## control possibly now updated control <- pcheck$control } From noreply at r-forge.r-project.org Sat Nov 9 03:05:21 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 03:05:21 +0100 (CET) Subject: [Vegan-commits] r2687 - pkg/permute/R Message-ID: <20131109020521.279831865CA@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 03:05:17 +0100 (Sat, 09 Nov 2013) New Revision: 2687 Modified: pkg/permute/R/print.how.R Log: need to be update following the change to getComplete to not return the minperm component Modified: pkg/permute/R/print.how.R =================================================================== --- pkg/permute/R/print.how.R 2013-11-09 02:04:20 UTC (rev 2686) +++ pkg/permute/R/print.how.R 2013-11-09 02:05:17 UTC (rev 2687) @@ -81,10 +81,9 @@ getNperm(x)), prefix = pfix)) writeLines(strwrap(paste("Max. number of permutations allowed:", getMaxperm(x)), prefix = pfix)) - complete <- getComplete(x) txt <- paste("Evaluate all permutations?:", - if(complete$complete) "Yes." else "No.", - " Activation limit:", complete$minperm) + if(getComplete(x)) "Yes." else "No.", + " Activation limit:", getMinperm(x)) writeLines(strwrap(txt, prefix = pfix)) } From noreply at r-forge.r-project.org Sat Nov 9 03:13:01 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 03:13:01 +0100 (CET) Subject: [Vegan-commits] r2688 - pkg/permute/tests/Examples Message-ID: <20131109021302.1A810186591@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 03:13:01 +0100 (Sat, 09 Nov 2013) New Revision: 2688 Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save Log: update the reference material for example checks Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save =================================================================== --- pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-09 02:05:17 UTC (rev 2687) +++ pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-09 02:13:01 UTC (rev 2688) @@ -55,7 +55,7 @@ > Nobs <- length(fac) > numPerms(seq_len(Nobs), control = ctrl) ## 6 [1] 6 -> (tmp <- allPerms(Nobs, control = ctrl, observed = TRUE)) +> (tmp <- allPerms(Nobs, control = update(ctrl, observed = TRUE))) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 2 3 4 5 6 1 8 9 10 11 12 7 [2,] 3 4 5 6 1 2 9 10 11 12 7 8 @@ -76,7 +76,7 @@ > ctrl <- update(ctrl, within = update(getWithin(ctrl), mirror = TRUE)) > numPerms(seq_len(Nobs), control = ctrl) [1] 12 -> (tmp3 <- allPerms(Nobs, control = ctrl, observed = TRUE)) +> (tmp3 <- allPerms(Nobs, control = update(ctrl, observed = TRUE))) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 2 3 4 5 6 1 8 9 10 11 12 7 [2,] 3 4 5 6 1 2 9 10 11 12 7 8 @@ -299,7 +299,7 @@ > > numPerms(1:12, control = ctrl) [1] 6 -> (tmp <- allPerms(12, control = ctrl, observed = TRUE)) +> (tmp <- allPerms(12, control = update(ctrl, observed = TRUE))) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 2 3 4 5 6 1 8 9 10 11 12 7 [2,] 3 4 5 6 1 2 9 10 11 12 7 8 @@ -319,7 +319,7 @@ > ctrl <- update(ctrl, within = update(getWithin(ctrl), mirror = TRUE)) > numPerms(1:12, control = ctrl) [1] 12 -> (tmp3 <- allPerms(12, control = ctrl, observed = TRUE)) +> (tmp3 <- allPerms(12, control = update(ctrl, observed = TRUE))) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [1,] 2 3 4 5 6 1 8 9 10 11 12 7 [2,] 3 4 5 6 1 2 9 10 11 12 7 8 @@ -499,7 +499,8 @@ > ### getNperm.permControl getMaxperm getMaxperm.default getMaxperm.how > ### getMaxperm.permControl getMinperm getMinperm.default getMinperm.how > ### getMinperm.permControl getComplete getComplete.default -> ### getComplete.how getComplete.permControl +> ### getComplete.how getComplete.permControl getMake getMake.default +> ### getMake.how getObserved getObserved.default getObserved.how > ### Keywords: methods utils > > ### ** Examples @@ -1166,7 +1167,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 2.065 0.041 2.124 0 0 +Time elapsed: 2.328 0.04 2.494 0 0 > grDevices::dev.off() null device 1 From noreply at r-forge.r-project.org Sat Nov 9 04:59:04 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 04:59:04 +0100 (CET) Subject: [Vegan-commits] r2689 - pkg/permute Message-ID: <20131109035904.EDEFC185A88@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 04:59:04 +0100 (Sat, 09 Nov 2013) New Revision: 2689 Modified: pkg/permute/DESCRIPTION Log: bump version to 0.7-6 Modified: pkg/permute/DESCRIPTION =================================================================== --- pkg/permute/DESCRIPTION 2013-11-09 02:13:01 UTC (rev 2688) +++ pkg/permute/DESCRIPTION 2013-11-09 03:59:04 UTC (rev 2689) @@ -1,6 +1,6 @@ Package: permute Title: Functions for generating restricted permutations of data -Version: 0.7-5 +Version: 0.7-6 Date: $Date$ Author: Gavin L. Simpson Maintainer: Gavin L. Simpson From noreply at r-forge.r-project.org Sat Nov 9 04:59:39 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 04:59:39 +0100 (CET) Subject: [Vegan-commits] r2690 - pkg/permute/R Message-ID: <20131109035939.2F610185A88@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 04:59:38 +0100 (Sat, 09 Nov 2013) New Revision: 2690 Modified: pkg/permute/R/print.summary.allPerms.R Log: remove duplicate sub-title Modified: pkg/permute/R/print.summary.allPerms.R =================================================================== --- pkg/permute/R/print.summary.allPerms.R 2013-11-09 03:59:04 UTC (rev 2689) +++ pkg/permute/R/print.summary.allPerms.R 2013-11-09 03:59:38 UTC (rev 2690) @@ -7,7 +7,6 @@ cat("\n") writeLines(strwrap("Complete enumeration of permutations\n", prefix = "\t")) - cat("\nPermutation Scheme:\n") print(control) cat("\nAll permutations:\n") writeLines(paste("Contains observed ordering?:", ifelse(observed, "Yes", "No"), From noreply at r-forge.r-project.org Sat Nov 9 05:00:13 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 05:00:13 +0100 (CET) Subject: [Vegan-commits] r2691 - in pkg/permute/inst: . tests Message-ID: <20131109040013.A901C185A88@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 05:00:13 +0100 (Sat, 09 Nov 2013) New Revision: 2691 Added: pkg/permute/inst/tests/test-check.R Modified: pkg/permute/inst/ChangeLog pkg/permute/inst/tests/test-shuffleSet.R Log: more unit test; document changes Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-09 03:59:38 UTC (rev 2690) +++ pkg/permute/inst/ChangeLog 2013-11-09 04:00:13 UTC (rev 2691) @@ -2,6 +2,12 @@ permute ChangeLog +Version 0.7-6 + + * summary.allPerms: Was printing two slightly different subtitles. + + * More unit tests... + Version 0.7-5 * how: the matched call is now returned permitting the use of Added: pkg/permute/inst/tests/test-check.R =================================================================== --- pkg/permute/inst/tests/test-check.R (rev 0) +++ pkg/permute/inst/tests/test-check.R 2013-11-09 04:00:13 UTC (rev 2691) @@ -0,0 +1,25 @@ +library(testthat) +library_if_available(permute) + +context("Testing check()") + +## test that check will return all perms including the observed +test_that("check returns observed ordering in set of all permutations *if* asked to", { + ## simple permutation + h <- how(observed = TRUE) + pp <- check(4, control = h) + expect_that(nrow(pp$control$all.perms), equals(factorial(4))) + + ## time series + h <- how(within = Within(type = "series"), observed = TRUE) + n <- 10 + pp <- check(n, control = h) + expect_that(nrow(pp$control$all.perms), equals(n)) + + ## time series specified as a vector + h <- how(within = Within(type = "series"), observed = TRUE) + n <- 10 + vec <- seq_len(n) + pp <- check(vec, control = h) + expect_that(nrow(pp$control$all.perms), equals(n)) +}) Modified: pkg/permute/inst/tests/test-shuffleSet.R =================================================================== --- pkg/permute/inst/tests/test-shuffleSet.R 2013-11-09 03:59:38 UTC (rev 2690) +++ pkg/permute/inst/tests/test-shuffleSet.R 2013-11-09 04:00:13 UTC (rev 2691) @@ -18,3 +18,25 @@ expect_that(p[i, ], equals(y)) } }) + +## test that nset permutations are always returned if +## make = FALSE in how() +test_that( "shuffleSet returns exactly nset permutations when make == FALSE", { + ## simple random permutation + h <- how(make = FALSE) + ss <- shuffleSet(n = 4, nset = 10, control = h) + expect_that(nrow(ss), equals(10)) + + ## time series + h <- how(within = Within(type = "series"), make = FALSE) + ss <- shuffleSet(n = 20, nset = 15, control = h) + expect_that(nrow(ss), equals(15)) + +}) + +## test that shuffleSet always returns a matrix, even for nset == 1 +test_that("shuffleSet returns a matrix even for nset == 1", { + h <- how() + ss <- shuffleSet(25, nset = 1, control = h) + expect_that(ss, is_a("matrix")) +}) From noreply at r-forge.r-project.org Sat Nov 9 05:03:06 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 05:03:06 +0100 (CET) Subject: [Vegan-commits] r2692 - pkg/permute/inst Message-ID: <20131109040307.150A7185A88@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 05:03:06 +0100 (Sat, 09 Nov 2013) New Revision: 2692 Modified: pkg/permute/inst/TODO.md Log: update the to do list Modified: pkg/permute/inst/TODO.md =================================================================== --- pkg/permute/inst/TODO.md 2013-11-09 04:00:13 UTC (rev 2691) +++ pkg/permute/inst/TODO.md 2013-11-09 04:03:06 UTC (rev 2692) @@ -57,3 +57,7 @@ * `check` insists on returning all permutations *without* the observed one. + + *DONE Completed somewhere, probably when I made observed only work via + how()* + From noreply at r-forge.r-project.org Sat Nov 9 05:08:25 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 9 Nov 2013 05:08:25 +0100 (CET) Subject: [Vegan-commits] r2693 - pkg/permute/tests/Examples Message-ID: <20131109040825.B53E1185A88@r-forge.r-project.org> Author: gsimpson Date: 2013-11-09 05:08:25 +0100 (Sat, 09 Nov 2013) New Revision: 2693 Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save Log: update reference material for examples Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save =================================================================== --- pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-09 04:03:06 UTC (rev 2692) +++ pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-09 04:08:25 UTC (rev 2693) @@ -110,8 +110,6 @@ Complete enumeration of permutations -Permutation Scheme: - Permutation Design: Blocks: @@ -153,8 +151,6 @@ Complete enumeration of permutations -Permutation Scheme: - Permutation Design: Blocks: @@ -352,8 +348,6 @@ Complete enumeration of permutations -Permutation Scheme: - Permutation Design: Blocks: @@ -389,8 +383,6 @@ Complete enumeration of permutations -Permutation Scheme: - Permutation Design: Blocks: @@ -1167,7 +1159,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 2.328 0.04 2.494 0 0 +Time elapsed: 2.133 0.036 2.187 0 0 > grDevices::dev.off() null device 1 From noreply at r-forge.r-project.org Sun Nov 10 15:20:43 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 10 Nov 2013 15:20:43 +0100 (CET) Subject: [Vegan-commits] r2694 - in pkg/vegan: . R inst man Message-ID: <20131110142043.1971E186579@r-forge.r-project.org> Author: jarioksa Date: 2013-11-10 15:20:42 +0100 (Sun, 10 Nov 2013) New Revision: 2694 Added: pkg/vegan/R/anovacca.R pkg/vegan/man/anovacca.Rd Modified: pkg/vegan/DESCRIPTION pkg/vegan/NAMESPACE pkg/vegan/inst/ChangeLog Log: start migration to permute-based anova.cca: add working function anovacca to replace anova.cca Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2013-11-09 04:08:25 UTC (rev 2693) +++ pkg/vegan/DESCRIPTION 2013-11-10 14:20:42 UTC (rev 2694) @@ -1,7 +1,7 @@ Package: vegan Title: Community Ecology Package -Version: 2.1-38 -Date: November 5, 2013 +Version: 2.1-39 +Date: November 10, 2013 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, Helene Wagner Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2013-11-09 04:08:25 UTC (rev 2693) +++ pkg/vegan/NAMESPACE 2013-11-10 14:20:42 UTC (rev 2694) @@ -29,7 +29,8 @@ treedist, treedive, treeheight, tsallisaccum, tsallis, varpart, vectorfit, vegandocs, vegdist, vegemite, veiledspec, wascores, wcmdscale, wisconsin) - +## Export temporary function later intended to replace anova.cca() +export(anovacca) ## <-- REMOVE THIS WHEN anova.cca IS UPGRADED <--!!! ## export pasteCall for 'permute' export(pasteCall) ## export anova.cca for 'BiodiversityR': this should be fixed there Added: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R (rev 0) +++ pkg/vegan/R/anovacca.R 2013-11-10 14:20:42 UTC (rev 2694) @@ -0,0 +1,31 @@ +`anovacca` <- + function(object, ..., permutations = how(nperm=999), by = NULL) +{ + if (is.null(object$CA) || is.null(object$CCA) || + object$CCA$rank == 0 || object$CA$rank == 0) + return(anova.ccanull(object)) + if (!is.null(by)) { + by <- match.arg(by, c("axis", "terms", "margin")) + .NotYetUsed("by") + } + seed <- NULL + tst <- permutest.cca(object, permutations = permutations, ...) + if (is.null(seed)) + seed <- tst$Random.seed + Fval <- c(tst$F.0, NA) + Pval <- (sum(tst$F.perm >= tst$F.0) + 1)/(tst$nperm + 1) + Pval <- c(Pval, NA) + nperm <- c(tst$nperm, NA) + table <- data.frame(tst$df, tst$chi, Fval, nperm, Pval) + is.rda <- inherits(object, "rda") + colnames(table) <- c("Df", ifelse(is.rda, "Var", "Chisq"), + "F", "N.Perm", "Pr(>F)") + head <- paste("Permutation test for", tst$method, "under", + tst$model, "model\n") + if (!is.null(tst$strata)) + head <- paste(head, "Permutations stratified within '", + tst$strata, "'\n", sep = "") + mod <- paste("Model:", c(object$call)) + structure(table, heading = c(head, mod), Random.seed = seed, + class = c("anova.cca", "anova", "data.frame")) +} Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-11-09 04:08:25 UTC (rev 2693) +++ pkg/vegan/inst/ChangeLog 2013-11-10 14:20:42 UTC (rev 2694) @@ -2,8 +2,19 @@ VEGAN DEVEL VERSIONS at http://r-forge.r-project.org/ -Version 2.1-38 (opened November 5, 2013) +Version 2.1-39 (opened November 10, 2013) + * anova.cca: started to rewrite the anova.cca family of functions + for permute package. At the first stage, a temporary development + function anovacca was created. The user interface was changed, and + the function no more adapts the number of iterations for the + P-value, and arguments 'step' and 'perm.max' were removed. + Instead, permute package is used to create a permutation matrix + used in all cases with fixed number of permutations. At the first + stage, only the overall test is provided. + +Version 2.1-38 (closed November 10, 2013) + * DESCRIPTION: depends on permute >= 0.7-5, where the permute::how() result object can be updated. Added: pkg/vegan/man/anovacca.Rd =================================================================== --- pkg/vegan/man/anovacca.Rd (rev 0) +++ pkg/vegan/man/anovacca.Rd 2013-11-10 14:20:42 UTC (rev 2694) @@ -0,0 +1,157 @@ +\name{anovacca} +\alias{anovacca} +%\alias{anova.ccanull} +%\alias{anova.ccabyaxis} +%\alias{anova.ccabyterm} +%\alias{anova.ccabymargin} +%\alias{anova.prc} +%\alias{permutest} +%\alias{permutest.default} +%\alias{permutest.cca} + +\title{Permutation Test for Constrained Correspondence Analysis, + Redundancy Analysis and Constrained Analysis of Principal Coordinates } + +\description{ + The function performs an ANOVA like permutation test for Constrained + Correspondence Analysis (\code{\link{cca}}), Redundancy Analysis + (\code{\link{rda}}) or distance-based Redundancy Analysis (dbRDA, + \code{\link{capscale}}) to assess the significance of constraints. + + This function is still experimental and unstable, but is scheduled + to replace \code{\link{anova.cca}} in the future. } + +\usage{ +anovacca(object, ..., permutations = how(nperm=999), + by = NULL) +} + +\arguments{ + + \item{object}{A result object from \code{\link{cca}}, + \code{\link{rda}} or \code{\link{capscale}}. } + + \item{permutations}{Either a \code{\link[permute]{how}} result + defining permutations, or a permutation matrix with each row giving + the permutation indices, or the number of permutations for simple + permutations. See \code{\link{permutations}} for details.} + + \item{by}{Setting \code{by = "axis"} will assess significance for + each constrained axis, and setting \code{by = "terms"} will assess + significance for each term (sequentially from first to last), and + setting \code{by = "margin"} will assess the marginal effects of + the terms (each marginal term analysed in a model with all other + variables). Not yet implemented.} + + \item{\dots}{Parameters passed to other functions. \code{anova.cca} + passes all arguments to \code{permutest.cca}. In \code{anova} with + \code{by = "axis"} you can use argument \code{cutoff} (defaults + \code{1}) which stops permutations after exceeding the given + level. } +} + +\details{ + + Functions \code{anova.cca} and \code{permutest.cca} implement an + ANOVA like permutation test for the joint effect of constraints in + \code{\link{cca}}, \code{\link{rda}} or \code{\link{capscale}}. + Functions \code{anova.cca} and \code{permutest.cca} differ in + printout style and in interface. Function \code{permutest.cca} is + the proper workhorse, but \code{anova.cca} passes all parameters to + \code{permutest.cca}. + + The default test is for the sum of all constrained eigenvalues. + Setting \code{first = TRUE} will perform a test for the first + constrained eigenvalue. Argument \code{first} can be set either in + \code{anova.cca} or in \code{permutest.cca}. It is also possible to + perform significance tests for each axis or for each term + (constraining variable) using argument \code{by} in + \code{anova.cca}. Setting \code{by = "axis"} will perform separate + significance tests for each constrained axis. All previous + constrained axes will be used as conditions (\dQuote{partialled + out}) and a test for the first constrained eigenvalues is + performed (Legendre et al. 2011). + You can stop permutation tests after exceeding a given + significance level with argument \code{cutoff} to speed up + calculations in large models. Setting \code{by = "terms"} will + perform separate significance test for each term (constraining + variable). The terms are assessed sequentially from first to last, + and the order of the terms will influence their + significances. Setting \code{by = "margin"} will perform separate + significance test for each marginal term in a model with all other + terms. The marginal test also accepts a \code{scope} argument for + the \code{\link{drop.scope}} which can be a character vector of term + labels that are analysed, or a fitted model of lower scope. The + marginal effects are also known as \dQuote{Type III} effects, but + the current function only evaluates marginal terms. It will, for + instance, ignore main effects that are included in interaction + terms. In calculating pseudo-\eqn{F}, all terms are compared to the + same residual of the full model. Permutations for all axes or terms + will start from the same \code{\link{.Random.seed}}, and the seed + will be advanced to the value after the longest permutation at the + exit from the function. + + Community data are permuted with choice \code{model="direct"}, + residuals after partial CCA/ RDA/ dbRDA with choice + \code{model="reduced"} (default), and residuals after CCA/ RDA/ + dbRDA under choice \code{model="full"}. If there is no partial CCA/ + RDA/ dbRDA stage, \code{model="reduced"} simply permutes the data + and is equivalent to \code{model="direct"}. The test statistic is + \dQuote{pseudo-\eqn{F}}, which is the ratio of constrained and + unconstrained total Inertia (Chi-squares, variances or something + similar), each divided by their respective ranks. If there are no + conditions (\dQuote{partial} terms), the sum of all eigenvalues + remains constant, so that pseudo-\eqn{F} and eigenvalues would give + equal results. In partial CCA/ RDA/ dbRDA, the effect of + conditioning variables (\dQuote{covariables}) is removed before + permutation, and these residuals are added to the non-permuted + fitted values of partial CCA (fitted values of \code{X ~ Z}). + Consequently, the total Chi-square is not fixed, and test based on + pseudo-\eqn{F} would differ from the test based on plain + eigenvalues. CCA is a weighted method, and environmental data are + re-weighted at each permutation step using permuted weights. } + +\value{ + The function \code{anovacca} calls \code{permutest.cca} and fills an + \code{\link{anova}} table. +} + +\note{ + Some cases of \code{anova} need access to the original data on + constraints (at least \code{by = "term"} and \code{by = "margin"}), + and they may fail if data are unavailable. + + The default permutation \code{model} changed from \code{"direct"} to + \code{"reduced"} in \pkg{vegan} version 1.15-0, and you must + explicitly set \code{model = "direct"} for compatibility with the old + version. + + Tests \code{by = "terms"} and \code{by = "margin"} are consistent + only when \code{model = "direct"}. +} +\references{ + Legendre, P. and Legendre, L. (2012). \emph{Numerical Ecology}. 3rd + English ed. Elsevier. + + Legendre, P., Oksanen, J. and ter Braak, C.J.F. (2011). Testing the + significance of canonical axes in redundancy analysis. + \emph{Methods in Ecology and Evolution} 2, 269--277. +} +\author{Jari Oksanen} + +\seealso{\code{\link{anova.cca}}, \code{\link{cca}}, + \code{\link{rda}}, \code{\link{capscale}} to get something to + analyse. Function \code{\link{drop1.cca}} calls \code{anova.cca} + with \code{by = "margin"}, and \code{\link{add1.cca}} an analysis + for single terms additions, which can be used in automatic or + semiautomatic model building (see \code{\link{deviance.cca}}). } + +\examples{ +data(varespec) +data(varechem) +vare.cca <- cca(varespec ~ Al + P + K, varechem) +## overall test +anovacca(vare.cca) +} +\keyword{ multivariate } +\keyword{ htest } From noreply at r-forge.r-project.org Sun Nov 10 16:08:25 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 10 Nov 2013 16:08:25 +0100 (CET) Subject: [Vegan-commits] r2695 - in pkg/vegan: R man Message-ID: <20131110150825.D867D1804C8@r-forge.r-project.org> Author: jarioksa Date: 2013-11-10 16:08:25 +0100 (Sun, 10 Nov 2013) New Revision: 2695 Modified: pkg/vegan/R/anovacca.R pkg/vegan/man/anovacca.Rd Log: add permute support to anovacca Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-11-10 14:20:42 UTC (rev 2694) +++ pkg/vegan/R/anovacca.R 2013-11-10 15:08:25 UTC (rev 2695) @@ -1,5 +1,6 @@ `anovacca` <- - function(object, ..., permutations = how(nperm=999), by = NULL) + function(object, ..., permutations = how(nperm=999), by = NULL, + strata = NULL) { if (is.null(object$CA) || is.null(object$CCA) || object$CCA$rank == 0 || object$CA$rank == 0) @@ -8,10 +9,33 @@ by <- match.arg(by, c("axis", "terms", "margin")) .NotYetUsed("by") } - seed <- NULL + if (!exists(".Random.seed", envir = .GlobalEnv, + inherits = FALSE)) + runif(1) + seed <- get(".Random.seed", envir = .GlobalEnv, inherits = FALSE) + ## permutations is either a single number, a how() structure or a + ## permutation matrix + if (length(permutations) == 1) { + nperm <- permutations + permutations <- how(nperm = nperm) + } + if (!is.null(strata)) { + if (!inherits(permutations, "how")) + stop("'strata' can be used only with simple permutation or with 'how()'") + if (!is.null(permutations$block)) + stop("'strata' cannot be applied when 'blocks' are defined in 'how()'") + permutations <- update(permutations, blocks = strata) + } + ## now permutations is either a how() structure or a permutation + ## matrix. Make it to a matrix if it is "how" + if (inherits(permutations, "how")) + permutations <- shuffleSet(nrow(object$CCA$u), + control = permutations) + else # we got a permutation matrix and seed is unknown + seed <- NA + nperm <- nrow(permutations) + ## stop permutations block tst <- permutest.cca(object, permutations = permutations, ...) - if (is.null(seed)) - seed <- tst$Random.seed Fval <- c(tst$F.0, NA) Pval <- (sum(tst$F.perm >= tst$F.0) + 1)/(tst$nperm + 1) Pval <- c(Pval, NA) Modified: pkg/vegan/man/anovacca.Rd =================================================================== --- pkg/vegan/man/anovacca.Rd 2013-11-10 14:20:42 UTC (rev 2694) +++ pkg/vegan/man/anovacca.Rd 2013-11-10 15:08:25 UTC (rev 2695) @@ -23,7 +23,7 @@ \usage{ anovacca(object, ..., permutations = how(nperm=999), - by = NULL) + by = NULL, strata = NULL) } \arguments{ @@ -43,6 +43,14 @@ the terms (each marginal term analysed in a model with all other variables). Not yet implemented.} + \item{strata}{An integer vector or factor specifying the strata for + permutation. If supplied, observations are permuted only within + the specified strata. It is an error to use this when + \code{permutations} is a matrix, or a \code{\link[permute]{how}} + defines \code{blocks}. This is a legacy argument that will be + deprecated in the future: use + \code{permutations = how(\dots, blocks)} instead. } + \item{\dots}{Parameters passed to other functions. \code{anova.cca} passes all arguments to \code{permutest.cca}. In \code{anova} with \code{by = "axis"} you can use argument \code{cutoff} (defaults From noreply at r-forge.r-project.org Sun Nov 10 16:42:29 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 10 Nov 2013 16:42:29 +0100 (CET) Subject: [Vegan-commits] r2696 - in pkg/vegan: R man Message-ID: <20131110154229.172C6186190@r-forge.r-project.org> Author: jarioksa Date: 2013-11-10 16:42:28 +0100 (Sun, 10 Nov 2013) New Revision: 2696 Modified: pkg/vegan/R/anova.ccalist.R pkg/vegan/R/anovacca.R pkg/vegan/man/anovacca.Rd Log: anovacca gained support for anova.ccalist Modified: pkg/vegan/R/anova.ccalist.R =================================================================== --- pkg/vegan/R/anova.ccalist.R 2013-11-10 15:08:25 UTC (rev 2695) +++ pkg/vegan/R/anova.ccalist.R 2013-11-10 15:42:28 UTC (rev 2696) @@ -1,16 +1,7 @@ `anova.ccalist` <- function(object, ..., permutations = 99) { - ## Collect cca class objects. FIXME: Eventually this should be in - ## a function that calls permutest.ccalist after collecting model - ## objects from dotargs. - dotargs <- list(...) - if (length(dotargs)) { - isCCA <- sapply(dotargs, function(z) inherits(z, "cca")) - dotargs <- dotargs[isCCA] - if (length(dotargs)) - object <- c(list(object), dotargs) - } + ## 'object' *must* be a list of cca objects nmodels <- length(object) ## check that input is valid ## 1. All models must be fitted with the same method Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-11-10 15:08:25 UTC (rev 2695) +++ pkg/vegan/R/anovacca.R 2013-11-10 15:42:28 UTC (rev 2696) @@ -5,10 +5,7 @@ if (is.null(object$CA) || is.null(object$CCA) || object$CCA$rank == 0 || object$CA$rank == 0) return(anova.ccanull(object)) - if (!is.null(by)) { - by <- match.arg(by, c("axis", "terms", "margin")) - .NotYetUsed("by") - } + if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) runif(1) @@ -35,6 +32,24 @@ seed <- NA nperm <- nrow(permutations) ## stop permutations block + ## see if this was a list of ordination objects + dotargs <- list(...) + if (length(dotargs)) { + isCCA <- sapply(dotargs, function(z) inherits(z, "cca")) + dotargs <- dotargs[isCCA] + if (length(dotargs)) { + object <- c(list(object), dotargs) + sol <- anova.ccalist(object, ..., + permutations = permutations) + return(sol) + } + } + ## by cases + if (!is.null(by)) { + by <- match.arg(by, c("axis", "terms", "margin")) + .NotYetUsed("by") + } + ## basic overall test tst <- permutest.cca(object, permutations = permutations, ...) Fval <- c(tst$F.0, NA) Pval <- (sum(tst$F.perm >= tst$F.0) + 1)/(tst$nperm + 1) Modified: pkg/vegan/man/anovacca.Rd =================================================================== --- pkg/vegan/man/anovacca.Rd 2013-11-10 15:08:25 UTC (rev 2695) +++ pkg/vegan/man/anovacca.Rd 2013-11-10 15:42:28 UTC (rev 2696) @@ -28,8 +28,11 @@ \arguments{ - \item{object}{A result object from \code{\link{cca}}, - \code{\link{rda}} or \code{\link{capscale}}. } + \item{object}{One or several result objects from \code{\link{cca}}, + \code{\link{rda}} or \code{\link{capscale}}. If there are several + result objects, they are compared against each other in the ordre + they were supplied. For a single object, a test specified in + \code{by} or an overal test is given. } \item{permutations}{Either a \code{\link[permute]{how}} result defining permutations, or a permutation matrix with each row giving From noreply at r-forge.r-project.org Sun Nov 10 17:06:53 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 10 Nov 2013 17:06:53 +0100 (CET) Subject: [Vegan-commits] r2697 - pkg/vegan/R Message-ID: <20131110160653.B465B186577@r-forge.r-project.org> Author: jarioksa Date: 2013-11-10 17:06:53 +0100 (Sun, 10 Nov 2013) New Revision: 2697 Modified: pkg/vegan/R/anovacca.R Log: anovacca should work with a list of objects where the first one is unconstrained Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-11-10 15:42:28 UTC (rev 2696) +++ pkg/vegan/R/anovacca.R 2013-11-10 16:06:53 UTC (rev 2697) @@ -2,10 +2,6 @@ function(object, ..., permutations = how(nperm=999), by = NULL, strata = NULL) { - if (is.null(object$CA) || is.null(object$CCA) || - object$CCA$rank == 0 || object$CA$rank == 0) - return(anova.ccanull(object)) - if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) runif(1) @@ -26,7 +22,7 @@ ## now permutations is either a how() structure or a permutation ## matrix. Make it to a matrix if it is "how" if (inherits(permutations, "how")) - permutations <- shuffleSet(nrow(object$CCA$u), + permutations <- shuffleSet(nrow(object$CA$u), control = permutations) else # we got a permutation matrix and seed is unknown seed <- NA From noreply at r-forge.r-project.org Mon Nov 11 11:37:56 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 11 Nov 2013 11:37:56 +0100 (CET) Subject: [Vegan-commits] r2698 - pkg/vegan/R Message-ID: <20131111103757.12F59185764@r-forge.r-project.org> Author: jarioksa Date: 2013-11-11 11:37:56 +0100 (Mon, 11 Nov 2013) New Revision: 2698 Modified: pkg/vegan/R/anova.ccalist.R Log: *First* calculate F-values, only *then* evaluate their P-values Modified: pkg/vegan/R/anova.ccalist.R =================================================================== --- pkg/vegan/R/anova.ccalist.R 2013-11-10 16:06:53 UTC (rev 2697) +++ pkg/vegan/R/anova.ccalist.R 2013-11-11 10:37:56 UTC (rev 2698) @@ -65,10 +65,10 @@ ## dropped to vector? if (!is.matrix(pfvals)) pfvals <- matrix(pfvals, nrow=1, ncol=nperm) + pfvals <- sweep(pfvals, 1, df, "/") + pfvals <- sweep(pfvals, 2, pscale, "/") pval <- rowSums(sweep(pfvals, 1, fval, ">=")) pval <- (pval + 1)/(nperm+1) - pfvals <- sweep(pfvals, 1, df, "/") - pfvals <- sweep(pfvals, 2, pscale, "/") ## collect table table <- data.frame(resdf, resdev, c(NA, df), c(NA,changedev), c(NA,fval), c(NA,pval)) From noreply at r-forge.r-project.org Mon Nov 11 19:30:53 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 11 Nov 2013 19:30:53 +0100 (CET) Subject: [Vegan-commits] r2699 - pkg/vegan/R Message-ID: <20131111183053.5069918628D@r-forge.r-project.org> Author: jarioksa Date: 2013-11-11 19:30:52 +0100 (Mon, 11 Nov 2013) New Revision: 2699 Modified: pkg/vegan/R/anova.ccalist.R pkg/vegan/R/anovacca.R Log: anova.ccalist passes 'model' and 'parallel' permutest.cca (could be neater) Modified: pkg/vegan/R/anova.ccalist.R =================================================================== --- pkg/vegan/R/anova.ccalist.R 2013-11-11 10:37:56 UTC (rev 2698) +++ pkg/vegan/R/anova.ccalist.R 2013-11-11 18:30:52 UTC (rev 2699) @@ -1,7 +1,10 @@ `anova.ccalist` <- - function(object, ..., permutations = 99) + function(object, permutations, model, parallel) { - ## 'object' *must* be a list of cca objects + ## 'object' *must* be a list of cca objects, and 'permutations' + ## *must* be a permutation matrix -- we assume that calling + ## function takes care of this, and this function is not directly + ## called by users. nmodels <- length(object) ## check that input is valid ## 1. All models must be fitted with the same method @@ -27,11 +30,7 @@ if(!all(trms[[o[i-1]]] %in% trms[[o[i]]])) stop("models must be nested") - ## Create permutation matrix if it does not exist. FIXME: should - ## take arguments for restricted permutation - if (length(permutations) == 1) - permutations <- shuffleSet(N, permutations) - ## permutations is now matrix + ## Check permutation matrix nperm <- nrow(permutations) ## check if (ncol(permutations) != N) @@ -42,9 +41,10 @@ ## be used to assess the significance of differences of fitted ## models. This strictly requires nested models (not checked ## here): all terms of the smaller model must be included in the - ## larger model. FIXME: should pass arguments to permutest.cca. + ## larger model. mods <- lapply(object, function(z) - permutest(z, permutations = permutations)) + permutest.cca(z, permutations = permutations, + model = model, parallel = parallel)) dfs <- sapply(mods, function(z) z$df) dev <- sapply(mods, function(z) z$chi) resdf <- dfs[2,] Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-11-11 10:37:56 UTC (rev 2698) +++ pkg/vegan/R/anovacca.R 2013-11-11 18:30:52 UTC (rev 2699) @@ -32,11 +32,24 @@ dotargs <- list(...) if (length(dotargs)) { isCCA <- sapply(dotargs, function(z) inherits(z, "cca")) - dotargs <- dotargs[isCCA] - if (length(dotargs)) { + if (any(isCCA)) { + ## we do not want to give dotargs to anova.ccalist, but we + ## evaluate 'parallel' and 'model' here + if (is.null(dotargs$model)) + model <- "reduced" + else + model <- dotargs$model + if (is.null(dotargs$parallel)) + parallel <- NULL + else + parallel <- dotargs$parallel + dotargs <- dotargs[isCCA] object <- c(list(object), dotargs) - sol <- anova.ccalist(object, ..., - permutations = permutations) + sol <- + anova.ccalist(object, + permutations = permutations, + model = model, + parallel = parallel) return(sol) } } From noreply at r-forge.r-project.org Tue Nov 12 21:17:26 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Nov 2013 21:17:26 +0100 (CET) Subject: [Vegan-commits] r2700 - in pkg/permute: R inst man Message-ID: <20131112201726.9B3AD184C50@r-forge.r-project.org> Author: gsimpson Date: 2013-11-12 21:17:26 +0100 (Tue, 12 Nov 2013) New Revision: 2700 Modified: pkg/permute/R/shuffleSet2.R pkg/permute/inst/ChangeLog pkg/permute/man/shuffleSet.Rd Log: a better way of handling small permutation sets; generate all of them, and then sample nset of them. Modified: pkg/permute/R/shuffleSet2.R =================================================================== --- pkg/permute/R/shuffleSet2.R 2013-11-11 18:30:52 UTC (rev 2699) +++ pkg/permute/R/shuffleSet2.R 2013-11-12 20:17:26 UTC (rev 2700) @@ -7,6 +7,8 @@ nset <- 1 else nset <- np + } else { + control <- update(control, nperm = nset) } sn <- seq_len(n) ## sequence of samples in order of input @@ -50,6 +52,16 @@ ## Use that instead of a ranodm set out <- control$all.perms } + + ## Because all.perms might have been generated, we have the + ## possibility that nrow(out) != nset. In that case, also no random + ## numbers have been generated. Hence we can sample nset rows from + ## out and return that. This has the nice side-effect of not + ## generating any non-unique permutations. Suggested by Jari. + if ((nr <- nrow(out)) > nset) { + out <- out[sample.int(nr, nset), ] + } + out } Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-11 18:30:52 UTC (rev 2699) +++ pkg/permute/inst/ChangeLog 2013-11-12 20:17:26 UTC (rev 2700) @@ -2,6 +2,21 @@ permute ChangeLog +Version 0.7-7 + + * shuffleSet: Implemented an idea of Jari's to allow `check()` and + `allPerms()` to do their thing and possibly generate the set of all + permutations, rather than turn off checking. If that now results in + more than `nset` permutations, `shuffleSet` randomly takes `nset` of + these. This is a nice suggestion as it avoids the problem that with + small numbers of possible permutations, you can randomly draw the + same permutation more than once. + + As I have added this feature, I reverted some earlier changes to the + documentation that used the `check = FALSE` in their call to + `shuffleSet()`. The `check` argument is retained though, as a way for + function writers to skip that part of the permute workflow if desired. + Version 0.7-6 * summary.allPerms: Was printing two slightly different subtitles. Modified: pkg/permute/man/shuffleSet.Rd =================================================================== --- pkg/permute/man/shuffleSet.Rd 2013-11-11 18:30:52 UTC (rev 2699) +++ pkg/permute/man/shuffleSet.Rd 2013-11-12 20:17:26 UTC (rev 2700) @@ -126,7 +126,7 @@ ## as above, but with same permutation for each Plot-level stratum CTRL <- how(plots = plotStrata, within = Within(type = "series", constant = TRUE)) -shuffleSet(20, 10, CTRL, check = FALSE) +shuffleSet(20, 10, CTRL) } % Add one or more standard keywords, see file 'KEYWORDS' in the % R documentation directory. From noreply at r-forge.r-project.org Tue Nov 12 21:22:29 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Nov 2013 21:22:29 +0100 (CET) Subject: [Vegan-commits] r2701 - in pkg/permute: R inst man Message-ID: <20131112202229.43C1E185DC6@r-forge.r-project.org> Author: gsimpson Date: 2013-11-12 21:22:28 +0100 (Tue, 12 Nov 2013) New Revision: 2701 Modified: pkg/permute/R/allPerms.R pkg/permute/inst/ChangeLog pkg/permute/man/allPerms.Rd Log: add argument 'check'; turn on some messages Modified: pkg/permute/R/allPerms.R =================================================================== --- pkg/permute/R/allPerms.R 2013-11-12 20:17:26 UTC (rev 2700) +++ pkg/permute/R/allPerms.R 2013-11-12 20:22:28 UTC (rev 2701) @@ -1,4 +1,4 @@ -`allPerms` <- function(n, control = how()) { +`allPerms` <- function(n, control = how(), check = TRUE) { ## start v <- n ## expand n if a numeric or integer vector of length 1 @@ -8,7 +8,8 @@ n <- nobs(v) ## check permutation scheme and update control make <- getMake(control) - pcheck <- check(v, control = update(control, make = FALSE)) + if (check) + pcheck <- check(v, control = update(control, make = FALSE)) ## ctrl <- pcheck$control ## if we do copy the new updated control, we need to update to ## reset make Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-12 20:17:26 UTC (rev 2700) +++ pkg/permute/inst/ChangeLog 2013-11-12 20:22:28 UTC (rev 2701) @@ -17,6 +17,18 @@ `shuffleSet()`. The `check` argument is retained though, as a way for function writers to skip that part of the permute workflow if desired. + * allPerms: gains an argument `check`, which defaults to `TRUE`. This + is used to turn off checking within `allPerms` if desired. A use-case + for this is in `check()`, which might end up caling `allPerms()` to + generate the set of all permutations. In that case `allPerms()` used + to recheck the design. Now this doesn't happen. + + Turned on some `message()`s when the user asks for too many permutations + (more than the set of possible permutations) and when the set of + possible permutations is smaller than the `minperm` value stored in the + `"how"` object. The latter notifies the user that the entire set of + permutations is being generated. + Version 0.7-6 * summary.allPerms: Was printing two slightly different subtitles. Modified: pkg/permute/man/allPerms.Rd =================================================================== --- pkg/permute/man/allPerms.Rd 2013-11-12 20:17:26 UTC (rev 2700) +++ pkg/permute/man/allPerms.Rd 2013-11-12 20:22:28 UTC (rev 2701) @@ -10,7 +10,7 @@ permutations for a given R object and a specified permutation design. } \usage{ -allPerms(n, control = how()) +allPerms(n, control = how(), check = TRUE) \method{summary}{allPerms}(object, \dots) } @@ -20,6 +20,9 @@ \item{control}{a list of control values describing properties of the permutation design, as returned by a call to \code{\link{how}}.} + \item{check}{logical; should \code{allPerms} check the design? The + default is to check, but this can be skipped, for example if a + function checked the design earlier.} \item{object}{an object of class \code{"allPerms"}.} \item{\dots}{arguments to other methods.} } From noreply at r-forge.r-project.org Tue Nov 12 21:22:59 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Nov 2013 21:22:59 +0100 (CET) Subject: [Vegan-commits] r2702 - pkg/permute/inst Message-ID: <20131112202259.B1030183CE5@r-forge.r-project.org> Author: gsimpson Date: 2013-11-12 21:22:59 +0100 (Tue, 12 Nov 2013) New Revision: 2702 Modified: pkg/permute/inst/TODO.md Log: Noticed an issue with numPerms that I need to look into Modified: pkg/permute/inst/TODO.md =================================================================== --- pkg/permute/inst/TODO.md 2013-11-12 20:22:28 UTC (rev 2701) +++ pkg/permute/inst/TODO.md 2013-11-12 20:22:59 UTC (rev 2702) @@ -61,3 +61,16 @@ *DONE Completed somewhere, probably when I made observed only work via how()* + * The following example from `shuffleSet()` gives same number of + permutations via `numPerms()` for both designs; should be fewer if + same permutation within each plot. + + ## 10 random permutations in presence of Plot-level strata + plotStrata <- Plots(strata = gl(4,5)) + CTRL <- how(plots = plotStrata, + within = Within(type = "free")) + shuffleSet(20, 10, control = CTRL) + ## as above but same random permutation within Plot-level strata + CTRL <- how(plots = plotStrata, + within = Within(type = "free", constant = TRUE)) + shuffleSet(20, 10, CTRL) From noreply at r-forge.r-project.org Tue Nov 12 21:25:29 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Nov 2013 21:25:29 +0100 (CET) Subject: [Vegan-commits] r2703 - in pkg/permute: R inst Message-ID: <20131112202529.B59A4183CE5@r-forge.r-project.org> Author: gsimpson Date: 2013-11-12 21:25:29 +0100 (Tue, 12 Nov 2013) New Revision: 2703 Modified: pkg/permute/R/check.R pkg/permute/inst/ChangeLog Log: 'check' no longer calls itself via 'allPerms' during checking Modified: pkg/permute/R/check.R =================================================================== --- pkg/permute/R/check.R 2013-11-12 20:22:59 UTC (rev 2702) +++ pkg/permute/R/check.R 2013-11-12 20:25:29 UTC (rev 2703) @@ -68,9 +68,10 @@ ## check if number requested permutations exceeds max possible if(getNperm(control) > num.pos) { control <- update(control, nperm = num.pos, maxperm = num.pos, - complete = TRUE) + complete = TRUE) control$call[["nperm"]] <- eval(control$call[["nperm"]]) control$call[["maxperm"]] <- eval(control$call[["maxperm"]]) + message("Requested number of permutations larger than entire set of possible permutations.\nReseting 'nperm' to number of permutations in entire set.") } ## if number of possible perms < minperm turn on complete enumeration @@ -79,11 +80,12 @@ complete = TRUE) control$call[["nperm"]] <- eval(control$call[["nperm"]]) control$call[["maxperm"]] <- eval(control$call[["maxperm"]]) + message("Number of permutations possible is less than 'minperm'.\nTurning on complete enumeration via 'complete = TRUE'. See '?how' for details.") } ## if complete enumeration, generate all permutations if(getComplete(control) && getMake(control)) { - ap <- allPerms(N, control = control) + ap <- allPerms(N, control = control, check = FALSE) control <- update(control, all.perms = ap) control$call[["all.perms"]] <- eval(control$call[["all.perms"]]) } Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-12 20:22:59 UTC (rev 2702) +++ pkg/permute/inst/ChangeLog 2013-11-12 20:25:29 UTC (rev 2703) @@ -29,6 +29,11 @@ `"how"` object. The latter notifies the user that the entire set of permutations is being generated. + * check: following the change to `allPerms` (see above), `check()` no + longer results in it calling itself, via `allPerms()`, when generating + the set of possible permutations if the check heuristics indicate it + should be. + Version 0.7-6 * summary.allPerms: Was printing two slightly different subtitles. From noreply at r-forge.r-project.org Tue Nov 12 21:26:23 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Nov 2013 21:26:23 +0100 (CET) Subject: [Vegan-commits] r2704 - pkg/permute/vignettes Message-ID: <20131112202623.BC838183CE5@r-forge.r-project.org> Author: gsimpson Date: 2013-11-12 21:26:23 +0100 (Tue, 12 Nov 2013) New Revision: 2704 Modified: pkg/permute/vignettes/permutations.Rnw Log: updated to reflect change in 'shuffleSet()' in r2700 Modified: pkg/permute/vignettes/permutations.Rnw =================================================================== --- pkg/permute/vignettes/permutations.Rnw 2013-11-12 20:25:29 UTC (rev 2703) +++ pkg/permute/vignettes/permutations.Rnw 2013-11-12 20:26:23 UTC (rev 2704) @@ -242,7 +242,7 @@ <>= set.seed(4) CTRL <- how(within = Within(type = "series")) -pset <- shuffleSet(10, nset = 5, control = CTRL, check = FALSE) +pset <- shuffleSet(10, nset = 5, control = CTRL) pset @ Note that we set \code{check = FALSE} in the call. As there are only 10 permutations of these data (including the observed one), by default \code{shuffleSet()} will check the permutation design and, following a few heuristics\footnote{Values used in these heuristics can be set when you create the permutation design with \code{how()}. See \code{?how} for further details and \code{?check} for the function that does the checking.}, will in this case generate all ten permutations. Setting \code{check = FALSE} turns this checking off, enabling exactly \code{nset} permutations to be returned. The downside of this is that you need to be aware of the implications of not checking the design; with a limited number of possible permutations, there is no guarantee that \code{shuffleSet()} will generate a set of \code{nset} unique permutations. @@ -259,9 +259,34 @@ One advantage of using \code{nperm} is that \code{shuffleSet()} will use this if the \code{nset} argument is not specified. Additionally, \code{shuffleSet()} will check to see if the desired number of permutations is possible given the data and the requested design. This is done via the function \code{check()}, which is discussed later. -\subsection{Permuting samples at the lowest level} -At the lowest level of a permutation design in \pkg{permute} +\subsection{The levels of the permutation hierarchy} +There are three levels at which permutations can be controlled in \pkg{permute}. The highest level of the hierarchy is the \emph{block} level. Blocks are defined by a factor vector. Blocks restrict permutation of samples to within the levels of this factor; samples are never swapped between blocks. +The \emph{plot} level sits below blocks. Plots are defined by a factor and group samples in the same way as blocks. As such, some permutation designs can be initiated using a factor at the plot level or the same factor at the plot level. The major difference between blocks and plots is that plots can also be permuted, whereas blocks are never permuted. + +The lowest level of a permutation design in \pkg{permute} hierarchy is known as \emph{within}, and refers to samples nested \emph{within} plots. If there are no plots or blocks, how samples are permuted at the \emph{within} level applies to the entire data set. + +\subsubsection{Permuting samples at the lowest level} +How samples at the \emph{within} level are permuted is configured using the \code{Within()} function. It takes the following arguments +<>= +args(Within) +@ + +\begin{description} + \item[\code{type}] + controls how the samples at the lowest level are permuted. The default is to form unrestricted permutations via option \code{"type"}. Options \code{"series"} and \code{"grid"} form restricted permutations via cyclic or toroidal shifts, respectively. The former is useful for samples that are a time series or line-transect, whilst the latter is used for samples on a regular spatial grid. The final option, \code{"none"}, will result in the samples at the lowest level not being permuted at all. This option is only of practical use when there are plots within the permutation/experimental design\footnote{As blocks are never permuted, using \code{type = "none"} at the \emph{within} level is also of no practical use.}. + \item[\code{constant}] + this argument only has an effect when there are plots in the design\footnote{Owing to the current implementation, whilst this option could also be useful when blocks to define groups of samples, it will not have any influence over how permutations are generated. As such, only use blocks for simple blocking structures and use plots if you require greater control of the permutations at the group (i.e. plot) level.}. \code{constant = FALSE}, stipulates that each plot should have the same \emph{within-plot} permutation. This is useful when you have time series of observations from several plots. If all plots were sampled at the same time points, it can be argued that the plot level, the samples experienced the same \emph{time} and hence the same permutation should be used within each plot. + \item[\code{mirror}] + when \code{type} is \code{"series"} or \code{"grid"}, argument \code{"mirror"} controls whether permutations are taken from the mirror image of the observed ordering in space or time. Consider the sequence \code{1, 2, 3, 4}. The relationship between observations is also preserved if we reverse the original ordering to \code{4, 3, 2, 1} and generate permutations from both these orderings. This is what happens when \code{mirror = TRUE}. For time series, the reversed ordering \code{4, 3, 2, 1} would imply an influence of observation 4 on observation 3, which is implausible. For spatial grids or line transects, however, this is a sensible option, and can significantly increase the number of possible permutations\footnote{Setting \code{mirror = TRUE} will double or quadruple the set of permutations for \code{"series"} or \code{"grid"} permutations, respectively, as long as there are more than two time points or columns in the grid.}. + \item[\code{ncol}, \code{nrow}] + define the dimensions of the spatial grid. +\end{description} + +How \code{Within()} is used has already been encountered in earlier sections of this vignette; the function is used to supply a value to the \code{within} argument of \code{how()}. You may have noticed that all the arguments of \code{Within()} have default values? This means that the user need only supply a modified value for the arguments they wish to change. Also, arguments that are not relevant for the type of permutation stated are simply ignored; \code{nrow} and \code{ncol}, for example, could be set to any value without affecting the permutation design if \code{type != "grid"}\footnote{No warnings are currently given if incompatible arguments are specified; they are ignored, but may show up in the printed output. This infelicity will be removed prior to \pkg{permute} version 1.0-0 being released.}. + +\subsubsection{Permuting samples at the Plot level} + \section*{Computational details} <>= toLatex(sessionInfo()) From noreply at r-forge.r-project.org Tue Nov 12 21:54:42 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Nov 2013 21:54:42 +0100 (CET) Subject: [Vegan-commits] r2705 - pkg/permute Message-ID: <20131112205442.6C439185A59@r-forge.r-project.org> Author: gsimpson Date: 2013-11-12 21:54:42 +0100 (Tue, 12 Nov 2013) New Revision: 2705 Modified: pkg/permute/DESCRIPTION Log: forgot to push this to bump the minor patch release to 0.7-7 Modified: pkg/permute/DESCRIPTION =================================================================== --- pkg/permute/DESCRIPTION 2013-11-12 20:26:23 UTC (rev 2704) +++ pkg/permute/DESCRIPTION 2013-11-12 20:54:42 UTC (rev 2705) @@ -1,6 +1,6 @@ Package: permute Title: Functions for generating restricted permutations of data -Version: 0.7-6 +Version: 0.7-7 Date: $Date$ Author: Gavin L. Simpson Maintainer: Gavin L. Simpson From noreply at r-forge.r-project.org Tue Nov 12 22:06:34 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 12 Nov 2013 22:06:34 +0100 (CET) Subject: [Vegan-commits] r2706 - in pkg/permute: . R inst Message-ID: <20131112210635.0E45B184495@r-forge.r-project.org> Author: gsimpson Date: 2013-11-12 22:06:34 +0100 (Tue, 12 Nov 2013) New Revision: 2706 Added: pkg/permute/R/as.matrix.permutationMatrix.R pkg/permute/R/print.permutationMatrix.R Modified: pkg/permute/NAMESPACE pkg/permute/R/shuffleSet2.R pkg/permute/inst/ChangeLog pkg/permute/inst/TODO.md Log: shuffleSet returns an object of class 'permutationMatrix' which has S3 methods for 'as.matrix()' and 'print()', which are registered but not exported Modified: pkg/permute/NAMESPACE =================================================================== --- pkg/permute/NAMESPACE 2013-11-12 20:54:42 UTC (rev 2705) +++ pkg/permute/NAMESPACE 2013-11-12 21:06:34 UTC (rev 2706) @@ -16,11 +16,13 @@ } ### S3 Methods +S3method(`as.matrix`, `permutationMatrix`) ## print methods S3method(`print`, `allPerms`) S3method(`print`, `check`) S3method(`print`, `how`) S3method(`print`, `permControl`) +S3method(`print`, `permutationMatrix`) S3method(`print`, `summary.allPerms`) S3method(`print`, `summary.check`) ## summary methods Added: pkg/permute/R/as.matrix.permutationMatrix.R =================================================================== --- pkg/permute/R/as.matrix.permutationMatrix.R (rev 0) +++ pkg/permute/R/as.matrix.permutationMatrix.R 2013-11-12 21:06:34 UTC (rev 2706) @@ -0,0 +1,10 @@ +## as.matrix.permutationMatrix - an S3 method to convert to the S3 +## matrix class. Essentially this just strips attributes and updates +## the class to only "matrix" + +`as.matrix.permutationMatrix` <- function(x, ...) { + attr(x, "seed") <- NULL + attr(x, "control") <- NULL + class(x) <- "matrix" + x +} Added: pkg/permute/R/print.permutationMatrix.R =================================================================== --- pkg/permute/R/print.permutationMatrix.R (rev 0) +++ pkg/permute/R/print.permutationMatrix.R 2013-11-12 21:06:34 UTC (rev 2706) @@ -0,0 +1,7 @@ +## Simple print method for objects of class "permutationMatrix" +## - at the moment, don't print the attributes + +`print.permutationMatrix` <- function(x, ...) { + x <- as.matrix(x) + print(x) +} Modified: pkg/permute/R/shuffleSet2.R =================================================================== --- pkg/permute/R/shuffleSet2.R 2013-11-12 20:54:42 UTC (rev 2705) +++ pkg/permute/R/shuffleSet2.R 2013-11-12 21:06:34 UTC (rev 2706) @@ -1,5 +1,12 @@ ## new version of shuffleSet() that allows for blocking `shuffleSet` <- function(n, nset, control = how(), check = TRUE) { + ## Store the .Random.seed, if it exists, so we can attach this as + ## an attribute to the permutation matrix returned in out + SEED <- NULL + if (exists(".Random.seed", envir = globalenv())) { + SEED <- .Random.seed + } + ## handle missing nset - take from control if can if(missing(nset)) { np <- getNperm(control) @@ -62,6 +69,16 @@ out <- out[sample.int(nr, nset), ] } + ## Attach random seed stored earlier to permutation matrix + attr(out, "seed") <- SEED + attr(out, "control") <- control + attr(out, "observed") <- NULL ## nullify this as allPerms may have added it? + + ## class the matrix so we can have a print method etc, but inherit from + ## the matrix S3 class + class(out) <- c("permutationMatrix", "matrix") + + ## return out } Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-12 20:54:42 UTC (rev 2705) +++ pkg/permute/inst/ChangeLog 2013-11-12 21:06:34 UTC (rev 2706) @@ -17,6 +17,9 @@ `shuffleSet()`. The `check` argument is retained though, as a way for function writers to skip that part of the permute workflow if desired. + The permutation matrix returned is now of class `"permutationMatrix"`. + This class has `as.matrix()` and `print()` S3 methods. + * allPerms: gains an argument `check`, which defaults to `TRUE`. This is used to turn off checking within `allPerms` if desired. A use-case for this is in `check()`, which might end up caling `allPerms()` to Modified: pkg/permute/inst/TODO.md =================================================================== --- pkg/permute/inst/TODO.md 2013-11-12 20:54:42 UTC (rev 2705) +++ pkg/permute/inst/TODO.md 2013-11-12 21:06:34 UTC (rev 2706) @@ -74,3 +74,7 @@ CTRL <- how(plots = plotStrata, within = Within(type = "free", constant = TRUE)) shuffleSet(20, 10, CTRL) + + * Write an Rd page for the `"permutationMatrix"` S3 class where I can + describe the object returned by `shuffleSet()` and the methods + available for it. From noreply at r-forge.r-project.org Wed Nov 13 05:53:05 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 13 Nov 2013 05:53:05 +0100 (CET) Subject: [Vegan-commits] r2707 - pkg/permute/man Message-ID: <20131113045306.10A6A185F15@r-forge.r-project.org> Author: gsimpson Date: 2013-11-13 05:53:04 +0100 (Wed, 13 Nov 2013) New Revision: 2707 Modified: pkg/permute/man/get-methods.Rd Log: remove a duplicated line in usage section Modified: pkg/permute/man/get-methods.Rd =================================================================== --- pkg/permute/man/get-methods.Rd 2013-11-12 21:06:34 UTC (rev 2706) +++ pkg/permute/man/get-methods.Rd 2013-11-13 04:53:04 UTC (rev 2707) @@ -81,7 +81,6 @@ getType(object, ...) getMirror(object, ...) getConstant(object, ...) -getConstant(object, ...) getCol(object, ...) getRow(object, ...) getDim(object, ...) From noreply at r-forge.r-project.org Fri Nov 15 13:37:55 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 15 Nov 2013 13:37:55 +0100 (CET) Subject: [Vegan-commits] r2708 - in pkg/vegan: R inst Message-ID: <20131115123755.B348B185CB4@r-forge.r-project.org> Author: jarioksa Date: 2013-11-15 13:37:55 +0100 (Fri, 15 Nov 2013) New Revision: 2708 Modified: pkg/vegan/R/print.oecosimu.R pkg/vegan/inst/ChangeLog Log: swap quantiles to match test direction as changed in r2495 Modified: pkg/vegan/R/print.oecosimu.R =================================================================== --- pkg/vegan/R/print.oecosimu.R 2013-11-13 04:53:04 UTC (rev 2707) +++ pkg/vegan/R/print.oecosimu.R 2013-11-15 12:37:55 UTC (rev 2708) @@ -28,8 +28,8 @@ } probs <- switch(x$oecosimu$alternative, two.sided = c(0.025, 0.5, 0.975), - less = c(0, 0.5, 0.95), - greater = c(0.05, 0.5, 1)) + greater = c(0, 0.5, 0.95), + less = c(0.05, 0.5, 1)) qu <- apply(x$oecosimu$simulated, 1, quantile, probs=probs, na.rm = TRUE) m <- cbind("statistic" = x$oecosimu$statistic, "z" = x$oecosimu$z, "mean" = x$oecosimu$means, t(qu), Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-11-13 04:53:04 UTC (rev 2707) +++ pkg/vegan/inst/ChangeLog 2013-11-15 12:37:55 UTC (rev 2708) @@ -12,6 +12,9 @@ Instead, permute package is used to create a permutation matrix used in all cases with fixed number of permutations. At the first stage, only the overall test is provided. + + * oecosimu: change printed quantiles to match the direction of the + test as changed in r2495. Version 2.1-38 (closed November 10, 2013) From noreply at r-forge.r-project.org Fri Nov 15 14:02:44 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 15 Nov 2013 14:02:44 +0100 (CET) Subject: [Vegan-commits] r2709 - pkg/vegan/tests/Examples Message-ID: <20131115130244.EFFBC185C1B@r-forge.r-project.org> Author: jarioksa Date: 2013-11-15 14:02:44 +0100 (Fri, 15 Nov 2013) New Revision: 2709 Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save Log: update examples Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save =================================================================== --- pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2013-11-15 12:37:55 UTC (rev 2708) +++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save 2013-11-15 13:02:44 UTC (rev 2709) @@ -1,5 +1,5 @@ -R Under development (unstable) (2013-07-10 r63264) -- "Unsuffered Consequences" +R Under development (unstable) (2013-11-15 r64218) -- "Unsuffered Consequences" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -22,7 +22,8 @@ > options(warn = 1) > library('vegan') Loading required package: permute -This is vegan 2.1-32 +Loading required package: lattice +This is vegan 2.1-39 > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > cleanEx() @@ -153,14 +154,15 @@ > plot(ef) > ordisurf(mod ~ pH, varechem, knots = 1, add = TRUE) Loading required package: mgcv -This is mgcv 1.7-24. For overview type 'help("mgcv-package")'. +Loading required package: nlme +This is mgcv 1.7-26. For overview type 'help("mgcv-package")'. Family: gaussian Link function: identity Formula: y ~ poly(x1, 1) + poly(x2, 1) - + Total model degrees of freedom 3 REML score: -3.185099 @@ -169,7 +171,7 @@ > > cleanEx() -detaching ?package:mgcv? +detaching ?package:mgcv?, ?package:nlme? > nameEx("MOStest") > ### * MOStest @@ -394,12 +396,12 @@ dune ~ 1 Df AIC F N.Perm Pr(>F) -+ Moisture 3 86.608 2.2536 199 0.005 ** ++ Moisture 3 86.608 2.2536 199 0.010 ** + Management 3 86.935 2.1307 199 0.005 ** -+ A1 1 87.411 2.1400 199 0.025 * ++ A1 1 87.411 2.1400 199 0.020 * 87.657 -+ Manure 4 88.832 1.5251 199 0.020 * -+ Use 2 89.134 1.1431 99 0.260 ++ Manure 4 88.832 1.5251 199 0.025 * ++ Use 2 89.134 1.1431 99 0.250 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 @@ -408,11 +410,11 @@ Df AIC F N.Perm Pr(>F) 86.608 -+ Management 3 86.813 1.4565 199 0.035 * -+ A1 1 86.992 1.2624 99 0.190 -+ Use 2 87.259 1.2760 99 0.130 -+ Manure 4 87.342 1.3143 199 0.075 . -- Moisture 3 87.657 2.2536 199 0.010 ** ++ Management 3 86.813 1.4565 199 0.020 * ++ A1 1 86.992 1.2624 99 0.150 ++ Use 2 87.259 1.2760 199 0.120 ++ Manure 4 87.342 1.3143 199 0.090 . +- Moisture 3 87.657 2.2536 199 0.005 ** --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Call: cca(formula = dune ~ Moisture, data = dune.env) @@ -446,21 +448,21 @@ > add1(m0, scope=formula(mbig), test="perm") Df AIC F N.Perm Pr(>F) 89.620 -A1 1 89.591 1.9217 199 0.030 * +A1 1 89.591 1.9217 199 0.070 . Moisture 3 87.707 2.5883 199 0.005 ** Management 3 87.082 2.8400 199 0.005 ** -Use 2 91.032 1.1741 99 0.170 +Use 2 91.032 1.1741 99 0.180 Manure 4 89.232 1.9539 199 0.010 ** --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > m0 <- update(m0, . ~ . + Management) > add1(m0, scope=formula(mbig), test="perm") - Df AIC F N.Perm Pr(>F) - 87.082 -A1 1 87.424 1.2965 99 0.200 -Moisture 3 85.567 1.9764 199 0.015 * -Use 2 88.284 1.0510 99 0.470 -Manure 3 87.517 1.3902 199 0.135 + Df AIC F N.Perm Pr(>F) + 87.082 +A1 1 87.424 1.2965 99 0.240 +Moisture 3 85.567 1.9764 199 0.005 ** +Use 2 88.284 1.0510 99 0.430 +Manure 3 87.517 1.3902 199 0.130 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > m0 <- update(m0, . ~ . + Moisture) @@ -468,16 +470,16 @@ > drop1(m0, test="perm") Df AIC F N.Perm Pr(>F) 85.567 -Management 3 87.707 2.1769 199 0.005 ** -Moisture 3 87.082 1.9764 199 0.010 ** +Management 3 87.707 2.1769 199 0.010 ** +Moisture 3 87.082 1.9764 199 0.015 * --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > add1(m0, scope=formula(mbig), test="perm") Df AIC F N.Perm Pr(>F) 85.567 -A1 1 86.220 0.8359 99 0.62 -Use 2 86.842 0.8027 99 0.72 -Manure 3 85.762 1.1225 99 0.27 +A1 1 86.220 0.8359 99 0.72 +Use 2 86.842 0.8027 99 0.77 +Manure 3 85.762 1.1225 99 0.26 > > > @@ -664,7 +666,6 @@ > Agropyron <- with(dat, as.numeric(field) + as.numeric(NO3)+2) +rnorm(12)/2 > Schizachyrium <- with(dat, as.numeric(field) - as.numeric(NO3)+2) +rnorm(12)/2 > total <- Agropyron + Schizachyrium -> library(lattice) > dotplot(total ~ NO3, dat, jitter.x=TRUE, groups=field, + type=c('p','a'), xlab="NO3", auto.key=list(columns=3, lines=TRUE) ) > @@ -716,9 +717,6 @@ > > > cleanEx() - -detaching ?package:lattice? - > nameEx("anosim") > ### * anosim > @@ -847,6 +845,36 @@ > > > cleanEx() +> nameEx("anovacca") +> ### * anovacca +> +> flush(stderr()); flush(stdout()) +> +> ### Name: anovacca +> ### Title: Permutation Test for Constrained Correspondence Analysis, +> ### Redundancy Analysis and Constrained Analysis of Principal Coordinates +> ### Aliases: anovacca +> ### Keywords: multivariate htest +> +> ### ** Examples +> +> data(varespec) +> data(varechem) +> vare.cca <- cca(varespec ~ Al + P + K, varechem) +> ## overall test +> anovacca(vare.cca) +Permutation test for cca under reduced model + +Model: cca(formula = varespec ~ Al + P + K, data = varechem) + Df Chisq F N.Perm Pr(>F) +Model 3 0.6441 2.9840 999 0.001 *** +Residual 20 1.4391 +--- +Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 +> +> +> +> cleanEx() > nameEx("as.mlm") > ### * as.mlm > @@ -1116,7 +1144,7 @@ No. of Positive Eigenvalues: 15 No. of Negative Eigenvalues: 8 -Average distance to medoid: +Average distance to median: grazed ungrazed 0.3926 0.2706 @@ -1211,7 +1239,7 @@ 27 -0.32914546 -0.17019348 0.231623720 0.019110623 23 -0.19259443 -0.01459250 -0.005679372 -0.209718312 19 -0.06794575 -0.14501690 -0.085645653 0.002431355 -> # group centroids/medoids +> # group centroids/medians > scores(mod, 1:4, display = "centroids") PCoA1 PCoA2 PCoA3 PCoA4 grazed -0.1455200 0.07584572 -0.01366220 -0.0178990 @@ -1238,7 +1266,7 @@ No. of Positive Eigenvalues: 15 No. of Negative Eigenvalues: 8 -Average distance to medoid: +Average distance to median: grazed ungrazed 0.4055 0.2893 @@ -1257,7 +1285,7 @@ No. of Positive Eigenvalues: 15 No. of Negative Eigenvalues: 8 -Average distance to medoid: +Average distance to median: grazed 0.4255 @@ -1299,7 +1327,7 @@ No. of Positive Eigenvalues: 14 No. of Negative Eigenvalues: 5 -Average distance to medoid: +Average distance to median: grazed ungrazed 0.3984 0.3008 @@ -1427,8 +1455,10 @@ 3 "c" = (b+c)/2 4 "wb" = b+c 5 "r" = 2*b*c/((a+b+c)^2-2*b*c) -6 "I" = log(2*a+b+c)-2*a*log(2)/(2*a+b+c)-((a+b)*log(a+b)+(a+c)*log(a+c))/(2*a+b+c) -7 "e" = exp(log(2*a+b+c)-2*a*log(2)/(2*a+b+c)-((a+b)*log(a+b)+(a+c)*log(a+c))/(2*a+b+c))-1 +6 "I" = log(2*a+b+c) - 2*a*log(2)/(2*a+b+c) - ((a+b)*log(a+b) + +(a+c)*log(a+c)) / (2*a+b+c) +7 "e" = exp(log(2*a+b+c) - 2*a*log(2)/(2*a+b+c) - ((a+b)*log(a+b) + +(a+c)*log(a+c)) / (2*a+b+c))-1 8 "t" = (b+c)/(2*a+b+c) 9 "me" = (b+c)/(2*a+b+c) 10 "j" = a/(a+b+c) @@ -1526,7 +1556,7 @@ > ### Name: bioenv > ### Title: Best Subset of Environmental Variables with Maximum (Rank) > ### Correlation with Community Dissimilarities -> ### Aliases: bioenv bioenv.default bioenv.formula summary.bioenv +> ### Aliases: bioenv bioenv.default bioenv.formula summary.bioenv bioenvdist > ### Keywords: multivariate > > ### ** Examples @@ -1608,10 +1638,10 @@ varechem, distance = "bray") Inertia Proportion Rank -Total 4.5444 -Real Total 4.8034 1.0000 -Conditional 0.9772 0.2034 1 -Constrained 0.9972 0.2076 3 +Total 4.5440 +Real Total 4.8030 1.0000 +Conditional 0.9770 0.2034 1 +Constrained 0.9970 0.2076 3 Unconstrained 2.8290 0.5890 15 Imaginary -0.2590 8 Inertia is squared Bray distance @@ -1643,10 +1673,10 @@ varechem, distance = "bray", add = TRUE) Inertia Proportion Rank -Total 8.9643 1.0000 -Conditional 1.5053 0.1679 1 -Constrained 1.7171 0.1915 3 -Unconstrained 5.7419 0.6405 19 +Total 8.9640 1.0000 +Conditional 1.5050 0.1679 1 +Constrained 1.7170 0.1915 3 +Unconstrained 5.7420 0.6405 19 Inertia is squared Bray distance (euclidified) Eigenvalues for constrained axes: @@ -1668,9 +1698,9 @@ Inertia Proportion Rank Total 6.9500 1.0000 -Conditional 0.9535 0.1372 1 -Constrained 1.2267 0.1765 3 -Unconstrained 4.7698 0.6863 19 +Conditional 0.9530 0.1372 1 +Constrained 1.2270 0.1765 3 +Unconstrained 4.7700 0.6863 19 Inertia is Bray distance Eigenvalues for constrained axes: @@ -1689,11 +1719,11 @@ Call: capscale(formula = varespec ~ 1, distance = "bray", metaMDSdist = TRUE) - Inertia Rank -Total 2.54753 -Real Total 2.59500 -Unconstrained 2.59500 19 -Imaginary -0.04747 4 + Inertia Rank +Total 2.5475 +Real Total 2.5950 +Unconstrained 2.5950 19 +Imaginary -0.0475 4 Inertia is squared Bray distance Eigenvalues for unconstrained axes: @@ -1804,9 +1834,9 @@ Call: cca(formula = varespec ~ Ca, data = varechem) Inertia Proportion Rank -Total 2.08320 1.00000 -Constrained 0.15722 0.07547 1 -Unconstrained 1.92598 0.92453 22 +Total 2.0832 1.0000 +Constrained 0.1572 0.0755 1 +Unconstrained 1.9260 0.9245 22 Inertia is mean squared contingency coefficient Eigenvalues for constrained axes: @@ -2294,16 +2324,12 @@ > data(dune.env) > mod <- adonis(dune ~ Management, data = dune.env) > plot(density(mod)) -> library(lattice) > mod <- adonis(dune ~ Management * Moisture, dune.env) > densityplot(mod) > > > > cleanEx() - -detaching ?package:lattice? - > nameEx("designdist") > ### * designdist > @@ -2668,6 +2694,8 @@ > plot(S, Srare, xlab = "Observed No. of Species", ylab = "Rarefied No. of Species") > abline(0, 1) > rarecurve(BCI, step = 20, sample = raremax, col = "blue", cex = 0.6) +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL > > > @@ -2801,21 +2829,21 @@ ***VECTORS - NMDS1 NMDS2 r2 Pr(>r) -N -0.057194 -0.998363 0.2537 0.046 * -P 0.619593 0.784923 0.1938 0.103 -K 0.766293 0.642492 0.1809 0.143 -Ca 0.685057 0.728489 0.4119 0.008 ** -Mg 0.632400 0.774642 0.4271 0.004 ** -S 0.191230 0.981545 0.1752 0.140 -Al -0.871691 0.490056 0.5269 0.001 *** -Fe -0.936135 0.351641 0.4451 0.002 ** -Mn 0.798733 -0.601685 0.5230 0.001 *** -Zn 0.617495 0.786575 0.1879 0.125 -Mo -0.903045 0.429546 0.0609 0.537 -Baresoil 0.925034 -0.379885 0.2508 0.039 * -Humdepth 0.932909 -0.360112 0.5200 0.002 ** -pH -0.648094 0.761560 0.2308 0.060 . + NMDS1 NMDS2 r2 Pr(>r) +N -0.05719 -0.99836 0.2537 0.046 * +P 0.61959 0.78492 0.1938 0.103 +K 0.76629 0.64249 0.1809 0.143 +Ca 0.68506 0.72849 0.4119 0.008 ** +Mg 0.63240 0.77464 0.4271 0.004 ** +S 0.19123 0.98155 0.1752 0.140 +Al -0.87169 0.49006 0.5269 0.001 *** +Fe -0.93613 0.35164 0.4451 0.002 ** +Mn 0.79873 -0.60169 0.5230 0.001 *** +Zn 0.61750 0.78657 0.1879 0.125 +Mo -0.90304 0.42955 0.0609 0.537 +Baresoil 0.92503 -0.37988 0.2508 0.039 * +Humdepth 0.93291 -0.36011 0.5200 0.002 ** +pH -0.64809 0.76156 0.2308 0.060 . --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 P values based on 999 permutations. @@ -2859,6 +2887,10 @@ > ordispider(ord, Moisture, col="skyblue") > points(ord, display = "sites", col = as.numeric(Moisture), pch=16) > plot(fit, cex=1.2, axis=TRUE, bg = rgb(1, 1, 1, 0.5)) +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL > ## Use shorter labels for factor centroids > labels(fit) $vectors @@ -2870,6 +2902,10 @@ > plot(ord) > plot(fit, labels=list(factors = paste("M", c(1,2,4,5), sep = "")), + bg = rgb(1,1,0,0.5)) +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL > > > @@ -2927,8 +2963,7 @@ > ### Name: fisherfit > ### Title: Fit Fisher's Logseries and Preston's Lognormal Model to > ### Abundance Data -> ### Aliases: fisherfit as.fisher plot.fisherfit profile.fisherfit -> ### confint.fisherfit plot.profile.fisherfit prestonfit prestondistr +> ### Aliases: fisherfit as.fisher plot.fisherfit prestonfit prestondistr > ### as.preston plot.prestonfit lines.prestonfit plot.preston > ### lines.preston plot.fisher veiledspec > ### Keywords: univar distribution @@ -2941,15 +2976,8 @@ Fisher log series model No. of species: 101 +Fisher alpha: 37.96423 - Estimate Std. Error -alpha 37.964 4.6847 - -> plot(profile(mod)) -> confint(mod) -Loading required package: MASS - 2.5 % 97.5 % -29.65932 48.12558 > # prestonfit seems to need large samples > mod.oct <- prestonfit(colSums(BCI)) > mod.ll <- prestondistr(colSums(BCI)) @@ -3003,9 +3031,6 @@ > > > cleanEx() - -detaching ?package:MASS? - > nameEx("goodness.cca") > ### * goodness.cca > @@ -3344,6 +3369,8 @@ > fun <- function(x, i) indpower(x)[i,-i] > ## 'c0' randomizes species occurrences > os <- oecosimu(dune, fun, "c0", i=i, nsimul=99) +Warning in oecosimu(dune, fun, "c0", i = i, nsimul = 99) : + nullmodel transformed 'comm' to binary data > ## get z values from oecosimu output > z <- os$oecosimu$z > ## p-value @@ -4492,20 +4519,18 @@ Axis lengths 2.9197 2.5442 2.7546 1.78074 - statistic z mean 5% 50% 100% Pr(sim.) -DCA1 0.382249 1.8658 0.32404 0.27338 0.32373 0.3918 0.02 * -DCA2 0.261208 1.5772 0.21939 0.17891 0.21617 0.2899 0.09 . -DCA3 0.166788 0.5209 0.15594 0.12380 0.15572 0.2361 0.30 -DCA4 0.087226 -1.9822 0.13015 0.10335 0.12649 0.2011 0.99 + statistic z mean 0% 50% 95% Pr(sim.) +DCA1 0.382249 1.8658 0.324042 0.230869 0.323729 0.3726 0.02 * +DCA2 0.261208 1.5772 0.219388 0.149703 0.216169 0.2637 0.09 . +DCA3 0.166788 0.5209 0.155941 0.105269 0.155716 0.1859 0.30 +DCA4 0.087226 -1.9822 0.130151 0.066742 0.126492 0.1649 0.99 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > ## Inspect the swap sequence as a time series object > plot(as.ts(out)) > lag.plot(as.ts(out)) > acf(as.ts(out)) -> ## Density plot: needs lattice -> require(lattice) -Loading required package: lattice +> ## Density plot > densityplot(out, as.table = TRUE) > ## Use quantitative null models to compare > ## mean Bray-Curtis dissimilarities @@ -4553,9 +4578,6 @@ > > > cleanEx() - -detaching ?package:lattice? - > nameEx("ordiarrows") > ### * ordiarrows > @@ -4581,12 +4603,18 @@ > plot(mod, type = "n") > ## Annual succession by ditches > ordiarrows(mod, ditch, label = TRUE) +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL > ## Show only control and highest Pyrifos treatment > plot(mod, type = "n") > ordiarrows(mod, ditch, label = TRUE, + show.groups = c("2", "3", "5", "11")) +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL > ordiarrows(mod, ditch, label = TRUE, show = c("6", "9"), + col = 2) +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL > legend("topright", c("Control", "Pyrifos 44"), lty = 1, col = c(1,2)) > > @@ -4624,6 +4652,8 @@ > plot(mod, type = "n") > pl <- ordihull(mod, Management, scaling = 3) > ordispider(pl, col="red", lty=3, label = TRUE ) +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL > ## ordispider to connect WA and LC scores > plot(mod, dis=c("wa","lc"), type="p") > ordispider(mod) @@ -4662,8 +4692,12 @@ > ord <- cca(dune) > plot(ord, type = "n") > ordilabel(ord, dis="sites", cex=1.2, font=3, fill="hotpink", col="blue") +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL > ## You may prefer separate plots, but here species as well > ordilabel(ord, dis="sp", font=2, priority=colSums(dune)) +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL > > > @@ -4797,14 +4831,10 @@ > data(varechem) > mod <- cca(varespec ~ Al + P + K, varechem) > ordiresids(mod) -Loading required package: lattice > > > > cleanEx() - -detaching ?package:lattice? - > nameEx("ordistep") > ### * ordistep > @@ -4870,9 +4900,9 @@ Call: rda(formula = dune ~ Management + Moisture, data = dune.env) Inertia Proportion Rank -Total 84.1237 1.0000 -Constrained 46.4249 0.5519 6 -Unconstrained 37.6988 0.4481 13 +Total 84.1200 1.0000 +Constrained 46.4200 0.5519 6 +Unconstrained 37.7000 0.4481 13 Inertia is variance Eigenvalues for constrained axes: @@ -4924,9 +4954,9 @@ Call: rda(formula = dune ~ Moisture + Manure, data = dune.env) Inertia Proportion Rank -Total 84.1237 1.0000 -Constrained 49.1609 0.5844 7 -Unconstrained 34.9628 0.4156 12 +Total 84.1200 1.0000 +Constrained 49.1600 0.5844 7 +Unconstrained 34.9600 0.4156 12 Inertia is variance Eigenvalues for constrained axes: @@ -5088,14 +5118,15 @@ > vare.mds <- monoMDS(vare.dist) > with(varechem, ordisurf(vare.mds, Baresoil, bubble = 5)) Loading required package: mgcv -This is mgcv 1.7-24. For overview type 'help("mgcv-package")'. +Loading required package: nlme +This is mgcv 1.7-26. For overview type 'help("mgcv-package")'. Family: gaussian Link function: identity Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 5.63 total = 6.63 @@ -5112,7 +5143,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 6.45 total = 7.45 @@ -5143,7 +5174,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 5.63 total = 6.63 @@ -5158,7 +5189,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "ts", fx = FALSE) - + Estimated degrees of freedom: 4.43 total = 5.43 @@ -5184,7 +5215,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "ds", fx = FALSE) - + Estimated degrees of freedom: 5.63 total = 6.63 @@ -5200,7 +5231,7 @@ Formula: y ~ s(x1, x2, k = 4, bs = "tp", fx = TRUE) - + Estimated degrees of freedom: 3 total = 4 @@ -5217,7 +5248,7 @@ Formula: y ~ te(x1, x2, k = c(4, 4), bs = c("cr", "cr"), fx = c(FALSE, FALSE)) - + Estimated degrees of freedom: 2.99 total = 3.99 @@ -5236,7 +5267,7 @@ Formula: y ~ te(x1, x2, k = c(3, 4), bs = c("cs", "cs"), fx = c(TRUE, TRUE)) - + Estimated degrees of freedom: 11 total = 12 @@ -5248,7 +5279,7 @@ > > cleanEx() -detaching ?package:mgcv? +detaching ?package:mgcv?, ?package:nlme? > nameEx("orditkplot") > ### * orditkplot @@ -5334,7 +5365,6 @@ > ord <- cca(dune) > ## Pairs plots > ordisplom(ord) -Loading required package: lattice > ordisplom(ord, data=dune.env, choices=1:2) > ordisplom(ord, data=dune.env, form = ~ . | Management, groups=Manure) > ## Scatter plot @@ -5354,9 +5384,6 @@ > > > cleanEx() - -detaching ?package:lattice? - > nameEx("pcnm") > ### * pcnm > @@ -5376,14 +5403,15 @@ > ## Map of PCNMs in the sample plot > ordisurf(mite.xy, scores(pcnm1, choi=1), bubble = 4, main = "PCNM 1") Loading required package: mgcv -This is mgcv 1.7-24. For overview type 'help("mgcv-package")'. +Loading required package: nlme +This is mgcv 1.7-26. For overview type 'help("mgcv-package")'. Family: gaussian Link function: identity Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 8.71 total = 9.71 @@ -5396,7 +5424,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 7.18 total = 8.18 @@ -5409,7 +5437,7 @@ Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 8.32 total = 9.32 @@ -5418,7 +5446,6 @@ > par(op) > ## Plot first PCNMs against each other > ordisplom(pcnm1, choices=1:4) -Loading required package: lattice > ## Weighted PCNM for CCA > data(mite) > rs <- rowSums(mite)/sum(mite) @@ -5433,7 +5460,7 @@ > graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() -detaching ?package:lattice?, ?package:mgcv? +detaching ?package:mgcv?, ?package:nlme? > nameEx("permatfull") > ### * permatfull @@ -5682,7 +5709,7 @@ No. of Positive Eigenvalues: 15 No. of Negative Eigenvalues: 8 -Average distance to medoid: +Average distance to median: grazed ungrazed 0.3926 0.2706 @@ -5905,10 +5932,10 @@ Call: prc(response = pyrifos, treatment = dose, time = week) Inertia Proportion Rank -Total 288.9920 1.0000 -Conditional 63.3493 0.2192 10 -Constrained 96.6837 0.3346 44 -Unconstrained 128.9589 0.4462 77 +Total 288.9900 1.0000 +Conditional 63.3500 0.2192 10 +Constrained 96.6800 0.3346 44 +Unconstrained 128.9600 0.4462 77 Inertia is variance Eigenvalues for constrained axes: @@ -6254,7 +6281,6 @@ > plot(mod, log = "xy") > ## Lattice graphics separately for each model > radlattice(mod) -Loading required package: lattice > # Take a subset of BCI to save time and nerves > mod <- radfit(BCI[3:5,]) > mod @@ -6272,9 +6298,6 @@ > > > cleanEx() - -detaching ?package:lattice? - > nameEx("rankindex") > ### * rankindex > @@ -6380,7 +6403,6 @@ > i <- sample(nrow(BCI), 12) > mod <- renyi(BCI[i,]) > plot(mod) -Loading required package: lattice > mod <- renyiaccum(BCI[i,]) > plot(mod, as.table=TRUE, col = c(1, 2, 2)) > persp(mod) @@ -6388,9 +6410,6 @@ > > > cleanEx() - -detaching ?package:lattice? - > nameEx("scores") > ### * scores > @@ -6747,9 +6766,9 @@ dune.env) Inertia Proportion Rank -Total 87.7829 1.0000 -Constrained 62.2577 0.7092 6 -Unconstrained 25.5252 0.2908 13 +Total 87.7800 1.0000 +Constrained 62.2600 0.7092 6 +Unconstrained 25.5300 0.2908 13 Inertia is variance Eigenvalues for constrained axes: @@ -6813,6 +6832,8 @@ > ## Add tree to a metric scaling > plot(tr, cmdscale(dis), type = "t") Loading required package: MASS +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL > ## Find a configuration to display the tree neatly > plot(tr, type = "t") Initial stress : 0.03111 @@ -6820,6 +6841,8 @@ stress after 20 iters: 0.01139, magic = 0.500 stress after 30 iters: 0.01118, magic = 0.500 stress after 40 iters: 0.01114, magic = 0.500 +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL > ## Depths of nodes > depths <- spandepth(tr) > plot(tr, type = "t", label = depths) @@ -6828,6 +6851,8 @@ stress after 20 iters: 0.01139, magic = 0.500 stress after 30 iters: 0.01118, magic = 0.500 stress after 40 iters: 0.01114, magic = 0.500 +Warning in rep(border, length = nrow(x)) : + 'x' is NULL so the result will be NULL > > > @@ -7105,7 +7130,6 @@ attr(,"class") [1] "summary.poolaccum" > plot(pool) -Loading required package: lattice > ## Quantitative model > estimateR(BCI[1:5,]) 1 2 3 4 5 @@ -7120,7 +7144,7 @@ > graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() -detaching ?package:lattice?, ?dune.env? +detaching ?dune.env? > nameEx("stepacross") > ### * stepacross @@ -7365,6 +7389,8 @@ > ## Significance test using Null model communities. > ## The current choice fixes only site totals. > oecosimu(dune, treedive, "r0", tree = cl) +Warning in oecosimu(dune, treedive, "r0", tree = cl) : + nullmodel transformed 'comm' to binary data oecosimu object Call: oecosimu(comm = dune, nestfun = treedive, method = "r0", tree = @@ -7450,7 +7476,6 @@ 14 19 28 43 10 41 42 29 27 3 9 7 TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE > plot(x1) -Loading required package: lattice > x2 <- tsallis(BCI[i,],norm=TRUE) > x2 0 0.2 0.4 0.6 0.8 1 1.2 1.4 @@ -7489,9 +7514,6 @@ > > > cleanEx() - -detaching ?package:lattice? - > nameEx("varechem") > ### * varechem > @@ -7805,21 +7827,21 @@ ***VECTORS - NMDS1 NMDS2 r2 Pr(>r) -N -0.057194 -0.998363 0.2537 0.046 * -P 0.619593 0.784923 0.1938 0.103 -K 0.766293 0.642492 0.1809 0.143 -Ca 0.685057 0.728489 0.4119 0.008 ** -Mg 0.632400 0.774642 0.4271 0.004 ** -S 0.191230 0.981545 0.1752 0.140 -Al -0.871691 0.490056 0.5269 0.001 *** -Fe -0.936135 0.351641 0.4451 0.002 ** -Mn 0.798733 -0.601685 0.5230 0.001 *** -Zn 0.617495 0.786575 0.1879 0.125 -Mo -0.903045 0.429546 0.0609 0.537 -Baresoil 0.925034 -0.379885 0.2508 0.039 * -Humdepth 0.932909 -0.360112 0.5200 0.002 ** -pH -0.648094 0.761560 0.2308 0.060 . + NMDS1 NMDS2 r2 Pr(>r) +N -0.05719 -0.99836 0.2537 0.046 * +P 0.61959 0.78492 0.1938 0.103 +K 0.76629 0.64249 0.1809 0.143 +Ca 0.68506 0.72849 0.4119 0.008 ** +Mg 0.63240 0.77464 0.4271 0.004 ** +S 0.19123 0.98155 0.1752 0.140 +Al -0.87169 0.49006 0.5269 0.001 *** +Fe -0.93613 0.35164 0.4451 0.002 ** +Mn 0.79873 -0.60169 0.5230 0.001 *** +Zn 0.61750 0.78657 0.1879 0.125 +Mo -0.90304 0.42955 0.0609 0.537 +Baresoil 0.92503 -0.37988 0.2508 0.039 * +Humdepth 0.93291 -0.36011 0.5200 0.002 ** +pH -0.64809 0.76156 0.2308 0.060 . --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 P values based on 999 permutations. @@ -7853,9 +7875,9 @@ data = dune.env) Inertia Proportion Rank -Total 84.1237 1.0000 -Constrained 63.2062 0.7513 12 -Unconstrained 20.9175 0.2487 7 +Total 84.1200 1.0000 +Constrained 63.2100 0.7513 12 +Unconstrained 20.9200 0.2487 7 Inertia is variance Some constraints were aliased because they were collinear (redundant) @@ -7916,9 +7938,9 @@ Call: rda(formula = dune ~ Management + Moisture, data = dune.env) Inertia Proportion Rank -Total 84.1237 1.0000 -Constrained 46.4249 0.5519 6 -Unconstrained 37.6988 0.4481 13 +Total 84.1200 1.0000 +Constrained 46.4200 0.5519 6 +Unconstrained 37.7000 0.4481 13 Inertia is variance Eigenvalues for constrained axes: @@ -7963,14 +7985,15 @@ > ## add fitted surface of diversity to the model > ordisurf(mod, diversity(dune), add = TRUE) Loading required package: mgcv -This is mgcv 1.7-24. For overview type 'help("mgcv-package")'. +Loading required package: nlme +This is mgcv 1.7-26. For overview type 'help("mgcv-package")'. Family: gaussian Link function: identity Formula: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE) - + Estimated degrees of freedom: 1.28 total = 2.28 @@ -8014,7 +8037,7 @@ > > cleanEx() -detaching ?package:mgcv? +detaching ?package:mgcv?, ?package:nlme? > nameEx("vegandocs") > ### * vegandocs @@ -8523,7 +8546,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 27.384 0.108 27.597 0 0 +Time elapsed: 25.872 0.092 25.999 0 0 > grDevices::dev.off() null device 1 From noreply at r-forge.r-project.org Fri Nov 15 14:15:07 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 15 Nov 2013 14:15:07 +0100 (CET) Subject: [Vegan-commits] r2710 - in pkg/vegan: inst tests Message-ID: <20131115131507.5A5D81861CA@r-forge.r-project.org> Author: jarioksa Date: 2013-11-15 14:15:07 +0100 (Fri, 15 Nov 2013) New Revision: 2710 Modified: pkg/vegan/inst/ChangeLog pkg/vegan/tests/vegan-tests.Rout.save Log: update vegan-tests Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-11-15 13:02:44 UTC (rev 2709) +++ pkg/vegan/inst/ChangeLog 2013-11-15 13:15:07 UTC (rev 2710) @@ -15,6 +15,16 @@ * oecosimu: change printed quantiles to match the direction of the test as changed in r2495. + + * tests: vegan examples and vegan-tests have been out of sync for + a long time. These have not been updated because most of the + changes seem to be triggered by switching to R 3.0-x, and we have + not had time to analyse the reasons. The differences also seem to + be platform specific, and Linux and MacOS give slightly different + results. In particular, there seem to be differences in + permutations, constrained ordination, in particular in capscale() + and rounding of output. We have also introduced some changes in + output that were not yet synced. Version 2.1-38 (closed November 10, 2013) Modified: pkg/vegan/tests/vegan-tests.Rout.save =================================================================== --- pkg/vegan/tests/vegan-tests.Rout.save 2013-11-15 13:02:44 UTC (rev 2709) +++ pkg/vegan/tests/vegan-tests.Rout.save 2013-11-15 13:15:07 UTC (rev 2710) @@ -1,8 +1,7 @@ -R version 2.15.3 (2013-03-01) -- "Security Blanket" +R Under development (unstable) (2013-11-15 r64218) -- "Unsuffered Consequences" Copyright (C) 2013 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) +Platform: x86_64-unknown-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. @@ -63,7 +62,7 @@ Model 6 1.3178 1.3341 99 0.07 . Residual 4 0.6585 --- -Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 +Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > anova(m, by="term", perm=100) Permutation test for cca under reduced model Terms added sequentially (first to last) @@ -75,7 +74,7 @@ spno 1 0.1558 0.9461 99 0.40 Residual 4 0.6585 --- -Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 +Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > anova(m, by="margin", perm=100) Permutation test for cca under reduced model Marginal effects of terms @@ -97,7 +96,7 @@ CCA6 1 0.0681 0.4139 99 0.83 Residual 4 0.6585 --- -Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 +Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > ## capscale > p <- capscale(fla, data=df, na.action=na.exclude, subset = Use != "Pasture" & spno > 7) > anova(p, perm=100) @@ -108,7 +107,7 @@ Model 6 64.324 1.9652 99 0.01 ** Residual 4 21.821 --- -Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 +Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > anova(p, by="term", perm=100) Permutation test for capscale under reduced model Terms added sequentially (first to last) @@ -120,7 +119,7 @@ spno 1 7.462 1.3679 99 0.19 Residual 4 21.821 --- -Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 +Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > anova(p, by="margin", perm=100) Permutation test for capscale under reduced model Marginal effects of terms @@ -132,7 +131,7 @@ spno 1 7.462 1.3679 99 0.31 Residual 4 21.821 --- -Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 +Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > anova(p, by="axis", perm=100) Model: capscale(formula = dune ~ Management + poly(A1, 2) + spno, data = df, na.action = na.exclude, subset = structure(c(TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE), .Names = c("2", "13", "4", "16", "6", "1", "8", "5", "17", "15", "10", "11", "9", "18", "3", "20", "14", "19", "12", "7"))) Df Var F N.Perm Pr(>F) @@ -144,7 +143,7 @@ CAP6 1 2.7811 0.5098 99 0.87 Residual 4 21.8213 --- -Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 +Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > ## see that capscale can be updated and also works with 'dist' input > dis <- vegdist(dune) > p <- update(p, dis ~ .) @@ -156,7 +155,7 @@ Model 6 1.55041 1.9024 99 0.06 . Residual 4 0.54333 --- -Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 +Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > anova(p, by="term", perm=100) Permutation test for capscale under reduced model Terms added sequentially (first to last) @@ -168,7 +167,7 @@ spno 1 0.20517 1.5105 99 0.21 Residual 4 0.54333 --- -Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 +Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > anova(p, by="margin", perm=100) Permutation test for capscale under reduced model Marginal effects of terms @@ -190,7 +189,7 @@ CAP6 1 0.02458 0.1810 99 0.98 Residual 4 0.54333 --- -Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 +Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > ### attach()ed data frame instead of data= > attach(df) > q <- cca(fla, na.action = na.omit, subset = Use != "Pasture" & spno > 7) @@ -212,7 +211,7 @@ spno 1 0.1558 0.9461 99 0.43 Residual 4 0.6585 --- -Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 +Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > anova(q, by="margin", perm=100) Permutation test for cca under reduced model Marginal effects of terms @@ -234,7 +233,7 @@ CCA6 1 0.0681 0.4139 99 0.75 Residual 4 0.6585 --- -Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 +Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > ### Check that constrained ordination functions can be embedded. > ### The data.frame 'df' is still attach()ed. > foo <- function(bar, Y, X, ...) @@ -266,9 +265,9 @@ Call: rda(formula = Y ~ X, na.action = ..1) Inertia Proportion Rank -Total 81.8333 1.0000 -Constrained 28.0931 0.3433 3 -Unconstrained 53.7402 0.6567 14 +Total 81.8300 1.0000 +Constrained 28.0900 0.3433 3 +Unconstrained 53.7400 0.6567 14 Inertia is variance 2 observations deleted due to missingness @@ -286,9 +285,9 @@ Call: bar(formula = Y ~ X, distance = "jaccard", na.action = ..2) Inertia Proportion Rank -Total 5.2931 1.0000 +Total 5.2930 1.0000 Constrained 1.5460 0.2921 3 -Unconstrained 3.7471 0.7079 14 +Unconstrained 3.7470 0.7079 14 Inertia is squared Jaccard distance 2 observations deleted due to missingness @@ -306,11 +305,11 @@ Call: bar(formula = Y ~ X, na.action = ..1) Inertia Proportion Rank -Total 3.9491 -Real Total 4.1689 1.0000 -Constrained 1.3488 0.3235 3 -Unconstrained 2.8201 0.6765 12 -Imaginary -0.2198 5 +Total 3.9490 +Real Total 4.1690 1.0000 +Constrained 1.3490 0.3235 3 +Unconstrained 2.8200 0.6765 12 +Imaginary -0.2200 5 Inertia is squared Bray distance 2 observations deleted due to missingness @@ -358,7 +357,7 @@ CCA4 1 0.0562 0.6132 99 0.75 Residual 10 0.9170 --- -Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 +Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > all.equal(tab[,2], c(m$CCA$eig, m$CA$tot.chi), check.attributes=FALSE) [1] TRUE > tab[nrow(tab),1] == m$CA$rank @@ -384,9 +383,9 @@ > anova(cap.model.cond, by="axis", strata=CC) # -> error pre r2287 Model: capscale(formula = X ~ A + B + Condition(CC)) Df Var F N.Perm Pr(>F) -CAP1 1 0.2682 1.3075 99 0.29 -CAP2 1 0.0685 0.3339 99 0.91 -CAP3 1 0.0455 0.2217 99 0.97 +CAP1 1 0.2682 1.3075 99 0.22 +CAP2 1 0.0685 0.3339 99 0.95 +CAP3 1 0.0455 0.2217 99 0.94 Residual 22 4.5130 > anova(cap.model.cond, by="terms", strata=CC) # -> error pre r2287 Permutation test for capscale under reduced model @@ -395,7 +394,7 @@ Model: capscale(formula = X ~ A + B + Condition(CC)) Df Var F N.Perm Pr(>F) -A 1 0.1316 0.6415 99 0.72 +A 1 0.1316 0.6415 99 0.71 B 2 0.2506 0.6108 99 0.84 Residual 22 4.5130 > @@ -404,9 +403,9 @@ > anova(cap.model, by="axis", strata=CC) # -> no error Model: capscale(formula = X ~ A + B) Df Var F N.Perm Pr(>F) -CAP1 1 0.2682 1.3267 99 0.18 -CAP2 1 0.0685 0.3388 99 0.96 -CAP3 1 0.0455 0.2249 99 0.95 +CAP1 1 0.2682 1.3267 99 0.25 +CAP2 1 0.0685 0.3388 99 0.95 +CAP3 1 0.0455 0.2249 99 0.98 Residual 26 5.2565 > anova(cap.model, by="terms", strata=CC) # -> no error Permutation test for capscale under reduced model @@ -415,8 +414,8 @@ Model: capscale(formula = X ~ A + B) Df Var F N.Perm Pr(>F) -A 1 0.1316 0.6509 99 0.62 -B 2 0.2506 0.6198 99 0.85 +A 1 0.1316 0.6509 99 0.65 +B 2 0.2506 0.6198 99 0.84 Residual 26 5.2565 > > # partial RDA @@ -424,9 +423,9 @@ > anova(rda.model.cond, by="axis", strata=CC) # -> no error Model: rda(formula = X ~ A + B + Condition(CC)) Df Var F N.Perm Pr(>F) -RDA1 1 0.2682 1.3075 99 0.28 -RDA2 1 0.0685 0.3339 99 0.92 -RDA3 1 0.0455 0.2217 99 0.97 +RDA1 1 0.2682 1.3075 99 0.31 +RDA2 1 0.0685 0.3339 99 0.85 +RDA3 1 0.0455 0.2217 99 0.98 Residual 22 4.5130 > anova(rda.model.cond, by="terms", strata=CC) # -> error pre r2287 Permutation test for rda under reduced model @@ -435,8 +434,8 @@ Model: rda(formula = X ~ A + B + Condition(CC)) Df Var F N.Perm Pr(>F) -A 1 0.1316 0.6415 99 0.65 -B 2 0.2506 0.6108 99 0.84 +A 1 0.1316 0.6415 99 0.63 +B 2 0.2506 0.6108 99 0.80 Residual 22 4.5130 > > # RDA without conditional factor @@ -444,9 +443,9 @@ > anova(rda.model, by="axis", strata=CC) # -> no error Model: rda(formula = X ~ A + B) Df Var F N.Perm Pr(>F) -RDA1 1 0.2682 1.3267 99 0.24 -RDA2 1 0.0685 0.3388 99 0.90 -RDA3 1 0.0455 0.2249 99 0.94 +RDA1 1 0.2682 1.3267 99 0.21 +RDA2 1 0.0685 0.3388 99 0.83 +RDA3 1 0.0455 0.2249 99 0.97 Residual 26 5.2565 > anova(rda.model, by="terms", strata=CC) # -> no error Permutation test for rda under reduced model @@ -455,8 +454,8 @@ Model: rda(formula = X ~ A + B) Df Var F N.Perm Pr(>F) -A 1 0.1316 0.6509 99 0.69 -B 2 0.2506 0.6198 99 0.84 +A 1 0.1316 0.6509 99 0.77 +B 2 0.2506 0.6198 99 0.83 Residual 26 5.2565 > ## clean.up > rm(X, A, B, CC, cap.model.cond, cap.model, rda.model.cond, rda.model) @@ -511,23 +510,39 @@ > ### end envfit & plot.envfit > > ### protest (& Procrustes analysis): Stability of the permutations and -> ### other results. +> ### other results. > data(mite) > mod <- rda(mite) > x <- scores(mod, display = "si", choices=1:6) > set.seed(4711) > xp <- x[sample(nrow(x)),] -> pro <- protest(x, xp, permutations = 99) +> pro <- protest(x, xp, control = how(nperm = 99)) > pro Call: -protest(X = x, Y = xp, permutations = 99) +protest(X = x, Y = xp, control = how(nperm = 99)) Procrustes Sum of Squares (m12 squared): 0.9147 Correlation in a symmetric Procrustes rotation: 0.292 Significance: 0.08 -Based on 99 permutations. +Based on 99 permutations +Permutation Design: +Blocks: + Defined by: none + +Plots: + Defined by: none + +Within Plots: + Permutation type: free + +Permutation details: + Number of permutations requested: 99 + Max. number of permutations allowed: 9999 + Evaluate all permutations?: No. Activation limit: 99 +. + > pro$t [1] 0.2056649 0.2008622 0.2062525 0.2656158 0.2739148 0.1990895 0.3124461 [8] 0.2287779 0.2033140 0.2396172 0.1868019 0.2736072 0.1830199 0.2026019 @@ -579,4 +594,4 @@ > > proc.time() user system elapsed - 9.182 0.136 9.543 + 2.387 0.039 2.415 From noreply at r-forge.r-project.org Mon Nov 18 13:09:23 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 18 Nov 2013 13:09:23 +0100 (CET) Subject: [Vegan-commits] r2711 - in pkg/vegan: inst man Message-ID: <20131118120923.2111D18629E@r-forge.r-project.org> Author: jarioksa Date: 2013-11-18 13:09:22 +0100 (Mon, 18 Nov 2013) New Revision: 2711 Modified: pkg/vegan/inst/ChangeLog pkg/vegan/man/commsim.Rd Log: restructure and (hopefully) streamline null model documentation Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-11-15 13:15:07 UTC (rev 2710) +++ pkg/vegan/inst/ChangeLog 2013-11-18 12:09:22 UTC (rev 2711) @@ -13,6 +13,12 @@ used in all cases with fixed number of permutations. At the first stage, only the overall test is provided. + * commsim: documentation (commsim.Rd) was restructured so that + nullmodels were collected under separate sections with a brief + introductory text and shorter specific text of the + algorithm. Hopefully this makes easier for an outsider to grasp + the width of the choices. + * oecosimu: change printed quantiles to match the direction of the test as changed in r2495. Modified: pkg/vegan/man/commsim.Rd =================================================================== --- pkg/vegan/man/commsim.Rd 2013-11-15 13:15:07 UTC (rev 2710) +++ pkg/vegan/man/commsim.Rd 2013-11-18 12:09:22 UTC (rev 2711) @@ -63,39 +63,59 @@ \item{\code{...}: }{additional arguments.} } -The following algorithms are currently predefined: -\itemize{ + Several null model algorithm are pre-defined and can be called by + their name. The predefined algorithms are described in detail in the + following chapters. The binary null models produce matrices of zeros + (absences) and ones (presences) also when input matrix is + quantitative. There are two types of quantitative data: Counts are + integers with a natural unit so that individuals can be shuffled, but + abundances can have real (floating point) values and do not have a + natural subunit for shuffling. All quantitative models can handle + counts, but only some are able to handle real values. Some of the null + models are sequential so that the next matrix is derived from the + current one. This makes models dependent on each other, and usually + you must thin these matrices and study the sequences for stability: + see \code{oecosimu} for details and instructions. + + See Examples for structural constraints imposed by each algorithm and + defining your own null model. + +} %% commsimulator +\section{Binary null models}{ + + All binary null models retain fill: number of absences or conversely + the number of absences. The classic models may also column (species) + frequencies (\code{c0}) or row frequencies or species richness of each + site (\code{r0}) and take into account commonness and rarity of + species (\code{r1}, \code{r2}). Algorithms \code{swap}, \code{tswap}, + \code{quasiswap} and \code{backtracking} preserve both row and column + frequencies. Two first of these are sequential but the two latter are + non-sequential and produce independent matrices. Basic algorithms are + reviewed by Wright et al. (1998). + +\itemize{ \item{\code{"r00"}: }{non-sequential algorithm for binary matrices - that maintains the number of presences but fills these anywhere so - that neither species (column) nor site (row) totals are - preserved. See Wright et al. (1998) for review.} + that only maintains the number of presences (fill).} \item{\code{"r0", "r0_old"}: }{non-sequential algorithm for binary - matrices that maintains the site (row) frequencies, fills - presences anywhere on the row with no respect to species (column) - frequencies. Methods \code{"r0"} and \code{"r0_old"} implement the + matrices that maintains the site (row) frequencies. + Methods \code{"r0"} and \code{"r0_old"} implement the same method, but use different random number sequences; use \code{"r0_old"} if you want to reproduce results in \pkg{vegan - 2.0-0} or older using \code{commsimulator} (now deprecated). See - Wright et al. (1998) for a review.} + 2.0-0} or older using \code{commsimulator} (now deprecated).} \item{\code{"r1"}: }{non-sequential algorithm for binary matrices - that maintains the site (row) frequencies, uses column marginal - frequencies as probabilities. It tries to simulate original - species frequencies, but it is not strictly constrained. See - Wright et al. (1998) for review.} + that maintains the site (row) frequencies, but uses column marginal + frequencies as probabilities of selecting species.} \item{\code{"r2"}: }{non-sequential algorithm for binary matrices - that maintains the site (row) frequencies, uses squared column - sums as as probabilities. It tries to simulate original species - frequencies, but it is not strictly constrained. See Wright et - al. (1998) for review.} + that maintains the site (row) frequencies, and uses squared column + sums as as probabilities of selecting species.} \item{\code{"c0"}: }{non-sequential algorithm for binary matrices - that maintains species frequencies, but does not honour site (row) - frequencies (Jonsson 2001). } + that maintains species frequencies (Jonsson 2001). } \item{\code{"swap"}: }{sequential algorithm for binary matrices that changes the matrix structure, but does not influence marginal sums @@ -103,8 +123,8 @@ 2} submatrices so long that a swap can be done.} \item{\code{"tswap"}: }{sequential algorithm for binary matrices. - Same as the \code{"swap"} algorithm, but it is trying a fixed - number of times and doing zero to many swaps at one step + Same as the \code{"swap"} algorithm, but it tries a fixed + number of times and performs zero to many swaps at one step (according the thin argument in later call). This approach was suggested by \enc{Mikl?s}{Miklos} & Podani (2004) because they found that ordinary swap may lead to biased @@ -115,9 +135,10 @@ honouring row and column totals, but with integers that may be larger than one. Then the method inspects random \eqn{2 \times 2}{2 by 2} matrices and performs a quasiswap on them. Quasiswap is - similar to ordinary swap, but it also can reduce numbers above one + similar to ordinary swap, but it can reduce numbers above one to ones maintaining marginal totals (\enc{Mikl?s}{Miklos} & Podani - 2004). } + 2004). This is the recommended algorithm if you want to retain both + species and row frequencies.} \item{\code{"backtracking"}: }{non-sequential algorithm for binary matrices that implements a filling method with constraints both @@ -127,108 +148,131 @@ all incidences are filled in. After that begins "backtracking", where some of the points are removed, and then filling is started again, and this backtracking is done so may times that all - incidences will be filled into matrix.} + incidences will be filled into matrix. The function may be very slow + for some matrices.} +} +} -%% permatswap - \item{\code{"swap_count"}: }{sequential algorithm for count matrices. - This algorithm tries to find 2 x 2 submatrices - (identified by 2 random row and 2 random column indices), - that can be swapped in order to leave column and row totals - and fill unchanged. First, the algorithm finds the largest - value in the submatrix that can be swapped (\eqn{d}) - and whether in diagonal or antidiagonal way. - Submatrices that contain values larger than zero in either - diagonal or antidiagonal position can be swapped. - Swap means that the values in diagonal or antidiagonal - positions are decreased by \eqn{d}, while remaining cells - are increased by \eqn{d}. A swap is made only if fill doesn't change. - \bold{WARNING}: according to simulations, - this algorithm seems to be biased and non random, - thus its use should be avoided!} +\section{Quantitative Models for Counts with Fixed Marginal Sums}{ - \item{\code{"quasiswap_count"}: }{non-sequential algorithm for count matrices. - This algorithm uses the same trick as - Carsten Dormann's \code{\link[bipartite]{swap.web}} - function in the package \pkg{bipartite}. First, a - random matrix is generated by the \code{\link{r2dtable}} - function retaining row and column sums. - Then the original matrix fill is reconstructed by - sequential steps to increase or decrease matrix fill in - the random matrix. These steps are based on swapping 2 x 2 - submatrices (see \code{"swap_count"} algorithm for details) - to maintain row and column totals. } + These models shuffle individuals of counts but keep marginal sums + fixed, but marginal frequencies are not preserved. Algorithm + \code{r2dtable} uses standard \R function \code{\link{r2dtable}} also + used for simulated \eqn{P}-values in \code{\link{chisq.test}}. + Algorithm \code{quasiswap_count} uses the same, but retains the + original fill. Typically this means increasing numbers of zero cells + and the result is zero-inflated with respect to \code{r2dtable}. +\itemize{ + + \item{\code{"r2dtable"}: }{non-sequential algorithm for count + matrices. This algorithm keeps matrix sum and row/column sums + constant. Based on \code{\link{r2dtable}}.} + + \item{\code{"quasiswap_count"}: }{non-sequential algorithm for count + matrices. This algorithm is similar as Carsten Dormann's + \code{\link[bipartite]{swap.web}} function in the package + \pkg{bipartite}. First, a random matrix is generated by the + \code{\link{r2dtable}} function retaining row and column sums. Then + the original matrix fill is reconstructed by sequential steps to + increase or decrease matrix fill in the random matrix. These steps + are based on swapping \eqn{2 \times 2}{2 x 2} submatrices (see + \code{"swap_count"} algorithm for details) to maintain row and + column totals. } +} +} + +\section{Quantitative Swap Models}{ + + Quantitative swap models are similar to binary \code{swap}, but they + swap the largest permissible value. The models in this section all + maintain the fill and perform a quantitative swap only if this can be + done without changing the fill. Single step of swap often changes the + matrix very little. In particular, if cell counts are variable, high + values change very slowly. Checking the chain stability and + independence is even more crucial than in binary swap, and very strong + \code{thin}ning is often needed. These models should never be used + without inspecting their properties for the current data. + + \itemize{ + + \item{\code{"swap_count"}: }{sequential algorithm for count matrices. + This algorithm find \eqn{2 \times 2}{2 x 2} submatrices that can be + swapped leaving column and row totals and fill unchanged. The + algorithm finds the largest value in the submatrix that can be + swapped (\eqn{d}). Swap means that the values in diagonal or + antidiagonal positions are decreased by \eqn{d}, while remaining + cells are increased by \eqn{d}. A swap is made only if fill does not + change. } + + \item{\code{"abuswap_r"}: }{sequential algorithm for count or + nonnegative real valued matrices with fixed row frequencies (see + also \code{\link{permatswap}}). The algorithm is similar to + \code{swap_count}, but uses different swap value for each row of the + \eqn{2 \times 2}{2 x 2} submatrix. Each step changes the the + corresponding column sums, but honours matrix fill, row sums, and + row/column frequencies (Hardy 2008; randomization scheme 2x).} + + \item{\code{"abuswap_c"}: }{sequential algorithm for count or + nonnegative real valued matrices with fixed column frequencies (see + also \code{\link{permatswap}}). The algorithm is similar as the + previous one, but operates on columns. 2 x 2 submatrices. Each step + changes the the corresponding row sums, but honours matrix fill, + column sums, and row/column frequencies (Hardy 2008; randomization + scheme 3x).} } +} + +\section{Quantitative Swap and Shuffle Models}{ + + Quantitative Swap and Shuffle methods (\code{swhs} methods) preserve + fill and column and row frequencies, and also either row or column + sums. The methods first perform a binary \code{quasiswap} and then + shuffle original count data to non-zero cells. The \code{samp} methods + shuffle original non-zero cell values, and \code{both} methods + redistribute individuals randomly among non-zero cells. The shuffling + is either free over the whole matrix, or within rows (\code{r} methods) + or within columns (\code{c} methods). Shuffling within a row preserves + row sums, and shuffling within a column preserves column sums. + +\itemize{ \item{\code{"swsh_samp"}: }{non-sequential algorithm for count matrices. - The algorithm is a hybrid algorithm. - First, it makes binary quasiswaps to keep row and column - incidences constant, then non-zero values are - modified by shuffling original nonzero samples among the new - nonzero cells of the binary matrix.} + Original non-zero values values are shuffled.} \item{\code{"swsh_both"}: }{non-sequential algorithm for count matrices. - The algorithm is a hybrid algorithm. - First, it makes binary quasiswaps to keep row and column - incidences constant, then non-zero values are - modified by shuffling original nonzero samples among the new - nonzero cells of the binary matrix, individuals of the - nonzero cells are also shuffled.} + Individuals are shuffled freely over non-zero cells.} \item{\code{"swsh_samp_r"}: }{non-sequential algorithm for count matrices. - The algorithm is a hybrid algorithm. - First, it makes binary quasiswaps to keep row and column - incidences constant, then non-zero values are - modified by shuffling original nonzero samples among the new - nonzero cells of the binary matrix, separately for each rows.} + Non-zero values (samples) are shuffled separately for each row.} - \item{\code{"swsh_samp_c"}: }{non-sequential algorithm for count matrices. - The algorithm is a hybrid algorithm. - First, it makes binary quasiswaps to keep row and column - incidences constant, then non-zero values are - modified by shuffling original nonzero samples among the new - nonzero cells of the binary matrix, separately for each columns.} + \item{\code{"swsh_samp_c"}: }{non-sequential algorithm for count + matrices. Non-zero values (samples) are shuffled separately for + each column.} \item{\code{"swsh_both_r"}: }{non-sequential algorithm for count matrices. - The algorithm is a hybrid algorithm. - First, it makes binary quasiswaps to keep row and column - incidences constant, then non-zero values are - modified by shuffling original nonzero samples among the new - nonzero cells of the binary matrix, individuals of the - nonzero cells are also shuffled, separately for each rows.} + Individuals are shuffled freely for non-zero values within each row.} \item{\code{"swsh_both_c"}: }{non-sequential algorithm for count matrices. - The algorithm is a hybrid algorithm. - First, it makes binary quasiswaps to keep row and column - incidences constant, then non-zero values are - modified by shuffling original nonzero samples among the new - nonzero cells of the binary matrix, individuals of the - nonzero cells are also shuffled, separately for each columns.} + Individuals are shuffled freely for non-zero values with each column.} +} +} - \item{\code{"abuswap_r"}: }{sequential algorithm for count - or nonnegative real valued (\code{mode = "double"}) matrices - (\code{"abuswap"} algorithm with fixed row frequencies, - see help page of \code{\link{permatswap}}). - The algorithm produces matrices by swapping - 2 x 2 submatrices. Each step changes the the corresponding - column sums, but honours matrix fill, row sums, - and row/column frequencies, - as described in Hardy (2008; randomization scheme 2x).} +\section{Quantitative Shuffle Methods}{ - \item{\code{"abuswap_c"}: }{sequential algorithm for count - or nonnegative real valued (\code{mode = "double"}) matrices. - (\code{"abuswap"} algorithm with fixed column frequencies, - see help page of \code{\link{permatswap}}). - The algorithm produces matrices by swapping - 2 x 2 submatrices. Each step changes the the corresponding - row sums, but honours matrix fill, column sums, - and row/column frequencies, - as described in Hardy (2008; randomization scheme 3x).} + Quantitative shuffle methods are generalizations of binary models + \code{r00}, \code{r0} and \code{c0}. The \code{_ind} methods shuffle + individuals so that the grand sum, row sum or column sums are similar + as in the observed matrix. These methods are similar as + \code{r2dtable} but with still slacker constraints on marginal + sums. The \code{_samp} and \code{_both} methods first perform the + correspongind binary model with similar restriction on marginal + frequencies, and then distribute quantitative values over non-zero + cells. The \code{_samp} models shuffle original cell values and can + therefore handle also non-count real values. The \code{_both} models + shuffle individuals among non-zero values. The shuffling is over the + whole matrix in \code{r00_}, and within row in \code{r0_} and within + column in \code{c0_} in all cases. -%% permatfull - \item{\code{"r2dtable"}: }{non-sequential algorithm for count matrices. - This algorithm keeps matrix sum and row/column sums constant, - based on Patefield's (1981) algorithm, see help page of - \code{\link{r2dtable}}.} - +\itemize{ \item{\code{"r00_ind"}: }{non-sequential algorithm for count matrices. This algorithm keeps total sum constant, individuals are shuffled among cells of the matrix.} @@ -254,7 +298,7 @@ \item{\code{"c0_samp"}: }{non-sequential algorithm for count or nonnegative real valued (\code{mode = "double"}) matrices. This algorithm keeps column sums constant, - cells within each columns are shuffled.} + cells within each column are shuffled.} \item{\code{"r00_both"}: }{non-sequential algorithm for count matrices. This algorithm keeps total sum constant, @@ -268,8 +312,8 @@ This algorithm keeps total sum constant, cells and individuals among cells of each column are shuffled.} } -For structural constraints imposed by each algorithm, see Examples. } + \value{ An object of class \code{commsim} with elements corresponding to the arguments (\code{method}, \code{binary}, @@ -311,13 +355,18 @@ W. (1998). A comparative analysis of nested subset patterns of species composition. \emph{Oecologia} 113, 1--20. } + \author{ Jari Oksanen and Peter Solymos } -\seealso{ -\code{\link{permatfull}}, \code{\link{permatswap}}, -\code{\link{oecosimu}}. -} + +\seealso{ See \code{\link{permatfull}}, \code{\link{permatswap}} for +alternative specification of quantitative null models. Function +\code{\link{oecosimu}} gives a higher-level interface for applying null +models in hypothesis testing and analysis of models. Function +\code{\link{nullmodel}} and \code{\link{simulate.nullmodel}} are used to +generate arrays of simulated null model matrices. } + \examples{ ## write the r00 algorithm f <- function(x, n, ...) From noreply at r-forge.r-project.org Mon Nov 18 20:52:40 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 18 Nov 2013 20:52:40 +0100 (CET) Subject: [Vegan-commits] r2712 - pkg/permute/inst/tests Message-ID: <20131118195240.D35CB1865CB@r-forge.r-project.org> Author: gsimpson Date: 2013-11-18 20:52:40 +0100 (Mon, 18 Nov 2013) New Revision: 2712 Modified: pkg/permute/inst/tests/test-shuffleSet.R Log: rep_len only introduced in R 3.0.0, switch to older rep(..., length.out = ) Modified: pkg/permute/inst/tests/test-shuffleSet.R =================================================================== --- pkg/permute/inst/tests/test-shuffleSet.R 2013-11-18 12:09:22 UTC (rev 2711) +++ pkg/permute/inst/tests/test-shuffleSet.R 2013-11-18 19:52:40 UTC (rev 2712) @@ -12,7 +12,7 @@ gr <- factor(rep(1:2, length=20)) ctrl <- how(nperm=5, blocks=gr) p <- shuffleSet(20, control = ctrl) %% 2 - y <- rep_len(c(1L, 0L), ncol(p)) + y <- rep(c(1L, 0L), length.out = ncol(p)) nc <- ncol(p) for (i in seq_len(nrow(p))) { expect_that(p[i, ], equals(y)) From noreply at r-forge.r-project.org Tue Nov 19 15:40:45 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 19 Nov 2013 15:40:45 +0100 (CET) Subject: [Vegan-commits] r2713 - in pkg/vegan: R inst man vignettes Message-ID: <20131119144045.1665518589A@r-forge.r-project.org> Author: jarioksa Date: 2013-11-19 15:40:44 +0100 (Tue, 19 Nov 2013) New Revision: 2713 Modified: pkg/vegan/R/adonis.R pkg/vegan/R/anosim.R pkg/vegan/R/bioenv.default.R pkg/vegan/R/mantel.R pkg/vegan/R/mantel.partial.R pkg/vegan/R/metaMDSiter.R pkg/vegan/R/mrpp.R pkg/vegan/R/oecosimu.R pkg/vegan/R/permutest.cca.R pkg/vegan/R/simper.R pkg/vegan/inst/ChangeLog pkg/vegan/man/nobs.adonis.Rd pkg/vegan/man/screeplot.cca.Rd pkg/vegan/vignettes/decision-vegan.Rnw Log: vegan depends on R>=2.14.0 and now remove unnecessary tests and references to older veersions Modified: pkg/vegan/R/adonis.R =================================================================== --- pkg/vegan/R/adonis.R 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/R/adonis.R 2013-11-19 14:40:44 UTC (rev 2713) @@ -107,7 +107,7 @@ ## Apply permutations for each term ## This is the new f.test (2011-06-15) that uses fewer arguments ## Set first parallel processing for all terms - if (is.null(parallel) || getRversion() < "2.14.0") + if (is.null(parallel)) parallel <- 1 hasClus <- inherits(parallel, "cluster") isParal <- (hasClus || parallel > 1) && require(parallel) Modified: pkg/vegan/R/anosim.R =================================================================== --- pkg/vegan/R/anosim.R 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/R/anosim.R 2013-11-19 14:40:44 UTC (rev 2713) @@ -48,7 +48,7 @@ permutations <- nrow(permat) } ## Parallel processing - if (is.null(parallel) || getRversion() < "2.14.0") + if (is.null(parallel)) parallel <- 1 hasClus <- inherits(parallel, "cluster") if ((hasClus || parallel > 1) && require(parallel)) { Modified: pkg/vegan/R/bioenv.default.R =================================================================== --- pkg/vegan/R/bioenv.default.R 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/R/bioenv.default.R 2013-11-19 14:40:44 UTC (rev 2713) @@ -71,7 +71,7 @@ comdis <- vegdist(comm, method = index) } ## Prepare for parallel processing - if (is.null(parallel) || getRversion() < "2.14.0") + if (is.null(parallel)) parallel <- 1 hasClus <- inherits(parallel, "cluster") isParal <- (hasClus || parallel > 1) && require(parallel) Modified: pkg/vegan/R/mantel.R =================================================================== --- pkg/vegan/R/mantel.R 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/R/mantel.R 2013-11-19 14:40:44 UTC (rev 2713) @@ -41,7 +41,7 @@ drop(cor(permvec, ydis, method = method, use = use)) } ## Parallel processing - if (is.null(parallel) || getRversion() < "2.14.0") + if (is.null(parallel)) parallel <- 1 hasClus <- inherits(parallel, "cluster") if ((hasClus || parallel > 1) && require(parallel)) { Modified: pkg/vegan/R/mantel.partial.R =================================================================== --- pkg/vegan/R/mantel.partial.R 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/R/mantel.partial.R 2013-11-19 14:40:44 UTC (rev 2713) @@ -49,7 +49,7 @@ part.cor(rxy, rxz, ryz) } ## parallel processing - if (is.null(parallel) || getRversion() < "2.14.0") + if (is.null(parallel)) parallel <- 1 hasClus <- inherits(parallel, "cluster") if ((hasClus || parallel > 1) && require(parallel)) { Modified: pkg/vegan/R/metaMDSiter.R =================================================================== --- pkg/vegan/R/metaMDSiter.R 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/R/metaMDSiter.R 2013-11-19 14:40:44 UTC (rev 2713) @@ -73,7 +73,7 @@ monostop(s0) tries <- 0 ## Prepare for parallel processing - if (is.null(parallel) || getRversion() < "2.14.0") + if (is.null(parallel)) parallel <- 1 hasClus <- inherits(parallel, "cluster") isParal <- (hasClus || parallel > 1) && require(parallel) Modified: pkg/vegan/R/mrpp.R =================================================================== --- pkg/vegan/R/mrpp.R 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/R/mrpp.R 2013-11-19 14:40:44 UTC (rev 2713) @@ -50,7 +50,7 @@ ncol(perms), N)) } ## Parallel processing - if (is.null(parallel) || getRversion() < "2.14.0") + if (is.null(parallel)) parallel <- 1 hasClus <- inherits(parallel, "cluster") if ((hasClus || parallel > 1) && require(parallel)) { Modified: pkg/vegan/R/oecosimu.R =================================================================== --- pkg/vegan/R/oecosimu.R 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/R/oecosimu.R 2013-11-19 14:40:44 UTC (rev 2713) @@ -87,7 +87,7 @@ simind <- NULL ## Go to parallel processing if 'parallel > 1' or 'parallel' could ## be a pre-defined socket cluster or 'parallel = NULL'. - if (is.null(parallel) || getRversion() < "2.14.0") + if (is.null(parallel)) parallel <- 1 hasClus <- inherits(parallel, "cluster") if ((hasClus || parallel > 1) && require(parallel)) { Modified: pkg/vegan/R/permutest.cca.R =================================================================== --- pkg/vegan/R/permutest.cca.R 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/R/permutest.cca.R 2013-11-19 14:40:44 UTC (rev 2713) @@ -132,7 +132,7 @@ permutations <- shuffleSet(N, control = permutations) nperm <- nrow(permutations) ## Parallel processing (similar as in oecosimu) - if (is.null(parallel) || getRversion() < "2.14.0") + if (is.null(parallel)) parallel <- 1 hasClus <- inherits(parallel, "cluster") if ((hasClus || parallel > 1) && require(parallel)) { Modified: pkg/vegan/R/simper.R =================================================================== --- pkg/vegan/R/simper.R 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/R/simper.R 2013-11-19 14:40:44 UTC (rev 2713) @@ -38,7 +38,7 @@ if (nperm > 0) perm.contr <- matrix(nrow=P, ncol=nperm) ## Parallel processing ? - if (is.null(parallel) || getRversion() < "2.14.0") + if (is.null(parallel)) parallel <- 1 hasClus <- inherits(parallel, "cluster") isParal <- (hasClus || parallel > 1) && require(parallel) Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/inst/ChangeLog 2013-11-19 14:40:44 UTC (rev 2713) @@ -31,6 +31,13 @@ permutations, constrained ordination, in particular in capscale() and rounding of output. We have also introduced some changes in output that were not yet synced. + + * janitorial: vegan has been dependent on R >= 2.14.0 since + version 2.1-34 (r2597 Wed 28-Aug-2013). Now superfluous references + and tests for the older R version were removed in R code and + documentation. FIXME: cca() returns residuals.zombie item that was + supposed to be needed in R < 2.13.0. This was not yet removed: we + must first check that this can be safely done. Version 2.1-38 (closed November 10, 2013) Modified: pkg/vegan/man/nobs.adonis.Rd =================================================================== --- pkg/vegan/man/nobs.adonis.Rd 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/man/nobs.adonis.Rd 2013-11-19 14:40:44 UTC (rev 2713) @@ -31,14 +31,15 @@ } } -\details{ Function \code{nobs} is generic in \R version 2.13.0, and +\details{ Function \code{nobs} is generic in \R, and \pkg{vegan} provides methods for objects from \code{\link{adonis}}, \code{\link{betadisper}}, \code{\link{cca}} and other related methods, \code{\link{CCorA}}, \code{\link{decorana}}, \code{\link{isomap}}, \code{\link{metaMDS}}, \code{\link{pcnm}}, \code{\link{procrustes}}, \code{\link{radfit}}, - \code{\link{varpart}} and \code{\link{wcmdscale}}. } \value{ A - single number, normally an integer, giving the number of + \code{\link{varpart}} and \code{\link{wcmdscale}}. } + +\value{ A single number, normally an integer, giving the number of observations. } \author{ Modified: pkg/vegan/man/screeplot.cca.Rd =================================================================== --- pkg/vegan/man/screeplot.cca.Rd 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/man/screeplot.cca.Rd 2013-11-19 14:40:44 UTC (rev 2713) @@ -116,10 +116,7 @@ Legendre, P. and Legendre, L. (2012) \emph{Numerical Ecology}. 3rd English ed. Elsevier. } -\note{Function \code{screeplot} is generic from \code{R} version - 2.5.0. In these versions you can use plain \code{screeplot} command - without suffices \code{cca}, \code{prcomp} etc. - } + \author{Gavin L. Simpson} \seealso{ \code{\link{cca}}, \code{\link{decorana}}, \code{\link{princomp}} and Modified: pkg/vegan/vignettes/decision-vegan.Rnw =================================================================== --- pkg/vegan/vignettes/decision-vegan.Rnw 2013-11-18 19:52:40 UTC (rev 2712) +++ pkg/vegan/vignettes/decision-vegan.Rnw 2013-11-19 14:40:44 UTC (rev 2713) @@ -38,8 +38,8 @@ \section{Parallel processing} Several \pkg{vegan} functions can perform parallel processing using -the standard \R{} package \pkg{parallel}.\footnote{Available since - \R{} version 2.14.0.} The \pkg{parallel} package in \R{} implements +the standard \R{} package \pkg{parallel}. +The \pkg{parallel} package in \R{} implements the functionality of earlier contributed packages \pkg{multicore} and \pkg{snow}. The \pkg{multicore} functionality forks the analysis to multiple cores, and \pkg{snow} functionality sets up a socket cluster From noreply at r-forge.r-project.org Wed Nov 20 12:26:37 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Nov 2013 12:26:37 +0100 (CET) Subject: [Vegan-commits] r2714 - in pkg/vegan: R inst Message-ID: <20131120112637.C46D4184C50@r-forge.r-project.org> Author: jarioksa Date: 2013-11-20 12:26:37 +0100 (Wed, 20 Nov 2013) New Revision: 2714 Added: pkg/vegan/R/anovacca.byterm.R Modified: pkg/vegan/R/anovacca.R pkg/vegan/inst/ChangeLog Log: add by='term' and by='margin' cases to new anova(.)cca tests Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-11-19 14:40:44 UTC (rev 2713) +++ pkg/vegan/R/anovacca.R 2013-11-20 11:26:37 UTC (rev 2714) @@ -30,19 +30,19 @@ ## stop permutations block ## see if this was a list of ordination objects dotargs <- list(...) + ## we do not want to give dotargs to anova.ccalist, but we + ## evaluate 'parallel' and 'model' here + if (is.null(dotargs$model)) + model <- "reduced" + else + model <- dotargs$model + if (is.null(dotargs$parallel)) + parallel <- NULL + else + parallel <- dotargs$parallel if (length(dotargs)) { isCCA <- sapply(dotargs, function(z) inherits(z, "cca")) if (any(isCCA)) { - ## we do not want to give dotargs to anova.ccalist, but we - ## evaluate 'parallel' and 'model' here - if (is.null(dotargs$model)) - model <- "reduced" - else - model <- dotargs$model - if (is.null(dotargs$parallel)) - parallel <- NULL - else - parallel <- dotargs$parallel dotargs <- dotargs[isCCA] object <- c(list(object), dotargs) sol <- @@ -55,8 +55,15 @@ } ## by cases if (!is.null(by)) { - by <- match.arg(by, c("axis", "terms", "margin")) - .NotYetUsed("by") + by <- match.arg(by, c("terms", "margin")) + sol <- switch(by, + "terms" = anovacca.byterm(object, + permutations = permutations, + model = model, parallel = parallel), + "margin" = anovacca.bymargin(object, + permutations = permutations, + model = model, parallel = parallel)) + return(sol) } ## basic overall test tst <- permutest.cca(object, permutations = permutations, ...) Added: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R (rev 0) +++ pkg/vegan/R/anovacca.byterm.R 2013-11-20 11:26:37 UTC (rev 2714) @@ -0,0 +1,69 @@ +### Implementation of by-cases for vegan 2.2 versions of +### anova.cca. These are all internal functions that are not intended +### to be called by users in normal sessions, but they should be +### called from anova.cca (2.2). Therefore the user interface is rigid +### and input is not checked. The 'permutations' should be a +### permutation matrix. + +### by = terms builds models as a sequence of adding terms and submits +### this to anova.ccalist + +`anovacca.byterm` <- + function(object, permutations, model, parallel) +{ + ## We need term labels but without Condition() terms + trms <- terms(object) + trmlab <- attr(trms, "term.labels") + trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo), + "term.labels")] + m0 <- update(object, . ~ 1) + mods <- list(m0) + for(i in seq_along(trmlab)) { + fla <- paste(". ~ . + ", trmlab[i]) + mods[[i+1]] <- update(mods[[i]], fla) + } + ## The result. Should be reformatted + anova.ccalist(mods, permutations = permutations, model = model, parallel = parallel) +} + +## by = margin: this is not a anova.ccalist case, but we omit each +## term in turn and compare against the complete model. + +`anovacca.bymargin` <- + function(object, permutations, ...) +{ + nperm <- nrow(permutations) + ## We need term labels but without Condition() terms + trms <- terms(object) + trmlab <- attr(trms, "term.labels") + trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo), + "term.labels")] + ## baseline: all terms + big <- permutest(object, permutations, ...) + dfbig <- big$df[2] + chibig <- big$chi[2] + scale <- big$den/dfbig + ## Collect all marginal models + mods <- lapply(trmlab, function(nm, ...) + permutest(update(object, paste(".~.-", nm)), + permutations, ...)) + ## Chande in df + Df <- sapply(mods, function(x) x$df[2]) - dfbig + ## F of change + Chisq <- sapply(mods, function(x) x$chi[2]) - chibig + Fstat <- (Chisq/Df)/(chibig/dfbig) + ## Simulated F-values + Fval <- sapply(mods, function(x) x$den) + Fval <- sweep(Fval, 1, big$den, "-") + Fval <- sweep(Fval, 2, Df, "/") + Fval <- sweep(Fval, 1, scale, "/") + ## Simulated P-values + Pval <- (colSums(sweep(Fval, 2, Fstat, ">=")) + 1)/(nperm + 1) + ## Collect results to anova data.frame + out <- data.frame(c(Df, dfbig), c(Chisq, chibig), + c(Fstat, NA), c(Pval, NA)) + colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)") + rownames(out) <- c(trmlab, "Residual") + class(out) <- c("anova", "data.frame") + out +} Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-11-19 14:40:44 UTC (rev 2713) +++ pkg/vegan/inst/ChangeLog 2013-11-20 11:26:37 UTC (rev 2714) @@ -10,9 +10,16 @@ the function no more adapts the number of iterations for the P-value, and arguments 'step' and 'perm.max' were removed. Instead, permute package is used to create a permutation matrix - used in all cases with fixed number of permutations. At the first - stage, only the overall test is provided. + used in all cases with fixed number of permutations. + In addition to the overall test, the function allows now testing + a sequence of models (anova.ccalist). Specific tests provided are + by = "term" (anovacca.byterm) which is fitted as a sequence of + models in anova.ccalist. Case by = "margin" directly calls + permutest.cca and gets the significances from differences of + residual variation similarly as anova.ccalist. Case by = "axis" is + not yet implemented. + * commsim: documentation (commsim.Rd) was restructured so that nullmodels were collected under separate sections with a brief introductory text and shorter specific text of the From noreply at r-forge.r-project.org Wed Nov 20 17:08:43 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Nov 2013 17:08:43 +0100 (CET) Subject: [Vegan-commits] r2715 - pkg/vegan/R Message-ID: <20131120160843.789D018660A@r-forge.r-project.org> Author: jarioksa Date: 2013-11-20 17:08:43 +0100 (Wed, 20 Nov 2013) New Revision: 2715 Modified: pkg/vegan/R/anovacca.byterm.R Log: reformat anovacca.byterm output to a standard term table Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-11-20 11:26:37 UTC (rev 2714) +++ pkg/vegan/R/anovacca.byterm.R 2013-11-20 16:08:43 UTC (rev 2715) @@ -16,6 +16,7 @@ trmlab <- attr(trms, "term.labels") trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo), "term.labels")] + ntrm <- length(trmlab) m0 <- update(object, . ~ 1) mods <- list(m0) for(i in seq_along(trmlab)) { @@ -23,7 +24,16 @@ mods[[i+1]] <- update(mods[[i]], fla) } ## The result. Should be reformatted - anova.ccalist(mods, permutations = permutations, model = model, parallel = parallel) + sol <- anova.ccalist(mods, permutations = permutations, + model = model, parallel = parallel) + out <- data.frame(c(sol[-1,3], sol[ntrm+1,1]), + c(sol[-1,4], sol[ntrm+1,2]), + c(sol[-1,5], NA), + c(sol[-1,6], NA)) + colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)") + rownames(out) <- c(trmlab, "Residual") + class(out) <- c("anova","data.frame") + out } ## by = margin: this is not a anova.ccalist case, but we omit each From noreply at r-forge.r-project.org Wed Nov 20 17:46:47 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Nov 2013 17:46:47 +0100 (CET) Subject: [Vegan-commits] r2716 - pkg/vegan/R Message-ID: <20131120164647.516B01855D5@r-forge.r-project.org> Author: jarioksa Date: 2013-11-20 17:46:47 +0100 (Wed, 20 Nov 2013) New Revision: 2716 Modified: pkg/vegan/R/anovacca.byterm.R Log: keep Conditions() in the null model in anovacca(..., by='term' Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-11-20 16:08:43 UTC (rev 2715) +++ pkg/vegan/R/anovacca.byterm.R 2013-11-20 16:46:47 UTC (rev 2716) @@ -17,15 +17,16 @@ trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo), "term.labels")] ntrm <- length(trmlab) - m0 <- update(object, . ~ 1) + m0 <- update(object, paste(".~.-", paste(trmlab, collapse="-"))) mods <- list(m0) for(i in seq_along(trmlab)) { fla <- paste(". ~ . + ", trmlab[i]) mods[[i+1]] <- update(mods[[i]], fla) } - ## The result. Should be reformatted + ## The result sol <- anova.ccalist(mods, permutations = permutations, model = model, parallel = parallel) + ## Reformat out <- data.frame(c(sol[-1,3], sol[ntrm+1,1]), c(sol[-1,4], sol[ntrm+1,2]), c(sol[-1,5], NA), From noreply at r-forge.r-project.org Wed Nov 20 18:03:19 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 20 Nov 2013 18:03:19 +0100 (CET) Subject: [Vegan-commits] r2717 - pkg/vegan/R Message-ID: <20131120170320.24743186120@r-forge.r-project.org> Author: jarioksa Date: 2013-11-20 18:03:19 +0100 (Wed, 20 Nov 2013) New Revision: 2717 Modified: pkg/vegan/R/permutest.cca.R Log: permutest gave wrong residual df for models for partial models without constraints (only Conditions) Modified: pkg/vegan/R/permutest.cca.R =================================================================== --- pkg/vegan/R/permutest.cca.R 2013-11-20 16:46:47 UTC (rev 2716) +++ pkg/vegan/R/permutest.cca.R 2013-11-20 17:03:19 UTC (rev 2717) @@ -13,7 +13,8 @@ if (is.null(x$CCA)) { sol <- list(call = match.call(), testcall = x$call, model = NA, F.0 = NA, F.perm = NA, chi = c(0, x$CA$tot.chi), - num = 0, den = 0, df = c(0, nrow(x$CA$u) - 1), + num = 0, den = 0, + df = c(0, nrow(x$CA$u) - max(x$pCCA$rank,0) - 1), nperm = 0, method = x$method, first = FALSE, Random.seed = NA) class(sol) <- "permutest.cca" From noreply at r-forge.r-project.org Thu Nov 21 17:06:36 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:06:36 +0100 (CET) Subject: [Vegan-commits] r2718 - pkg/vegan/R Message-ID: <20131121160636.4DAB6184706@r-forge.r-project.org> Author: jarioksa Date: 2013-11-21 17:06:35 +0100 (Thu, 21 Nov 2013) New Revision: 2718 Modified: pkg/vegan/R/anovacca.byterm.R Log: add marginal tests for CCA axes (no interface yet) Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-11-20 17:03:19 UTC (rev 2717) +++ pkg/vegan/R/anovacca.byterm.R 2013-11-21 16:06:35 UTC (rev 2718) @@ -78,3 +78,32 @@ class(out) <- c("anova", "data.frame") out } + +### Marginal test for axes + +`anovacca.byaxis` <- + function(object, permutations, model, parallel) +{ + nperm <- nrow(permutations) + ## Observed F-values and Df + eig <- object$CCA$eig + resdf <- nobs(object) - length(eig) - max(object$pCCA$rank, 0) - 1 + Fstat <- eig/object$CA$tot.chi*resdf + Df <- rep(1, length(eig)) + ## Marginal P-values + LC <- object$CCA$u + Pvals <- numeric(length(eig)) + environment(object$terms) <- environment() + for (i in 1:length(eig)) { + Partial <- LC[,-i] + mod <- permutest(update(object, . ~ . + Condition(Partial)), + model = model, parellel = parallel) + Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1) + } + out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi), + c(Fstat, NA), c(Pvals,NA)) + rownames(out) <- c(names(eig), "Residual") + colnames(out) <- c("Df", "Chisq", "F", "Pr(>F)") + class(out) <- c("anova", "data.frame") + out +} From noreply at r-forge.r-project.org Thu Nov 21 17:24:14 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:24:14 +0100 (CET) Subject: [Vegan-commits] r2719 - pkg/permute/R Message-ID: <20131121162414.D526C1855D5@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:24:14 +0100 (Thu, 21 Nov 2013) New Revision: 2719 Modified: pkg/permute/R/getFoo-methods.R Log: add some new meothods to work with Plots and Within classed objects Modified: pkg/permute/R/getFoo-methods.R =================================================================== --- pkg/permute/R/getFoo-methods.R 2013-11-21 16:06:35 UTC (rev 2718) +++ pkg/permute/R/getFoo-methods.R 2013-11-21 16:24:14 UTC (rev 2719) @@ -1,66 +1,66 @@ ## Extractor functions for blocks, plots and within, plus strata ## Blocks -getBlocks <- function(object, ...) { +`getBlocks` <- function(object, ...) { UseMethod("getBlocks") } -getBlocks.default <- function(object, ...) { +`getBlocks.default` <- function(object, ...) { stop("No default method for 'getBlocks()'") } -getBlocks.permControl <- function(object, ...) { +`getBlocks.permControl` <- function(object, ...) { object$blocks } -getBlocks.how <- function(object, ...) { +`getBlocks.how` <- function(object, ...) { object$blocks } ## Plots -getPlots <- function(object, ...) { +`getPlots` <- function(object, ...) { UseMethod("getPlots") } -getPlots.default <- function(object, ...) { +`getPlots.default` <- function(object, ...) { stop("No default method for 'getPlots()'") } -getPlots.permControl <- function(object, ...) { +`getPlots.permControl` <- function(object, ...) { object$plots } -getPlots.how <- function(object, ...) { +`getPlots.how` <- function(object, ...) { object$plots } ## Within plots -getWithin <- function(object, ...) { +`getWithin` <- function(object, ...) { UseMethod("getWithin") } -getWithin.default <- function(object, ...) { +`getWithin.default` <- function(object, ...) { stop("No default method for 'getWithin()'") } -getWithin.permControl <- function(object, ...) { +`getWithin.permControl` <- function(object, ...) { object$within } -getWithin.how <- function(object, ...) { +`getWithin.how` <- function(object, ...) { object$within } ## Strata -getStrata <- function(object, ...) { +`getStrata` <- function(object, ...) { UseMethod("getStrata") } -getStrata.default <- function(object, ...) { +`getStrata.default` <- function(object, ...) { stop("No default method for 'getStrata()'") } -getStrata.permControl <- function(object, +`getStrata.permControl` <- function(object, which = c("plots", "blocks"), drop = TRUE, ...) { which <- match.arg(which) @@ -74,7 +74,7 @@ strata } -getStrata.how <- function(object, +`getStrata.how` <- function(object, which = c("plots","blocks"), drop = TRUE, ...) { which <- match.arg(which) @@ -89,17 +89,24 @@ strata } +`getStrata.Plots` <- function(object, drop = TRUE, ... ) { + strata <- object$strata + if(isTRUE(drop) && !is.null(strata)) + strata <- droplevels(strata) + strata +} + ## Get type of permutation -getType <- function(object, ...) { +`getType` <- function(object, ...) { UseMethod("getType") } -getType.default <- function(object, ...) { +`getType.default` <- function(object, ...) { stop("No default method for 'getType()'") } -getType.permControl <- function(object, - which = c("plots","within"), ...) { +`getType.permControl` <- function(object, + which = c("plots","within"), ...) { which <- match.arg(which) if(isTRUE(all.equal(which, "plots"))) type <- getPlots(object)$type @@ -110,8 +117,8 @@ type } -getType.how <- function(object, - which = c("plots","within"), ...) { +`getType.how` <- function(object, + which = c("plots","within"), ...) { which <- match.arg(which) if(isTRUE(all.equal(which, "plots"))) type <- getPlots(object)$type @@ -122,6 +129,14 @@ type } +`getType.Within` <- function(object, ...) { + object$within$type +} + +`getType.Plots` <- function(object, ...) { + object$plots$type +} + ## suppose we can also have setBlocks() etc... ## to update the control object in place.... @@ -158,6 +173,14 @@ mirror } +`getMirror.Within` <- function(object, ...) { + object$within$mirror +} + +`getMirror.Plots` <- function(object, ...) { + object$plots$mirror +} + ## Get constant status - i.e. same permutation in each Plot `getConstant` <- function(object, ...) { UseMethod("getConstant") @@ -175,6 +198,10 @@ getWithin(object)$constant } +`getConstant.Within` <- function(object, ...) { + object$within$constant +} + ## Get the number of rows and colums from grid designs `getRow` <- function(object, ...) { UseMethod("getRow") @@ -208,6 +235,14 @@ nrow } +`getRow.Within` <- function(object, ...) { + object$within$nrow +} + +`getRow.Plots` <- function(object, ...) { + object$plots$nrow +} + `getCol` <- function(object, ...) { UseMethod("getCol") } @@ -240,6 +275,14 @@ ncol } +`getCol.Within` <- function(object, ...) { + object$within$ncol +} + +`getCol.Plots` <- function(object, ...) { + object$plots$ncol +} + `getDim` <- function(object, ...) { UseMethod("getDim") } @@ -282,6 +325,14 @@ c(nr, nc) } +`getDim.Within` <- function(object, ...) { + c(object$nrow, object$ncol) +} + +`getDim.Plots` <- function(object, ...) { + c(object$nrow, object$ncol) +} + ## return the requested number of permutations `getNperm` <- function(object, ...) { UseMethod("getNperm") From noreply at r-forge.r-project.org Thu Nov 21 17:25:59 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:25:59 +0100 (CET) Subject: [Vegan-commits] r2720 - pkg/permute/R Message-ID: <20131121162559.7C7B81855D5@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:25:59 +0100 (Thu, 21 Nov 2013) New Revision: 2720 Added: pkg/permute/R/setFoo-methods.R Log: add a new function and methods to update feature of a permutation design without using update() Added: pkg/permute/R/setFoo-methods.R =================================================================== --- pkg/permute/R/setFoo-methods.R (rev 0) +++ pkg/permute/R/setFoo-methods.R 2013-11-21 16:25:59 UTC (rev 2720) @@ -0,0 +1,161 @@ +`setNperm<-` <- function(object, value) { + UseMethod("setNperm<-") +} + +`setNperm<-.default` <- function(object, value) { + stop("No default method for `setNperm`") +} + +`setNperm<-.how` <- function(object, value) { + object[["nperm"]] <- value + object <- fixupCall(object, "nperm", value) + object +} + +`setNperm<-.permControl` <- function(object, value) { + object[["nperm"]] <- value + object <- fixupCall(object, "nperm", value) + object +} + +`setMaxperm<-` <- function(object, value) { + UseMethod("setMaxperm<-") +} + +`setMaxperm<-.default` <- function(object, value) { + stop("No default method for `setMaxperm`") +} + +`setMaxperm<-.how` <- function(object, value) { + object[["maxperm"]] <- value + object <- fixupCall(object, "maxperm", value) + object +} + +`setMaxperm<-.permControl` <- function(object, value) { + object[["maxperm"]] <- value + object <- fixupCall(object, "maxperm", value) + object +} + +`setMinperm<-` <- function(object, value) { + UseMethod("setMinperm<-") +} + +`setMinperm<-.default` <- function(object, value) { + stop("No default method for `setMinperm`") +} + +`setMinperm<-.how` <- function(object, value) { + object[["minperm"]] <- value + object <- fixupCall(object, "minperm", value) + object +} + +`setMinperm<-.permControl` <- function(object, value) { + object[["minperm"]] <- value + object <- fixupCall(object, "minperm", value) + object +} + +`setComplete<-` <- function(object, value) { + UseMethod("setComplete<-") +} + +`setComplete<-.default` <- function(object, value) { + stop("No default method for `setComplete`") +} + +`setComplete<-.how` <- function(object, value) { + object[["complete"]] <- value + object <- fixupCall(object, "complete", value) + object +} + +`setComplete<-.permControl` <- function(object, value) { + object[["complete"]] <- value + object <- fixupCall(object, "complete", value) + object +} + +`setAllperms<-` <- function(object, value) { + UseMethod("setAllperms<-") +} + +`setAllperms<-.default` <- function(object, value) { + stop("No default method for `setAllperms`") +} + +`setAllperms<-.how` <- function(object, value) { + object[["all.perms"]] <- value + object <- fixupCall(object, "all.perms", value) + object +} + +`setAllperms<-.permControl` <- function(object, value) { + object[["all.perms"]] <- value + object <- fixupCall(object, "all.perms", value) + object +} + +`setMake<-` <- function(object, value) { + UseMethod("setMake<-") +} + +`setMake<-.default` <- function(object, value) { + stop("No default method for `setMake`") +} + +`setMake<-.how` <- function(object, value) { + object[["make"]] <- value + object <- fixupCall(object, "make", value) + object +} + +`setMake<-.permControl` <- function(object, value) { + object[["all.perms"]] <- value + object <- fixupCall(object, "make", value) + object +} + +`setBlocks<-` <- function(object, value) { + UseMethod("setBlocks<-") +} + +`setBlocks<-.default` <- function(object, value) { + stop("No default method for `setBlocks`") +} + +`setBlocks<-.how` <- function(object, value) { + object["blocks"] <- list(value) + object[["blocks.name"]] <- deparse(substitute(value)) + object <- fixupCall(object, "blocks", value) + object +} + +`setBlocks<-.permControl` <- function(object, value) { + object["blocks"] <- list(value) + object[["blocks.name"]] <- deparse(substitute(value)) + object <- fixupCall(object, "blocks", value) + object +} + +`setObserved<-` <- function(object, value) { + UseMethod("setObserved<-") +} + +`setObserved<-.default` <- function(object, value) { + stop("No default method for `setObserved`") +} + +`setObserved<-.how` <- function(object, value) { + object[["observed"]] <- value + object <- fixupCall(object, "observed", value) + object +} + +`setObserved<-.permControl` <- function(object, value) { + object[["all.perms"]] <- value + object <- fixupCall(object, "observed", value) + object +} From noreply at r-forge.r-project.org Thu Nov 21 17:28:43 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:28:43 +0100 (CET) Subject: [Vegan-commits] r2721 - pkg/permute Message-ID: <20131121162843.67EEA1855D5@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:28:43 +0100 (Thu, 21 Nov 2013) New Revision: 2721 Modified: pkg/permute/NAMESPACE Log: update NAMESPACE due to more get-methods and new set-methods Modified: pkg/permute/NAMESPACE =================================================================== --- pkg/permute/NAMESPACE 2013-11-21 16:25:59 UTC (rev 2720) +++ pkg/permute/NAMESPACE 2013-11-21 16:28:43 UTC (rev 2721) @@ -17,6 +17,8 @@ ### S3 Methods S3method(`as.matrix`, `permutationMatrix`) +S3method(`update`, `how`) +S3method(`update`, `Plots`) ## print methods S3method(`print`, `allPerms`) S3method(`print`, `check`) @@ -46,15 +48,21 @@ S3method(`getStrata`, `default`) S3method(`getStrata`, `how`) S3method(`getStrata`, `permControl`) +S3method(`getStrata`, `Plots`) S3method(`getType`, `default`) S3method(`getType`, `how`) S3method(`getType`, `permControl`) +S3method(`getType`, `Plots`) +S3method(`getType`, `Within`) S3method(`getMirror`, `default`) S3method(`getMirror`, `how`) S3method(`getMirror`, `permControl`) +S3method(`getMirror`, `Plots`) +S3method(`getMirror`, `Within`) S3method(`getConstant`, `default`) S3method(`getConstant`, `how`) S3method(`getConstant`, `permControl`) +S3method(`getConstant`, `Within`) S3method(`getNperm`, `default`) S3method(`getNperm`, `how`) S3method(`getNperm`, `permControl`) @@ -70,13 +78,71 @@ S3method(`getRow`, `default`) S3method(`getRow`, `how`) S3method(`getRow`, `permControl`) +S3method(`getRow`, `Plots`) +S3method(`getRow`, `Within`) S3method(`getCol`, `default`) S3method(`getCol`, `how`) S3method(`getCol`, `permControl`) +S3method(`getCol`, `Plots`) +S3method(`getCol`, `Within`) S3method(`getDim`, `default`) S3method(`getDim`, `how`) S3method(`getDim`, `permControl`) +S3method(`getDim`, `Plots`) +S3method(`getDim`, `Within`) S3method(`getMake`, `default`) 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(`setNperm<-`, `default`) +S3method(`setNperm<-`, `how`) +S3method(`setNperm<-`, `permControl`) +S3method(`setMaxperm<-`, `default`) +S3method(`setMaxperm<-`, `how`) +S3method(`setMaxperm<-`, `permControl`) +S3method(`setMinperm<-`, `default`) +S3method(`setMinperm<-`, `how`) +S3method(`setMinperm<-`, `permControl`) +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(`setMake<-`, `default`) +S3method(`setMake<-`, `how`) +S3method(`setMake<-`, `permControl`) +S3method(`setObserved<-`, `default`) +S3method(`setObserved<-`, `how`) +S3method(`setObserved<-`, `permControl`) +S3method(`setAllperms<-`, `default`) +S3method(`setAllperms<-`, `how`) +S3method(`setAllperms<-`, `permControl`) From noreply at r-forge.r-project.org Thu Nov 21 17:29:06 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:29:06 +0100 (CET) Subject: [Vegan-commits] r2722 - pkg/permute/man Message-ID: <20131121162906.EF0651855D5@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:29:06 +0100 (Thu, 21 Nov 2013) New Revision: 2722 Modified: pkg/permute/man/get-methods.Rd Log: document new get-methods Modified: pkg/permute/man/get-methods.Rd =================================================================== --- pkg/permute/man/get-methods.Rd 2013-11-21 16:28:43 UTC (rev 2721) +++ pkg/permute/man/get-methods.Rd 2013-11-21 16:29:06 UTC (rev 2722) @@ -12,18 +12,24 @@ \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} @@ -32,14 +38,20 @@ \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{getNperm} \alias{getNperm.default} \alias{getNperm.how} @@ -99,18 +111,30 @@ \method{getStrata}{how}(object, which = c("plots", "blocks"), drop = TRUE, ...) +\method{getStrata}{Plots}(object, drop = TRUE, ...) \method{getType}{how}(object, which = c("plots", "within"), ...) +\method{getType}{Plots}(object, ...) +\method{getType}{Within}(object, ...) \method{getMirror}{how}(object, which = c("plots", "within"), ...) +\method{getMirror}{Plots}(object, ...) +\method{getMirror}{Within}(object, ...) \method{getConstant}{how}(object, ...) +\method{getConstant}{Within}(object, ...) \method{getCol}{how}(object, which = c("plots", "within"), ...) +\method{getCol}{Plots}(object, ...) +\method{getCol}{Within}(object, ...) \method{getRow}{how}(object, which = c("plots", "within"), ...) +\method{getRow}{Plots}(object, ...) +\method{getRow}{Within}(object, ...) \method{getDim}{how}(object, which = c("plots", "within"), ...) +\method{getDim}{Plots}(object, ...) +\method{getDim}{Within}(object, ...) \method{getNperm}{how}(object, ...) From noreply at r-forge.r-project.org Thu Nov 21 17:30:03 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:30:03 +0100 (CET) Subject: [Vegan-commits] r2723 - pkg/permute/R Message-ID: <20131121163003.DE5BB1855D5@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:30:03 +0100 (Thu, 21 Nov 2013) New Revision: 2723 Added: pkg/permute/R/fixupCall.R Log: add fixupCall(), a new function to programmatically update the call stored in the how object. Added: pkg/permute/R/fixupCall.R =================================================================== --- pkg/permute/R/fixupCall.R (rev 0) +++ pkg/permute/R/fixupCall.R 2013-11-21 16:30:03 UTC (rev 2723) @@ -0,0 +1,12 @@ +## Non-exported function that can be used to fix up elements of a call +`fixupCall` <- function(object, element, value) { + ## element must be character! Try to coerce + element <- as.character(element) ## Fails if not coercible + .call <- getElement(object, "call") ## get call from object + .ll <- as.list(.call) ## convert to a list to manipulate + names(.ll) <- names(.call) ## set names on the list + .ll[[element]] <- value ## set element to value + .call <- as.call(.ll) ## convert back to a call + object$call <- .call ## push back into object + object +} From noreply at r-forge.r-project.org Thu Nov 21 17:33:48 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:33:48 +0100 (CET) Subject: [Vegan-commits] r2724 - pkg/permute/R Message-ID: <20131121163348.3FCD91855D5@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:33:47 +0100 (Thu, 21 Nov 2013) New Revision: 2724 Modified: pkg/permute/R/allStrata.R Log: small tweak to simplify some code whilst getting the update() and set-methods to work Modified: pkg/permute/R/allStrata.R =================================================================== --- pkg/permute/R/allStrata.R 2013-11-21 16:30:03 UTC (rev 2723) +++ pkg/permute/R/allStrata.R 2013-11-21 16:33:47 UTC (rev 2724) @@ -7,8 +7,8 @@ lev <- length(levels(strata)) ## compute nperms on number of levels - for this need Within() ## and type == typeP - newControl <- - how(within = Within(type = getType(control, which = "plots"))) + type <- getType(control, which = "plots") + newControl <- how(within = Within(type = type)) nperms <- numPerms(lev, newControl) ## result object X <- matrix(nrow = nperms, ncol = length(strata)) From noreply at r-forge.r-project.org Thu Nov 21 17:34:34 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:34:34 +0100 (CET) Subject: [Vegan-commits] r2725 - pkg/permute Message-ID: <20131121163434.1DA131855D5@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:34:33 +0100 (Thu, 21 Nov 2013) New Revision: 2725 Modified: pkg/permute/DESCRIPTION Log: permute now depends on a version of R equal to or later than 2.14.0 Modified: pkg/permute/DESCRIPTION =================================================================== --- pkg/permute/DESCRIPTION 2013-11-21 16:33:47 UTC (rev 2724) +++ pkg/permute/DESCRIPTION 2013-11-21 16:34:33 UTC (rev 2725) @@ -4,6 +4,7 @@ Date: $Date$ Author: Gavin L. Simpson Maintainer: Gavin L. Simpson +Depends: R (>= 2.14.0) Suggests: vegan (>= 2.0-0), testthat (>= 0.5) Description: The 'permute' package implements a set of restricted permutation designs for freely exchangeable, line transects (time series), and spatial grid designs plus permutation of blocks (groups of samples). 'permute' also allows split-plot designs, in which the whole-plots or split-plots or both can be freely-exchangeable or one of the restricted designs. The 'permute' package is modelled after the permutation schemes of Canoco 3.1 (and later) by Cajo ter Braak. License: GPL-2 From noreply at r-forge.r-project.org Thu Nov 21 17:36:37 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:36:37 +0100 (CET) Subject: [Vegan-commits] r2726 - pkg/permute/R Message-ID: <20131121163637.20CE31860C6@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:36:36 +0100 (Thu, 21 Nov 2013) New Revision: 2726 Added: pkg/permute/R/update.Plots.R pkg/permute/R/update.how.R Log: add updated methods for classes 'how' and 'Plots' Added: pkg/permute/R/update.Plots.R =================================================================== --- pkg/permute/R/update.Plots.R (rev 0) +++ pkg/permute/R/update.Plots.R 2013-11-21 16:36:36 UTC (rev 2726) @@ -0,0 +1,62 @@ +# File permute/R/update.Plots.R +# Part of the R package, http://www.R-project.org +# +# Copyright (C) 1995-2012 The R Core Team +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License is available at +# http://www.r-project.org/Licenses/ +# +# Modifications by Gavin L. Simpson +# +# Copyright (C) 2013 Gavin L. Simpson +# +# Modifcations made: +# 1) Remove `formula.` argument and processing thereof. +# 2) Evaluation is forced to the global environment. +# 3) (minor) Took the definition of `call` out of the `if ()` statement +# for clarity/style issues. +# 4) Added this modification section to the copyright/licence header. +# 5) Added code to preserve some components of the original object. + +`update.Plots` <- function (object, ..., evaluate = TRUE) { + call <- getCall(object) + if (is.null(call)) + stop("need an object with call component") + extras <- match.call(expand.dots = FALSE)$... + + ## preserve or update the plots names + pname <- if ("strata" %in% names(extras)) { + deparse(substitute(extras[["strata"]])) + } else { + object$plots.name + } + + if (length(extras)) { + existing <- !is.na(match(names(extras), names(call))) + ## do these individually to allow NULL to remove entries. + for (a in names(extras)[existing]) + call[[a]] <- extras[[a]] + if (any(!existing)) { + call <- c(as.list(call), extras[!existing]) + call <- as.call(call) + } + } + if (evaluate) { + out <- eval(call, parent.frame()) + out$plots.name <- pname + } else { + out <- call + } + + out +} Added: pkg/permute/R/update.how.R =================================================================== --- pkg/permute/R/update.how.R (rev 0) +++ pkg/permute/R/update.how.R 2013-11-21 16:36:36 UTC (rev 2726) @@ -0,0 +1,73 @@ +# File permute/R/update.how.R +# Part of the R package, http://www.R-project.org +# +# Copyright (C) 1995-2012 The R Core Team +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License is available at +# http://www.r-project.org/Licenses/ +# +# Modifications by Gavin L. Simpson +# +# Copyright (C) 2013 Gavin L. Simpson +# +# Modifcations made: +# 1) Remove `formula.` argument and processing thereof. +# 2) Evaluation is forced to the global environment. +# 3) (minor) Took the definition of `call` out of the `if ()` statement +# for clarity/style issues. +# 4) Added this modification section to the copyright/licence header. +# 5) Added code to preserve some components of the original object. + +`update.how` <- function (object, ..., evaluate = TRUE) { + call <- getCall(object) + if (is.null(call)) + stop("need an object with call component") + extras <- match.call(expand.dots = FALSE)$... + + ## preserve or update block and/or plot names + bname <- if ("blocks" %in% names(extras)) { + deparse(substitute(extras[["blocks"]])) + } else { + object$blocks.name + } + pname <- if ("plots" %in% names(extras)) { + dots <- list(...) + dots$plots$plots.name + } else { + object$plots$plots.name + } + + ## process remaining ... args + if (length(extras)) { + existing <- !is.na(match(names(extras), names(call))) + ## do these individually to allow NULL to remove entries. + for (a in names(extras)[existing]) + call[[a]] <- extras[[a]] + if (any(!existing)) { + call <- c(as.list(call), extras[!existing]) + call <- as.call(call) + } + } + + ## probably want to evaluate hence default is TRUE + if (evaluate) { + out <- eval(call, parent.frame()) + ## add back in the chars we discovered earlier + out$blocks.name <- bname + out$plots$plots.name <- pname + } else { + out <- call + } + + out +} From noreply at r-forge.r-project.org Thu Nov 21 17:42:33 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:42:33 +0100 (CET) Subject: [Vegan-commits] r2727 - pkg/permute/R Message-ID: <20131121164233.591ED1860D2@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:42:32 +0100 (Thu, 21 Nov 2013) New Revision: 2727 Modified: pkg/permute/R/check.R Log: reduce length of messages; switch from 'update' to 'set-methods' Modified: pkg/permute/R/check.R =================================================================== --- pkg/permute/R/check.R 2013-11-21 16:36:36 UTC (rev 2726) +++ pkg/permute/R/check.R 2013-11-21 16:42:32 UTC (rev 2727) @@ -67,27 +67,24 @@ ## check if number requested permutations exceeds max possible if(getNperm(control) > num.pos) { - control <- update(control, nperm = num.pos, maxperm = num.pos, - complete = TRUE) - control$call[["nperm"]] <- eval(control$call[["nperm"]]) - control$call[["maxperm"]] <- eval(control$call[["maxperm"]]) - message("Requested number of permutations larger than entire set of possible permutations.\nReseting 'nperm' to number of permutations in entire set.") + setComplete(control) <- TRUE + setNperm(control) <- num.pos + setMaxperm(control) <- num.pos + message("'nperm' > set of all permutations; Resetting 'nperm'.") } ## if number of possible perms < minperm turn on complete enumeration if((num.pos < getMinperm(control))) { - control <- update(control, nperm = num.pos, maxperm = num.pos, - complete = TRUE) - control$call[["nperm"]] <- eval(control$call[["nperm"]]) - control$call[["maxperm"]] <- eval(control$call[["maxperm"]]) - message("Number of permutations possible is less than 'minperm'.\nTurning on complete enumeration via 'complete = TRUE'. See '?how' for details.") + setComplete(control) <- TRUE + setNperm(control) <- num.pos + setMaxperm(control) <- num.pos + message("Set of permutations < 'minperm'. Generating entire set.") } ## if complete enumeration, generate all permutations if(getComplete(control) && getMake(control)) { ap <- allPerms(N, control = control, check = FALSE) - control <- update(control, all.perms = ap) - control$call[["all.perms"]] <- eval(control$call[["all.perms"]]) + setAllperms(control) <- ap } retval <- list(n = num.pos, control = control) class(retval) <- "check" From noreply at r-forge.r-project.org Thu Nov 21 17:43:35 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:43:35 +0100 (CET) Subject: [Vegan-commits] r2728 - pkg/permute/inst/tests Message-ID: <20131121164335.0B5EC1860D2@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:43:34 +0100 (Thu, 21 Nov 2013) New Revision: 2728 Modified: pkg/permute/inst/tests/test-shuffleSet.R Log: minor stylistic change Modified: pkg/permute/inst/tests/test-shuffleSet.R =================================================================== --- pkg/permute/inst/tests/test-shuffleSet.R 2013-11-21 16:42:32 UTC (rev 2727) +++ pkg/permute/inst/tests/test-shuffleSet.R 2013-11-21 16:43:34 UTC (rev 2728) @@ -10,7 +10,7 @@ ## a vector of 1,0,1,0,1,... test_that("shuffleSet interleves block-level perms correctly", { gr <- factor(rep(1:2, length=20)) - ctrl <- how(nperm=5, blocks=gr) + ctrl <- how(nperm = 5, blocks = gr) p <- shuffleSet(20, control = ctrl) %% 2 y <- rep(c(1L, 0L), length.out = ncol(p)) nc <- ncol(p) From noreply at r-forge.r-project.org Thu Nov 21 17:44:06 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:44:06 +0100 (CET) Subject: [Vegan-commits] r2729 - pkg/permute/vignettes Message-ID: <20131121164406.73D9B1860D2@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:44:06 +0100 (Thu, 21 Nov 2013) New Revision: 2729 Modified: pkg/permute/vignettes/permutations.Rnw pkg/permute/vignettes/permute.bib Log: small additions and modifications to the vignette Modified: pkg/permute/vignettes/permutations.Rnw =================================================================== --- pkg/permute/vignettes/permutations.Rnw 2013-11-21 16:43:34 UTC (rev 2728) +++ pkg/permute/vignettes/permutations.Rnw 2013-11-21 16:44:06 UTC (rev 2729) @@ -286,7 +286,15 @@ How \code{Within()} is used has already been encountered in earlier sections of this vignette; the function is used to supply a value to the \code{within} argument of \code{how()}. You may have noticed that all the arguments of \code{Within()} have default values? This means that the user need only supply a modified value for the arguments they wish to change. Also, arguments that are not relevant for the type of permutation stated are simply ignored; \code{nrow} and \code{ncol}, for example, could be set to any value without affecting the permutation design if \code{type != "grid"}\footnote{No warnings are currently given if incompatible arguments are specified; they are ignored, but may show up in the printed output. This infelicity will be removed prior to \pkg{permute} version 1.0-0 being released.}. \subsubsection{Permuting samples at the Plot level} +Permutation of samples at the \emph{plot} level is configured via the \code{Plots()} function. As with \code{Within()}, \code{Plots()} is supplied to the \code{plots} argument of \code{how()}. \code{Plots()} takes many of the same arguments as \code{Within()}, the two differences being \code{strata}, a factor variable that describes the grouping of samples at the \emph{plot} level, and the absence of a \code{constant} argument. As the majority of arguments are similar between \code{Within()} and \code{Plots()}, I will not repeat the details again, and only describe the \code{strata} argument +\begin{description} + \item[\code{strata}] + a factor variable. \code{strata} describes the grouping of samples at the \emph{plot} level, where samples from the same \emph{plot} are take the same \emph{level} of the factor. +\end{description} + +When a \emph{plot}-level design is specified, samples are never permuted between \emph{plots}, only within plots if they are permuted at all. Hence, the type of permutation \emph{within} the \emph{plots} is controlled by \code{Within()}. Note also that with \code{Plots()}, the way the individual \emph{plots} are permuted can be from any one of the four basic permutation types; \code{"none"}, \code{"free"}, \code{"series"}, and \code{"grid"}, as described above. To permute the \emph{plots} only (i.e. retain the ordering of the samples \emph{within} plots), you need to use \code{Within(type = "none", ...)} as the default in \code{Within()} is \code{type = "free"}. The ability to permute the plots whilst preserving the within-plot ordering is an impotant feature in testing explanatory factors at the whole-plot level in split-plot designs and in multifactorial analysis of variance \citep{canoco5manual}. + \section*{Computational details} <>= toLatex(sessionInfo()) Modified: pkg/permute/vignettes/permute.bib =================================================================== --- pkg/permute/vignettes/permute.bib 2013-11-21 16:43:34 UTC (rev 2728) +++ pkg/permute/vignettes/permute.bib 2013-11-21 16:44:06 UTC (rev 2729) @@ -16,3 +16,11 @@ edition = {3rd} } + at Manual{canoco5manual, + title = {Canoco Reference Manual and User's Guide: Software for Ordination (Version 5.0)}, + OPTauthor = {ter Braak, C.J.F. and \v{S}milauer, P.}, + OPTorganization = {Microcomputer Power}, + OPTaddress = {Ithaca, NY, USA}, + OPTyear = {2012} +} + From noreply at r-forge.r-project.org Thu Nov 21 17:44:39 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:44:39 +0100 (CET) Subject: [Vegan-commits] r2730 - pkg/permute/R Message-ID: <20131121164439.26C121860D2@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:44:38 +0100 (Thu, 21 Nov 2013) New Revision: 2730 Modified: pkg/permute/R/print.permutationMatrix.R Log: changes in the way the design is printed Modified: pkg/permute/R/print.permutationMatrix.R =================================================================== --- pkg/permute/R/print.permutationMatrix.R 2013-11-21 16:44:06 UTC (rev 2729) +++ pkg/permute/R/print.permutationMatrix.R 2013-11-21 16:44:38 UTC (rev 2730) @@ -2,6 +2,81 @@ ## - at the moment, don't print the attributes `print.permutationMatrix` <- function(x, ...) { + ## indicators of plot and block strata + pl <- bl <- FALSE + + ## grab the permutation design + ctrl <- attr(x, "control") ## gives us the list generated by how() + + ## print out dimensions of permutation matrix + msg <- paste("No. of Permutations: ", nrow(x), "; No. of Samples: ", + ncol(x), sep = "") + writeLines(strwrap(msg)) + + ## print info on blocking, but ONLY if set + if (!is.null(blocks <- getBlocks(ctrl))) { + bl <- TRUE + ll <- length(levels(blocks)) + msg <- paste("Restricted by Blocks: ", ctrl$blocks.name, + " (", ll, " ", if (ll == 1L) "block" else "blocks", + ")", sep = "") + writeLines(strwrap(msg)) + } + + ## print info on plots, but ONLY if set + if (!is.null(strata <- getStrata(ctrl, which = "plots"))) { + pl <- TRUE + plots <- getPlots(ctrl) + pmsg <- switch(pt <- getType(ctrl, which = "plots"), + none = "", + free = "; Randomised", + series = "; Sequence", + grid = paste("; Spatial grid: ", + getRow(ctrl, which = "plots"), "r, ", + getCol(ctrl, which = "plots"), "c", sep = "")) + ## add info on mirroring if series or grid + if ((pt %in% c("series","grid")) && getMirror(ctrl, which = "plots")) { + pmsg <- paste(pmsg, " - mirrored") + } + ll <- length(levels(strata)) + msg <- paste("Restricted by Plots: ", plots$plots.name, + " (", ll, " ", if (ll == 1L) "plot" else "plots", + pmsg, ")", sep = "") + writeLines(strwrap(msg)) + } + + ## print info on the within level + msg <- "Samples (" + if (any(pl, bl)) { + msg <- paste(msg, "Nested in: ", sep = "") + if (pl && !bl) { + nmsg <- "plots; " + } else if (bl && !pl) { + nmsg <- "blocks; " + } else { + nmsg <- "plots & blocks; " + } + msg <- paste(msg, nmsg, sep = "") + } + wmsg <- switch(wt <- getType(ctrl, which = "within"), + none = "", + free = "Randomised", + series = "Sequence", + grid = paste("Spatial grid: ", + getRow(ctrl, which = "within"), "r, ", + getCol(ctrl, which = "within"), "c", sep = "")) + msg <- paste(msg, wmsg, sep = "") + ## add info on mirroring if series or grid + if ((wt %in% c("series", "grid")) && getMirror(ctrl, which = "within")) { + msg <- paste(msg, "; mirrored", sep = "") + } + ## add info on constant + if (getConstant(ctrl, which = "within") && pl) { + msg <- paste(msg, "; same permutation in each plot", sep = "") + } + writeLines(strwrap(paste(msg, ")", sep = ""))) + + cat("\n") x <- as.matrix(x) - print(x) + print(x, ...) } From noreply at r-forge.r-project.org Thu Nov 21 17:47:13 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:47:13 +0100 (CET) Subject: [Vegan-commits] r2731 - pkg/permute/R Message-ID: <20131121164713.94D481860B9@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:47:13 +0100 (Thu, 21 Nov 2013) New Revision: 2731 Modified: pkg/permute/R/allPerms.R Log: change from using 'update()' to 'set-methods' functions when updating the design object Modified: pkg/permute/R/allPerms.R =================================================================== --- pkg/permute/R/allPerms.R 2013-11-21 16:44:38 UTC (rev 2730) +++ pkg/permute/R/allPerms.R 2013-11-21 16:47:13 UTC (rev 2731) @@ -8,8 +8,11 @@ n <- nobs(v) ## check permutation scheme and update control make <- getMake(control) - if (check) - pcheck <- check(v, control = update(control, make = FALSE)) + if (check) { + control2 <- control + setMake(control2) <- FALSE + pcheck <- check(v, control = control2) + } ## ctrl <- pcheck$control ## if we do copy the new updated control, we need to update to ## reset make @@ -46,7 +49,8 @@ out <- vector(mode = "list", length = nb) ## null-out Blocks in control - control2 <- update(control, blocks = NULL) + control2 <- control + setBlocks(control2) <- NULL ## loop over blocks and return allPerms on each block for (i in seq_along(spl)) { @@ -65,8 +69,7 @@ out <- out[!obs.row, ] ## reduce the number of permutations to get rid of the ## observed ordering - ##control$nperm <- control$nperm - 1 - control <- update(control, nperm = getNperm(control) - 1) + setNperm(control) <- getNperm(control) - 1 } class(out) <- "allPerms" attr(out, "control") <- control From noreply at r-forge.r-project.org Thu Nov 21 17:50:29 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:50:29 +0100 (CET) Subject: [Vegan-commits] r2732 - in pkg/permute: R man Message-ID: <20131121165029.1DB6B1860B9@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:50:28 +0100 (Thu, 21 Nov 2013) New Revision: 2732 Modified: pkg/permute/R/Plots.R pkg/permute/R/Within.R pkg/permute/R/how.R pkg/permute/man/how.Rd Log: work much harder to preserve blocks and plots names and to update the call Modified: pkg/permute/R/Plots.R =================================================================== --- pkg/permute/R/Plots.R 2013-11-21 16:47:13 UTC (rev 2731) +++ pkg/permute/R/Plots.R 2013-11-21 16:50:28 UTC (rev 2732) @@ -1,10 +1,24 @@ `Plots` <- function(strata = NULL, type = c("none","free","series","grid"), mirror = FALSE, ncol = NULL, nrow = NULL) { + + plots.name <- deparse(substitute(strata)) + type <- match.arg(type) + + ## process the call to make it standalone + .call <- match.call() + if (length(.call) > 1L) { + .ll <- as.list(.call[-1]) + for (i in seq_along(.ll)) + .ll[[i]] <- eval(.ll[[i]], parent.frame()) + .ll <- c(as.list(.call[[1]]), .ll) + names(.ll) <- names(.call) + .call <- as.call(.ll) + } + out <- list(strata = strata, type = type, mirror = mirror, ncol = ncol, nrow = nrow, - plots.name = deparse(substitute(strata)), call = match.call()) - ## keep as list for now - ##class(out) <- "Plots" + plots.name = plots.name, call = .call) + class(out) <- "Plots" out } Modified: pkg/permute/R/Within.R =================================================================== --- pkg/permute/R/Within.R 2013-11-21 16:47:13 UTC (rev 2731) +++ pkg/permute/R/Within.R 2013-11-21 16:50:28 UTC (rev 2732) @@ -2,13 +2,21 @@ constant = FALSE, mirror = FALSE, ncol = NULL, nrow = NULL) { - if(missing(type)) - type <- "free" - else - type <- match.arg(type) + type <- match.arg(type) + + ## process the call to make it standalone + .call <- match.call() + if (length(.call) > 1L) { + .ll <- as.list(.call[-1]) + for (i in seq_along(.ll)) + .ll[[i]] <- eval(.ll[[i]], parent.frame()) + .ll <- c(as.list(.call[[1]]), .ll) + names(.ll) <- names(.call) + .call <- as.call(.ll) + } + out <- list(type = type, constant = constant, mirror = mirror, - ncol = ncol, nrow = nrow, call = match.call()) - ## keep as default list for now - ##class(out) <- "Within" + ncol = ncol, nrow = nrow, call = .call) + class(out) <- "Within" out } Modified: pkg/permute/R/how.R =================================================================== --- pkg/permute/R/how.R 2013-11-21 16:47:13 UTC (rev 2731) +++ pkg/permute/R/how.R 2013-11-21 16:50:28 UTC (rev 2732) @@ -8,13 +8,45 @@ all.perms = NULL, make = TRUE, observed = FALSE) { + + blocks.name <- deparse(substitute(blocks)) + + ## process the call to make it standalone + .call <- match.call() + if (length(.call) > 1L) { + .ll <- as.list(.call[-1]) + args <- names(.call)[-1] + ## evaluate arguments other than within and plots + ## those handled in their respective functions + for (i in args[!args %in% c("within","plots")]) { + .ll[[i]] <- eval(.ll[[i]], parent.frame()) + } + } + out <- list(within = within, plots = plots, blocks = blocks, nperm = nperm, complete = complete, maxperm = maxperm, minperm = minperm, all.perms = all.perms, make = make, observed = observed, - blocks.name = deparse(substitute(blocks)), - call = match.call()) + blocks.name = blocks.name) + + ## process within and plots separately + if (length(.call) > 1L && "within" %in% args) { + .ll[["within"]] <- getCall(within) + } + if (length(.call) > 1L && "plots" %in% args) { + .ll[["plots"]] <- getCall(plots) + } + + ## finsh off + if (length(.call) > 1L) { + .ll <- c(as.list(.call[[1]]), .ll) + names(.ll) <- names(.call) + .call <- as.call(.ll) + } + + out$call <- .call + class(out) <- "how" out } Modified: pkg/permute/man/how.Rd =================================================================== --- pkg/permute/man/how.Rd 2013-11-21 16:47:13 UTC (rev 2731) +++ pkg/permute/man/how.Rd 2013-11-21 16:50:28 UTC (rev 2732) @@ -122,6 +122,8 @@ update(h1, blocks = NULL) ## ... or switch the type of shuffling at a level: -update(h1, plots = update(getPlots(h1), type = "none")) +#update(h1, plots = update(getPlots(h1), type = "none")) +plots2 <- update(getPlots(h1), type = "none") +update(h1, plots = plots2) } \keyword{ utils } \ No newline at end of file From noreply at r-forge.r-project.org Thu Nov 21 17:52:27 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:52:27 +0100 (CET) Subject: [Vegan-commits] r2733 - in pkg/permute: R man Message-ID: <20131121165227.C9F461860B9@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:52:27 +0100 (Thu, 21 Nov 2013) New Revision: 2733 Modified: pkg/permute/R/shuffleSet2.R pkg/permute/man/shuffleSet.Rd Log: use 'set-methods' instead of 'update()'; minor documentation tweak Modified: pkg/permute/R/shuffleSet2.R =================================================================== --- pkg/permute/R/shuffleSet2.R 2013-11-21 16:50:28 UTC (rev 2732) +++ pkg/permute/R/shuffleSet2.R 2013-11-21 16:52:27 UTC (rev 2733) @@ -15,7 +15,7 @@ else nset <- np } else { - control <- update(control, nperm = nset) + setNperm(control) <- nset ## this fixes the control$call too! } sn <- seq_len(n) ## sequence of samples in order of input Modified: pkg/permute/man/shuffleSet.Rd =================================================================== --- pkg/permute/man/shuffleSet.Rd 2013-11-21 16:50:28 UTC (rev 2732) +++ pkg/permute/man/shuffleSet.Rd 2013-11-21 16:52:27 UTC (rev 2733) @@ -95,8 +95,7 @@ shuffleSet(n = 10, nset = 5) ## series random permutations, 5 permutations in set -shuffleSet(10, 5, how(within = Within(type = "series")), - check = FALSE) +shuffleSet(10, 5, how(within = Within(type = "series"))) ## series random permutations, 10 permutations in set, ## with possible mirroring @@ -117,7 +116,7 @@ ## as above but same random permutation within Plot-level strata CTRL <- how(plots = plotStrata, within = Within(type = "free", constant = TRUE)) -shuffleSet(20, 10, CTRL) +shuffleSet(20, 10, CTRL) ## check this. ## time series within each level of Plot strata CTRL <- how(plots = plotStrata, From noreply at r-forge.r-project.org Thu Nov 21 17:53:00 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 17:53:00 +0100 (CET) Subject: [Vegan-commits] r2734 - pkg/permute/inst Message-ID: <20131121165300.941401860B9@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 17:53:00 +0100 (Thu, 21 Nov 2013) New Revision: 2734 Modified: pkg/permute/inst/ChangeLog Log: document the suite of recent changes Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-21 16:52:27 UTC (rev 2733) +++ pkg/permute/inst/ChangeLog 2013-11-21 16:53:00 UTC (rev 2734) @@ -26,17 +26,57 @@ generate the set of all permutations. In that case `allPerms()` used to recheck the design. Now this doesn't happen. - Turned on some `message()`s when the user asks for too many permutations - (more than the set of possible permutations) and when the set of - possible permutations is smaller than the `minperm` value stored in the - `"how"` object. The latter notifies the user that the entire set of - permutations is being generated. + `allPerms` also uses the new `set<-` replacement functions rather than + `update()` as the latter causes problems when used within functions as + it often evaluates the stored call in the wrong environment. * check: following the change to `allPerms` (see above), `check()` no longer results in it calling itself, via `allPerms()`, when generating the set of possible permutations if the check heuristics indicate it should be. + Turned on some `message()`s when the user asks for too many permutations + (more than the set of possible permutations) and when the set of + possible permutations is smaller than the `minperm` value stored in the + `"how"` object. The latter notifies the user that the entire set of + permutations is being generated. These messages were updated to reduce + their length. + + `check` also uses the new `set<-` replacement functions rather than + `update()` as the latter causes problems when used within functions as + it often evaluates the stored call in the wrong environment. + + * Plots, Within: now return a object of class `"Plots"` or `"Within"`, + respectively. + + * get-methods: added a number of a new methods for existing functions + to work with `"Within"` and `"Plots"` classes. + + * set-methods: added a number of a new functions and methods with the + common name `setFoo<-.Bar` where `Foo` is the component to be updated, + and `Bar` is the class. These are replacement functions only. They are + intended to be used within functions, where the user-friendly `update()` + will have problems getting the call updated correctly ot evaluating it. + + * how, Plots, Within: Now work much harder to preserve details of the + design (i.e. the names of objects passed for the blocks or plot strata), + and also process the matched call so that the user can `update()` it. + + * fixupCall: a new, unexported function that allows the call objects + stored in a `"how"` object to be updated. This is not exported as it is + intended only for internal use. Function writers should use the + `setFoo<-` functions instead. Ordinary users should use `update()` as + long as it is not in a function. + + * update: new methods for objects of classes `"how"` and `"Plots". + Thes are copies of the standard R function `update.default` with some + changes. The source files for these two functions preserver the R + copyright statement and document modifications made by Gavin L. + Simpson. + + * Depends: permute requires a version of R no earlier than version + 2.14.0. + Version 0.7-6 * summary.allPerms: Was printing two slightly different subtitles. From noreply at r-forge.r-project.org Thu Nov 21 18:46:21 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 18:46:21 +0100 (CET) Subject: [Vegan-commits] r2735 - pkg/vegan/R Message-ID: <20131121174621.5A1FE185FB9@r-forge.r-project.org> Author: jarioksa Date: 2013-11-21 18:46:21 +0100 (Thu, 21 Nov 2013) New Revision: 2735 Modified: pkg/vegan/R/anovacca.byterm.R Log: use 'permutations' matrix in anovacca.byaxis Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-11-21 16:53:00 UTC (rev 2734) +++ pkg/vegan/R/anovacca.byterm.R 2013-11-21 17:46:21 UTC (rev 2735) @@ -54,7 +54,10 @@ dfbig <- big$df[2] chibig <- big$chi[2] scale <- big$den/dfbig - ## Collect all marginal models + ## Collect all marginal models. This differs from old version + ## (vegan 2.0) where other but 'nm' were partialled out within + ## Condition(). Now we only fit the model without 'nm' and compare + ## the difference against the complete model. mods <- lapply(trmlab, function(nm, ...) permutest(update(object, paste(".~.-", nm)), permutations, ...)) @@ -97,7 +100,8 @@ for (i in 1:length(eig)) { Partial <- LC[,-i] mod <- permutest(update(object, . ~ . + Condition(Partial)), - model = model, parellel = parallel) + permutations, model = model, + parellel = parallel) Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1) } out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi), From noreply at r-forge.r-project.org Thu Nov 21 19:03:57 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 19:03:57 +0100 (CET) Subject: [Vegan-commits] r2736 - pkg/permute Message-ID: <20131121180357.54B59186637@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 19:03:56 +0100 (Thu, 21 Nov 2013) New Revision: 2736 Modified: pkg/permute/DESCRIPTION Log: bump version to 0.7-8; prepare for a release to CRAN Modified: pkg/permute/DESCRIPTION =================================================================== --- pkg/permute/DESCRIPTION 2013-11-21 17:46:21 UTC (rev 2735) +++ pkg/permute/DESCRIPTION 2013-11-21 18:03:56 UTC (rev 2736) @@ -1,6 +1,6 @@ Package: permute Title: Functions for generating restricted permutations of data -Version: 0.7-7 +Version: 0.7-8 Date: $Date$ Author: Gavin L. Simpson Maintainer: Gavin L. Simpson From noreply at r-forge.r-project.org Thu Nov 21 19:04:39 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 19:04:39 +0100 (CET) Subject: [Vegan-commits] r2737 - in pkg/permute: R inst man Message-ID: <20131121180439.CFF3A186637@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 19:04:39 +0100 (Thu, 21 Nov 2013) New Revision: 2737 Modified: pkg/permute/R/Plots.R pkg/permute/R/how.R pkg/permute/inst/ChangeLog pkg/permute/man/how.Rd Log: enforce that 'blocks' and 'strata' are factors. Modified: pkg/permute/R/Plots.R =================================================================== --- pkg/permute/R/Plots.R 2013-11-21 18:03:56 UTC (rev 2736) +++ pkg/permute/R/Plots.R 2013-11-21 18:04:39 UTC (rev 2737) @@ -2,6 +2,9 @@ mirror = FALSE, ncol = NULL, nrow = NULL) { plots.name <- deparse(substitute(strata)) + ## strata should also be a factor - coerce + if(!is.null(strata)) + strata <- as.factor(strata) type <- match.arg(type) Modified: pkg/permute/R/how.R =================================================================== --- pkg/permute/R/how.R 2013-11-21 18:03:56 UTC (rev 2736) +++ pkg/permute/R/how.R 2013-11-21 18:04:39 UTC (rev 2737) @@ -10,6 +10,9 @@ observed = FALSE) { blocks.name <- deparse(substitute(blocks)) + ## blocks should also be a factor - coerce + if(!is.null(blocks)) + blocks <- as.factor(blocks) ## process the call to make it standalone .call <- match.call() Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-21 18:03:56 UTC (rev 2736) +++ pkg/permute/inst/ChangeLog 2013-11-21 18:04:39 UTC (rev 2737) @@ -2,6 +2,11 @@ permute ChangeLog +Version 0.7-8 + + * how, Plots: enforces that `blocks` and `strata` are factors, or + can be coerced to a factor via `as.factor()`, if specified. + Version 0.7-7 * shuffleSet: Implemented an idea of Jari's to allow `check()` and @@ -117,15 +122,15 @@ * allPerms, doAllPerms: now correctly work in presence of blocks, and where there are no plots. - `allPerms` now includes the permutation design (its `control` - argument) as an attribute, `"control"`, on the returned matrix of - permutations. + `allPerms` now includes the permutation design (its `control` + argument) as an attribute, `"control"`, on the returned matrix of + permutations. - `allPerms` looses arguments `max` and `observed` as these are - supposed to be in the control object created by `how()`. + `allPerms` loses arguments `max` and `observed` as these are + supposed to be in the control object created by `how()`. - `summary.allPerms` (its `print` method, more correctly) now prints - the permutation design alongside the set of permutations. + `summary.allPerms` (its `print` method, more correctly) now prints + the permutation design alongside the set of permutations. * get-methods: new extractor functions `getObserved()` and `getMake()` return the `observed` and `make` components of object @@ -135,7 +140,7 @@ the `"how"` object. Use `getMinperm()` to extract the component no-longer returned by `getComplete()`. - * check: function looses arguments `make.all` and `observed` as + * check: function loses arguments `make.all` and `observed` as these are in the control object returned by `how()`. The logic of some of the checks has been tweaked slightly. @@ -232,7 +237,7 @@ Version 0.7-1 * allPerms: implement Doug Bates version which simplifies and - speeds up the code. A faste RcppEigen-based version also exists + speeds up the code. A fast RcppEigen-based version also exists but will need larger changes to the package to implement. Version 0.7-0 Modified: pkg/permute/man/how.Rd =================================================================== --- pkg/permute/man/how.Rd 2013-11-21 18:03:56 UTC (rev 2736) +++ pkg/permute/man/how.Rd 2013-11-21 18:04:39 UTC (rev 2737) @@ -33,8 +33,9 @@ themselves, or for the definition of blocking structures which further restrict permutations (\code{blocks}). \code{within} and \code{plots} each require a named list as produced by \code{Within} - and \code{Plots} respectively. \code{blocks} takes a factor, the - levels of which define the blocking structure.} + and \code{Plots} respectively. \code{blocks} takes a factor (or an + object coercible to a factor via \code{as.factor}), the levels of + which define the blocking structure.} \item{nperm}{numeric; the number of permutations.} \item{complete}{logical; should complete enumeration of all permutations be performed?} @@ -61,8 +62,8 @@ \item{mirror}{logical; should mirroring of sequences be allowed?} \item{ncol, nrow}{numeric; the number of columns and rows of samples in the spatial grid respectively.} - \item{strata}{An integer vector or factor specifying the strata for - permutation.} + \item{strata}{A factor, or an object that can be coerced to a factor + via \code{as.factor}, specifying the strata for permutation.} } \details{ \code{shuffle} can generate permutations for a wide range of From noreply at r-forge.r-project.org Thu Nov 21 19:26:38 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 19:26:38 +0100 (CET) Subject: [Vegan-commits] r2738 - in pkg/vegan: R inst man Message-ID: <20131121182638.A2BBC185AC9@r-forge.r-project.org> Author: jarioksa Date: 2013-11-21 19:26:38 +0100 (Thu, 21 Nov 2013) New Revision: 2738 Modified: pkg/vegan/R/anovacca.R pkg/vegan/inst/ChangeLog pkg/vegan/man/anovacca.Rd Log: update anovacca interface and add by = 'margin' Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-11-21 18:04:39 UTC (rev 2737) +++ pkg/vegan/R/anovacca.R 2013-11-21 18:26:38 UTC (rev 2738) @@ -1,7 +1,9 @@ `anovacca` <- function(object, ..., permutations = how(nperm=999), by = NULL, - strata = NULL) + model = c("reduced", "direct", "full"), + parallel = getOption("mc.cores"), strata = NULL) { + model <- match.arg(model) if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) runif(1) @@ -32,15 +34,7 @@ dotargs <- list(...) ## we do not want to give dotargs to anova.ccalist, but we ## evaluate 'parallel' and 'model' here - if (is.null(dotargs$model)) - model <- "reduced" - else - model <- dotargs$model - if (is.null(dotargs$parallel)) - parallel <- NULL - else - parallel <- dotargs$parallel - if (length(dotargs)) { + if (length(dotargs)) { isCCA <- sapply(dotargs, function(z) inherits(z, "cca")) if (any(isCCA)) { dotargs <- dotargs[isCCA] @@ -55,13 +49,16 @@ } ## by cases if (!is.null(by)) { - by <- match.arg(by, c("terms", "margin")) + by <- match.arg(by, c("terms", "margin", "axis")) sol <- switch(by, "terms" = anovacca.byterm(object, permutations = permutations, model = model, parallel = parallel), "margin" = anovacca.bymargin(object, permutations = permutations, + model = model, parallel = parallel), + "axis" = anovacca.byaxis(object, + permutations = permutations, model = model, parallel = parallel)) return(sol) } Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-11-21 18:04:39 UTC (rev 2737) +++ pkg/vegan/inst/ChangeLog 2013-11-21 18:26:38 UTC (rev 2738) @@ -18,8 +18,15 @@ models in anova.ccalist. Case by = "margin" directly calls permutest.cca and gets the significances from differences of residual variation similarly as anova.ccalist. Case by = "axis" is - not yet implemented. + is implemented as a marginal model. + Simple permutations give identical results for "term" and "axis" + cases, but by = "margin" is different. Marginal models were + implemented as partial models with other parameters partialled out + in vegan 2.0 and earlier, but the current implementation is an + anova.ccalist model where the parameter in question was removed + and model compared against the complete model. + * commsim: documentation (commsim.Rd) was restructured so that nullmodels were collected under separate sections with a brief introductory text and shorter specific text of the Modified: pkg/vegan/man/anovacca.Rd =================================================================== --- pkg/vegan/man/anovacca.Rd 2013-11-21 18:04:39 UTC (rev 2737) +++ pkg/vegan/man/anovacca.Rd 2013-11-21 18:26:38 UTC (rev 2738) @@ -23,7 +23,8 @@ \usage{ anovacca(object, ..., permutations = how(nperm=999), - by = NULL, strata = NULL) + by = NULL, model = c("reduced", "direct", "full"), + parallel = getOption("mc.cores"), strata = NULL) } \arguments{ @@ -46,6 +47,10 @@ the terms (each marginal term analysed in a model with all other variables). Not yet implemented.} + \item{model}{Model} + + \item{parallel}{Parallel processing} + \item{strata}{An integer vector or factor specifying the strata for permutation. If supplied, observations are permuted only within the specified strata. It is an error to use this when From noreply at r-forge.r-project.org Thu Nov 21 21:30:04 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 21:30:04 +0100 (CET) Subject: [Vegan-commits] r2739 - in pkg/permute: R man Message-ID: <20131121203004.A4C61186688@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 21:30:04 +0100 (Thu, 21 Nov 2013) New Revision: 2739 Modified: pkg/permute/R/check.R pkg/permute/man/check.Rd Log: adds argument 'quietly = FALSE' to configure message printing Modified: pkg/permute/R/check.R =================================================================== --- pkg/permute/R/check.R 2013-11-21 18:26:38 UTC (rev 2738) +++ pkg/permute/R/check.R 2013-11-21 20:30:04 UTC (rev 2739) @@ -1,4 +1,4 @@ -`check` <- function(object, control = how()) +`check` <- function(object, control = how(), quietly = FALSE) { ## if object is numeric or integer and of length 1, ## extend the object @@ -70,7 +70,8 @@ setComplete(control) <- TRUE setNperm(control) <- num.pos setMaxperm(control) <- num.pos - message("'nperm' > set of all permutations; Resetting 'nperm'.") + if(!quietly) + message("'nperm' > set of all permutations; Resetting 'nperm'.") } ## if number of possible perms < minperm turn on complete enumeration @@ -78,7 +79,8 @@ setComplete(control) <- TRUE setNperm(control) <- num.pos setMaxperm(control) <- num.pos - message("Set of permutations < 'minperm'. Generating entire set.") + if(!quietly) + message("Set of permutations < 'minperm'. Generating entire set.") } ## if complete enumeration, generate all permutations Modified: pkg/permute/man/check.Rd =================================================================== --- pkg/permute/man/check.Rd 2013-11-21 18:26:38 UTC (rev 2738) +++ pkg/permute/man/check.Rd 2013-11-21 20:30:04 UTC (rev 2739) @@ -11,7 +11,7 @@ selected permutation design. } \usage{ -check(object, control = how()) +check(object, control = how(), quietly = FALSE) \method{summary}{check}(object, \dots) } @@ -22,6 +22,7 @@ \code{\link{summary.check}} an object of class \code{"check"}.} \item{control}{a list of control values describing properties of the permutation design, as returned by a call to \code{\link{how}}.} + \item{quietly}{logical; should messages by suppressed?} \item{\dots}{arguments to other methods.} } \details{ From noreply at r-forge.r-project.org Thu Nov 21 21:30:30 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 21:30:30 +0100 (CET) Subject: [Vegan-commits] r2740 - pkg/permute/R Message-ID: <20131121203030.EE004186688@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 21:30:30 +0100 (Thu, 21 Nov 2013) New Revision: 2740 Modified: pkg/permute/R/allPerms.R Log: allPerms now suppresses messages from check via 'quietly = TRUE' Modified: pkg/permute/R/allPerms.R =================================================================== --- pkg/permute/R/allPerms.R 2013-11-21 20:30:04 UTC (rev 2739) +++ pkg/permute/R/allPerms.R 2013-11-21 20:30:30 UTC (rev 2740) @@ -11,7 +11,7 @@ if (check) { control2 <- control setMake(control2) <- FALSE - pcheck <- check(v, control = control2) + pcheck <- check(v, control = control2, quietly = TRUE) } ## ctrl <- pcheck$control ## if we do copy the new updated control, we need to update to From noreply at r-forge.r-project.org Thu Nov 21 21:31:07 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 21:31:07 +0100 (CET) Subject: [Vegan-commits] r2741 - pkg/permute/R Message-ID: <20131121203107.AC15B1866D4@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 21:31:07 +0100 (Thu, 21 Nov 2013) New Revision: 2741 Modified: pkg/permute/R/print.permutationMatrix.R Log: change the ordering and way that the information about the permutation design is printed. Modified: pkg/permute/R/print.permutationMatrix.R =================================================================== --- pkg/permute/R/print.permutationMatrix.R 2013-11-21 20:30:30 UTC (rev 2740) +++ pkg/permute/R/print.permutationMatrix.R 2013-11-21 20:31:07 UTC (rev 2741) @@ -8,14 +8,46 @@ ## grab the permutation design ctrl <- attr(x, "control") ## gives us the list generated by how() + blocks <- getBlocks(ctrl) + plots <- getPlots(ctrl) + ## print out dimensions of permutation matrix - msg <- paste("No. of Permutations: ", nrow(x), "; No. of Samples: ", - ncol(x), sep = "") + msg <- paste("No. of Permutations: ", nrow(x), sep = "") writeLines(strwrap(msg)) + ## print info on the within level + msg <- paste("No. of Samples:", ncol(x), "(") + if (any(pl <- !is.null(plots), bl <- !is.null(blocks))) { + msg <- paste(msg, "Nested in: ", sep = "") + if (pl && !bl) { + nmsg <- "plots; " + } else if (bl && !pl) { + nmsg <- "blocks; " + } else { + nmsg <- "plots & blocks; " + } + msg <- paste(msg, nmsg, sep = "") + } + wmsg <- switch(wt <- getType(ctrl, which = "within"), + none = "", + free = "Randomised", + series = "Sequence", + grid = paste("Spatial grid: ", + getRow(ctrl, which = "within"), "r, ", + getCol(ctrl, which = "within"), "c", sep = "")) + msg <- paste(msg, wmsg, sep = "") + ## add info on mirroring if series or grid + if ((wt %in% c("series", "grid")) && getMirror(ctrl, which = "within")) { + msg <- paste(msg, "; mirrored", sep = "") + } + ## add info on constant + if (getConstant(ctrl, which = "within") && pl) { + msg <- paste(msg, "; same permutation in each plot", sep = "") + } + writeLines(strwrap(paste(msg, ")", sep = ""))) + ## print info on blocking, but ONLY if set if (!is.null(blocks <- getBlocks(ctrl))) { - bl <- TRUE ll <- length(levels(blocks)) msg <- paste("Restricted by Blocks: ", ctrl$blocks.name, " (", ll, " ", if (ll == 1L) "block" else "blocks", @@ -25,7 +57,7 @@ ## print info on plots, but ONLY if set if (!is.null(strata <- getStrata(ctrl, which = "plots"))) { - pl <- TRUE + #pl <- TRUE plots <- getPlots(ctrl) pmsg <- switch(pt <- getType(ctrl, which = "plots"), none = "", @@ -45,36 +77,6 @@ writeLines(strwrap(msg)) } - ## print info on the within level - msg <- "Samples (" - if (any(pl, bl)) { - msg <- paste(msg, "Nested in: ", sep = "") - if (pl && !bl) { - nmsg <- "plots; " - } else if (bl && !pl) { - nmsg <- "blocks; " - } else { - nmsg <- "plots & blocks; " - } - msg <- paste(msg, nmsg, sep = "") - } - wmsg <- switch(wt <- getType(ctrl, which = "within"), - none = "", - free = "Randomised", - series = "Sequence", - grid = paste("Spatial grid: ", - getRow(ctrl, which = "within"), "r, ", - getCol(ctrl, which = "within"), "c", sep = "")) - msg <- paste(msg, wmsg, sep = "") - ## add info on mirroring if series or grid - if ((wt %in% c("series", "grid")) && getMirror(ctrl, which = "within")) { - msg <- paste(msg, "; mirrored", sep = "") - } - ## add info on constant - if (getConstant(ctrl, which = "within") && pl) { - msg <- paste(msg, "; same permutation in each plot", sep = "") - } - writeLines(strwrap(paste(msg, ")", sep = ""))) cat("\n") x <- as.matrix(x) From noreply at r-forge.r-project.org Thu Nov 21 21:31:32 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 21:31:32 +0100 (CET) Subject: [Vegan-commits] r2742 - pkg/permute/inst Message-ID: <20131121203132.1CCEA1866D4@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 21:31:31 +0100 (Thu, 21 Nov 2013) New Revision: 2742 Modified: pkg/permute/inst/ChangeLog Log: document reecnt changes Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-21 20:31:07 UTC (rev 2741) +++ pkg/permute/inst/ChangeLog 2013-11-21 20:31:31 UTC (rev 2742) @@ -7,6 +7,16 @@ * how, Plots: enforces that `blocks` and `strata` are factors, or can be coerced to a factor via `as.factor()`, if specified. + * check: gains a new argument `quietly = FALSE` to suppress messages + about updates to the permutation design when they are not needed. + + * allPerms: no longer allows messages about generating set of + permutations to be generated by `check()`. It calls `check()` now + with `quietly = TRUE` to achieve this. + + * shuffleSet: played about a bit with the way the design is printed + if you show the matrix of permutations. + Version 0.7-7 * shuffleSet: Implemented an idea of Jari's to allow `check()` and From noreply at r-forge.r-project.org Thu Nov 21 21:34:39 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 21 Nov 2013 21:34:39 +0100 (CET) Subject: [Vegan-commits] r2743 - pkg/permute/tests/Examples Message-ID: <20131121203439.D5268186688@r-forge.r-project.org> Author: gsimpson Date: 2013-11-21 21:34:39 +0100 (Thu, 21 Nov 2013) New Revision: 2743 Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save Log: update the reference materials for checking Examples Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save =================================================================== --- pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-21 20:31:31 UTC (rev 2742) +++ pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-21 20:34:39 UTC (rev 2743) @@ -1,5 +1,5 @@ -R version 3.0.2 Patched (2013-09-26 r64005) -- "Frisbee Sailing" +R version 3.0.2 Patched (2013-10-07 r64035) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -207,7 +207,7 @@ > require(vegan) Loading required package: vegan Loading required package: lattice -This is vegan 2.1-37 +This is vegan 2.1-33 > example(pyrifos) pyrifs> data(pyrifos) @@ -230,6 +230,7 @@ > ## no strata but data are series with no mirroring, so 132 permutations > CONTROL <- how(within = Within(type = "series", mirror = FALSE)) > check(pyrifos, CONTROL) +'nperm' > set of all permutations; Resetting 'nperm'. [1] 132 > > ## no strata but data are series with mirroring, so 264 permutations @@ -259,6 +260,8 @@ > check(pyrifos, + control = how(plots = Plots(strata = ditch), + within = Within(type = "series", constant = TRUE))) +'nperm' > set of all permutations; Resetting 'nperm'. +Set of permutations < 'minperm'. Generating entire set. [1] 11 > > ## time series within strata, with mirroring, same permutation @@ -267,6 +270,8 @@ + control = how(plots = Plots(strata = ditch), + within = Within(type = "series", mirror = TRUE, + constant = TRUE))) +'nperm' > set of all permutations; Resetting 'nperm'. +Set of permutations < 'minperm'. Generating entire set. [1] 22 > ## permute strata > check(pyrifos, how(plots = Plots(strata = ditch, type = "free"), @@ -279,6 +284,7 @@ > all.equal(vec1, vec2) [1] TRUE > vec3 <- check(1:100, how(within = Within(type = "series"))) +'nperm' > set of all permutations; Resetting 'nperm'. > all.equal(100, vec3$n) [1] TRUE > vec4 <- check(1:100, how(within = Within(type= "series", mirror = TRUE))) @@ -291,6 +297,8 @@ + within = Within(type = "grid", mirror = FALSE, + constant = TRUE, nrow = 3, ncol = 2)) > check(1:12, ctrl) +'nperm' > set of all permutations; Resetting 'nperm'. +Set of permutations < 'minperm'. Generating entire set. [1] 6 > > numPerms(1:12, control = ctrl) @@ -480,19 +488,22 @@ > ### Aliases: get-methods getBlocks getBlocks.default getBlocks.how > ### getBlocks.permControl getWithin getWithin.default getWithin.how > ### getWithin.permControl getStrata getStrata.default getStrata.how -> ### getStrata.permControl getType getType.default getType.how -> ### getType.permControl getMirror getMirror.default getMirror.how -> ### getMirror.permControl getConstant getConstant.default getConstant.how -> ### getConstant.permControl getPlots getPlots.default getPlots.how -> ### getPlots.permControl getRow getRow.default getRow.how -> ### getRow.permControl getCol getCol.default getCol.how -> ### getCol.permControl getDim getDim.default getDim.how -> ### getDim.permControl getNperm getNperm.default getNperm.how -> ### getNperm.permControl getMaxperm getMaxperm.default getMaxperm.how -> ### getMaxperm.permControl getMinperm getMinperm.default getMinperm.how -> ### getMinperm.permControl getComplete getComplete.default -> ### getComplete.how getComplete.permControl getMake getMake.default -> ### getMake.how getObserved getObserved.default getObserved.how +> ### getStrata.permControl getStrata.Plots getType getType.default +> ### getType.how getType.permControl getType.Plots getType.Within +> ### getMirror getMirror.default getMirror.how getMirror.permControl +> ### getMirror.Plots getMirror.Within getConstant getConstant.default +> ### getConstant.how getConstant.permControl getConstant.Within getPlots +> ### getPlots.default getPlots.how getPlots.permControl getRow +> ### getRow.default getRow.how getRow.permControl getRow.Plots +> ### getRow.Within getCol getCol.default getCol.how getCol.permControl +> ### getCol.Plots getCol.Within getDim getDim.default getDim.how +> ### getDim.permControl getDim.Plots getDim.Within getNperm +> ### getNperm.default getNperm.how getNperm.permControl getMaxperm +> ### getMaxperm.default getMaxperm.how getMaxperm.permControl getMinperm +> ### getMinperm.default getMinperm.how getMinperm.permControl getComplete +> ### getComplete.default getComplete.how getComplete.permControl getMake +> ### getMake.default getMake.how getObserved getObserved.default +> ### getObserved.how > ### Keywords: methods utils > > ### ** Examples @@ -518,6 +529,8 @@ $call Within() +attr(,"class") +[1] "Within" > getNperm(hh) [1] 199 > @@ -570,7 +583,9 @@ Evaluate all permutations?: No. Activation limit: 99 > > ## ... or switch the type of shuffling at a level: -> update(h1, plots = update(getPlots(h1), type = "none")) +> #update(h1, plots = update(getPlots(h1), type = "none")) +> plots2 <- update(getPlots(h1), type = "none") +> update(h1, plots = plots2) Permutation Design: @@ -950,6 +965,9 @@ > > ## simple random permutations, 5 permutations in set > shuffleSet(n = 10, nset = 5) +No. of Permutations: 5 +No. of Samples: 10 (Nested in: plots; Randomised) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 3 4 5 7 2 8 9 6 10 1 [2,] 3 2 6 10 5 7 8 4 1 9 @@ -958,200 +976,185 @@ [5,] 9 6 7 4 8 10 1 2 3 5 > > ## series random permutations, 5 permutations in set -> shuffleSet(10, 5, how(within = Within(type = "series")), -+ check = FALSE) +> shuffleSet(10, 5, how(within = Within(type = "series"))) +Set of permutations < 'minperm'. Generating entire set. +No. of Permutations: 5 +No. of Samples: 10 (Nested in: plots; Sequence) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 6 7 8 9 10 1 2 3 4 5 -[2,] 10 1 2 3 4 5 6 7 8 9 -[3,] 6 7 8 9 10 1 2 3 4 5 -[4,] 4 5 6 7 8 9 10 1 2 3 +[2,] 8 9 10 1 2 3 4 5 6 7 +[3,] 5 6 7 8 9 10 1 2 3 4 +[4,] 3 4 5 6 7 8 9 10 1 2 [5,] 2 3 4 5 6 7 8 9 10 1 > > ## series random permutations, 10 permutations in set, > ## with possible mirroring > CTRL <- how(within = Within(type = "series", mirror = TRUE)) > shuffleSet(10, 10, CTRL) +Set of permutations < 'minperm'. Generating entire set. +No. of Permutations: 10 +No. of Samples: 10 (Nested in: plots; Sequence; mirrored) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] - [1,] 2 3 4 5 6 7 8 9 10 1 - [2,] 3 4 5 6 7 8 9 10 1 2 - [3,] 4 5 6 7 8 9 10 1 2 3 - [4,] 5 6 7 8 9 10 1 2 3 4 - [5,] 6 7 8 9 10 1 2 3 4 5 - [6,] 7 8 9 10 1 2 3 4 5 6 - [7,] 8 9 10 1 2 3 4 5 6 7 - [8,] 9 10 1 2 3 4 5 6 7 8 - [9,] 10 1 2 3 4 5 6 7 8 9 -[10,] 1 10 9 8 7 6 5 4 3 2 -[11,] 2 1 10 9 8 7 6 5 4 3 -[12,] 3 2 1 10 9 8 7 6 5 4 -[13,] 4 3 2 1 10 9 8 7 6 5 -[14,] 5 4 3 2 1 10 9 8 7 6 -[15,] 6 5 4 3 2 1 10 9 8 7 -[16,] 7 6 5 4 3 2 1 10 9 8 -[17,] 8 7 6 5 4 3 2 1 10 9 -[18,] 9 8 7 6 5 4 3 2 1 10 -[19,] 10 9 8 7 6 5 4 3 2 1 + [1,] 3 4 5 6 7 8 9 10 1 2 + [2,] 7 8 9 10 1 2 3 4 5 6 + [3,] 10 1 2 3 4 5 6 7 8 9 + [4,] 2 1 10 9 8 7 6 5 4 3 + [5,] 8 9 10 1 2 3 4 5 6 7 + [6,] 4 3 2 1 10 9 8 7 6 5 + [7,] 5 6 7 8 9 10 1 2 3 4 + [8,] 9 8 7 6 5 4 3 2 1 10 + [9,] 5 4 3 2 1 10 9 8 7 6 +[10,] 6 5 4 3 2 1 10 9 8 7 > > ## Permuting strata > ## 4 groups of 5 observations > CTRL <- how(within = Within(type = "none"), + plots = Plots(strata = gl(4,5), type = "free")) > shuffleSet(20, 10, control = CTRL) +Set of permutations < 'minperm'. Generating entire set. +No. of Permutations: 10 +No. of Samples: 20 (Nested in: plots; ) +Restricted by Plots: gl(4, 5) (4 plots; Randomised) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] - [1,] 1 2 3 4 5 6 7 8 9 10 16 17 18 - [2,] 1 2 3 4 5 11 12 13 14 15 6 7 8 - [3,] 1 2 3 4 5 11 12 13 14 15 16 17 18 - [4,] 1 2 3 4 5 16 17 18 19 20 6 7 8 - [5,] 1 2 3 4 5 16 17 18 19 20 11 12 13 - [6,] 6 7 8 9 10 1 2 3 4 5 11 12 13 - [7,] 6 7 8 9 10 1 2 3 4 5 16 17 18 - [8,] 6 7 8 9 10 11 12 13 14 15 1 2 3 - [9,] 6 7 8 9 10 11 12 13 14 15 16 17 18 -[10,] 6 7 8 9 10 16 17 18 19 20 1 2 3 -[11,] 6 7 8 9 10 16 17 18 19 20 11 12 13 -[12,] 11 12 13 14 15 1 2 3 4 5 6 7 8 -[13,] 11 12 13 14 15 1 2 3 4 5 16 17 18 -[14,] 11 12 13 14 15 6 7 8 9 10 1 2 3 -[15,] 11 12 13 14 15 6 7 8 9 10 16 17 18 -[16,] 11 12 13 14 15 16 17 18 19 20 1 2 3 -[17,] 11 12 13 14 15 16 17 18 19 20 6 7 8 -[18,] 16 17 18 19 20 1 2 3 4 5 6 7 8 -[19,] 16 17 18 19 20 1 2 3 4 5 11 12 13 -[20,] 16 17 18 19 20 6 7 8 9 10 1 2 3 -[21,] 16 17 18 19 20 6 7 8 9 10 11 12 13 -[22,] 16 17 18 19 20 11 12 13 14 15 1 2 3 -[23,] 16 17 18 19 20 11 12 13 14 15 6 7 8 + [1,] 6 7 8 9 10 1 2 3 4 5 11 12 13 + [2,] 6 7 8 9 10 16 17 18 19 20 11 12 13 + [3,] 11 12 13 14 15 16 17 18 19 20 6 7 8 + [4,] 1 2 3 4 5 11 12 13 14 15 6 7 8 + [5,] 16 17 18 19 20 6 7 8 9 10 11 12 13 + [6,] 6 7 8 9 10 1 2 3 4 5 16 17 18 + [7,] 11 12 13 14 15 6 7 8 9 10 16 17 18 + [8,] 16 17 18 19 20 11 12 13 14 15 6 7 8 + [9,] 11 12 13 14 15 16 17 18 19 20 1 2 3 +[10,] 16 17 18 19 20 1 2 3 4 5 6 7 8 [,14] [,15] [,16] [,17] [,18] [,19] [,20] - [1,] 19 20 11 12 13 14 15 - [2,] 9 10 16 17 18 19 20 - [3,] 19 20 6 7 8 9 10 - [4,] 9 10 11 12 13 14 15 - [5,] 14 15 6 7 8 9 10 - [6,] 14 15 16 17 18 19 20 - [7,] 19 20 11 12 13 14 15 - [8,] 4 5 16 17 18 19 20 - [9,] 19 20 1 2 3 4 5 -[10,] 4 5 11 12 13 14 15 -[11,] 14 15 1 2 3 4 5 -[12,] 9 10 16 17 18 19 20 -[13,] 19 20 6 7 8 9 10 -[14,] 4 5 16 17 18 19 20 -[15,] 19 20 1 2 3 4 5 -[16,] 4 5 6 7 8 9 10 -[17,] 9 10 1 2 3 4 5 -[18,] 9 10 11 12 13 14 15 -[19,] 14 15 6 7 8 9 10 -[20,] 4 5 11 12 13 14 15 -[21,] 14 15 1 2 3 4 5 -[22,] 4 5 6 7 8 9 10 -[23,] 9 10 1 2 3 4 5 + [1,] 14 15 16 17 18 19 20 + [2,] 14 15 1 2 3 4 5 + [3,] 9 10 1 2 3 4 5 + [4,] 9 10 16 17 18 19 20 + [5,] 14 15 1 2 3 4 5 + [6,] 19 20 11 12 13 14 15 + [7,] 19 20 1 2 3 4 5 + [8,] 9 10 1 2 3 4 5 + [9,] 4 5 6 7 8 9 10 +[10,] 9 10 11 12 13 14 15 > > ## 10 random permutations in presence of Plot-level strata > plotStrata <- Plots(strata = gl(4,5)) > CTRL <- how(plots = plotStrata, + within = Within(type = "free")) > shuffleSet(20, 10, control = CTRL) +No. of Permutations: 10 +No. of Samples: 20 (Nested in: plots; Randomised) +Restricted by Plots: gl(4, 5) (4 plots) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] - [1,] 1 2 4 3 5 10 7 9 6 8 12 15 13 - [2,] 5 4 2 3 1 8 10 7 6 9 12 13 11 - [3,] 4 2 5 3 1 9 7 6 10 8 12 11 15 - [4,] 1 3 5 4 2 10 7 9 6 8 13 15 11 - [5,] 3 5 2 4 1 9 8 6 10 7 13 11 15 - [6,] 1 3 5 4 2 7 9 10 8 6 13 11 12 - [7,] 5 3 4 2 1 7 6 8 10 9 11 14 13 - [8,] 3 1 5 4 2 7 6 10 9 8 13 15 11 - [9,] 2 3 4 5 1 7 6 9 10 8 13 12 11 -[10,] 4 3 2 1 5 7 8 9 6 10 12 15 11 + [1,] 5 4 2 3 1 8 10 7 6 9 12 13 11 + [2,] 4 2 5 3 1 9 7 6 10 8 12 11 15 + [3,] 1 3 5 4 2 10 7 9 6 8 13 15 11 + [4,] 3 5 2 4 1 9 8 6 10 7 13 11 15 + [5,] 1 3 5 4 2 7 9 10 8 6 13 11 12 + [6,] 5 3 4 2 1 7 6 8 10 9 11 14 13 + [7,] 3 1 5 4 2 7 6 10 9 8 13 15 11 + [8,] 2 3 4 5 1 7 6 9 10 8 13 12 11 + [9,] 4 3 2 1 5 7 8 9 6 10 12 15 11 +[10,] 1 5 2 4 3 8 7 6 9 10 11 15 13 [,14] [,15] [,16] [,17] [,18] [,19] [,20] - [1,] 11 14 17 19 20 16 18 - [2,] 14 15 17 16 20 18 19 - [3,] 13 14 20 18 17 16 19 - [4,] 14 12 18 16 19 17 20 - [5,] 14 12 19 18 16 20 17 - [6,] 15 14 19 20 18 16 17 - [7,] 12 15 19 17 16 20 18 - [8,] 14 12 20 16 18 17 19 - [9,] 15 14 17 16 20 18 19 -[10,] 13 14 19 20 17 18 16 + [1,] 14 15 17 16 20 18 19 + [2,] 13 14 20 18 17 16 19 + [3,] 14 12 18 16 19 17 20 + [4,] 14 12 19 18 16 20 17 + [5,] 15 14 19 20 18 16 17 + [6,] 12 15 19 17 16 20 18 + [7,] 14 12 20 16 18 17 19 + [8,] 15 14 17 16 20 18 19 + [9,] 13 14 19 20 17 18 16 +[10,] 12 14 16 20 17 19 18 > ## as above but same random permutation within Plot-level strata > CTRL <- how(plots = plotStrata, + within = Within(type = "free", constant = TRUE)) -> shuffleSet(20, 10, CTRL) +> shuffleSet(20, 10, CTRL) ## check this. +No. of Permutations: 10 +No. of Samples: 20 (Nested in: plots; Randomised; same permutation in +each plot) +Restricted by Plots: gl(4, 5) (4 plots) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] - [1,] 1 5 2 4 3 6 10 7 9 8 11 15 12 - [2,] 3 2 1 4 5 8 7 6 9 10 13 12 11 - [3,] 1 5 3 2 4 6 10 8 7 9 11 15 13 - [4,] 1 5 2 4 3 6 10 7 9 8 11 15 12 - [5,] 1 2 5 3 4 6 7 10 8 9 11 12 15 - [6,] 1 3 4 5 2 6 8 9 10 7 11 13 14 - [7,] 1 2 5 3 4 6 7 10 8 9 11 12 15 - [8,] 2 1 3 4 5 7 6 8 9 10 12 11 13 - [9,] 4 1 5 3 2 9 6 10 8 7 14 11 15 -[10,] 4 1 2 5 3 9 6 7 10 8 14 11 12 + [1,] 1 2 5 3 4 6 7 10 8 9 11 12 15 + [2,] 1 3 4 5 2 6 8 9 10 7 11 13 14 + [3,] 1 2 5 3 4 6 7 10 8 9 11 12 15 + [4,] 2 1 3 4 5 7 6 8 9 10 12 11 13 + [5,] 4 1 5 3 2 9 6 10 8 7 14 11 15 + [6,] 4 1 2 5 3 9 6 7 10 8 14 11 12 + [7,] 5 1 3 4 2 10 6 8 9 7 15 11 13 + [8,] 1 5 3 2 4 6 10 8 7 9 11 15 13 + [9,] 3 1 2 5 4 8 6 7 10 9 13 11 12 +[10,] 4 2 5 3 1 9 7 10 8 6 14 12 15 [,14] [,15] [,16] [,17] [,18] [,19] [,20] - [1,] 14 13 16 20 17 19 18 - [2,] 14 15 18 17 16 19 20 - [3,] 12 14 16 20 18 17 19 - [4,] 14 13 16 20 17 19 18 - [5,] 13 14 16 17 20 18 19 - [6,] 15 12 16 18 19 20 17 - [7,] 13 14 16 17 20 18 19 - [8,] 14 15 17 16 18 19 20 - [9,] 13 12 19 16 20 18 17 -[10,] 15 13 19 16 17 20 18 + [1,] 13 14 16 17 20 18 19 + [2,] 15 12 16 18 19 20 17 + [3,] 13 14 16 17 20 18 19 + [4,] 14 15 17 16 18 19 20 + [5,] 13 12 19 16 20 18 17 + [6,] 15 13 19 16 17 20 18 + [7,] 14 12 20 16 18 19 17 + [8,] 12 14 16 20 18 17 19 + [9,] 15 14 18 16 17 20 19 +[10,] 13 11 19 17 20 18 16 > > ## time series within each level of Plot strata > CTRL <- how(plots = plotStrata, + within = Within(type = "series")) > shuffleSet(20, 10, CTRL) +No. of Permutations: 10 +No. of Samples: 20 (Nested in: plots; Sequence) +Restricted by Plots: gl(4, 5) (4 plots) + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] - [1,] 1 2 3 4 5 7 8 9 10 6 11 12 13 - [2,] 4 5 1 2 3 7 8 9 10 6 12 13 14 - [3,] 5 1 2 3 4 8 9 10 6 7 14 15 11 - [4,] 3 4 5 1 2 6 7 8 9 10 15 11 12 - [5,] 3 4 5 1 2 9 10 6 7 8 11 12 13 - [6,] 1 2 3 4 5 6 7 8 9 10 15 11 12 - [7,] 5 1 2 3 4 6 7 8 9 10 13 14 15 - [8,] 1 2 3 4 5 7 8 9 10 6 13 14 15 - [9,] 2 3 4 5 1 9 10 6 7 8 11 12 13 -[10,] 2 3 4 5 1 9 10 6 7 8 13 14 15 + [1,] 1 2 3 4 5 6 7 8 9 10 15 11 12 + [2,] 5 1 2 3 4 6 7 8 9 10 13 14 15 + [3,] 1 2 3 4 5 7 8 9 10 6 13 14 15 + [4,] 2 3 4 5 1 9 10 6 7 8 11 12 13 + [5,] 2 3 4 5 1 9 10 6 7 8 13 14 15 + [6,] 3 4 5 1 2 9 10 6 7 8 12 13 14 + [7,] 5 1 2 3 4 9 10 6 7 8 12 13 14 + [8,] 4 5 1 2 3 6 7 8 9 10 13 14 15 + [9,] 2 3 4 5 1 6 7 8 9 10 14 15 11 +[10,] 3 4 5 1 2 6 7 8 9 10 13 14 15 [,14] [,15] [,16] [,17] [,18] [,19] [,20] - [1,] 14 15 17 18 19 20 16 - [2,] 15 11 16 17 18 19 20 - [3,] 12 13 17 18 19 20 16 - [4,] 13 14 20 16 17 18 19 - [5,] 14 15 16 17 18 19 20 - [6,] 13 14 18 19 20 16 17 - [7,] 11 12 18 19 20 16 17 - [8,] 11 12 19 20 16 17 18 - [9,] 14 15 16 17 18 19 20 -[10,] 11 12 20 16 17 18 19 + [1,] 13 14 18 19 20 16 17 + [2,] 11 12 18 19 20 16 17 + [3,] 11 12 19 20 16 17 18 + [4,] 14 15 16 17 18 19 20 + [5,] 11 12 20 16 17 18 19 + [6,] 15 11 18 19 20 16 17 + [7,] 15 11 20 16 17 18 19 + [8,] 11 12 16 17 18 19 20 + [9,] 12 13 17 18 19 20 16 +[10,] 11 12 19 20 16 17 18 > ## as above, but with same permutation for each Plot-level stratum > CTRL <- how(plots = plotStrata, + within = Within(type = "series", constant = TRUE)) -> shuffleSet(20, 10, CTRL, check = FALSE) - [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] - [1,] 3 4 5 1 2 8 9 10 6 7 13 14 15 - [2,] 2 3 4 5 1 7 8 9 10 6 12 13 14 - [3,] 5 1 2 3 4 10 6 7 8 9 15 11 12 - [4,] 2 3 4 5 1 7 8 9 10 6 12 13 14 - [5,] 4 5 1 2 3 9 10 6 7 8 14 15 11 - [6,] 3 4 5 1 2 8 9 10 6 7 13 14 15 - [7,] 2 3 4 5 1 7 8 9 10 6 12 13 14 - [8,] 4 5 1 2 3 9 10 6 7 8 14 15 11 - [9,] 3 4 5 1 2 8 9 10 6 7 13 14 15 -[10,] 3 4 5 1 2 8 9 10 6 7 13 14 15 - [,14] [,15] [,16] [,17] [,18] [,19] [,20] - [1,] 11 12 18 19 20 16 17 - [2,] 15 11 17 18 19 20 16 - [3,] 13 14 20 16 17 18 19 - [4,] 15 11 17 18 19 20 16 - [5,] 12 13 19 20 16 17 18 - [6,] 11 12 18 19 20 16 17 - [7,] 15 11 17 18 19 20 16 - [8,] 12 13 19 20 16 17 18 - [9,] 11 12 18 19 20 16 17 -[10,] 11 12 18 19 20 16 17 +> shuffleSet(20, 10, CTRL) +'nperm' > set of all permutations; Resetting 'nperm'. +Set of permutations < 'minperm'. Generating entire set. +No. of Permutations: 4 +No. of Samples: 20 (Nested in: plots; Sequence; same permutation in +each plot) +Restricted by Plots: gl(4, 5) (4 plots) + + [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] +[1,] 2 3 4 5 1 7 8 9 10 6 12 13 14 15 +[2,] 3 4 5 1 2 8 9 10 6 7 13 14 15 11 +[3,] 4 5 1 2 3 9 10 6 7 8 14 15 11 12 +[4,] 5 1 2 3 4 10 6 7 8 9 15 11 12 13 + [,15] [,16] [,17] [,18] [,19] [,20] +[1,] 11 17 18 19 20 16 +[2,] 12 18 19 20 16 17 +[3,] 13 19 20 16 17 18 +[4,] 14 20 16 17 18 19 > > > @@ -1159,7 +1162,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 2.133 0.036 2.187 0 0 +Time elapsed: 1.581 0.033 1.623 0 0 > grDevices::dev.off() null device 1 From noreply at r-forge.r-project.org Fri Nov 22 18:59:07 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 22 Nov 2013 18:59:07 +0100 (CET) Subject: [Vegan-commits] r2744 - in pkg/vegan: . R Message-ID: <20131122175907.52034185632@r-forge.r-project.org> Author: gsimpson Date: 2013-11-22 18:59:07 +0100 (Fri, 22 Nov 2013) New Revision: 2744 Modified: pkg/vegan/DESCRIPTION pkg/vegan/R/permutest.cca.R Log: using update is dangerous in functions; use the new setFoo<- functions instead; this means we now depend on permute 0.7-8 or later Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2013-11-21 20:34:39 UTC (rev 2743) +++ pkg/vegan/DESCRIPTION 2013-11-22 17:59:07 UTC (rev 2744) @@ -6,7 +6,7 @@ Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, Helene Wagner Maintainer: Jari Oksanen -Depends: permute (>= 0.7-5), lattice, R (>= 2.14.0) +Depends: permute (>= 0.7-8), lattice, R (>= 2.14.0) Suggests: MASS, mgcv, cluster, parallel, scatterplot3d, rgl, tcltk Description: Ordination methods, diversity analysis and other functions for community and vegetation ecologists. Modified: pkg/vegan/R/permutest.cca.R =================================================================== --- pkg/vegan/R/permutest.cca.R 2013-11-21 20:34:39 UTC (rev 2743) +++ pkg/vegan/R/permutest.cca.R 2013-11-22 17:59:07 UTC (rev 2744) @@ -7,7 +7,7 @@ `permutest.cca` <- function (x, permutations = how(nperm=99), model = c("reduced", "direct", "full"), first = FALSE, - strata = NULL, parallel = getOption("mc.cores") , ...) + strata = NULL, parallel = getOption("mc.cores") , ...) { ## do something sensible with insensible input (no constraints) if (is.null(x$CCA)) { @@ -53,7 +53,7 @@ Q <- qr(XY) } tmp <- qr.fitted(Q, Y) - if (first) + if (first) cca.ev <- La.svd(tmp, nv = 0, nu = 0)$d[1]^2 else cca.ev <- sum(tmp * tmp) if (isPartial || first) { @@ -74,15 +74,15 @@ Chi.z <- x$CCA$tot.chi names(Chi.z) <- "Model" q <- x$CCA$qrank - } - ## Set up + } + ## Set up Chi.xz <- x$CA$tot.chi names(Chi.xz) <- "Residual" r <- nrow(x$CA$Xbar) - x$CCA$QR$rank - 1 - if (model == "full") + if (model == "full") Chi.tot <- Chi.xz else Chi.tot <- Chi.z + Chi.xz - if (!isCCA) + if (!isCCA) Chi.tot <- Chi.tot * (nrow(x$CCA$Xbar) - 1) F.0 <- (Chi.z/q)/(Chi.xz/r) Q <- x$CCA$QR @@ -99,10 +99,10 @@ Z <- sweep(Z, 1, sqrt(w), "/") } } - if (model == "reduced" || model == "direct") + if (model == "reduced" || model == "direct") E <- x$CCA$Xbar else E <- x$CA$Xbar - if (isPartial && model == "direct") + if (isPartial && model == "direct") E <- E + Y.Z ## Save dimensions N <- nrow(E) @@ -111,7 +111,7 @@ if (isPartial) Zcol <- ncol(Z) } - if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) + if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) runif(1) seed <- get(".Random.seed", envir = .GlobalEnv, inherits = FALSE) ## permutations is either a single number, a how() structure or a @@ -123,9 +123,9 @@ if (!is.null(strata)) { if (!inherits(permutations, "how")) stop("'strata' can be used only with simple permutation or with 'how()'") - if (!is.null(permutations$block)) + if (!is.null(getBlocks(permutations))) stop("'strata' cannot be applied when 'blocks' are defined in 'how()'") - permutations <- update(permutations, blocks = strata) + setBlocks(permutations) <- strata } ## now permutations is either a how() structure or a permutation ## matrix. Make it to a matrix if it is "how" From noreply at r-forge.r-project.org Fri Nov 22 18:59:51 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 22 Nov 2013 18:59:51 +0100 (CET) Subject: [Vegan-commits] r2745 - in pkg/vegan: R man Message-ID: <20131122175951.81905185632@r-forge.r-project.org> Author: gsimpson Date: 2013-11-22 18:59:51 +0100 (Fri, 22 Nov 2013) New Revision: 2745 Modified: pkg/vegan/R/permutest.betadisper.R pkg/vegan/R/print.permutest.betadisper.R pkg/vegan/man/permutest.betadisper.Rd Log: update permutest method to the new permute API Modified: pkg/vegan/R/permutest.betadisper.R =================================================================== --- pkg/vegan/R/permutest.betadisper.R 2013-11-22 17:59:07 UTC (rev 2744) +++ pkg/vegan/R/permutest.betadisper.R 2013-11-22 17:59:51 UTC (rev 2745) @@ -1,6 +1,6 @@ `permutest.betadisper` <- function(x, pairwise = FALSE, - control = how(nperm = 999), - permutations = NULL, ...) + permutations = how(nperm = 999), + ...) { t.statistic <- function(x, y) { m <- length(x) @@ -17,27 +17,31 @@ stop("Only for class \"betadisper\"") ## will issue error if only a single group mod.aov <- anova(x) - nobs <- length(x$distances) + nobs <- length(x$distances) ## number of observations mod <- lm(x$distances ~ x$group) mod.Q <- mod$qr p <- mod.Q$rank resids <- qr.resid(mod.Q, x$distances) - N <- nrow(x) ## number of observations - ## extract groups group <- x$group + ## permutations is either a single number, a how() structure or a + ## permutation matrix + if (length(permutations) == 1) { + nperm <- permutations + permutations <- how(nperm = nperm) + } - ## If permutations is NULL, work with control - if(is.null(permutations)) { - permutations <- shuffleSet(length(group), control = control) - } else { - permutations <- as.matrix(permutations) - if (ncol(permutations) != N) - stop(gettextf("'permutations' have %d columns, but data have %d observations", - ncol(permutations), N)) + ## permutations is either a single number, a how() structure or a + ## permutation matrix + if (length(permutations) == 1) { + nperm <- permutations + permutations <- how(nperm = nperm) } - + ## now permutations is either a how() structure or a permutation + ## matrix. Make it to a matrix if it is "how" + if (inherits(permutations, "how")) + permutations <- shuffleSet(nobs, control = permutations) ## number of permutations being performed, possibly adjusted after ## checking in shuffleSet nperm <- nrow(permutations) @@ -45,7 +49,6 @@ ## set-up objects to hold permuted results res <- numeric(length = nperm + 1) res[1] <- summary(mod)$fstatistic[1] - ## pairwise comparisons if(pairwise) { ## unique pairings @@ -95,12 +98,13 @@ pairwise <- NULL } - retval <- cbind(mod.aov[, 1:4], c(nperm, NA), c(pval, NA)) + retval <- cbind(mod.aov[, 1:4], c(nperm + 1, NA), c(pval, NA)) dimnames(retval) <- list(c("Groups", "Residuals"), c("Df", "Sum Sq", "Mean Sq", "F", "N.Perm", "Pr(>F)")) retval <- list(tab = retval, pairwise = pairwise, - groups = levels(group), control = control) + groups = levels(group), + control = attr(permutations, "control")) class(retval) <- "permutest.betadisper" retval } Modified: pkg/vegan/R/print.permutest.betadisper.R =================================================================== --- pkg/vegan/R/print.permutest.betadisper.R 2013-11-22 17:59:07 UTC (rev 2744) +++ pkg/vegan/R/print.permutest.betadisper.R 2013-11-22 17:59:51 UTC (rev 2745) @@ -21,7 +21,7 @@ zap.i <- zap.i[!(zap.i %in% i)] if (length(i <- grep("N.Perm$", cn))) zap.i <- zap.i[!(zap.i %in% i)] - cat("Response: Distances", sep = "\n") + cat("\nResponse: Distances", sep = "\n") printCoefmat(x$tab, digits = digits, signif.stars = getOption("show.signif.stars"), has.Pvalue = has.P, P.values = has.P, cs.ind = NULL, Modified: pkg/vegan/man/permutest.betadisper.Rd =================================================================== --- pkg/vegan/man/permutest.betadisper.Rd 2013-11-22 17:59:07 UTC (rev 2744) +++ pkg/vegan/man/permutest.betadisper.Rd 2013-11-22 17:59:51 UTC (rev 2745) @@ -10,18 +10,18 @@ } \usage{ \method{permutest}{betadisper}(x, pairwise = FALSE, - control = how(nperm = 999), permutations = NULL, - \dots) + permutations = how(nperm = 999), + \dots) } %- maybe also 'usage' for other objects documented here. \arguments{ \item{x}{an object of class \code{"betadisper"}, the result of a call to \code{betadisper}.} \item{pairwise}{logical; perform pairwise comparisons of group means?} - \item{control}{a list of control values for the permutations - as returned by the function \code{\link[permute]{how}}.} - \item{permutations}{A permutation matrix where each row gives the - permuted indices. If this is supplied, \code{control} is ignored.} + \item{permutations}{a list of control values for the permutations + as returned by the function \code{\link[permute]{how}}, or the + number of permutations required, or a permutation matrix where each + row gives the permuted indices.} \item{\dots}{Arguments passed to other methods.} } \details{ @@ -82,7 +82,7 @@ anova(mod) ## Permutation test for F -permutest(mod, pairwise = TRUE) +permutest(mod, permutations = 99, pairwise = TRUE) ## Tukey's Honest Significant Differences (mod.HSD <- TukeyHSD(mod)) From noreply at r-forge.r-project.org Fri Nov 22 19:00:35 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 22 Nov 2013 19:00:35 +0100 (CET) Subject: [Vegan-commits] r2746 - pkg/vegan/inst Message-ID: <20131122180035.3F26D185632@r-forge.r-project.org> Author: gsimpson Date: 2013-11-22 19:00:34 +0100 (Fri, 22 Nov 2013) New Revision: 2746 Modified: pkg/vegan/inst/ChangeLog Log: document r2744 and r2745 Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2013-11-22 17:59:51 UTC (rev 2745) +++ pkg/vegan/inst/ChangeLog 2013-11-22 18:00:34 UTC (rev 2746) @@ -10,7 +10,7 @@ the function no more adapts the number of iterations for the P-value, and arguments 'step' and 'perm.max' were removed. Instead, permute package is used to create a permutation matrix - used in all cases with fixed number of permutations. + used in all cases with fixed number of permutations. In addition to the overall test, the function allows now testing a sequence of models (anova.ccalist). Specific tests provided are @@ -36,6 +36,11 @@ * oecosimu: change printed quantiles to match the direction of the test as changed in r2495. + * permutest.betadisper: updated to the new permute API and operates + similarly to permutest.cca in respect of how the permutation test + can be defined. It currently doesn't support the parallel processing + of the cca method, however. + * tests: vegan examples and vegan-tests have been out of sync for a long time. These have not been updated because most of the changes seem to be triggered by switching to R 3.0-x, and we have @@ -44,7 +49,7 @@ results. In particular, there seem to be differences in permutations, constrained ordination, in particular in capscale() and rounding of output. We have also introduced some changes in - output that were not yet synced. + output that were not yet synced. * janitorial: vegan has been dependent on R >= 2.14.0 since version 2.1-34 (r2597 Wed 28-Aug-2013). Now superfluous references @@ -52,7 +57,9 @@ documentation. FIXME: cca() returns residuals.zombie item that was supposed to be needed in R < 2.13.0. This was not yet removed: we must first check that this can be safely done. - + + vegan also now depends on permute version 0.7-8 or later. + Version 2.1-38 (closed November 10, 2013) * DESCRIPTION: depends on permute >= 0.7-5, where the From noreply at r-forge.r-project.org Sat Nov 23 09:05:04 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 23 Nov 2013 09:05:04 +0100 (CET) Subject: [Vegan-commits] r2747 - pkg/permute Message-ID: <20131123080504.8A141183C20@r-forge.r-project.org> Author: jarioksa Date: 2013-11-23 09:05:04 +0100 (Sat, 23 Nov 2013) New Revision: 2747 Modified: pkg/permute/NAMESPACE Log: "setBlocks<-" must be exported (and within upright quotes) Modified: pkg/permute/NAMESPACE =================================================================== --- pkg/permute/NAMESPACE 2013-11-22 18:00:34 UTC (rev 2746) +++ pkg/permute/NAMESPACE 2013-11-23 08:05:04 UTC (rev 2747) @@ -5,7 +5,7 @@ `getBlocks`, `getWithin`, `getStrata`, `getType`, `getMirror`, `getConstant`, `getPlots`, `getRow`, `getCol`, `getDim`, `getNperm`,`getMaxperm`, `getMinperm`, `getComplete`, `getMake`, - `getObserved`, `shuffleSet`, `how`) + `getObserved`, "setBlocks<-", `shuffleSet`, `how`) ### Imports: nobs() only exists in R 2.13.0 for import. We define the ### same nobs() generic in permute for export in older R. From noreply at r-forge.r-project.org Sun Nov 24 08:38:27 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 24 Nov 2013 08:38:27 +0100 (CET) Subject: [Vegan-commits] r2748 - pkg/vegan/R Message-ID: <20131124073827.66C9618500F@r-forge.r-project.org> Author: jarioksa Date: 2013-11-24 08:38:26 +0100 (Sun, 24 Nov 2013) New Revision: 2748 Modified: pkg/vegan/R/anovacca.R pkg/vegan/R/permutest.cca.R Log: take Random.seed and control from permutationMatrix Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-11-23 08:05:04 UTC (rev 2747) +++ pkg/vegan/R/anovacca.R 2013-11-24 07:38:26 UTC (rev 2748) @@ -4,10 +4,6 @@ parallel = getOption("mc.cores"), strata = NULL) { model <- match.arg(model) - if (!exists(".Random.seed", envir = .GlobalEnv, - inherits = FALSE)) - runif(1) - seed <- get(".Random.seed", envir = .GlobalEnv, inherits = FALSE) ## permutations is either a single number, a how() structure or a ## permutation matrix if (length(permutations) == 1) { @@ -23,11 +19,14 @@ } ## now permutations is either a how() structure or a permutation ## matrix. Make it to a matrix if it is "how" - if (inherits(permutations, "how")) + if (inherits(permutations, "how")) { permutations <- shuffleSet(nrow(object$CA$u), control = permutations) - else # we got a permutation matrix and seed is unknown - seed <- NA + seed <- attr(permutations, "seed") + control <- attr(permutations, "control") + } + else # we got a permutation matrix and seed & control are unknown + seed <- control <- NULL nperm <- nrow(permutations) ## stop permutations block ## see if this was a list of ordination objects @@ -44,6 +43,8 @@ permutations = permutations, model = model, parallel = parallel) + attr(sol, "Random.seed") <- seed + attr(sol, "control") <- control return(sol) } } @@ -60,6 +61,8 @@ "axis" = anovacca.byaxis(object, permutations = permutations, model = model, parallel = parallel)) + attr(sol, "Random.seed") <- seed + attr(sol, "control") <- control return(sol) } ## basic overall test @@ -78,6 +81,7 @@ head <- paste(head, "Permutations stratified within '", tst$strata, "'\n", sep = "") mod <- paste("Model:", c(object$call)) - structure(table, heading = c(head, mod), Random.seed = seed, + structure(table, heading = c(head, mod), Random.seed = seed, + control = control, class = c("anova.cca", "anova", "data.frame")) } Modified: pkg/vegan/R/permutest.cca.R =================================================================== --- pkg/vegan/R/permutest.cca.R 2013-11-23 08:05:04 UTC (rev 2747) +++ pkg/vegan/R/permutest.cca.R 2013-11-24 07:38:26 UTC (rev 2748) @@ -111,9 +111,6 @@ if (isPartial) Zcol <- ncol(Z) } - if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) - runif(1) - seed <- get(".Random.seed", envir = .GlobalEnv, inherits = FALSE) ## permutations is either a single number, a how() structure or a ## permutation matrix if (length(permutations) == 1) { @@ -167,7 +164,9 @@ sol <- list(call = Call, testcall = x$call, model = model, F.0 = F.0, F.perm = F.perm, chi = c(Chi.z, Chi.xz), num = num, den = den, df = c(q, r), nperm = nperm, - method = x$method, first = first, Random.seed = seed) + method = x$method, first = first) + sol$Random.seed <- attr(permutations, "seed") + sol$control <- attr(permutations, "control") if (!missing(strata)) { sol$strata <- deparse(substitute(strata)) sol$stratum.values <- strata From noreply at r-forge.r-project.org Sun Nov 24 08:56:54 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 24 Nov 2013 08:56:54 +0100 (CET) Subject: [Vegan-commits] r2749 - pkg/vegan/R Message-ID: <20131124075654.EF267184F97@r-forge.r-project.org> Author: jarioksa Date: 2013-11-24 08:56:54 +0100 (Sun, 24 Nov 2013) New Revision: 2749 Modified: pkg/vegan/R/anovacca.byterm.R Log: use drop.scope Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-11-24 07:38:26 UTC (rev 2748) +++ pkg/vegan/R/anovacca.byterm.R 2013-11-24 07:56:54 UTC (rev 2749) @@ -45,9 +45,8 @@ { nperm <- nrow(permutations) ## We need term labels but without Condition() terms - trms <- terms(object) - trmlab <- attr(trms, "term.labels") - trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo), + trms <- drop.scope(object) + trmlab <- trms[trms %in% attr(terms(object$terminfo), "term.labels")] ## baseline: all terms big <- permutest(object, permutations, ...) From noreply at r-forge.r-project.org Sun Nov 24 14:54:51 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 24 Nov 2013 14:54:51 +0100 (CET) Subject: [Vegan-commits] r2750 - pkg/vegan/R Message-ID: <20131124135451.630B91849F3@r-forge.r-project.org> Author: jarioksa Date: 2013-11-24 14:54:51 +0100 (Sun, 24 Nov 2013) New Revision: 2750 Modified: pkg/vegan/R/anovacca.R Log: handle null-models without constraints Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-11-24 07:56:54 UTC (rev 2749) +++ pkg/vegan/R/anovacca.R 2013-11-24 13:54:51 UTC (rev 2750) @@ -33,7 +33,7 @@ dotargs <- list(...) ## we do not want to give dotargs to anova.ccalist, but we ## evaluate 'parallel' and 'model' here - if (length(dotargs)) { + if (length(dotargs)) { isCCA <- sapply(dotargs, function(z) inherits(z, "cca")) if (any(isCCA)) { dotargs <- dotargs[isCCA] @@ -48,6 +48,10 @@ return(sol) } } + ## We only have a single model: check if it is empty + if (is.null(object$CA) || is.null(object$CCA) || + object$CCA$rank == 0 || object$CA$rank == 0) + return(anova.ccanull(object)) ## by cases if (!is.null(by)) { by <- match.arg(by, c("terms", "margin", "axis")) From noreply at r-forge.r-project.org Sun Nov 24 15:50:18 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 24 Nov 2013 15:50:18 +0100 (CET) Subject: [Vegan-commits] r2751 - pkg/vegan/R Message-ID: <20131124145018.16CB01862F7@r-forge.r-project.org> Author: jarioksa Date: 2013-11-24 15:50:17 +0100 (Sun, 24 Nov 2013) New Revision: 2751 Modified: pkg/vegan/R/anovacca.byterm.R pkg/vegan/R/permutest.cca.R Log: handle one axis and one constraint cases in anovacca by= Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-11-24 13:54:51 UTC (rev 2750) +++ pkg/vegan/R/anovacca.byterm.R 2013-11-24 14:50:17 UTC (rev 2751) @@ -67,6 +67,9 @@ Fstat <- (Chisq/Df)/(chibig/dfbig) ## Simulated F-values Fval <- sapply(mods, function(x) x$den) + ## Had we an empty model we need to clone the denominator + if (length(Fval) == 1) + Fval <- matrix(Fval, nrow=nperm) Fval <- sweep(Fval, 1, big$den, "-") Fval <- sweep(Fval, 2, Df, "/") Fval <- sweep(Fval, 1, scale, "/") @@ -97,10 +100,16 @@ Pvals <- numeric(length(eig)) environment(object$terms) <- environment() for (i in 1:length(eig)) { - Partial <- LC[,-i] - mod <- permutest(update(object, . ~ . + Condition(Partial)), - permutations, model = model, - parellel = parallel) + Partial <- LC[,-i, drop = FALSE] + ## only one axis, and cannot partial out? + if (!ncol(Partial)) + mod <- permutest(object, permutations, model = model, + parallel = parallel) + else + mod <- + permutest(update(object, . ~ . + Condition(Partial)), + permutations, model = model, + parellel = parallel) Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1) } out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi), Modified: pkg/vegan/R/permutest.cca.R =================================================================== --- pkg/vegan/R/permutest.cca.R 2013-11-24 13:54:51 UTC (rev 2750) +++ pkg/vegan/R/permutest.cca.R 2013-11-24 14:50:17 UTC (rev 2751) @@ -13,7 +13,7 @@ if (is.null(x$CCA)) { sol <- list(call = match.call(), testcall = x$call, model = NA, F.0 = NA, F.perm = NA, chi = c(0, x$CA$tot.chi), - num = 0, den = 0, + num = 0, den = x$CA$tot.chi, df = c(0, nrow(x$CA$u) - max(x$pCCA$rank,0) - 1), nperm = 0, method = x$method, first = FALSE, Random.seed = NA) From noreply at r-forge.r-project.org Sun Nov 24 17:30:09 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 24 Nov 2013 17:30:09 +0100 (CET) Subject: [Vegan-commits] r2752 - pkg/permute Message-ID: <20131124163009.5C2561800FB@r-forge.r-project.org> Author: gsimpson Date: 2013-11-24 17:30:09 +0100 (Sun, 24 Nov 2013) New Revision: 2752 Modified: pkg/permute/NAMESPACE Log: export the setFoo() functions; change all to quotes rather than back ticks Modified: pkg/permute/NAMESPACE =================================================================== --- pkg/permute/NAMESPACE 2013-11-24 14:50:17 UTC (rev 2751) +++ pkg/permute/NAMESPACE 2013-11-24 16:30:09 UTC (rev 2752) @@ -1,148 +1,157 @@ ### Visible functions: -export(`allPerms`, `Blocks`, `numPerms`, `check`, `permCheck`, - `permControl`, `permute`, `shuffle`, `Within`, `Plots`, - `shuffleFree`, `shuffleSeries`, `shuffleGrid`, `shuffleStrata`, - `getBlocks`, `getWithin`, `getStrata`, `getType`, `getMirror`, - `getConstant`, `getPlots`, `getRow`, `getCol`, `getDim`, - `getNperm`,`getMaxperm`, `getMinperm`, `getComplete`, `getMake`, - `getObserved`, "setBlocks<-", `shuffleSet`, `how`) +export("allPerms", "Blocks", "numPerms", "check", "permCheck", + "permControl", "permute", "shuffle", "Within", "Plots", + "shuffleFree", "shuffleSeries", "shuffleGrid", "shuffleStrata", + "getBlocks", "getWithin", "getStrata", "getType", "getMirror", + "getConstant", "getPlots", "getRow", "getCol", "getDim", + "getNperm","getMaxperm", "getMinperm", "getComplete", "getMake", + "getObserved", "shuffleSet", "how", + "setBlocks<-", + "setNperm<-", + "setMaxperm<-", + "setMinperm<-", + "setComplete<-", + "setMake<-", + "setObserved<-", + "setAllperms<-" + ) ### Imports: nobs() only exists in R 2.13.0 for import. We define the ### same nobs() generic in permute for export in older R. if (getRversion() >= "2.13.0") { - importFrom(`stats`, `nobs`) + importFrom("stats", "nobs") } else { export(nobs) } ### S3 Methods -S3method(`as.matrix`, `permutationMatrix`) -S3method(`update`, `how`) -S3method(`update`, `Plots`) +S3method("as.matrix", "permutationMatrix") +S3method("update", "how") +S3method("update", "Plots") ## print methods -S3method(`print`, `allPerms`) -S3method(`print`, `check`) -S3method(`print`, `how`) -S3method(`print`, `permControl`) -S3method(`print`, `permutationMatrix`) -S3method(`print`, `summary.allPerms`) -S3method(`print`, `summary.check`) +S3method("print", "allPerms") +S3method("print", "check") +S3method("print", "how") +S3method("print", "permControl") +S3method("print", "permutationMatrix") +S3method("print", "summary.allPerms") +S3method("print", "summary.check") ## summary methods -S3method(`summary`, `allPerms`) -S3method(`summary`, `check`) +S3method("summary", "allPerms") +S3method("summary", "check") ## nobs() methods -S3method(`nobs`, `numeric`) -S3method(`nobs`, `integer`) -S3method(`nobs`, `matrix`) -S3method(`nobs`, `data.frame`) +S3method("nobs", "numeric") +S3method("nobs", "integer") +S3method("nobs", "matrix") +S3method("nobs", "data.frame") ## getFoo methods -S3method(`getBlocks`, `default`) -S3method(`getBlocks`, `how`) -S3method(`getBlocks`, `permControl`) -S3method(`getPlots`, `default`) -S3method(`getPlots`, `how`) -S3method(`getPlots`, `permControl`) -S3method(`getWithin`, `default`) -S3method(`getWithin`, `how`) -S3method(`getWithin`, `permControl`) -S3method(`getStrata`, `default`) -S3method(`getStrata`, `how`) -S3method(`getStrata`, `permControl`) -S3method(`getStrata`, `Plots`) -S3method(`getType`, `default`) -S3method(`getType`, `how`) -S3method(`getType`, `permControl`) -S3method(`getType`, `Plots`) -S3method(`getType`, `Within`) -S3method(`getMirror`, `default`) -S3method(`getMirror`, `how`) -S3method(`getMirror`, `permControl`) -S3method(`getMirror`, `Plots`) -S3method(`getMirror`, `Within`) -S3method(`getConstant`, `default`) -S3method(`getConstant`, `how`) -S3method(`getConstant`, `permControl`) -S3method(`getConstant`, `Within`) -S3method(`getNperm`, `default`) -S3method(`getNperm`, `how`) -S3method(`getNperm`, `permControl`) -S3method(`getMaxperm`, `default`) -S3method(`getMaxperm`, `how`) -S3method(`getMaxperm`, `permControl`) -S3method(`getMinperm`, `default`) -S3method(`getMinperm`, `how`) -S3method(`getMinperm`, `permControl`) -S3method(`getComplete`, `default`) -S3method(`getComplete`, `how`) -S3method(`getComplete`, `permControl`) -S3method(`getRow`, `default`) -S3method(`getRow`, `how`) -S3method(`getRow`, `permControl`) -S3method(`getRow`, `Plots`) -S3method(`getRow`, `Within`) -S3method(`getCol`, `default`) -S3method(`getCol`, `how`) -S3method(`getCol`, `permControl`) -S3method(`getCol`, `Plots`) -S3method(`getCol`, `Within`) -S3method(`getDim`, `default`) -S3method(`getDim`, `how`) -S3method(`getDim`, `permControl`) -S3method(`getDim`, `Plots`) -S3method(`getDim`, `Within`) -S3method(`getMake`, `default`) -S3method(`getMake`, `how`) -S3method(`getObserved`, `default`) -S3method(`getObserved`, `how`) +S3method("getBlocks", "default") +S3method("getBlocks", "how") +S3method("getBlocks", "permControl") +S3method("getPlots", "default") +S3method("getPlots", "how") +S3method("getPlots", "permControl") +S3method("getWithin", "default") +S3method("getWithin", "how") +S3method("getWithin", "permControl") +S3method("getStrata", "default") +S3method("getStrata", "how") +S3method("getStrata", "permControl") +S3method("getStrata", "Plots") +S3method("getType", "default") +S3method("getType", "how") +S3method("getType", "permControl") +S3method("getType", "Plots") +S3method("getType", "Within") +S3method("getMirror", "default") +S3method("getMirror", "how") +S3method("getMirror", "permControl") +S3method("getMirror", "Plots") +S3method("getMirror", "Within") +S3method("getConstant", "default") +S3method("getConstant", "how") +S3method("getConstant", "permControl") +S3method("getConstant", "Within") +S3method("getNperm", "default") +S3method("getNperm", "how") +S3method("getNperm", "permControl") +S3method("getMaxperm", "default") +S3method("getMaxperm", "how") +S3method("getMaxperm", "permControl") +S3method("getMinperm", "default") +S3method("getMinperm", "how") +S3method("getMinperm", "permControl") +S3method("getComplete", "default") +S3method("getComplete", "how") +S3method("getComplete", "permControl") +S3method("getRow", "default") +S3method("getRow", "how") +S3method("getRow", "permControl") +S3method("getRow", "Plots") +S3method("getRow", "Within") +S3method("getCol", "default") +S3method("getCol", "how") +S3method("getCol", "permControl") +S3method("getCol", "Plots") +S3method("getCol", "Within") +S3method("getDim", "default") +S3method("getDim", "how") +S3method("getDim", "permControl") +S3method("getDim", "Plots") +S3method("getDim", "Within") +S3method("getMake", "default") +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(`setNperm<-`, `default`) -S3method(`setNperm<-`, `how`) -S3method(`setNperm<-`, `permControl`) -S3method(`setMaxperm<-`, `default`) -S3method(`setMaxperm<-`, `how`) -S3method(`setMaxperm<-`, `permControl`) -S3method(`setMinperm<-`, `default`) -S3method(`setMinperm<-`, `how`) -S3method(`setMinperm<-`, `permControl`) -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(`setMake<-`, `default`) -S3method(`setMake<-`, `how`) -S3method(`setMake<-`, `permControl`) -S3method(`setObserved<-`, `default`) -S3method(`setObserved<-`, `how`) -S3method(`setObserved<-`, `permControl`) -S3method(`setAllperms<-`, `default`) -S3method(`setAllperms<-`, `how`) -S3method(`setAllperms<-`, `permControl`) +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("setNperm<-", "default") +S3method("setNperm<-", "how") +S3method("setNperm<-", "permControl") +S3method("setMaxperm<-", "default") +S3method("setMaxperm<-", "how") +S3method("setMaxperm<-", "permControl") +S3method("setMinperm<-", "default") +S3method("setMinperm<-", "how") +S3method("setMinperm<-", "permControl") +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("setMake<-", "default") +S3method("setMake<-", "how") +S3method("setMake<-", "permControl") +S3method("setObserved<-", "default") +S3method("setObserved<-", "how") +S3method("setObserved<-", "permControl") +S3method("setAllperms<-", "default") +S3method("setAllperms<-", "how") +S3method("setAllperms<-", "permControl") From noreply at r-forge.r-project.org Sun Nov 24 17:30:50 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 24 Nov 2013 17:30:50 +0100 (CET) Subject: [Vegan-commits] r2753 - pkg/permute/man Message-ID: <20131124163050.65C3D1800FB@r-forge.r-project.org> Author: gsimpson Date: 2013-11-24 17:30:50 +0100 (Sun, 24 Nov 2013) New Revision: 2753 Added: pkg/permute/man/set-methods.Rd Log: as these are now exported, must be documented Added: pkg/permute/man/set-methods.Rd =================================================================== --- pkg/permute/man/set-methods.Rd (rev 0) +++ pkg/permute/man/set-methods.Rd 2013-11-24 16:30:50 UTC (rev 2753) @@ -0,0 +1,150 @@ +\name{set-methods} +\alias{set-methods} +\alias{setBlocks<-} +\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{setNperm<-} +\alias{setNperm<-.default} +\alias{setNperm<-.how} +\alias{setNperm<-.permControl} +\alias{setAllperms<-} +\alias{setAllperms<-.default} +\alias{setAllperms<-.how} +\alias{setAllperms<-.permControl} +\alias{setMaxperm<-} +\alias{setMaxperm<-.default} +\alias{setMaxperm<-.how} +\alias{setMaxperm<-.permControl} +\alias{setMinperm<-} +\alias{setMinperm<-.default} +\alias{setMinperm<-.how} +\alias{setMinperm<-.permControl} +\alias{setComplete<-} +\alias{setComplete<-.default} +\alias{setComplete<-.how} +\alias{setComplete<-.permControl} +\alias{setMake<-} +\alias{setMake<-.default} +\alias{setMake<-.how} +\alias{setObserved<-} +\alias{setObserved<-.default} +\alias{setObserved<-.how} + +\title{Replacement functions to set components of a permutation design} +\description{ + Simple functions to allow abstracted replacement of components of a + permutation design, for example as returned by \code{\link{how}}. In + addition to performing replacement of components of the list returned + by \code{\link{how}}, these replacement function also update the + matched calls stored within the list to facilitate the use of + \code{\link{update}} by users. +} +\usage{ + +setBlocks(object) <- value +setNperm(object) <- value +setAllperms(object) <- value +setMaxperm(object) <- value +setMinperm(object) <- value +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 + +} + +\arguments{ + \item{object}{An R object to dispatch on.} + \item{value}{The replacement value/object.} +} +\details{ + These are replacement functions for working with permutation design + objects created by \code{\link{how}}. They should be used in + preference to directly updating the permutation design in case the + internal structure of object changes as \pkg{permute} is developed and + because the matched call also needs to be updated to facilitate use of + \code{\link{update}} on the \code{\link{how}} object. +} +\value{ + These replacement functions return \code{object} suitably modified. +} +\author{Gavin Simpson} +\seealso{\code{\link{check}}, a utility function for checking + permutation scheme described by \code{\link{how}}. Comparable + extractor functions are also available; see + \code{\link{get-methods}}. +} + +\examples{ +## extract components from a "how" object +hh <- how() +getNperm(hh) +setNperm(hh) <- 999 +getNperm(hh) +} +\keyword{ methods } +\keyword{ utils } \ No newline at end of file From noreply at r-forge.r-project.org Sun Nov 24 17:36:31 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 24 Nov 2013 17:36:31 +0100 (CET) Subject: [Vegan-commits] r2754 - pkg/permute/R Message-ID: <20131124163631.C782E1800FB@r-forge.r-project.org> Author: gsimpson Date: 2013-11-24 17:36:31 +0100 (Sun, 24 Nov 2013) New Revision: 2754 Modified: pkg/permute/R/setFoo-methods.R Log: fix a few copy-paste errors; be more defensive about what 'value' is and coerce to appropriate types Modified: pkg/permute/R/setFoo-methods.R =================================================================== --- pkg/permute/R/setFoo-methods.R 2013-11-24 16:30:50 UTC (rev 2753) +++ pkg/permute/R/setFoo-methods.R 2013-11-24 16:36:31 UTC (rev 2754) @@ -67,12 +67,16 @@ } `setComplete<-.how` <- function(object, value) { + if (!is.null(value)) + value <- rep(as.logical(value), length.out = 1) object[["complete"]] <- value object <- fixupCall(object, "complete", value) object } `setComplete<-.permControl` <- function(object, value) { + if (!is.null(value)) + value <- rep(as.logical(value), length.out = 1) object[["complete"]] <- value object <- fixupCall(object, "complete", value) object @@ -87,12 +91,16 @@ } `setAllperms<-.how` <- function(object, value) { + if (!is.null(value)) + value <- as.matrix(value) object[["all.perms"]] <- value object <- fixupCall(object, "all.perms", value) object } `setAllperms<-.permControl` <- function(object, value) { + if (!is.null(value)) + value <- as.matrix(value) object[["all.perms"]] <- value object <- fixupCall(object, "all.perms", value) object @@ -107,13 +115,17 @@ } `setMake<-.how` <- function(object, value) { + if (!is.null(value)) + value <- rep(as.logical(value), length.out = 1) object[["make"]] <- value object <- fixupCall(object, "make", value) object } `setMake<-.permControl` <- function(object, value) { - object[["all.perms"]] <- value + if (!is.null(value)) + value <- rep(as.logical(value), length.out = 1) + object[["make"]] <- value object <- fixupCall(object, "make", value) object } @@ -127,6 +139,8 @@ } `setBlocks<-.how` <- function(object, value) { + if (!is.null(value)) + value <- as.factor(value) object["blocks"] <- list(value) object[["blocks.name"]] <- deparse(substitute(value)) object <- fixupCall(object, "blocks", value) @@ -134,6 +148,8 @@ } `setBlocks<-.permControl` <- function(object, value) { + if (!is.null(value)) + value <- as.factor(value) object["blocks"] <- list(value) object[["blocks.name"]] <- deparse(substitute(value)) object <- fixupCall(object, "blocks", value) @@ -149,13 +165,17 @@ } `setObserved<-.how` <- function(object, value) { + if (!is.null(value)) + value <- rep(as.logical(value), length.out = 1) object[["observed"]] <- value object <- fixupCall(object, "observed", value) object } `setObserved<-.permControl` <- function(object, value) { - object[["all.perms"]] <- value + if (!is.null(value)) + value <- rep(as.logical(value), length.out = 1) + object[["observed"]] <- value object <- fixupCall(object, "observed", value) object } From noreply at r-forge.r-project.org Sun Nov 24 17:39:05 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 24 Nov 2013 17:39:05 +0100 (CET) Subject: [Vegan-commits] r2755 - in pkg/permute: . vignettes Message-ID: <20131124163905.5678B1800FB@r-forge.r-project.org> Author: gsimpson Date: 2013-11-24 17:39:04 +0100 (Sun, 24 Nov 2013) New Revision: 2755 Modified: pkg/permute/DESCRIPTION pkg/permute/vignettes/Z.cls pkg/permute/vignettes/permutations.Rnw pkg/permute/vignettes/permute.bib Log: added more to the vignette; now suggest parallel package as I have a parallel example in the vignette Modified: pkg/permute/DESCRIPTION =================================================================== --- pkg/permute/DESCRIPTION 2013-11-24 16:36:31 UTC (rev 2754) +++ pkg/permute/DESCRIPTION 2013-11-24 16:39:04 UTC (rev 2755) @@ -5,7 +5,7 @@ Author: Gavin L. Simpson Maintainer: Gavin L. Simpson Depends: R (>= 2.14.0) -Suggests: vegan (>= 2.0-0), testthat (>= 0.5) +Suggests: vegan (>= 2.0-0), testthat (>= 0.5), parallel Description: The 'permute' package implements a set of restricted permutation designs for freely exchangeable, line transects (time series), and spatial grid designs plus permutation of blocks (groups of samples). 'permute' also allows split-plot designs, in which the whole-plots or split-plots or both can be freely-exchangeable or one of the restricted designs. The 'permute' package is modelled after the permutation schemes of Canoco 3.1 (and later) by Cajo ter Braak. License: GPL-2 ByteCompile: true Modified: pkg/permute/vignettes/Z.cls =================================================================== --- pkg/permute/vignettes/Z.cls 2013-11-24 16:36:31 UTC (rev 2754) +++ pkg/permute/vignettes/Z.cls 2013-11-24 16:39:04 UTC (rev 2755) @@ -183,7 +183,7 @@ \newcommand{\jsssubsubsec}[2][default]{\vskip \preSskip% \pdfbookmark[3]{#1}{Subsubsection.\thesubsubsection.#1}% \refstepcounter{subsubsection}% - {\large \textit{#2}} \nopagebreak + {\large \thesubsubsection. \textit{#2}} \nopagebreak \vskip \postSskip \nopagebreak} \newcommand{\jsssubsubsecnn}[1]{\vskip \preSskip% {\textit{\large #1}} \nopagebreak Modified: pkg/permute/vignettes/permutations.Rnw =================================================================== --- pkg/permute/vignettes/permutations.Rnw 2013-11-24 16:36:31 UTC (rev 2754) +++ pkg/permute/vignettes/permutations.Rnw 2013-11-24 16:39:04 UTC (rev 2755) @@ -10,12 +10,12 @@ %% almost as usual \author{Gavin L. Simpson\\University of Regina} -\title{Restricted permutations; using the \pkg{permute} Package} +\title{Restricted permutations; using the \pkg{permute} package} %% for pretty printing and a nice hypersummary also set: \Plainauthor{Gavin L. Simpson} %% comma-separated -\Plaintitle{Restricted permutations; using the permute Package} %% without formatting -\Shorttitle{Using the permute Package} %% a short title (if necessary) +\Plaintitle{Restricted permutations; using the permute package} %% without formatting +\Shorttitle{Using the permute package} %% a short title (if necessary) %% an abstract and keywords \Abstract{ @@ -51,18 +51,18 @@ %% include your article here, just as usual %% Note that you should use the \pkg{}, \proglang{} and \code{} commands. <>= -options("prompt" = "R> ", "continue" = "+ ") +options("prompt" = "R> ", "continue" = "+ ") options(useFancyQuotes="UTF-8") @ \section{Introduction} In classical frequentist statistics, the significance of a relationship or model is determined by reference to a null distribution for the test statistic. This distribution is derived mathematically and the probability of achieving a test statistic as large or larger if the null hypothesis were true is looked-up from this null distribution. In deriving this probability, some assumptions about the data or the errors are made. If these assumptions are violated, then the validity of the derived $p$-value may be questioned. -An alternative to deriving the null distribution from theory is to generate a null distribution for the test statistic by randomly shuffling the data in some manner, refitting the model and deriving values for the test statistic for the permuted data. The level of significance of the test can be computed as the proportion of values of the test statistic from the null distribution that are equal to or larger than the observed value. +An alternative to deriving the null distribution from theory is to generate a null distribution of the test statistic by randomly shuffling the data in some manner, refitting the model and deriving values for the test statistic for the permuted data. The level of significance of the test can be computed as the proportion of values of the test statistic from the null distribution that are equal to or larger than the observed value. -In many data sets, simply shuffling the data at random is inappropriate; under the null hypothesis, that data are not freely exchangeable. If there is temporal or spatial correlation, or the samples are clustered in some way, such as multiple samples collected from each of a number of fields. The \pkg{permute} was designed to provide facilities for generating these restricted permutations for use in randomisation tests. +In many data sets, simply shuffling the data at random is inappropriate; under the null hypothesis, that data are not freely exchangeable, for example if there is temporal or spatial correlation, or the samples are clustered in some way, such as multiple samples collected from each of a number of fields. The \pkg{permute} package was designed to provide facilities for generating these restricted permutations for use in randomisation tests. -\section{Simple randomisation} -As an illustration of both randomisation and the use of the \pkg{permute} package we consider a small data set of mandible length measurements on specimens of the golden jackal (\emph{Canis aureus}) from the British Museum of Natural History, London, UK. These data were collected as part of a study comparing prehistoric and modern canids \citep{higham80}, and were analysed by \citet{manly07}. There are ten measurements of mandible length on both male and female specimens. The data are available in the \code{jackal} data frame supplied with \pkg{permute}. +\section{Simple randomisation}\label{sec:simple} +As an illustration of both randomisation and simple usage of the \pkg{permute} package we consider a small data set of mandible length measurements on specimens of the golden jackal (\emph{Canis aureus}) from the British Museum of Natural History, London, UK. These data were collected as part of a study comparing prehistoric and modern canids \citep{higham80}, and were analysed by \citet{manly07}. There are ten measurements of mandible length on both male and female specimens. The data are available in the \code{jackal} data frame supplied with \pkg{permute}. <>= require(permute) @@ -70,7 +70,7 @@ jackal @ -The interest is whether there is a difference in the mean mandible length between male and female golden jackals. The null hypothesis is that there is zero difference in mandible length between the two sexes or that females have larger mandible. The alternative hypothesis is that males have larger mandibles. The usual statistical test of this hypothesis is a one-sided $t$ test, which can be applied using \code{t.test()} +The interest is whether there is a difference in the mean mandible length between male and female golden jackals. The null hypothesis is that there is zero difference in mandible length between the two sexes or that females have larger mandibles. The alternative hypothesis is that males have larger mandibles. The usual statistical test of this hypothesis is a one-sided $t$ test, which can be applied using \code{t.test()} <>= jack.t <- t.test(Length ~ Sex, data = jackal, var.equal = TRUE, @@ -91,7 +91,7 @@ var.test(Length ~ Sex, data = jackal) fligner.test(Length ~ Sex, data = jackal) @ -This assumption may be relaxed using \code{var.equal = FALSE} (the default) in our call to \code{t.test()}, to employ Welch's modification for unequal variances. Assumption 3 may be valid, but with such a small sample we are able to reliably test this. +This assumption may be relaxed using \code{var.equal = FALSE} (the default) in the call to \code{t.test()}, to employ Welch's modification for unequal variances. Assumption 3 may be valid, but with such a small sample we are unable to reliably test this. A randomisation test of the same hypothesis can be performed by randomly allocating ten of the mandible lengths to the male group and the remaining lengths to the female group. This randomisation is justified under the null hypothesis because the observed difference in mean mandible length between the two sexes is just a typical value for the difference in a sample if there were no difference in the population. An appropriate test statistic needs to be selected. We could use the $t$ statistic as derived in the $t$-test. Alternatively, we could base our randomisation test on the difference of means $D_i$ (male - female). @@ -101,7 +101,7 @@ mean(x[grp == "Male"]) - mean(x[grp == "Female"]) } @ -which can be used in a simple \code{for()} loop to generate the null distribution for the difference of means. First, we allocate some storage to hold the null difference of means; here we use 4999 random permutations so allocate a vector of length 5000. Then we iterate, randomly generating an ordering of the \code{Sex} vector and computing the difference means for that permutation. +which can be used in a simple \code{for()} loop to generate the null distribution for the difference of means. First, we allocate some storage to hold the null difference of means; here we use 4999 random permutations so allocate a vector of length 5000. Then we iterate, randomly generating an ordering of the \code{Sex} vector and computing the difference of means for that permutation. <>= Djackal <- numeric(length = 5000) N <- nrow(jackal) @@ -129,7 +129,7 @@ <<>>= Dbig / length(Djackal) @ -which is comparable with that determined from the frequentist $t$-test, and indicate strong evidence against the null hypothesis of no difference. +which is comparable with that determined from the frequentist $t$-test, and indicates strong evidence against the null hypothesis of no difference. \begin{figure}[t] \centering <>= @@ -153,7 +153,7 @@ <>= args(shuffle) @ -A series of convenience functions are provided that allow the user to set-up even quite complex permutation designs with little effort. The user only needs to specify the aspects of the design they require and the convenience functions ensure all configuration choices are set and passed on to \code{shuffle()}. The main convenience function is \code{how()}, which returns a list specifying all the options available for controlling the sorts of permutations returned by \code{shuffle()} +A series of convenience functions are provided that allow the user to set-up even quite complex permutation designs with little effort. The user only needs to specify the aspects of the design they require and the convenience functions ensure all configuration choices are set and passed on to \code{shuffle()}. The main convenience function is \code{how()}, which returns a list specifying all the options available for controlling the sorts of permutations returned by \code{shuffle()}. <>= str(how()) @ @@ -179,7 +179,7 @@ The first three of these can be nested within the levels of a factor or to the levels of that factor, or to both. Such flexibility allows the analysis of split-plot designs using permutation tests, especially when combined with blocks. -\code{how()} is used to set up the design from which \code{shuffle()} will draw a permutation. \code{how()} has two main arguments that specify how samples are permuted \emph{within} plots of samples or at the plot level itself. These are \code{within} and \code{plots}. Two convenience functions, \code{Within()} and \code{Plots()} can be used to set the various options for permutation. Blocks operate at the uppermost level of this hierarchy; blocks define groups of plots, each of which contain groups of samples. +\code{how()} is used to set up the design from which \code{shuffle()} will draw a permutation. \code{how()} has two main arguments that specify how samples are permuted \emph{within} plots of samples or at the plot level itself. These are \code{within} and \code{plots}. Two convenience functions, \code{Within()} and \code{Plots()} can be used to set the various options for permutation. Blocks operate at the uppermost level of this hierarchy; blocks define groups of plots, each of which may contain groups of samples. For example, to permute the observations \code{1:10} assuming a time series design for the entire set of observations, the following control object would be used @@ -229,13 +229,13 @@ \subsection{Generating sets of permutations with shuffleSet()} There are several reasons why one might wish to generate a set of $n$ permutations instead of repeatedly generating permutations one at a time. Interpreting the permutation design happens each time \code{shuffle()} is called. This is an unnecessary computational burden, especially if you want to perform tests with large numbers of permutations. Furthermore, having the set of permutations available allows for expedited use with other functions, they can be iterated over using \code{for} loops or the \code{apply} family of functions, and the set of permutations can be exported for use outside of R. -The \code{shuffleSet()} function allows the generation of sets of permutations from any of the designs available in \pkg{permute}. \code{shuffleSet()} takes an additional argument to that of \code{shuffle()}, \code{nset}, which is the number of permutations required for the set. \code{nset} can be missing, in which case the number of permutations in the set is looked for in the object passed to \code{control}; using this, the desired number of permutation can be set at the time the design is created via the \code{nperm} argument of \code{how()}. For example, +The \code{shuffleSet()} function allows the generation of sets of permutations from any of the designs available in \pkg{permute}. \code{shuffleSet()} takes an additional argument to that of \code{shuffle()}, \code{nset}, which is the number of permutations required for the set. \code{nset} can be missing, in which case the number of permutations in the set is looked for in the object passed to \code{control}; using this, the desired number of permutations can be set at the time the design is created via the \code{nperm} argument of \code{how()}. For example, <>= how(nperm = 10, within = Within(type = "series")) @ -Internally, \code{shuffle()} and \code{shuffleSet()} are very similar, with the major difference being that \code{shuffleSet()} arranges repeated calls to the workhorse permutation-generating functions with only the overhead associated with interpreting the permutation design once. \code{shuffleSet()} returns a matrix where the rows represent different permutations in the set. +Internally, \code{shuffle()} and \code{shuffleSet()} are very similar, with the major difference being that \code{shuffleSet()} arranges repeated calls to the workhorse permutation-generating functions, only incurring the overhead associated with interpreting the permutation design once. \code{shuffleSet()} returns a matrix where the rows represent different permutations in the set. As an illustration, consider again the simple time series example from earlier. Here I generate a set of 5 permutations from the design, with the results returned as a matrix @@ -245,10 +245,11 @@ pset <- shuffleSet(10, nset = 5, control = CTRL) pset @ -Note that we set \code{check = FALSE} in the call. As there are only 10 permutations of these data (including the observed one), by default \code{shuffleSet()} will check the permutation design and, following a few heuristics\footnote{Values used in these heuristics can be set when you create the permutation design with \code{how()}. See \code{?how} for further details and \code{?check} for the function that does the checking.}, will in this case generate all ten permutations. Setting \code{check = FALSE} turns this checking off, enabling exactly \code{nset} permutations to be returned. The downside of this is that you need to be aware of the implications of not checking the design; with a limited number of possible permutations, there is no guarantee that \code{shuffleSet()} will generate a set of \code{nset} unique permutations. +It is worth taking a moment to explain what has happened here, behind the scenes. There are only \Sexpr{numPerms(10, CTRL)} unique orderings (including the observed) in the set of permutations for this design. Such a small set of permutations triggers\footnote{The trigger is via the utility function \code{check()}, which calls another utility function, \code{allPerms()}, to generate the set of permutations for the stated design. The trigger for complete enumeration is set via \code{how()} using argument \code{minperm}; below this value, by default \code{check()} will generate the entire set of permutations.} the generation of the entire set of permutations. From this set, \code{shuffleSet()} samples at random \code{nset} permutations. Hence the same number of random values has been generated via the pseudo-random number generator in \proglang{R} but we ensure a set of unique permutations is drawn, rather than randomly sample from a small set. + \section{Defining permutation designs} -In this section examples are given of how various permutation designs can be specified using \code{how()}. It is not the intention to provide exhaustive coverage of all possible designs that can be produced; such a list would be tedious to both write \emph{and} read. Instead, the main features and options will be described through a series of examples. The reader should then be able to put together the various options to create the exact structure required. +In this section I give examples how various permutation designs can be specified using \code{how()}. It is not the intention to provide exhaustive coverage of all possible designs that can be produced; such a list would be tedious to both write \emph{and} read. Instead, the main features and options will be described through a series of examples. The reader should then be able to put together the various options to create the exact structure required. \subsection{Set the number of permutations} It may be useful to specify the number of permutations required in a permutation test alongside the permutation design. This is done via the \code{nperm} argument, as seen earlier. If nothing else is specified @@ -260,11 +261,11 @@ One advantage of using \code{nperm} is that \code{shuffleSet()} will use this if the \code{nset} argument is not specified. Additionally, \code{shuffleSet()} will check to see if the desired number of permutations is possible given the data and the requested design. This is done via the function \code{check()}, which is discussed later. \subsection{The levels of the permutation hierarchy} -There are three levels at which permutations can be controlled in \pkg{permute}. The highest level of the hierarchy is the \emph{block} level. Blocks are defined by a factor vector. Blocks restrict permutation of samples to within the levels of this factor; samples are never swapped between blocks. +There are three levels at which permutations can be controlled in \pkg{permute}. The highest level of the hierarchy is the \emph{block} level. Blocks are defined by a factor variable. Blocks restrict permutation of samples to within the levels of this factor; samples are never swapped between blocks. -The \emph{plot} level sits below blocks. Plots are defined by a factor and group samples in the same way as blocks. As such, some permutation designs can be initiated using a factor at the plot level or the same factor at the plot level. The major difference between blocks and plots is that plots can also be permuted, whereas blocks are never permuted. +The \emph{plot} level sits below blocks. Plots are defined by a factor and group samples in the same way as blocks. As such, some permutation designs can be initiated using a factor at the plot level or the same factor at the block level. The major difference between blocks and plots is that plots can also be permuted, whereas blocks are never permuted. -The lowest level of a permutation design in \pkg{permute} hierarchy is known as \emph{within}, and refers to samples nested \emph{within} plots. If there are no plots or blocks, how samples are permuted at the \emph{within} level applies to the entire data set. +The lowest level of a permutation design in the \pkg{permute} hierarchy is known as \emph{within}, and refers to samples nested \emph{within} plots. If there are no plots or blocks, how samples are permuted at the \emph{within} level applies to the entire data set. \subsubsection{Permuting samples at the lowest level} How samples at the \emph{within} level are permuted is configured using the \code{Within()} function. It takes the following arguments @@ -276,7 +277,7 @@ \item[\code{type}] controls how the samples at the lowest level are permuted. The default is to form unrestricted permutations via option \code{"type"}. Options \code{"series"} and \code{"grid"} form restricted permutations via cyclic or toroidal shifts, respectively. The former is useful for samples that are a time series or line-transect, whilst the latter is used for samples on a regular spatial grid. The final option, \code{"none"}, will result in the samples at the lowest level not being permuted at all. This option is only of practical use when there are plots within the permutation/experimental design\footnote{As blocks are never permuted, using \code{type = "none"} at the \emph{within} level is also of no practical use.}. \item[\code{constant}] - this argument only has an effect when there are plots in the design\footnote{Owing to the current implementation, whilst this option could also be useful when blocks to define groups of samples, it will not have any influence over how permutations are generated. As such, only use blocks for simple blocking structures and use plots if you require greater control of the permutations at the group (i.e. plot) level.}. \code{constant = FALSE}, stipulates that each plot should have the same \emph{within-plot} permutation. This is useful when you have time series of observations from several plots. If all plots were sampled at the same time points, it can be argued that the plot level, the samples experienced the same \emph{time} and hence the same permutation should be used within each plot. + this argument only has an effect when there are plots in the design\footnote{Owing to the current implementation, whilst this option could also be useful when blocks to define groups of samples, it will not have any influence over how permutations are generated. As such, only use blocks for simple blocking structures and use plots if you require greater control of the permutations at the group (i.e. plot) level.}. \code{constant = FALSE}, stipulates that each plot should have the same \emph{within-plot} permutation. This is useful when you have time series of observations from several plots. If all plots were sampled at the same time points, it can be argued that at the plot level, the samples experienced the same \emph{time} and hence the same permutation should be used within each plot. \item[\code{mirror}] when \code{type} is \code{"series"} or \code{"grid"}, argument \code{"mirror"} controls whether permutations are taken from the mirror image of the observed ordering in space or time. Consider the sequence \code{1, 2, 3, 4}. The relationship between observations is also preserved if we reverse the original ordering to \code{4, 3, 2, 1} and generate permutations from both these orderings. This is what happens when \code{mirror = TRUE}. For time series, the reversed ordering \code{4, 3, 2, 1} would imply an influence of observation 4 on observation 3, which is implausible. For spatial grids or line transects, however, this is a sensible option, and can significantly increase the number of possible permutations\footnote{Setting \code{mirror = TRUE} will double or quadruple the set of permutations for \code{"series"} or \code{"grid"} permutations, respectively, as long as there are more than two time points or columns in the grid.}. \item[\code{ncol}, \code{nrow}] @@ -293,8 +294,180 @@ a factor variable. \code{strata} describes the grouping of samples at the \emph{plot} level, where samples from the same \emph{plot} are take the same \emph{level} of the factor. \end{description} -When a \emph{plot}-level design is specified, samples are never permuted between \emph{plots}, only within plots if they are permuted at all. Hence, the type of permutation \emph{within} the \emph{plots} is controlled by \code{Within()}. Note also that with \code{Plots()}, the way the individual \emph{plots} are permuted can be from any one of the four basic permutation types; \code{"none"}, \code{"free"}, \code{"series"}, and \code{"grid"}, as described above. To permute the \emph{plots} only (i.e. retain the ordering of the samples \emph{within} plots), you need to use \code{Within(type = "none", ...)} as the default in \code{Within()} is \code{type = "free"}. The ability to permute the plots whilst preserving the within-plot ordering is an impotant feature in testing explanatory factors at the whole-plot level in split-plot designs and in multifactorial analysis of variance \citep{canoco5manual}. +When a \emph{plot}-level design is specified, samples are never permuted between \emph{plots}, only within plots if they are permuted at all. Hence, the type of permutation \emph{within} the \emph{plots} is controlled by \code{Within()}. Note also that with \code{Plots()}, the way the individual \emph{plots} are permuted can be from any one of the four basic permutation types; \code{"none"}, \code{"free"}, \code{"series"}, and \code{"grid"}, as described above. To permute the \emph{plots} only (i.e. retain the ordering of the samples \emph{within} plots), you also need to specify \code{Within(type = "none", ...)} as the default in \code{Within()} is \code{type = "free"}. The ability to permute the plots whilst preserving the within-plot ordering is an impotant feature in testing explanatory factors at the whole-plot level in split-plot designs and in multifactorial analysis of variance \citep{canoco5manual}. +\subsubsection[Specifying blocks; the top of the permute hierarchy]{Specifying blocks; the top of the \pkg{permute} hierarchy} +In constrast to the \emph{within} and \emph{plots} levels, the \emph{blocks} level is simple to specify; all that is required is an indicator variable the same length as the data. Usually this is a factor, but \code{how()} will take anything that can be coerced to a factor via \code{as.factor()}. + +It is worth repeating what the role of the block-level structure is; blocks simply restrict permutation to \emph{within}, and never between, blocks, and blocks are never permuted. This is reflected in the implementation; the \emph{split}-\emph{apply}-\code{combine} paradigm is used to split on the blocking factor, the plot- and within-level permutation design is applied separately to each block, and finally the sets of permutations for each block are recombined. + +\subsection{Examples} +To do. + +\section[Using permute in R functions]{Using \pkg{permute} in \proglang{R} functions} +\pkg{permute} originally started life as a set of functions contained within the \pkg{vegan} package \citep{vegan} designed to provide a replacement for the \code{permuted.index()} function. From these humble origins, I realised other users and package authors might want to make use of the code I was writing and so Jari oksanen, the maintainer of \pkg{vegan}, and I decided to spin off the code into the \pkg{permute} package. Hence from the very beginning, \pkg{permute} was intended for use both by users, to defining permutation designs, and by package authors, with which to implement permutation tests within their packages. + +In the previous sections, I described the various user-facing functions that are employed to set up permutation designs and generate permutations from these. Here I will outline how package authors can use functionality in the \pkg{permute} package to implement permutation tests. + +In Section~\ref{sec:simple} I showed how a permutation test function could be written using the \code{shuffle()} function and allowing the user to pass into the test function an object created with \code{how()}. As mentioned earlier, it is more efficient to generate a set of permutations via a call to \code{shuffleSet()} than to repeatedly call \code{shuffle()} and large number of times. Another advantage of using \code{shuffleSet()} is that once the set of permutations has been created, parallel processing can be used to break the set of permutations down into smaller chunks, each of which can be worked on simultaneously. As a result, package authors are encouraged to use \code{shuffleSet()} instead of the simpler \code{shuffle()}. + +To illustrate how to use \pkg{permute} in \proglang{R} functions, I'll rework the permutation test I used for the \code{jackal} data earlier in Section~\ref{sec:simple}. + +<>= +options("prompt" = " ", "continue" = " ") +@ +<>= +pt.test <- function(x, group, nperm = 199) { + ## mean difference function + meanDif <- function(i, x, grp) { + grp <- grp[i] + mean(x[grp == "Male"]) - mean(x[grp == "Female"]) + } + ## check x and group are of same length + stopifnot(all.equal(length(x), length(group))) + ## number of observations + N <- nobs(x) + ## generate the required set of permutations + pset <- shuffleSet(N, nset = nperm) + ## iterate over the set of permutations applying meanDif + D <- apply(pset, 1, meanDif, x = x, grp = group) + ## add on the observed mean difference + D <- c(meanDif(seq_len(N), x, group), D) + ## compute & return the p-value + Ds <- sum(D >= D[1]) # how many >= to the observed diff? + Ds / (nperm + 1) # what proportion of perms is this (the pval)? +} +@ +<>= +options("prompt" = "R> ", "continue" = "+ ") +@ + +The commented function should be reasonably self explanatory. I've altered the in-line version of the \code{meanDif()} function to take a vector of permutation indices \code{i} as the first argument, and internally the \code{grp} vector is permuted according to \code{i}. The other major change is that \code{shuffleSet()} is used to generate a set of permutations, which are then iterated over using \code{apply()}. + +In use we see +<>= +set.seed(42) ## same seed as earlier +pval <- with(jackal, pt.test(Length, Sex, nperm = 4999)) +pval +@ +which nicely agrees with the test we did earlier by hand. + +Iterating over a set of permutation indices also means that adding parallel processing of the permutations requires only trivial changes to the main function code. As an illustration, below I show a parallel version of \code{pt.test()} + +<>= +options("prompt" = " ", "continue" = " ") +@ +<>= +ppt.test <- function(x, group, nperm = 199, cores = 2) { + ## mean difference function + meanDif <- function(i, .x, .grp) { + .grp <- .grp[i] + mean(.x[.grp == "Male"]) - mean(.x[.grp == "Female"]) + } + ## check x and group are of same length + stopifnot(all.equal(length(x), length(group))) + ## number of observations + N <- nobs(x) + ## generate the required set of permutations + pset <- shuffleSet(N, nset = nperm) + if (cores > 1) { + ## initiate a cluster + cl <- makeCluster(cores) + on.exit(stopCluster(cl = cl)) + ## iterate over the set of permutations applying meanDif + D <- parRapply(cl, pset, meanDif, .x = x, .grp = group) + } else { + D <- apply(pset, 1, meanDif, .x = x, .grp = group) + } + ## add on the observed mean difference + D <- c(meanDif(seq_len(N), x, group), D) + ## compute & return the p-value + Ds <- sum(D >= D[1]) # how many >= to the observed diff? + Ds / (nperm + 1) # what proportion of perms is this (the pval)? +} +@ +<>= +options("prompt" = "R> ", "continue" = "+ ") +@ +In use we observe +<>= +require("parallel") +set.seed(42) +system.time(ppval <- ppt.test(jackal$Length, jackal$Sex, nperm = 9999, + cores = 2)) +ppval +@ +In this case there is little to be gained by splitting the computations over two CPU cores +<>= +set.seed(42) +system.time(ppval2 <- ppt.test(jackal$Length, jackal$Sex, nperm = 9999, + cores = 1)) +ppval2 +@ [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/vegan -r 2755 From noreply at r-forge.r-project.org Mon Nov 25 07:30:43 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 25 Nov 2013 07:30:43 +0100 (CET) Subject: [Vegan-commits] r2756 - pkg/vegan/R Message-ID: <20131125063043.B4874180941@r-forge.r-project.org> Author: jarioksa Date: 2013-11-25 07:30:43 +0100 (Mon, 25 Nov 2013) New Revision: 2756 Modified: pkg/vegan/R/anova.ccalist.R Log: fix comparison for equality of numbers of observation Modified: pkg/vegan/R/anova.ccalist.R =================================================================== --- pkg/vegan/R/anova.ccalist.R 2013-11-24 16:39:04 UTC (rev 2755) +++ pkg/vegan/R/anova.ccalist.R 2013-11-25 06:30:43 UTC (rev 2756) @@ -19,7 +19,7 @@ stop("response must be same in all models") ## 3. Same no. of observations N <- sapply(object, nobs) - if (!all(N = N[1])) + if (!all(N == N[1])) stop("number of observations must be same in all models") else N <- N[1] From noreply at r-forge.r-project.org Mon Nov 25 08:29:26 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 25 Nov 2013 08:29:26 +0100 (CET) Subject: [Vegan-commits] r2757 - pkg/vegan/R Message-ID: <20131125072926.47085184F44@r-forge.r-project.org> Author: jarioksa Date: 2013-11-25 08:29:25 +0100 (Mon, 25 Nov 2013) New Revision: 2757 Modified: pkg/vegan/R/anovacca.byterm.R Log: handle NA in anovacca models (if you can) Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-11-25 06:30:43 UTC (rev 2756) +++ pkg/vegan/R/anovacca.byterm.R 2013-11-25 07:29:25 UTC (rev 2757) @@ -44,6 +44,9 @@ function(object, permutations, ...) { nperm <- nrow(permutations) + ## Refuse to handle models with missing data + if (!is.null(object$na.action)) + stop("by = 'margin' models cannot handle missing data") ## We need term labels but without Condition() terms trms <- drop.scope(object) trmlab <- trms[trms %in% attr(terms(object$terminfo), @@ -97,17 +100,24 @@ Df <- rep(1, length(eig)) ## Marginal P-values LC <- object$CCA$u + if (!is.null(object$na.action)) + LC <- napredict(structure(object$na.action, + class="exclude"), LC) + LC <- as.data.frame(LC) + fla <- reformulate(names(LC)) Pvals <- numeric(length(eig)) environment(object$terms) <- environment() for (i in 1:length(eig)) { - Partial <- LC[,-i, drop = FALSE] + part <- paste("~ . +Condition(", + paste(names(LC)[-i], collapse = "+"), ")") + upfla <- update(fla, part) ## only one axis, and cannot partial out? - if (!ncol(Partial)) + if (length(eig) == 1) mod <- permutest(object, permutations, model = model, parallel = parallel) else mod <- - permutest(update(object, . ~ . + Condition(Partial)), + permutest(update(object, upfla, data = LC), permutations, model = model, parellel = parallel) Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1) From noreply at r-forge.r-project.org Mon Nov 25 08:56:41 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 25 Nov 2013 08:56:41 +0100 (CET) Subject: [Vegan-commits] r2758 - pkg/vegan/R Message-ID: <20131125075642.012091852BE@r-forge.r-project.org> Author: jarioksa Date: 2013-11-25 08:56:41 +0100 (Mon, 25 Nov 2013) New Revision: 2758 Modified: pkg/vegan/R/anovacca.byterm.R Log: handle subsets in anovacca Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-11-25 07:29:25 UTC (rev 2757) +++ pkg/vegan/R/anovacca.byterm.R 2013-11-25 07:56:41 UTC (rev 2758) @@ -100,9 +100,18 @@ Df <- rep(1, length(eig)) ## Marginal P-values LC <- object$CCA$u + ## missing values? if (!is.null(object$na.action)) LC <- napredict(structure(object$na.action, class="exclude"), LC) + ## subset? + if (!is.null(object$subset)) { + tmp <- matrix(NA, nrow=length(object$subset), + ncol = ncol(LC)) + tmp[object$subset,] <- LC + LC <- tmp + object <- update(object, subset = object$subset) + } LC <- as.data.frame(LC) fla <- reformulate(names(LC)) Pvals <- numeric(length(eig)) From noreply at r-forge.r-project.org Tue Nov 26 05:56:33 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 26 Nov 2013 05:56:33 +0100 (CET) Subject: [Vegan-commits] r2759 - in pkg/permute: . R man Message-ID: <20131126045633.7A0A2185044@r-forge.r-project.org> 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. } From noreply at r-forge.r-project.org Tue Nov 26 05:57:32 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 26 Nov 2013 05:57:32 +0100 (CET) Subject: [Vegan-commits] r2760 - pkg/permute/vignettes Message-ID: <20131126045733.06FCC185044@r-forge.r-project.org> Author: gsimpson Date: 2013-11-26 05:57:32 +0100 (Tue, 26 Nov 2013) New Revision: 2760 Modified: pkg/permute/vignettes/permutations.Rnw pkg/permute/vignettes/permute.bib Log: Updates to the vignette; mainly adding the new setFoo functions Modified: pkg/permute/vignettes/permutations.Rnw =================================================================== --- pkg/permute/vignettes/permutations.Rnw 2013-11-26 04:56:32 UTC (rev 2759) +++ pkg/permute/vignettes/permutations.Rnw 2013-11-26 04:57:32 UTC (rev 2760) @@ -59,7 +59,7 @@ An alternative to deriving the null distribution from theory is to generate a null distribution of the test statistic by randomly shuffling the data in some manner, refitting the model and deriving values for the test statistic for the permuted data. The level of significance of the test can be computed as the proportion of values of the test statistic from the null distribution that are equal to or larger than the observed value. -In many data sets, simply shuffling the data at random is inappropriate; under the null hypothesis, that data are not freely exchangeable, for example if there is temporal or spatial correlation, or the samples are clustered in some way, such as multiple samples collected from each of a number of fields. The \pkg{permute} package was designed to provide facilities for generating these restricted permutations for use in randomisation tests. +In many data sets, simply shuffling the data at random is inappropriate; under the null hypothesis, that data are not freely exchangeable, for example if there is temporal or spatial correlation, or the samples are clustered in some way, such as multiple samples collected from each of a number of fields. The \pkg{permute} package was designed to provide facilities for generating these restricted permutations for use in randomisation tests. \pkg{permute} takes as its motivation the permutation schemes originally available in \proglang{Canoco} version 3.1 \citep{canoco31}, which employed the cyclic- or toroidal-shifts suggested by \citet{besagclifford}. \section{Simple randomisation}\label{sec:simple} As an illustration of both randomisation and simple usage of the \pkg{permute} package we consider a small data set of mandible length measurements on specimens of the golden jackal (\emph{Canis aureus}) from the British Museum of Natural History, London, UK. These data were collected as part of a study comparing prehistoric and modern canids \citep{higham80}, and were analysed by \citet{manly07}. There are ten measurements of mandible length on both male and female specimens. The data are available in the \code{jackal} data frame supplied with \pkg{permute}. @@ -434,25 +434,37 @@ returns a logical, which indicates whether the observed permutation (ordering of samples) is included in the entire set of permutation generated by \code{allPerms()}. \end{description} -At the moment, the range of \code{setFoo()<-} functions is not as comprehensive as for the \code{getFoo()} functions. The available \code{setFoo()<-} functions are +The available \code{setFoo()<-} functions are \begin{description} - \item[\code{setBlocks()<-};] + \item[\code{setPlots<-()}, \code{setWithin<-()};] + replaces the details of the \emph{within}-, and \emph{plots}-, components of the design. The replacement object must be of class \code{"Plots"} or \code{"Within"}, respectively, and hence is most usefully used in combination with the \code{Plots()} or \code{Within()} constructor functions. + \item[\code{setBlocks<-()};] replaces the factor that partitions the observations into blocks. \code{value} can be any \proglang{R} object that can be coerced to a factor vector via \code{as.factor()}. - \item[\code{setNperm()<-}, \code{setMinperm<-()}, \code{setMaxperm<-()};] - update the stored values for the requested number of permutations and the minimum and maximum permutation thresholds that control whether the entire set of permutations is generated instead of the \code{nperm} permutations. - \item[\code{setAllperms()<-};] + \item[\code{setStrata<-()};] + replaces either the \code{blocks} or \code{strata} components of the design, depending on what class of object \code{setStrata<-()} is applied to. When used on an object of class \code{"how"}, \code{setStrata<-()} replaces the \code{blocks} component of that object. When used on an object of class \code{"Plots"}, \code{setStrata<-()} replaces the \code{strata} component of that object. In both cases a factor variable is required and the replacement object will be coerced to a factor via \code{as.factor()} if possible. + \item[\code{setType<-()};] + replaces the \code{type} component of an object of class \code{"Plots"} or \code{"Within"} with a character vector of length one. Must be one of the available types: \code{"none"}, \code{"free"}, \code{"series"}, or \code{"grid"}. + \item[\code{setMirror<-()};] + replaces the \code{mirror} component of an object of class \code{"Plots"} or \code{"Within"} with a logical vector of length one. + \item[\code{setConstant<-()};] + replaces the \code{mirror} component of an object of class \code{"Within"} with a logical vector of length one. + \item[\code{setRow<-()}, \code{setCol<-()}, \code{setDim<-()};] + replace one or both of the spatial grid dimensions of an object of class \code{"Plots"} or \code{"Within"} with am integer vector of length one, or, in the case of \code{setDim<-()}, of length 2. + \item[\code{setNperm<-()}, \code{setMinperm<-()}, \code{setMaxperm<-()};] + update the stored values for the requested number of permutations and the minimum and maximum permutation thresholds that control whether the entire set of permutations is generated instead of \code{nperm} permutations. + \item[\code{setAllperms<-()};] assigns a matrix of permutation indices to the \code{all.perms} component of the design list object. - \item[\code{setComplete()<-};] + \item[\code{setComplete<-()};] updates the status of the \code{complete} setting. Takes a logical vector of length 1 or any object coercible to such. - \item[\code{setMake()<-};] + \item[\code{setMake<-()};] sets the indicator controlling whether the entrie set of permutations is generated during checking of the design via \code{check()}. Takes a logical vector of length 1 or any object coercible to such. - \item[\code{setObserved()<-};] + \item[\code{setObserved<-()};] updates the indicator of whether the observed ordering is included in the set of all permutations should they be generated. Takes a logical vector of length 1 or any object coercible to such. \end{description} \subsubsection{Examples} -I illustrate the behaviour of the \code{getFoo()} and \code{setFoo<-()} functions through a couple of simple examples. Firstly, generate or design object +I illustrate the behaviour of the \code{getFoo()} and \code{setFoo<-()} functions through a couple of simple examples. Firstly, generate a design object <>= hh <- how() @ @@ -467,9 +479,11 @@ getNperm(hh) getCall(hh) @ +Note how the \code{call} component has been altered to include the argument pair \code{nperm = 999}, hence if this call were evaluated, the resulting object would be a copy of \code{hh}. \section*{Computational details} -<>= +This vignette was built within the following environment: +<>= toLatex(sessionInfo()) @ \bibliography{permute} Modified: pkg/permute/vignettes/permute.bib =================================================================== --- pkg/permute/vignettes/permute.bib 2013-11-26 04:56:32 UTC (rev 2759) +++ pkg/permute/vignettes/permute.bib 2013-11-26 04:57:32 UTC (rev 2760) @@ -30,4 +30,22 @@ year = {2013}, note = {R package version 2.1-33}, url = {http://vegan.r-forge.r-project.org/} -} \ No newline at end of file +} + + at Manual{canoco31, + title = {Update notes: CANOCO version 3.1}, + author = {ter Braak, C.J.F.}, + organization = {Wageningen: Agricultural Mathematics Group}, + year = {1990} +} + + at Article{besagclifford, + author = {Besag, J. and Clifford, P.}, + title = {Generalized Monte Carlo significance tests}, + journal = {Biometrika}, + year = {1989}, + volume = {76}, + number = {4}, + pages = {633--642} +} + From noreply at r-forge.r-project.org Tue Nov 26 05:58:01 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 26 Nov 2013 05:58:01 +0100 (CET) Subject: [Vegan-commits] r2761 - pkg/permute/tests/Examples Message-ID: <20131126045801.88DCC185044@r-forge.r-project.org> Author: gsimpson Date: 2013-11-26 05:58:01 +0100 (Tue, 26 Nov 2013) New Revision: 2761 Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save Log: update the reference materials Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save =================================================================== --- pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-26 04:57:32 UTC (rev 2760) +++ pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-26 04:58:01 UTC (rev 2761) @@ -1,5 +1,5 @@ -R version 3.0.2 Patched (2013-10-07 r64035) -- "Frisbee Sailing" +R version 3.0.2 Patched (2013-09-26 r64005) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -207,7 +207,7 @@ > require(vegan) Loading required package: vegan Loading required package: lattice -This is vegan 2.1-33 +This is vegan 2.1-37 > example(pyrifos) pyrifs> data(pyrifos) @@ -717,6 +717,47 @@ > > > cleanEx() +> nameEx("set-methods") +> ### * set-methods +> +> flush(stderr()); flush(stdout()) +> +> ### Name: set-methods +> ### Title: Replacement functions to set components of a permutation design +> ### Aliases: set-methods setBlocks<- setBlocks<-.default setBlocks<-.how +> ### setBlocks<-.permControl setWithin<- setWithin<-.default +> ### setWithin<-.how setStrata<- setStrata<-.default setStrata<-.how +> ### setStrata<-.Plots setType<- setType<-.default setType<-.how +> ### setType<-.Plots setType<-.Within setMirror<- setMirror<-.default +> ### setMirror<-.how setMirror<-.Plots setMirror<-.Within setConstant<- +> ### setConstant<-.default setConstant<-.how setConstant<-.Plots +> ### setConstant<-.Within setPlots<- setPlots<-.default setPlots<-.how +> ### setRow<- setRow<-.default setRow<-.how setRow<-.Plots setRow<-.Within +> ### setCol<- setCol<-.default setCol<-.how setCol<-.Plots setCol<-.Within +> ### setDim<- setDim<-.default setDim<-.how setDim<-.Plots setDim<-.Within +> ### setNperm<- setNperm<-.default setNperm<-.how setNperm<-.permControl +> ### setAllperms<- setAllperms<-.default setAllperms<-.how +> ### setAllperms<-.permControl setMaxperm<- setMaxperm<-.default +> ### setMaxperm<-.how setMaxperm<-.permControl setMinperm<- +> ### setMinperm<-.default setMinperm<-.how setMinperm<-.permControl +> ### setComplete<- setComplete<-.default setComplete<-.how +> ### setComplete<-.permControl setMake<- setMake<-.default setMake<-.how +> ### setObserved<- setObserved<-.default setObserved<-.how +> ### Keywords: methods utils +> +> ### ** Examples +> +> ## extract components from a "how" object +> hh <- how() +> getNperm(hh) +[1] 199 +> setNperm(hh) <- 999 +> getNperm(hh) +[1] 999 +> +> +> +> cleanEx() > nameEx("shuffle-utils") > ### * shuffle-utils > @@ -1162,7 +1203,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 1.581 0.033 1.623 0 0 +Time elapsed: 2.25 0.044 2.404 0 0 > grDevices::dev.off() null device 1 From noreply at r-forge.r-project.org Tue Nov 26 05:58:25 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 26 Nov 2013 05:58:25 +0100 (CET) Subject: [Vegan-commits] r2762 - pkg/permute/inst Message-ID: <20131126045825.96138185044@r-forge.r-project.org> Author: gsimpson Date: 2013-11-26 05:58:25 +0100 (Tue, 26 Nov 2013) New Revision: 2762 Modified: pkg/permute/inst/ChangeLog Log: minor tweaking Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-26 04:58:01 UTC (rev 2761) +++ pkg/permute/inst/ChangeLog 2013-11-26 04:58:25 UTC (rev 2762) @@ -220,8 +220,11 @@ Version 0.7-2 * Major API change: Added capability to handle true blocking - constraints, as suggested by Cajo ter Braak. We now have + constraints. + Suggested by Cajo ter Braak. + We now have: + o Blocks: samples are *never* permuted between blocks. Blocks can't be permuted either. o Plots: these define groups of samples, for example the @@ -266,7 +269,8 @@ if `mirror = FALSE` for the `constant = TRUE` case. * shuffleStrata: assumed that the samples were in contiguous - blocks. Reported by Cajo ter Braak. + blocks. + Reported by Cajo ter Braak. * .Internal: removed all instances of .Internal calls in the code. From noreply at r-forge.r-project.org Tue Nov 26 09:02:21 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 26 Nov 2013 09:02:21 +0100 (CET) Subject: [Vegan-commits] r2763 - pkg/vegan/R Message-ID: <20131126080222.08BC6185C40@r-forge.r-project.org> Author: jarioksa Date: 2013-11-26 09:02:15 +0100 (Tue, 26 Nov 2013) New Revision: 2763 Modified: pkg/vegan/R/anovacca.R Log: use setBlocks<- Modified: pkg/vegan/R/anovacca.R =================================================================== --- pkg/vegan/R/anovacca.R 2013-11-26 04:58:25 UTC (rev 2762) +++ pkg/vegan/R/anovacca.R 2013-11-26 08:02:15 UTC (rev 2763) @@ -15,7 +15,7 @@ stop("'strata' can be used only with simple permutation or with 'how()'") if (!is.null(permutations$block)) stop("'strata' cannot be applied when 'blocks' are defined in 'how()'") - permutations <- update(permutations, blocks = strata) + setBlocks(permutations) <- strata } ## now permutations is either a how() structure or a permutation ## matrix. Make it to a matrix if it is "how" From noreply at r-forge.r-project.org Wed Nov 27 18:41:07 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 27 Nov 2013 18:41:07 +0100 (CET) Subject: [Vegan-commits] r2764 - pkg/vegan/R Message-ID: <20131127174107.9F21D18638E@r-forge.r-project.org> Author: jarioksa Date: 2013-11-27 18:41:07 +0100 (Wed, 27 Nov 2013) New Revision: 2764 Modified: pkg/vegan/R/anovacca.byterm.R Log: anovacca.bymargin did not pass ... to the permutest.cca workhorse Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-11-26 08:02:15 UTC (rev 2763) +++ pkg/vegan/R/anovacca.byterm.R 2013-11-27 17:41:07 UTC (rev 2764) @@ -62,7 +62,7 @@ ## the difference against the complete model. mods <- lapply(trmlab, function(nm, ...) permutest(update(object, paste(".~.-", nm)), - permutations, ...)) + permutations, ...), ...) ## Chande in df Df <- sapply(mods, function(x) x$df[2]) - dfbig ## F of change From noreply at r-forge.r-project.org Wed Nov 27 19:17:25 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 27 Nov 2013 19:17:25 +0100 (CET) Subject: [Vegan-commits] r2765 - pkg/vegan/R Message-ID: <20131127181725.EA0A9183E06@r-forge.r-project.org> Author: jarioksa Date: 2013-11-27 19:17:25 +0100 (Wed, 27 Nov 2013) New Revision: 2765 Modified: pkg/vegan/R/anosim.R pkg/vegan/R/fitspecaccum.R pkg/vegan/R/mantel.R pkg/vegan/R/mantel.partial.R Log: add some dots to really pass arguments to function in [mc]lapply (untested) Modified: pkg/vegan/R/anosim.R =================================================================== --- pkg/vegan/R/anosim.R 2013-11-27 17:41:07 UTC (rev 2764) +++ pkg/vegan/R/anosim.R 2013-11-27 18:17:25 UTC (rev 2765) @@ -55,7 +55,7 @@ if(.Platform$OS.type == "unix" && !hasClus) { perm <- unlist(mclapply(1:permutations, function(i, ...) ptest(permat[i,]), - mc.cores = parallel)) + mc.cores = parallel, ...)) } else { if (!hasClus) { parallel <- makeCluster(parallel) Modified: pkg/vegan/R/fitspecaccum.R =================================================================== --- pkg/vegan/R/fitspecaccum.R 2013-11-27 17:41:07 UTC (rev 2764) +++ pkg/vegan/R/fitspecaccum.R 2013-11-27 18:17:25 UTC (rev 2765) @@ -32,7 +32,7 @@ function(i, ...) NLSFUN(SpeciesRichness[,i], if (hasWeights) object$weights[,i] else x, - model, ...)) + model, ...), ...) object$fitted <- drop(sapply(mods, fitted)) object$residuals <- drop(sapply(mods, residuals)) object$coefficients <- drop(sapply(mods, coef)) Modified: pkg/vegan/R/mantel.R =================================================================== --- pkg/vegan/R/mantel.R 2013-11-27 17:41:07 UTC (rev 2764) +++ pkg/vegan/R/mantel.R 2013-11-27 18:17:25 UTC (rev 2765) @@ -49,7 +49,7 @@ perm <- do.call(rbind, mclapply(1:permutations, function(i, ...) ptest(permat[i,],...), - mc.cores = parallel)) + mc.cores = parallel, ...)) } else { if (!hasClus) { parallel <- makeCluster(parallel) Modified: pkg/vegan/R/mantel.partial.R =================================================================== --- pkg/vegan/R/mantel.partial.R 2013-11-27 17:41:07 UTC (rev 2764) +++ pkg/vegan/R/mantel.partial.R 2013-11-27 18:17:25 UTC (rev 2765) @@ -57,7 +57,7 @@ perm <- do.call(rbind, mclapply(1:permutations, function(i, ...) ptest(permat[i,],...), - mc.cores = parallel)) + mc.cores = parallel, ...)) } else { if (!hasClus) { parallel <- makeCluster(parallel) From noreply at r-forge.r-project.org Thu Nov 28 15:09:19 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 28 Nov 2013 15:09:19 +0100 (CET) Subject: [Vegan-commits] r2766 - pkg/vegan/R Message-ID: <20131128140919.616751858B4@r-forge.r-project.org> Author: jarioksa Date: 2013-11-28 15:09:19 +0100 (Thu, 28 Nov 2013) New Revision: 2766 Modified: pkg/vegan/R/anovacca.byterm.R Log: you must use constrained inertia with model='full' (it does not matter with other 'model's) Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-11-27 18:17:25 UTC (rev 2765) +++ pkg/vegan/R/anovacca.byterm.R 2013-11-28 14:09:19 UTC (rev 2766) @@ -69,11 +69,11 @@ Chisq <- sapply(mods, function(x) x$chi[2]) - chibig Fstat <- (Chisq/Df)/(chibig/dfbig) ## Simulated F-values - Fval <- sapply(mods, function(x) x$den) + Fval <- sapply(mods, function(x) x$num) ## Had we an empty model we need to clone the denominator if (length(Fval) == 1) Fval <- matrix(Fval, nrow=nperm) - Fval <- sweep(Fval, 1, big$den, "-") + Fval <- sweep(-Fval, 1, big$num, "+") Fval <- sweep(Fval, 2, Df, "/") Fval <- sweep(Fval, 1, scale, "/") ## Simulated P-values From noreply at r-forge.r-project.org Thu Nov 28 15:11:06 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 28 Nov 2013 15:11:06 +0100 (CET) Subject: [Vegan-commits] r2767 - pkg/vegan/R Message-ID: <20131128141106.A207E18611C@r-forge.r-project.org> Author: jarioksa Date: 2013-11-28 15:11:06 +0100 (Thu, 28 Nov 2013) New Revision: 2767 Modified: pkg/vegan/R/anovacca.byterm.R Log: a typo, and parallel processing failed Modified: pkg/vegan/R/anovacca.byterm.R =================================================================== --- pkg/vegan/R/anovacca.byterm.R 2013-11-28 14:09:19 UTC (rev 2766) +++ pkg/vegan/R/anovacca.byterm.R 2013-11-28 14:11:06 UTC (rev 2767) @@ -128,7 +128,7 @@ mod <- permutest(update(object, upfla, data = LC), permutations, model = model, - parellel = parallel) + parallel = parallel) Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1) } out <- data.frame(c(Df, resdf), c(eig, object$CA$tot.chi), From noreply at r-forge.r-project.org Fri Nov 29 03:29:41 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 29 Nov 2013 03:29:41 +0100 (CET) Subject: [Vegan-commits] r2768 - pkg/permute Message-ID: <20131129022941.EA388186899@r-forge.r-project.org> Author: gsimpson Date: 2013-11-29 03:29:38 +0100 (Fri, 29 Nov 2013) New Revision: 2768 Modified: pkg/permute/DESCRIPTION Log: settled on gmail account for email address of maintainer Modified: pkg/permute/DESCRIPTION =================================================================== --- pkg/permute/DESCRIPTION 2013-11-28 14:11:06 UTC (rev 2767) +++ pkg/permute/DESCRIPTION 2013-11-29 02:29:38 UTC (rev 2768) @@ -3,10 +3,11 @@ Version: 0.7-8 Date: $Date$ Author: Gavin L. Simpson -Maintainer: Gavin L. Simpson +Maintainer: Gavin L. Simpson Depends: R (>= 2.14.0) Suggests: vegan (>= 2.0-0), testthat (>= 0.5), parallel Description: The 'permute' package implements a set of restricted permutation designs for freely exchangeable, line transects (time series), and spatial grid designs plus permutation of blocks (groups of samples). 'permute' also allows split-plot designs, in which the whole-plots or split-plots or both can be freely-exchangeable or one of the restricted designs. The 'permute' package is modelled after the permutation schemes of Canoco 3.1 (and later) by Cajo ter Braak. License: GPL-2 ByteCompile: true URL: http://vegan.r-forge.r-project.org/ +Copyright: see file COPYRIGHTS From noreply at r-forge.r-project.org Fri Nov 29 03:30:52 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 29 Nov 2013 03:30:52 +0100 (CET) Subject: [Vegan-commits] r2769 - pkg/permute/inst Message-ID: <20131129023052.4A8C2186899@r-forge.r-project.org> Author: gsimpson Date: 2013-11-29 03:30:51 +0100 (Fri, 29 Nov 2013) New Revision: 2769 Added: pkg/permute/inst/COPYRIGHTS Log: added COPYRIGHTS to clarify R Core's copyright of the update.how and update.Plots codes as these are based on their update.default function. Added: pkg/permute/inst/COPYRIGHTS =================================================================== --- pkg/permute/inst/COPYRIGHTS (rev 0) +++ pkg/permute/inst/COPYRIGHTS 2013-11-29 02:30:51 UTC (rev 2769) @@ -0,0 +1,16 @@ +Unless otherwise stated, the source code of the permute package is +copyright (C) Gavin L. Simpson 2010 - 2013. + +One exception is the code for the `update.how` and `update.Plots` S3 +methods in files + +PKG_BASE/R/update.how.R +PKG_BASE/R/update.Plots.R + +These functions are based upon code from the `update.default` method of +base R. These are Copyright (C) 1995-2012 The R Core Team. These codes +are released under the GPL version 2 or, at your discretion, any later +version. + +The full copyright and licence statements for these codes are retained +in the header of the respective .R files listed above. \ No newline at end of file From noreply at r-forge.r-project.org Sat Nov 30 17:10:33 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 17:10:33 +0100 (CET) Subject: [Vegan-commits] r2770 - in pkg/permute: . R man Message-ID: <20131130161033.CA8C61855B0@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 17:10:33 +0100 (Sat, 30 Nov 2013) New Revision: 2770 Modified: pkg/permute/NAMESPACE pkg/permute/R/getFoo-methods.R pkg/permute/man/get-methods.Rd Log: add 'getAllperms' extractor and method for class "how" Modified: pkg/permute/NAMESPACE =================================================================== --- pkg/permute/NAMESPACE 2013-11-29 02:30:51 UTC (rev 2769) +++ pkg/permute/NAMESPACE 2013-11-30 16:10:33 UTC (rev 2770) @@ -1,12 +1,40 @@ ### Visible functions: -export("allPerms", "Blocks", "numPerms", "check", "permCheck", - "permControl", "permute", "shuffle", "Within", "Plots", - "shuffleFree", "shuffleSeries", "shuffleGrid", "shuffleStrata", - "getBlocks", "getWithin", "getStrata", "getType", "getMirror", - "getConstant", "getPlots", "getRow", "getCol", "getDim", - "getNperm","getMaxperm", "getMinperm", "getComplete", "getMake", - "getObserved", "shuffleSet", "how", +export("allPerms", + "Blocks", + "check", + "getBlocks", + "getWithin", + "getStrata", + "getType", + "getMirror", + "getConstant", + "getPlots", + "getRow", + "getCol", + "getDim", + "getNperm", + "getMaxperm", + "getMinperm", + "getComplete", + "getMake", + "getObserved", + "getAllperms", + "how", + "numPerms", + "permCheck", + "permControl", + "permute", + "Plots", "setBlocks<-", + "setWithin<-", + "setStrata<-", + "setType<-", + "setMirror<-", + "setConstant<-", + "setPlots<-", + "setRow<-", + "setCol<-", + "setDim<-", "setNperm<-", "setMaxperm<-", "setMinperm<-", @@ -14,12 +42,13 @@ "setMake<-", "setObserved<-", "setAllperms<-", - "setPlots<-", - "setWithin<-", - "setStrata<-", - "setRow<-", - "setCol<-", - "setDim<-" + "shuffle", + "shuffleFree", + "shuffleGrid", + "shuffleSeries", + "shuffleSet", + "shuffleStrata", + "Within" ) ### Imports: nobs() only exists in R 2.13.0 for import. We define the @@ -109,6 +138,8 @@ S3method("getMake", "how") S3method("getObserved", "default") S3method("getObserved", "how") +S3method("getAllperms", "default") +S3method("getAllperms", "how") ## setFoo methods S3method("setBlocks<-", "default") Modified: pkg/permute/R/getFoo-methods.R =================================================================== --- pkg/permute/R/getFoo-methods.R 2013-11-29 02:30:51 UTC (rev 2769) +++ pkg/permute/R/getFoo-methods.R 2013-11-30 16:10:33 UTC (rev 2770) @@ -428,3 +428,16 @@ `getObserved.how` <- function(object, ...) { object$observed } + +## Extractor for all.perms component +`getAllperms` <- function(object, ...) { + UseMethod("getAllperms") +} + +`getAllperms.how` <- function(object, ...) { + object$all.perms +} + +`getAllperms.default` <- function(object, ...) { + stop("No default method for `getAllperms`") +} Modified: pkg/permute/man/get-methods.Rd =================================================================== --- pkg/permute/man/get-methods.Rd 2013-11-29 02:30:51 UTC (rev 2769) +++ pkg/permute/man/get-methods.Rd 2013-11-30 16:10:33 UTC (rev 2770) @@ -74,6 +74,9 @@ \alias{getObserved} \alias{getObserved.default} \alias{getObserved.how} +\alias{getAllperms} +\alias{getAllperms.default} +\alias{getAllperms.how} \title{Extractor functions to access components of a permutation design} \description{ @@ -86,68 +89,71 @@ } \usage{ -getWithin(object, ...) -getPlots(object, ...) +getAllperms(object, ...) getBlocks(object, ...) -getStrata(object, ...) -getType(object, ...) -getMirror(object, ...) +getComplete(object, ...) getConstant(object, ...) getCol(object, ...) -getRow(object, ...) getDim(object, ...) -getNperm(object, ...) +getMake(object, ...) getMaxperm(object, ...) getMinperm(object, ...) -getComplete(object, ...) -getMake(object, ...) +getMirror(object, ...) +getNperm(object, ...) getObserved(object, ...) +getPlots(object, ...) +getRow(object, ...) +getStrata(object, ...) +getType(object, ...) +getWithin(object, ...) -\method{getWithin}{how}(object, ...) +\method{getAllperms}{how}(object, ...) -\method{getPlots}{how}(object, ...) - \method{getBlocks}{how}(object, ...) -\method{getStrata}{how}(object, which = c("plots", "blocks"), - drop = TRUE, ...) -\method{getStrata}{Plots}(object, drop = TRUE, ...) +\method{getCol}{how}(object, which = c("plots", "within"), ...) +\method{getCol}{Plots}(object, ...) +\method{getCol}{Within}(object, ...) -\method{getType}{how}(object, which = c("plots", "within"), ...) -\method{getType}{Plots}(object, ...) -\method{getType}{Within}(object, ...) +\method{getComplete}{how}(object, ...) -\method{getMirror}{how}(object, which = c("plots", "within"), ...) -\method{getMirror}{Plots}(object, ...) -\method{getMirror}{Within}(object, ...) - \method{getConstant}{how}(object, ...) \method{getConstant}{Within}(object, ...) -\method{getCol}{how}(object, which = c("plots", "within"), ...) -\method{getCol}{Plots}(object, ...) -\method{getCol}{Within}(object, ...) - -\method{getRow}{how}(object, which = c("plots", "within"), ...) -\method{getRow}{Plots}(object, ...) -\method{getRow}{Within}(object, ...) - \method{getDim}{how}(object, which = c("plots", "within"), ...) \method{getDim}{Plots}(object, ...) \method{getDim}{Within}(object, ...) -\method{getNperm}{how}(object, ...) +\method{getMake}{how}(object, ...) \method{getMaxperm}{how}(object, ...) \method{getMinperm}{how}(object, ...) -\method{getComplete}{how}(object, ...) +\method{getMirror}{how}(object, which = c("plots", "within"), ...) +\method{getMirror}{Plots}(object, ...) +\method{getMirror}{Within}(object, ...) -\method{getMake}{how}(object, ...) +\method{getNperm}{how}(object, ...) \method{getObserved}{how}(object, ...) +\method{getPlots}{how}(object, ...) + +\method{getRow}{how}(object, which = c("plots", "within"), ...) +\method{getRow}{Plots}(object, ...) +\method{getRow}{Within}(object, ...) + +\method{getStrata}{how}(object, which = c("plots", "blocks"), + drop = TRUE, ...) +\method{getStrata}{Plots}(object, drop = TRUE, ...) + +\method{getType}{how}(object, which = c("plots", "within"), ...) +\method{getType}{Plots}(object, ...) +\method{getType}{Within}(object, ...) + +\method{getWithin}{how}(object, ...) + } \arguments{ From noreply at r-forge.r-project.org Sat Nov 30 17:11:35 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 17:11:35 +0100 (CET) Subject: [Vegan-commits] r2771 - pkg/permute/R Message-ID: <20131130161135.D8BC21855B0@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 17:11:35 +0100 (Sat, 30 Nov 2013) New Revision: 2771 Modified: pkg/permute/R/shuffleSet2.R Log: use 'getAllperms' extractor Modified: pkg/permute/R/shuffleSet2.R =================================================================== --- pkg/permute/R/shuffleSet2.R 2013-11-30 16:10:33 UTC (rev 2770) +++ pkg/permute/R/shuffleSet2.R 2013-11-30 16:11:35 UTC (rev 2771) @@ -32,7 +32,7 @@ control <- pcheck$control } - if(is.null(control$all.perms)) { + if(is.null(AP <- getAllperms(control))) { ## get blocking, if any Block <- getStrata(control, which = "blocks") if(is.null(Block)) @@ -57,7 +57,7 @@ ## if we have all.perms now then we must have generated it ## during checking or user passed it with control ## Use that instead of a ranodm set - out <- control$all.perms + out <- AP } ## Because all.perms might have been generated, we have the From noreply at r-forge.r-project.org Sat Nov 30 20:47:02 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 20:47:02 +0100 (CET) Subject: [Vegan-commits] r2772 - pkg/permute/vignettes Message-ID: <20131130194702.C4AAD180AFE@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 20:47:02 +0100 (Sat, 30 Nov 2013) New Revision: 2772 Modified: pkg/permute/vignettes/permutations.Rnw Log: add a more complex example of updating components of the design; some other tweaks and fixes for typos Modified: pkg/permute/vignettes/permutations.Rnw =================================================================== --- pkg/permute/vignettes/permutations.Rnw 2013-11-30 16:11:35 UTC (rev 2771) +++ pkg/permute/vignettes/permutations.Rnw 2013-11-30 19:47:02 UTC (rev 2772) @@ -432,6 +432,8 @@ returns a logical, indicating whether the entire set of permutations should be produced or not. \item[\code{getObserved()}] returns a logical, which indicates whether the observed permutation (ordering of samples) is included in the entire set of permutation generated by \code{allPerms()}. + \item[\code{getAllperms()}] + extracts the complete set of permutations if present. Returns \code{NULL} if the set has not been generated. \end{description} The available \code{setFoo()<-} functions are @@ -448,7 +450,7 @@ \item[\code{setMirror<-()};] replaces the \code{mirror} component of an object of class \code{"Plots"} or \code{"Within"} with a logical vector of length one. \item[\code{setConstant<-()};] - replaces the \code{mirror} component of an object of class \code{"Within"} with a logical vector of length one. + replaces the \code{constant} component of an object of class \code{"Within"} with a logical vector of length one. \item[\code{setRow<-()}, \code{setCol<-()}, \code{setDim<-()};] replace one or both of the spatial grid dimensions of an object of class \code{"Plots"} or \code{"Within"} with am integer vector of length one, or, in the case of \code{setDim<-()}, of length 2. \item[\code{setNperm<-()}, \code{setMinperm<-()}, \code{setMaxperm<-()};] @@ -481,10 +483,39 @@ @ Note how the \code{call} component has been altered to include the argument pair \code{nperm = 999}, hence if this call were evaluated, the resulting object would be a copy of \code{hh}. +As a more complex example, consider the following design consisting of 5 blocks, each containing 2 plots of 5 samples each. Hence there are a total of 10 plots. Both the plots and within-plot sample are time series. This design can be created using +<>= +hh <- how(within = Within(type = "series"), + plots = Plots(type = "series", strata = gl(10, 5)), + blocks = gl(5, 10)) +@ + +To alter the design at the plot or within-plot levels, it is convenient to extract the relevant component using \code{getPlots()} or \code{getWithin()}, update the extracted object, and finally use the updated object to update \code{hh}. This process is illustrated below in order to change the plot-level permutation type to \code{"free"} +<>= +pl <- getPlots(hh) +setType(pl) <- "free" +setPlots(hh) <- pl +@ +We can confirm this has been changed by extracting the permutation type for the plot level +<>= +getType(hh, which = "plots") +@ +Notice too how the call has been expanded from \code{gl(10, 5)} to an integer vector. This expansion is to avoid the obvious problem of locating the objects referred to in the call should the call be re-evaluated later. +<>= +getCall(getPlots(hh)) +@ + +At the top level, a user can update the design using \code{update()}. Hence the equivalent of the above update (this time resetting the original type; \code{type = "series"}) +<>= +hh <- update(hh, plots = update(getPlots(hh), type = "series")) +getType(hh, which = "plots") +@ +This however is not guaranteed to work within a function, because we do not guarantee that components of the call used to create \code{hh} can be found from the execution frame where \code{update()} is called. To be safe, always use the \code{setFoo<-()} replacement functions to update design objects from within your functions. + \section*{Computational details} This vignette was built within the following environment: <>= -toLatex(sessionInfo()) +toLatex(sessionInfo(), locale = FALSE) @ \bibliography{permute} \end{document} From noreply at r-forge.r-project.org Sat Nov 30 21:19:11 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 21:19:11 +0100 (CET) Subject: [Vegan-commits] r2773 - pkg/permute/vignettes Message-ID: <20131130201911.BFECB183AD8@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 21:19:11 +0100 (Sat, 30 Nov 2013) New Revision: 2773 Modified: pkg/permute/vignettes/permutations.Rnw Log: rewording Modified: pkg/permute/vignettes/permutations.Rnw =================================================================== --- pkg/permute/vignettes/permutations.Rnw 2013-11-30 19:47:02 UTC (rev 2772) +++ pkg/permute/vignettes/permutations.Rnw 2013-11-30 20:19:11 UTC (rev 2773) @@ -505,12 +505,12 @@ getCall(getPlots(hh)) @ -At the top level, a user can update the design using \code{update()}. Hence the equivalent of the above update (this time resetting the original type; \code{type = "series"}) +At the top level, a user can update the design using \code{update()}. Hence the equivalent of the above update is (this time resetting the original type; \code{type = "series"}) <>= hh <- update(hh, plots = update(getPlots(hh), type = "series")) getType(hh, which = "plots") @ -This however is not guaranteed to work within a function, because we do not guarantee that components of the call used to create \code{hh} can be found from the execution frame where \code{update()} is called. To be safe, always use the \code{setFoo<-()} replacement functions to update design objects from within your functions. +However, this approach is not assured of working within a function because we do not guarantee that components of the call used to create \code{hh} can be found from the execution frame where \code{update()} is called. To be safe, always use the \code{setFoo<-()} replacement functions to update design objects from within your functions. \section*{Computational details} This vignette was built within the following environment: From noreply at r-forge.r-project.org Sat Nov 30 21:21:04 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 21:21:04 +0100 (CET) Subject: [Vegan-commits] r2774 - pkg/permute Message-ID: <20131130202104.DF5E6183AD8@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 21:21:04 +0100 (Sat, 30 Nov 2013) New Revision: 2774 Modified: pkg/permute/DESCRIPTION Log: switch to Authors at R instead of Author and Maintainer fields Modified: pkg/permute/DESCRIPTION =================================================================== --- pkg/permute/DESCRIPTION 2013-11-30 20:19:11 UTC (rev 2773) +++ pkg/permute/DESCRIPTION 2013-11-30 20:21:04 UTC (rev 2774) @@ -1,9 +1,11 @@ Package: permute Title: Functions for generating restricted permutations of data -Version: 0.7-8 +Version: 0.8-0 Date: $Date$ -Author: Gavin L. Simpson -Maintainer: Gavin L. Simpson +Authors at R: c(person(given = "Gavin L.", family = "Simpson", + email = "ucfagls at gmail.com", + role = c("aut", "cph", "cre")), + person(given = "R Core Team", role = "cph")) Depends: R (>= 2.14.0) Suggests: vegan (>= 2.0-0), testthat (>= 0.5), parallel Description: The 'permute' package implements a set of restricted permutation designs for freely exchangeable, line transects (time series), and spatial grid designs plus permutation of blocks (groups of samples). 'permute' also allows split-plot designs, in which the whole-plots or split-plots or both can be freely-exchangeable or one of the restricted designs. The 'permute' package is modelled after the permutation schemes of Canoco 3.1 (and later) by Cajo ter Braak. From noreply at r-forge.r-project.org Sat Nov 30 21:43:16 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 21:43:16 +0100 (CET) Subject: [Vegan-commits] r2775 - pkg/permute/inst Message-ID: <20131130204316.F206E1856AF@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 21:43:16 +0100 (Sat, 30 Nov 2013) New Revision: 2775 Removed: pkg/permute/inst/doc/ Log: remove now-redundant inst/doc/ folder From noreply at r-forge.r-project.org Sat Nov 30 21:50:05 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 21:50:05 +0100 (CET) Subject: [Vegan-commits] r2776 - pkg/permute Message-ID: <20131130205005.503D0186882@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 21:50:04 +0100 (Sat, 30 Nov 2013) New Revision: 2776 Modified: pkg/permute/DESCRIPTION Log: add contributions of Jari and Doug Bates Modified: pkg/permute/DESCRIPTION =================================================================== --- pkg/permute/DESCRIPTION 2013-11-30 20:43:16 UTC (rev 2775) +++ pkg/permute/DESCRIPTION 2013-11-30 20:50:04 UTC (rev 2776) @@ -5,7 +5,9 @@ Authors at R: c(person(given = "Gavin L.", family = "Simpson", email = "ucfagls at gmail.com", role = c("aut", "cph", "cre")), - person(given = "R Core Team", role = "cph")) + person(given = "R Core Team", role = "cph"), + person(given = "Douglas M.", family = "Bates", role = "ctb"), + person(given = "Jari", family = "Oksanen", role = "ctb")) Depends: R (>= 2.14.0) Suggests: vegan (>= 2.0-0), testthat (>= 0.5), parallel Description: The 'permute' package implements a set of restricted permutation designs for freely exchangeable, line transects (time series), and spatial grid designs plus permutation of blocks (groups of samples). 'permute' also allows split-plot designs, in which the whole-plots or split-plots or both can be freely-exchangeable or one of the restricted designs. The 'permute' package is modelled after the permutation schemes of Canoco 3.1 (and later) by Cajo ter Braak. From noreply at r-forge.r-project.org Sat Nov 30 21:51:30 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 21:51:30 +0100 (CET) Subject: [Vegan-commits] r2777 - pkg/permute/inst Message-ID: <20131130205130.89F3C186123@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 21:51:30 +0100 (Sat, 30 Nov 2013) New Revision: 2777 Modified: pkg/permute/inst/ChangeLog Log: minor documentation additions Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-30 20:50:04 UTC (rev 2776) +++ pkg/permute/inst/ChangeLog 2013-11-30 20:51:30 UTC (rev 2777) @@ -2,6 +2,14 @@ permute ChangeLog +Version 0.8-0 + + * Released to CRAN + + * DESCRIPTION: now uses `Authors at R` to populate `Author` and + `Maintainer` fields. Finer grained recognition of contributors and + R Core Team's copyright. + Version 0.7-8 * how, Plots: enforces that `blocks` and `strata` are factors, or From noreply at r-forge.r-project.org Sat Nov 30 22:48:52 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 22:48:52 +0100 (CET) Subject: [Vegan-commits] r2778 - pkg/permute/inst Message-ID: <20131130214852.10EC41855AC@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 22:48:51 +0100 (Sat, 30 Nov 2013) New Revision: 2778 Added: pkg/permute/inst/NEWS.Rd Log: Add a NEWS file following the Rd format Added: pkg/permute/inst/NEWS.Rd =================================================================== --- pkg/permute/inst/NEWS.Rd (rev 0) +++ pkg/permute/inst/NEWS.Rd 2013-11-30 21:48:51 UTC (rev 2778) @@ -0,0 +1,83 @@ +\name{NEWS} +\title{permute News} +\encoding{UTF-8} + +\section{Changes in version 0.8-0}{ + + \subsection{GENERAL}{ + + \itemize{ + \item Version 0.8-0 represents a major update of \pkg{permute}, + with some backwards-incompatible changes to the main + functions. The main addition is the availability of block-level + restrictions on the permutations, which are required for whole- and + split-plot designs. + } + + } % general + + \subsection{NEW FEATURES}{ + + \itemize{ + \item \code{how()}, a new function to create permutation + designs. This replaces the deprecated function \code{permControl}. + + \item \pkg{permute} gains the addition of true blocking structures + with which to restrict the permutations. Blocks sit as the + outermost layer of the permutations, and can contain plots which + in turn contain samples. In contrasts to plots, blocks are never + permuted and samples are never shuffled between + blocks. Permutation only ever happens within blocks. + + To facilitate this, plot-level strata are no specified via + \code{Plots} instead of via the old strata argument of + \code{how}. Blocks are specified via a new argument \code{blocks}, + which takes a factor variable. + + \item A new suite of extractor and replacement functions is + provided with which to interact with permutation designs created + by \code{how}. Extractor functions have names \code{getFoo}, where + \code{Foo} is a component of the design. Replacement functions + have names \code{setFoo}. The replacement function are especially + for use by package authors wishing to alter permutation within + their functions. The extractor functions are recommened for all + users wishing to extract features of the permutation design. + + \item As a convenience for users, the \code{update()} function + will now work with objects of classes \code{"how"}, \code{"Plots"} + or \code{"Within"} to allow quick updating of features of the + permutation design. This approach is intended for interactive use + at the top-level and not within functions, where the new + \code{setFoo} replacement functions should be used. + + \item \code{shuffleSet} is enhanced in this version. Firstly, the + function now returns a classed object which has a \code{print} + method to allow for compact printing of the design elements used + to generate the set of permutations. Second, \code{shuffleSet} + will sample \code{nset} permutations from the entire set of + permutations should a small number of possible permutations + trigger generation of the entire set. This avoids the generation + of a set of non-unique permutations. Finally the random seed that + generated the set is stored as an attribute. + + \item The package vignette is much expanded in this version with + new sections on using \pkg{permute} within functions that will be + of interest to package authors wishing to use \pkg{permute} in + their packages. + } + + } % new features + + \subsection{DEPRECATED}{ + + \itemize{ + \item \code{permControl} is deprecated in favour of \code{how}. + + \item \code{permuplot} is broken and effectively defunct given the + changes to the way permutation are defined and the addition of + blocks. \code{permuplot} is no longer expoerted from the package + namespace. + } + + } % deprecated +} \ No newline at end of file From noreply at r-forge.r-project.org Sat Nov 30 22:49:11 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 22:49:11 +0100 (CET) Subject: [Vegan-commits] r2779 - pkg/permute/inst Message-ID: <20131130214911.8207E18686F@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 22:49:11 +0100 (Sat, 30 Nov 2013) New Revision: 2779 Modified: pkg/permute/inst/ChangeLog Log: document recent changes Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-30 21:48:51 UTC (rev 2778) +++ pkg/permute/inst/ChangeLog 2013-11-30 21:49:11 UTC (rev 2779) @@ -10,6 +10,10 @@ `Maintainer` fields. Finer grained recognition of contributors and R Core Team's copyright. + * NEWS: added a `NEWS.Rd` file to document high-level changes to + permute. Detailed changes remain in `CHANGELOG`, whilst `NEWS.Rd` + will summarise the main user-level changes to the package. + Version 0.7-8 * how, Plots: enforces that `blocks` and `strata` are factors, or From noreply at r-forge.r-project.org Sat Nov 30 23:05:57 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 23:05:57 +0100 (CET) Subject: [Vegan-commits] r2780 - pkg/permute/R Message-ID: <20131130220557.4D6381855AC@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 23:05:56 +0100 (Sat, 30 Nov 2013) New Revision: 2780 Modified: pkg/permute/R/allPerms.R Log: fix a bug in recombining the sets of all permutations for each block Modified: pkg/permute/R/allPerms.R =================================================================== --- pkg/permute/R/allPerms.R 2013-11-30 21:49:11 UTC (rev 2779) +++ pkg/permute/R/allPerms.R 2013-11-30 22:05:56 UTC (rev 2780) @@ -61,7 +61,8 @@ } ## bind all the blocks together - out <- do.call(rbind, out) ## hmm are any of these the same shape? + out <- do.call(cbind, out) ## hmm are any of these the same shape? + out[, unlist(spl)] <- out if(!(observed <- getObserved(control))) { obs.v <- seq_len(n) From noreply at r-forge.r-project.org Sat Nov 30 23:08:37 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 23:08:37 +0100 (CET) Subject: [Vegan-commits] r2781 - in pkg/permute: inst man Message-ID: <20131130220837.202E81855AC@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 23:08:36 +0100 (Sat, 30 Nov 2013) New Revision: 2781 Modified: pkg/permute/inst/NEWS.Rd pkg/permute/man/allPerms.Rd Log: Remove warning about requiring that samples be in plot/block order; document this as a user-level new feature Modified: pkg/permute/inst/NEWS.Rd =================================================================== --- pkg/permute/inst/NEWS.Rd 2013-11-30 22:05:56 UTC (rev 2780) +++ pkg/permute/inst/NEWS.Rd 2013-11-30 22:08:36 UTC (rev 2781) @@ -29,19 +29,19 @@ permuted and samples are never shuffled between blocks. Permutation only ever happens within blocks. - To facilitate this, plot-level strata are no specified via - \code{Plots} instead of via the old strata argument of - \code{how}. Blocks are specified via a new argument \code{blocks}, + To facilitate this, plot-level strata are now specified via + \code{Plots()} instead of via the old strata argument of + \code{how()}. Blocks are specified via a new argument \code{blocks}, which takes a factor variable. \item A new suite of extractor and replacement functions is provided with which to interact with permutation designs created - by \code{how}. Extractor functions have names \code{getFoo}, where - \code{Foo} is a component of the design. Replacement functions - have names \code{setFoo}. The replacement function are especially - for use by package authors wishing to alter permutation within - their functions. The extractor functions are recommened for all - users wishing to extract features of the permutation design. + by \code{how()}. Extractor functions have names \code{getFoo()}, + where \code{Foo()} is a component of the design. Replacement + functions have names \code{setFoo}. The replacement function are + especially for use by package authors wishing to alter permutation + within their functions. The extractor functions are recommened for + all users wishing to extract features of the permutation design. \item As a convenience for users, the \code{update()} function will now work with objects of classes \code{"how"}, \code{"Plots"} @@ -50,16 +50,19 @@ at the top-level and not within functions, where the new \code{setFoo} replacement functions should be used. - \item \code{shuffleSet} is enhanced in this version. Firstly, the - function now returns a classed object which has a \code{print} + \item \code{shuffleSet()} is enhanced in this version. Firstly, the + function now returns a classed object which has a \code{print()} method to allow for compact printing of the design elements used - to generate the set of permutations. Second, \code{shuffleSet} + to generate the set of permutations. Second, \code{shuffleSet()} will sample \code{nset} permutations from the entire set of permutations should a small number of possible permutations trigger generation of the entire set. This avoids the generation of a set of non-unique permutations. Finally the random seed that generated the set is stored as an attribute. + \item \code{allPerms()} no longer assumes that samples are in + block and/or plot ordering. + \item The package vignette is much expanded in this version with new sections on using \pkg{permute} within functions that will be of interest to package authors wishing to use \pkg{permute} in Modified: pkg/permute/man/allPerms.Rd =================================================================== --- pkg/permute/man/allPerms.Rd 2013-11-30 22:05:56 UTC (rev 2780) +++ pkg/permute/man/allPerms.Rd 2013-11-30 22:08:36 UTC (rev 2781) @@ -54,10 +54,6 @@ \code{observed} contains argument \code{observed}. } \section{Warning}{ - This function currently assumes that any strata are represented by - contiguous blocks in the order of the levels of \code{strata}. This is - unlike \code{\link{shuffle}} and \code{\link{shuffleSet}}. - If permuting the strata themselves, a balanced design is required (the same number of observations in each level of \code{strata}. This is common to all functions in the package. From noreply at r-forge.r-project.org Sat Nov 30 23:09:58 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 23:09:58 +0100 (CET) Subject: [Vegan-commits] r2782 - pkg/permute/R Message-ID: <20131130220958.1DF121855AC@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 23:09:57 +0100 (Sat, 30 Nov 2013) New Revision: 2782 Modified: pkg/permute/R/allPerms.R Log: minor change to a comment Modified: pkg/permute/R/allPerms.R =================================================================== --- pkg/permute/R/allPerms.R 2013-11-30 22:08:36 UTC (rev 2781) +++ pkg/permute/R/allPerms.R 2013-11-30 22:09:57 UTC (rev 2782) @@ -131,7 +131,7 @@ function(x, ord) x[ord[i,]], ord = ord) } } else { - ## different permutations within blocks + ## different permutations within plots nperms <- numPerms(sum(tab), control) ng <- length(tab) From noreply at r-forge.r-project.org Sat Nov 30 23:12:06 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 23:12:06 +0100 (CET) Subject: [Vegan-commits] r2783 - pkg/permute/inst Message-ID: <20131130221206.70E5C1851D9@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 23:12:05 +0100 (Sat, 30 Nov 2013) New Revision: 2783 Modified: pkg/permute/inst/ChangeLog Log: document bug fix in allPerms from r2781 Modified: pkg/permute/inst/ChangeLog =================================================================== --- pkg/permute/inst/ChangeLog 2013-11-30 22:09:57 UTC (rev 2782) +++ pkg/permute/inst/ChangeLog 2013-11-30 22:12:05 UTC (rev 2783) @@ -11,9 +11,12 @@ R Core Team's copyright. * NEWS: added a `NEWS.Rd` file to document high-level changes to - permute. Detailed changes remain in `CHANGELOG`, whilst `NEWS.Rd` + permute. Detailed changes remain in `ChangeLog`, whilst `NEWS.Rd` will summarise the main user-level changes to the package. + * allPerms: fix a bug where the blocks of permutations were being + recombined in the wrong way, by rows instead of by columns. + Version 0.7-8 * how, Plots: enforces that `blocks` and `strata` are factors, or From noreply at r-forge.r-project.org Sat Nov 30 23:17:01 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 30 Nov 2013 23:17:01 +0100 (CET) Subject: [Vegan-commits] r2784 - pkg/permute/tests/Examples Message-ID: <20131130221701.5E1101851D9@r-forge.r-project.org> Author: gsimpson Date: 2013-11-30 23:17:01 +0100 (Sat, 30 Nov 2013) New Revision: 2784 Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save Log: update reference material for example checks/tests Modified: pkg/permute/tests/Examples/permute-Ex.Rout.save =================================================================== --- pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-30 22:12:05 UTC (rev 2783) +++ pkg/permute/tests/Examples/permute-Ex.Rout.save 2013-11-30 22:17:01 UTC (rev 2784) @@ -503,7 +503,7 @@ > ### getMinperm.default getMinperm.how getMinperm.permControl getComplete > ### getComplete.default getComplete.how getComplete.permControl getMake > ### getMake.default getMake.how getObserved getObserved.default -> ### getObserved.how +> ### getObserved.how getAllperms getAllperms.default getAllperms.how > ### Keywords: methods utils > > ### ** Examples @@ -1203,7 +1203,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 2.25 0.044 2.404 0 0 +Time elapsed: 2.227 0.035 2.282 0 0 > grDevices::dev.off() null device 1