api-cell.Rd
Low level table cell operations.
cell2entry(cell, dim)
entry2cell(entry, dim)
next_cell(cell, dim)
next_cell2(cell, dim)
next_cell_slice(cell, dim, slice_marg)
slice2entry(slice_cell, slice_marg, dim)
cell2entry_perm(cell, dim, perm)
perm_cell_entries(perm, dim)
fact_grid(dim, slice_cell = NULL, slice_marg = NULL)
Vector giving the cell, e.g. c(1, 1, 2) in 3-way table.
Vector giving array dimension, eg c(2, 2, 2).
An entry in an array (a number indexing a vector).
Vector giving the margin of a table, eg. c(2, 3)
Vector giving the corresponding cell of marginal table, e.g. c(1, 2)
Vector giving permutaion of array, eg. c(1, 3, 2).
di <- c(2, 2, 3)
cell2entry(c(1, 1, 1), dim=di)
#> [1] 1
cell2entry(c(2, 2, 3), dim=di)
#> [1] 12
entry2cell(1, dim=di)
#> [1] 1 1 1
entry2cell(12, dim=di)
#> [1] 2 2 3
next_cell(c(1, 1, 1), dim=di)
#> [1] 2 1 1
next_cell(c(2, 1, 1), dim=di)
#> [1] 1 2 1
## The first two entries are kept fixed
next_cell_slice(c(2, 1, 1), dim=di, slice_marg=c(1, 2))
#> [1] 2 1 2
next_cell_slice(c(2, 1, 2), dim=di, slice_marg=c(1, 2))
#> [1] 2 1 3
## Cell (2, 2, 1) corresponds to entry 4
cell2entry(c(2, 2, 1), dim=di)
#> [1] 4
## Same as
cell2entry_perm(c(2, 2, 1), dim=di, perm=c(1, 2, 3))
#> [1] 4
## If the table dimensions are permuted as (3, 1, 2)
## the entry becomes
cell2entry_perm(c(2, 2, 1), dim=di, perm=c(3, 1, 2))
#> [1] 10