1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
`allStrata` <- function(n, control)
{
## seq vector of observation indices
v <- seq_len(n)
## number of groups
strata <- getStrata(control, which = "plots")
lev <- length(levels(strata))
## compute nperms on number of levels - for this need Within()
## and type == typeP
type <- getType(control, which = "plots")
newControl <- how(within = Within(type = type))
nperms <- numPerms(lev, newControl)
## result object
X <- matrix(nrow = nperms, ncol = length(strata))
## store the type
type <- getType(control, which = "plots")
mirror <- getMirror(control, which = "plots")
perms <- if(type == "free") {
allFree(lev)
} else if(type == "series") {
allSeries(lev, nperms = nperms, mirror = mirror)
} else if(type == "grid") {
nr <- getRow(control, which = "plots")
nc <- getCol(control, which = "plots")
constant <- getConstant(control)
allGrid(lev, nperms = nperms, nr = nr, nc = nc,
mirror = mirror, constant = constant)
} else {
## if in here, must have both types == "none"
## this is here just in case - need to check if this
## is possible given calling function...
return(v)
}
sp <- split(v, strata)
## build permutations by concatenating components of sp
## for each row of level permutations
for(i in seq_len(nrow(perms)))
X[i,] <- unname(do.call(c, sp[perms[i,]]))
X
}
|