Learn R Programming

gRbase (version 1.6-4)

parray: Representation of and operations on multidimensional tables

Description

General representation of multidimensional tables (by parray objects).

Usage

parray(varNames, levels, values = 1, normalize = c("none", "first", "all"), smooth = 0)
as.parray(values, normalize=c("none","first","all"), smooth=0)
## S3 method for class 'parray':
varNames(x)
## S3 method for class 'parray':
nLevels(x)
## S3 method for class 'parray':
valueLabels(x)

Arguments

varNames
Names of variables defining table
levels
Either vector with number of levels of the factors in varNames or list vith specification of the levels of the factors in varNames. See 'examples' below.
values
Table values
x
Objects of class "parray"
normalize
Should result be normalized, see 'Details' below.
smooth
Should values be smoothed, see 'Details' below.

Value

  • An object of class parray.

Details

A parray object represents a table defined by a set of variables and their levels, together with the values of the table. E.g. f(a,b,c) can be a table with a,b,c representing levels of binary variable If normalize="first" then for each configuration of the parents, "pa", the probabilities are normalized to sum to one. Thus f(a,b,c) becomes a conditional probability table of the form p(a|b,c). If normalize="all" then the sum over all entries of f(a,b,c) is one. If smooth is positive then smooth is added to values before normalization takes place. as.parray can be used for coercing a an array to a parray object.

Examples

Run this code
t1 <- parray(c("gender","answer"),list(c('male','female'),c('yes','no')), values=1:4)
t1 <- parray(~gender:answer,list(c('male','female'),c('yes','no')), values=1:4)
t1 <- parray(~gender:answer,c(2,2), values=1:4)

t2 <- parray(c("answer","category"), list(c('yes','no'),c(1,2)), values=1:4+10)
t3 <- parray(c("category","foo"), c(2,2), values=1:4+100)

varNames(t1)
nLevels(t1)
valueLabels(t1)

Run the code above in your browser using DataLab