CrossTables with margins and either overall, row or column percentages.

CrossTabs(fac1, fac2 = NULL, TYPE = "ALL", NOZEROS = T, DIGITS = 1,
  PVALUE = F, VARNAME = F, LONGNAME = NULL, ALL = NULL)

Arguments

fac1

factor or variable convertible to factor

fac2

= NULL factor or variable convertible to factor. If not provided a dummy factor is generated.

TYPE

= "ALL" chooses between "ALL", "ROW", "COL"

NOZEROS

= T Option to discard factor levels which do not occur

DIGITS

= 1 Number of decimals for percentages

PVALUE

= F p-value from Chi2-test

VARNAME

= F Option to add a column on the left with the varname of fac1

LONGNAME

= NULL alternative to varname derived from function call

ALL

= NULL If ALL=NULL 'All' columns on the right, if ALL=T on the left and if ALL=F omitted

Value

CrossTable as data.frame with Counts and Percentages intercalated.

See also

Examples

if (FALSE) { a<-c(rep("M",240),rep("F",170)) b<-sample(c(rep("Stage1",110),rep("Stage2",180),rep("Stage3",120)),410) CrossTabs(a,b,TYPE="ALL") CrossTabs(a,b,TYPE="ROW") CrossTabs(a,b,TYPE="ROW",ALL=F) CrossTabs(a,b,TYPE="ROW",ALL=T) CrossTabs(a,b,TYPE="COL") }