Description Usage Arguments Value Examples
Expand the given vector into all possible values in each location, with or without duplicates.
1 | permuteWithRepeats(x, unique = TRUE)
|
x |
list or vector |
unique |
logical, if |
data frame, each row being one permutation
1 2 3 4 5 6 7 8 9 10 11 12 | ltr <- c("a", "b", "c")
x <- permuteWithRepeats(ltr, unique = FALSE)
print(x)
stopifnot(nrow(x) == length(ltr)^length(ltr))
# duplicate results are dropped
y <- permuteWithRepeats(c("X", "Y", "Y"))
print(y)
stopifnot(nrow(y) == 2^3)
z <- permuteWithRepeats(c("X", "Y", "Y", "Y"))
stopifnot(nrow(z) == 2^4)
a <- permuteWithRepeats(c(1, 2, 3, 1))
stopifnot(nrow(a) == 3^4)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.