This function initialises the permutation object. It must be called before
nextPerm can be called
initMC(x)a object of class mc which is a list containing elements
- the mode of the original data in x, "integer",
"double", or mode(x)
- a multiset of integer codes 1, ..., k, one code for
each unique element of x
- the unique elements of x, so that
elements[set] recovers the multiset being permuted
- the length of the multiset
- TRUE if elements is a plain integer, double,
logical or character vector, which the C++ code can write directly
- an external pointer to the internal C++ object that holds the
position of nextPerm. Users should not use this unless they really
know what they are doing. It does not survive saving and reloading the
object, so call initMC again in a new session
nextPerm
x = c(1,1,2,2)
m1 = initMC(x)
m1
#> $mode
#> [1] "integer"
#>
#> $set
#> [1] 1 1 2 2
#>
#> $elements
#> [1] 1 2
#>
#> $length
#> [1] 4
#>
#> $plain
#> [1] TRUE
#>
#> $mc
#> <pointer: 0x55a1bbb46990>
#>
#> attr(,"class")
#> [1] "mc"
## a non-integer example
x = rep(letters[1:4],c(2,1,2,2))
m2 = initMC(x)
m2
#> $mode
#> [1] "character"
#>
#> $set
#> [1] 1 1 2 3 3 4 4
#>
#> $elements
#> [1] "a" "b" "c" "d"
#>
#> $length
#> [1] 7
#>
#> $plain
#> [1] TRUE
#>
#> $mc
#> <pointer: 0x55a1bbade3c0>
#>
#> attr(,"class")
#> [1] "mc"
## a real-valued example
m3 = initMC(c(1.5, 1.5, 2.5))
allPerm(m3)
#> [,1] [,2] [,3]
#> [1,] 2.5 1.5 1.5
#> [2,] 1.5 2.5 1.5
#> [3,] 1.5 1.5 2.5