Description Usage Arguments Details Value Author(s) See Also Examples
Alternative ways of creating arrays
Convert dataframe to contingency table
1 2 3 4 5 
names 
Names of variables defining table; a character vector or a right hand sided formula. 
levels 
1) a list with specification of the levels of the factors in

values 
values to go into the parray 
normalize 
Either "none", "first" or "all". Should result be normalized, see 'Details' below. 
smooth 
Should values be smoothed, see 'Details' below. 
indata 
A dataframe. 
If normalize="first"
then for each configuration of
all other variables than the first, the probabilities are
normalized to sum to one. Thus f(a,b,c) becomes a conditional
probability table of the form p(ab,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.
An array.
S<c3><b8>ren H<c3><b8>jsgaard, [email protected]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  universe < list(gender=c('male','female'),
answer=c('yes','no'),
rain=c('yes','no'))
t1 < ar_new(c("gender","answer"), levels=universe, values=1:4)
t1
t2 < ar_new(~gender:answer, levels=universe, values=1:4)
t2
t3 < ar_new(~gender:answer, c(2,2), values=1:4)
t3
## Extract arrays from dataframe (much like xtabs() but with more flexibility)
data(cad1)
df2xtabs(cad1, ~Sex:AngPec:AMI)
df2xtabs(cad1, c("Sex","AngPec","AMI"))
df2xtabs(cad1, c(1,2,3))
## Extract arrays from dataframe (much like xtabs() but with more flexibility)
data(cad1)
df2xtabs(cad1, ~Sex:AngPec:AMI)
df2xtabs(cad1, c("Sex","AngPec","AMI"))
df2xtabs(cad1, c(1,2,3))

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.