oii.xtab: A cross-tabulation with measures of association

Description Usage Arguments See Also Examples

Description

This function prints a 2-way table with optional cell statistics and measures of association

Usage

1
2
3
4
oii.xtab(r, c = NULL, s = NULL, row = FALSE, col = FALSE,
  pctcell = FALSE, stats = FALSE, rescell = FALSE, chistd = FALSE,
  expcell = FALSE, chicell = FALSE, warnings = FALSE, varnames = NULL,
  include.missing = FALSE, ...)

Arguments

r

the row variable. If r is a table, data.frame, or matrix, then c and s are ignored.

c

the column variable.

s

the split variable. The r and c will be separately tabulated for each unique value of s.

row

Show row percentages? Defaults to FALSE.

col

Show column percentages? Defaults to FALSE.

pctcell

Print cell percentages? Defaults to FALSE.

stats

Print measures of association? Defaults to FALSE. This parameter is ignored either r or c has only one value. See association.measures.

rescell

Print residual cell count under the null hypothesis? Defaults to FALSE.

chistd

Print cell standardized residuals to pearson chi-square? Defaults to FALSE.

expcell

Print expected cell count under the null hypothesis? Defaults to FALSE.

chicell

Print cell contribution to pearson chi-square? Defaults to FALSE.

warnings

a logical value indicating whether warnings should be shown (defaults to FALSE, no warnings).

varnames

Names used to refer to r, c, and s in the printed output.

include.missing

Set to TRUE to include factor levels with no instances in the output. Default (FALSE) excludes them.

...

Additional parameters to be passed to CrossTable.

See Also

association.measures, CrossTable, likelihood.test, lambda.test

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#Create var1 as 200 A's, B's, and C's
var1<-sample(LETTERS[1:3],size=200,replace=TRUE)
#Create var2 as 200 numbers in the range 1 to 4
var2<-sample(1:4,size=200,replace=TRUE)

#Print a simple 2-way table of var1 and var2
oii.xtab(var1,var2)

#Print the row and column percents
oii.xtab(var1,var2,row=TRUE,col=TRUE)

#Print measures of association statistics
oii.xtab(var1,var2,stats=TRUE)

#If the variables are part of a data.frame
my.data.frame<-data.frame(var1,var2)
#We can use the $ to get the variables
oii.xtab(my.data.frame$var1,my.data.frame$var2)
#or use the with(...) command to save some typing
with(my.data.frame,oii.xtab(var1,var2))

#Three-way tables are also possible
#Create var3 as 200 "I"'s, "II"'s, and "III"'s
var3<-sample(c("I","II","III"),size=200,replace=TRUE)
oii.xtab(var1,var2,var3)

#We can also pass in a data.frame directly as the first argument
my.data.frame<-data.frame(var1,var2,var3)
oii.xtab(my.data.frame,stats=TRUE)
#The variables in the data.frame are used in order;
#so, sometimes it is useful to re-order them. For example,
oii.xtab(my.data.frame[,c("var3","var1","var2")],stats=TRUE)
#Of course, it is also possible to pass in the variables one 
#at a time or use with(...) as shown above.

oii documentation built on May 2, 2019, 6:33 a.m.

Related to oii.xtab in oii...