Description Usage Arguments See Also Examples
This function prints a 2-way table with optional cell statistics and measures of association
1 2 3 4 |
r |
the row variable. If |
c |
the column variable. |
s |
the split variable. The |
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 |
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 |
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 |
association.measures
, CrossTable
, likelihood.test
, lambda.test
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.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.