[Vegan-commits] r1677 - in pkg/permute: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jul 5 10:22:31 CEST 2011
Author: gsimpson
Date: 2011-07-05 10:22:30 +0200 (Tue, 05 Jul 2011)
New Revision: 1677
Added:
pkg/permute/R/shuffleSet.R
pkg/permute/man/shuffleSet.Rd
Modified:
pkg/permute/DESCRIPTION
pkg/permute/NAMESPACE
pkg/permute/inst/ChangeLog
Log:
add shuffleSet for simple cases without strata
Modified: pkg/permute/DESCRIPTION
===================================================================
--- pkg/permute/DESCRIPTION 2011-07-05 06:07:23 UTC (rev 1676)
+++ pkg/permute/DESCRIPTION 2011-07-05 08:22:30 UTC (rev 1677)
@@ -1,6 +1,6 @@
Package: permute
Title: Functions for generating restricted permutations of data
-Version: 0.5-1
+Version: 0.5-2
Date: $Date$
Author: Gavin L. Simpson
Maintainer: Gavin L. Simpson <gavin.simpson at ucl.ac.uk>
Modified: pkg/permute/NAMESPACE
===================================================================
--- pkg/permute/NAMESPACE 2011-07-05 06:07:23 UTC (rev 1676)
+++ pkg/permute/NAMESPACE 2011-07-05 08:22:30 UTC (rev 1677)
@@ -2,7 +2,8 @@
export(`allPerms`, `Blocks`, `numPerms`, `permCheck`,
`permControl`, `permute`, `shuffle`, `Within`,
`shuffleFree`, `shuffleSeries`, `shuffleGrid`, `shuffleStrata`,
- `getBlocks`, `getWithin`, `getStrata`)
+ `getBlocks`, `getWithin`, `getStrata`,
+ `shuffleSet`)
### Imports
importFrom(`stats`, `nobs`)
Added: pkg/permute/R/shuffleSet.R
===================================================================
--- pkg/permute/R/shuffleSet.R (rev 0)
+++ pkg/permute/R/shuffleSet.R 2011-07-05 08:22:30 UTC (rev 1677)
@@ -0,0 +1,26 @@
+`shuffleSet` <- function(n, nset = 1, control = permControl()) {
+ Set <- matrix(nrow = nset, ncol = n)
+ ## If no strata then permute all samples using stated scheme
+ WI <- getWithin(control)
+ if(is.null(getStrata(control))) {
+ Args <- switch(WI$type,
+ "free" = list(x = n, size = n),
+ "series" = list(x = seq_len(n), mirror = WI$mirror),
+ "grid" = list(nrow = WI$nrow, ncol = WI$ncol,
+ mirror = WI$mirror))
+ FUN <- switch(WI$type,
+ "free" = shuffleFree,
+ "series" = shuffleSeries,
+ "grid" = shuffleGrid)
+ if(WI$type == "none") {
+ Set <- rep(seq_len(n), each = nset)
+ } else {
+ for(i in seq_len(nset)) {
+ Set[i,] <- do.call(FUN, Args)
+ }
+ }
+ } else {
+ .NotYetImplemented()
+ }
+ Set
+}
Modified: pkg/permute/inst/ChangeLog
===================================================================
--- pkg/permute/inst/ChangeLog 2011-07-05 06:07:23 UTC (rev 1676)
+++ pkg/permute/inst/ChangeLog 2011-07-05 08:22:30 UTC (rev 1677)
@@ -2,8 +2,15 @@
permute ChangeLog
-Version 0.5-1 (opened June 28, 2011)
+Version 0.5-2 (opened 5, 2011)
+ * shuffelSet: new function to generate a set of `n`
+ permutations without the overhead of `n` repeated calls to
+ `shuffle()`. Currently only for designs without
+ strata/blocks.
+
+Version 0.5-1 (closed July 5, 2011)
+
* shuffle: now returns seq_len(n) for no permutation within
blocks or of blocks.
Added: pkg/permute/man/shuffleSet.Rd
===================================================================
--- pkg/permute/man/shuffleSet.Rd (rev 0)
+++ pkg/permute/man/shuffleSet.Rd 2011-07-05 08:22:30 UTC (rev 1677)
@@ -0,0 +1,68 @@
+\name{shuffleSet}
+\alias{shuffleSet}
+
+\title{
+ Generate a set of permutations from the specified design.
+}
+\description{
+ \code{shuffleSet} returns a set of \code{nset} permutations from the
+ specified design. The main purpose of the function is to circumvent
+ the overhead of repeatedly calling \code{\link{shuffle}} to generate a
+ set of permutations.
+}
+\usage{
+shuffleSet(n, nset = 1, control = permControl())
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+ \item{n}{
+ numeric; the number of observations in the sample set.
+ }
+ \item{nset}{
+ numeric; the number of permutations to generate for the set
+ }
+ \item{control}{
+ an object of class \code{"permControl"} describing a valid
+ permutation design.
+ }
+}
+\details{
+ Currently, only the simple case of permutations not in the presence of
+ blocks (strata) is implemented.
+}
+\value{
+ Returns a matrix of permutations, where each row is a separate
+ permutation. As such, the returned matrix has \code{nset} rows and
+ \code{n} columns.
+}
+\author{
+ Gavin L. Simpson
+}
+
+%\note{
+%% ~~further notes~~
+%}
+
+%% ~Make other sections like Warning with \section{Warning }{....} ~
+
+\seealso{
+ See \code{\link{shuffle}} for generating a single permutation, and
+ \code{\link{permControl}} for setting up permutation designs.
+}
+\examples{
+## simple random permutations, 5 permutations in set
+shuffleSet(n = 10, nset = 10)
+
+## series random permutations, 10 permutations in set
+shuffleSet(10, 10, permControl(within = Within(type = "series")))
+
+## series random permutations, 10 permutations in set,
+## with possible mirroring
+CTRL <- permControl(within = Within(type = "series", mirror = TRUE))
+shuffleSet(10, 10, CTRL)
+
+}
+% Add one or more standard keywords, see file 'KEYWORDS' in the
+% R documentation directory.
+\keyword{ htest }
+\keyword{ design }% __ONLY ONE__ keyword per line
More information about the Vegan-commits
mailing list