initMC.Rd
This function initialises the permutation object. It must be called before
nextPerm
can be called
initMC(x)
a vector of integers, reals, logicals or characters
a object of class mc
which is a list containing elements
mode - the mode of the original data in x
, "integer",
"double", or mode(x)
set - either the multiset being permuted if mode
is "integer" or
a set of integers corresponding to the elements of the multiset
elements - if mode
is not "integer" then this contains the
elements being permuted otherwise NULL
length - the length of the multiset
mc - a pointer to the internal C++ Multicool object. Users should not use this unless they really know what they are doing
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
#>
#> $mc
#> C++ object <0x55dd21fc8bd0> of class 'Multicool' <0x55dd21ddc6f0>
#>
#> 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
#>
#> $mc
#> C++ object <0x55dd1f85ad80> of class 'Multicool' <0x55dd21ddc6f0>
#>
#> attr(,"class")
#> [1] "mc"