Description Usage Arguments Value Examples
Split a vector into groups
1 | .splitIndex(index, nGroups, randomize = FALSE)
|
index |
the vector of index values to be split into groups |
nGroups |
number of groups to be generated |
randomize |
should the groups contain a random or ordered sampling from the index vector |
returns a list containing 'groups' and 'groupIndex' both of which are lists of length nGroups
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ## Not run:
index <- c(c(1:10), c(30:40))
groupedIndex <- .splitIndex(nGroups = 3, index = index, randomize = TRUE)
groups <- unlist(groupedIndex$groups)
groups_i <- unlist(groupedIndex$groupIndex)
all(index %in% groups)
#Reorder the radomized groups by groups_i
groups_reorder <- vector(mode = "numeric", length = length(groups))
groups_reorder[groups_i] <- groups
groups_reorder
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.