api_tabSlice: Array slices

Description Usage Arguments Author(s) Examples

Description

Functions for extracting slices of arrays

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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)

Arguments

tab

An array with named dimnames.

slice

A list defining the slice.

margin

Names of variables in slice.

drop

If TRUE then dimensions with only one level will be dropped from the output.

as.array

If the resulting array is one-dimensional the result will by default be a vector with no dim attribute unless as.array is TRUE.

margin.idx

Indec of variables in slice.

val

The values that entries in the slice will be multiplied with.

comp

The values that entries NOT in the slice will be multiplied with.

complement

If TRUE the complement of the entries are returned.

Author(s)

Søren Højsgaard, sorenh@math.aau.dk

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x = HairEyeColor
s = list(Hair=c("Black", "Brown"), Eye=c("Brown", "Blue"))

s1 = tabSlice(x, slice=s); s1

tabSlice2Entries(x, slice=s)
tabSlice2Entries(x, slice=s, complement=TRUE)

## ar_slice_mult
s2 = tabSliceMult(x, slice=s); s2

sp = list(c(1,2), c(1,2), TRUE)
tabSlicePrim(x, slice=sp)
tabSlice(x, slice=s)

DataSciBurgoon/gRbase documentation built on March 25, 2020, 12:03 a.m.