Learn R Programming

gRbase (version 1.8-6.7)

api-pct-operations: Array algebra

Description

Addition, subtraction etc. of arrays

Usage

a1 %a+% a2

a1 %a-% a2

a1 %a*% a2

a1 %a/% a2

a1 %a/0% a2

tab1 %ap% perm

tab1 %a_% marg

tab1 %a==% tab2

tab1 %a^% extra

tab1 %aa% tab2

Arguments

tab1, tab2

Multidimensional arrays with named dimnames (we call them 'named arrays').

perm

A vector of indices or dimnames or a right hand sided formula giving the desired permutiation.

marg

A vector of indices or dimnames or a right hand sided formula giving the desired marginal.

extra

List defining the extra dimensions.

a, a1, a2

Arrays (with named dimnames)

Examples

Run this code
# NOT RUN {
hec <- HairEyeColor
a1 <- tabMarg(hec, c("Hair", "Eye"))
a2 <- tabMarg(hec, c("Hair", "Sex"))
a3 <- tabMarg(hec, c("Eye", "Sex"))

## Binary operations
a1 %a+% a2
a1 %a-% a2
a1 %a*% a2
a1 %a/% a2
# }

Run the code above in your browser using DataLab