Combinations and permutations of record-sets.
sets(n, r, permutations_allowed = TRUE, repeats_allowed = TRUE)
make_sets(
x,
r,
strata = NULL,
permutations_allowed = TRUE,
repeats_allowed = TRUE
)
make_pairs(
x,
strata = NULL,
repeats_allowed = TRUE,
permutations_allowed = FALSE
)
make_pairs_wf_source(..., data_source = NULL)
[integer]
. Size of Vector.
[integer]
. Number of elements in a set.
[logical]
. If TRUE
, permutations of the same set are included.
[logical]
. If TRUE
, repeat values are included in each set.
[atomic]
. Vector.
Subsets of x
. Blocking attribute. Limits the creation of combinations or permutations to those from the same strata
.
Arguments passed to make_pairs
.
[character]
. Data source identifier. Limits the creation of combinations or permutations to those from a different data_source
A list
of a vector's elements and corresponding indexes.
set()
- Create r
-set combinations or permutations of n
observations.
make_set()
- Create r
-set combinations or permutations of vector x
.
make_pairs()
- Create 2
-set combinations or permutations of vector x
.
make_pairs_wf_source()
- Create 2
-set combinations or permutations of vector x
that are from different sources (data_source
).
sets(4, 2)
#> [,1] [,2]
#> [1,] 1 1
#> [2,] 1 2
#> [3,] 1 3
#> [4,] 1 4
#> [5,] 2 1
#> [6,] 2 2
#> [7,] 2 3
#> [8,] 2 4
#> [9,] 3 1
#> [10,] 3 2
#> [11,] 3 3
#> [12,] 3 4
#> [13,] 4 1
#> [14,] 4 2
#> [15,] 4 3
#> [16,] 4 4
sets(4, 2, repeats_allowed = FALSE, permutations_allowed = FALSE)
#> [,1] [,2]
#> [1,] 1 2
#> [2,] 1 3
#> [3,] 1 4
#> [4,] 2 3
#> [5,] 2 4
#> [6,] 3 4
make_sets(month.abb[1:4], 2)
#> $x1_pos
#> [1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4
#>
#> $x2_pos
#> [1] 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4
#>
#> $x1_val
#> [1] "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" "Feb" "Feb" "Mar" "Mar" "Mar" "Mar"
#> [13] "Apr" "Apr" "Apr" "Apr"
#>
#> $x2_val
#> [1] "Jan" "Feb" "Mar" "Apr" "Jan" "Feb" "Mar" "Apr" "Jan" "Feb" "Mar" "Apr"
#> [13] "Jan" "Feb" "Mar" "Apr"
#>
make_sets(month.abb[1:4], 3)
#> $x1_pos
#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3
#> [39] 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
#>
#> $x2_pos
#> [1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 1 1 1 1 2 2
#> [39] 2 2 3 3 3 3 4 4 4 4 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4
#>
#> $x3_pos
#> [1] 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2
#> [39] 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4
#>
#> $x1_val
#> [1] "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan"
#> [13] "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" "Feb" "Feb" "Feb" "Feb" "Feb" "Feb"
#> [25] "Feb" "Feb" "Feb" "Feb" "Feb" "Feb" "Feb" "Feb" "Mar" "Mar" "Mar" "Mar"
#> [37] "Mar" "Mar" "Mar" "Mar" "Mar" "Mar" "Mar" "Mar" "Mar" "Mar" "Mar" "Mar"
#> [49] "Apr" "Apr" "Apr" "Apr" "Apr" "Apr" "Apr" "Apr" "Apr" "Apr" "Apr" "Apr"
#> [61] "Apr" "Apr" "Apr" "Apr"
#>
#> $x2_val
#> [1] "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" "Feb" "Feb" "Mar" "Mar" "Mar" "Mar"
#> [13] "Apr" "Apr" "Apr" "Apr" "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" "Feb" "Feb"
#> [25] "Mar" "Mar" "Mar" "Mar" "Apr" "Apr" "Apr" "Apr" "Jan" "Jan" "Jan" "Jan"
#> [37] "Feb" "Feb" "Feb" "Feb" "Mar" "Mar" "Mar" "Mar" "Apr" "Apr" "Apr" "Apr"
#> [49] "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" "Feb" "Feb" "Mar" "Mar" "Mar" "Mar"
#> [61] "Apr" "Apr" "Apr" "Apr"
#>
#> $x3_val
#> [1] "Jan" "Feb" "Mar" "Apr" "Jan" "Feb" "Mar" "Apr" "Jan" "Feb" "Mar" "Apr"
#> [13] "Jan" "Feb" "Mar" "Apr" "Jan" "Feb" "Mar" "Apr" "Jan" "Feb" "Mar" "Apr"
#> [25] "Jan" "Feb" "Mar" "Apr" "Jan" "Feb" "Mar" "Apr" "Jan" "Feb" "Mar" "Apr"
#> [37] "Jan" "Feb" "Mar" "Apr" "Jan" "Feb" "Mar" "Apr" "Jan" "Feb" "Mar" "Apr"
#> [49] "Jan" "Feb" "Mar" "Apr" "Jan" "Feb" "Mar" "Apr" "Jan" "Feb" "Mar" "Apr"
#> [61] "Jan" "Feb" "Mar" "Apr"
#>
make_pairs(month.abb[1:4])
#> $x_pos
#> [1] 3 2 4 1 2 4 1 4 1 1
#>
#> $y_pos
#> [1] 3 3 3 3 2 2 2 4 4 1
#>
#> $index_ord
#> [1] 1 1 1 1 2 2 2 3 3 4
#>
#> $x_val
#> [1] "Mar" "Feb" "Apr" "Jan" "Feb" "Apr" "Jan" "Apr" "Jan" "Jan"
#>
#> $y_val
#> [1] "Mar" "Mar" "Mar" "Mar" "Feb" "Feb" "Feb" "Apr" "Apr" "Jan"
#>
#> $strata
#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#>
make_pairs(month.abb[1:4], strata = c(1, 1, 2, 2))
#> $x_pos
#> [1] 2 1 1 3 4 4
#>
#> $y_pos
#> [1] 2 2 1 3 3 4
#>
#> $index_ord
#> [1] 1 1 2 1 1 2
#>
#> $x_val
#> [1] "Feb" "Jan" "Jan" "Mar" "Apr" "Apr"
#>
#> $y_val
#> [1] "Feb" "Feb" "Jan" "Mar" "Mar" "Apr"
#>
#> $strata
#> [1] 1 1 1 2 2 2
#>
make_pairs_wf_source(month.abb[1:4], data_source = c(1, 1, 2, 2))
#> $x_pos
#> [1] 3 4 3 4
#>
#> $y_pos
#> [1] 1 1 2 2
#>
#> $index_ord
#> [1] 1 1 2 2
#>
#> $x_val
#> [1] "Mar" "Apr" "Mar" "Apr"
#>
#> $y_val
#> [1] "Jan" "Jan" "Feb" "Feb"
#>