Functions for extracting slices of arrays
tabSlice(tab, slice = NULL, margin = names(slice), drop = TRUE,
as.array = FALSE)tabSlice2(tab, slice, margin.idx, drop = TRUE, as.array = FALSE)
tabSlicePrim(tab, slice, drop = TRUE)
tabSliceMult(tab, slice, val = 1, comp = 0)
tabSlice2Entries(tab, slice, complement = FALSE)
ar_slice(tab, slice = NULL, margin = names(slice), drop = TRUE,
as.array = FALSE)
ar_slice_prim(tab, slice, drop = TRUE)
ar_slice_mult(tab, slice, val = 1, comp = 0)
ar_slice_entries(tab, slice, complement = FALSE)
An array with named dimnames.
A list defining the slice.
Names of variables in slice.
If TRUE then dimensions with only one level will be dropped from the output.
If the resulting array is one-dimensional the result will by default be a vector with no dim attribute unless as.array is TRUE.
Indec of variables in slice.
The values that entries in the slice will be multiplied with.
The values that entries NOT in the slice will be multiplied with.
If TRUE the complement of the entries are returned.
ar_perm
, ar_marg
,
ar_mult
, ar_div
,
ar_add
, ar_subt
,
ar_sum
, ar_prod
# NOT RUN {
x = HairEyeColor
s = list(Hair=c("Black","Brown"), Eye=c("Brown", "Blue"))
## arslice
s1 = ar_slice(x, slice=s)
s1
## ar_slice_entries
ar_slice_entries(x, slice=s)
ar_slice_entries(x, slice=s, complement=TRUE)
## ar_slice_mult
s2 = ar_slice_mult(x, slice=s)
s2
## arslice_prim does the same as arslice - faster, but the function is less
# flexible
sp = list(c(1,2), c(1,2), TRUE)
ar_slice_prim(x, slice=sp)
ar_slice(x, slice=s)
# }
Run the code above in your browser using DataLab