Contingency Table

DESCRIPTION:

This function is used by the Contingency Table dialog.

USAGE:

menuCrosstabs(formula, data=sys.parent(), margin.p=T, subset,  
              na.action=na.fail, drop.unused.levels=T, 
              print.object.p=T, digits=2, marginal.totals=T, 
              chi2.test=T) 

REQUIRED ARGUMENTS:

formula
a formula object with the terms, separated by + operators, on the right of the ~. Each term on the right hand side should be a factor, and will be converted to one if not. If there is a term to the left of the ~ it should be a vector of counts -- this useful for data that has al- ready been tabulated. If the formula is omitted or is ~ . and the data argument is a data frame, then all the variables in data will be crosstabulated.

OPTIONAL ARGUMENTS:

data
a data frame or frame number telling where the variables named in the formula (and in the subset argument) may be found. If a variable is not found by searching in the data frame or frame given by data, it is expected to be on the search list.
subset
an expression telling which subset of the rows of the data should be used in the table. It can be an expression that evaluates to a logical vector, or a vector of logical values, or a vector of row numbers or row names---in short, anything you would normaly use to subscript the rows of a data frame. The variable names in the expression should be names in the same place supplied by the data argument, otherwise they will be looked for on the search list. All observations are included by default.
na.action
a function for handling missing values. If there are any missing values in the data to be crosstabulated, the data will be put into a data frame and passed to the function given by na.action. The default is na.fail, which issues a fatal error message describing the problem. A common alternative is na.omit, which deletes cases with NAs in any of the variables to be crosstabulated. na.include will add the level NA to each factor before crosstabulating them ( formula may also include terms like na.include(x) to do this only for certain variables).
drop.unused.levels
if TRUE, then any unused levels in factors will be omitted from the table. If FALSE, they will not be dropped and the table will contain rows or columns of zeros for those unused levels. This will cause the marginal proportions for those levels and the overall chi-squared statistic to be NAs, but may be useful for making parallel tables of similar data sets.
print.object.p
if TRUE, a contingency table is printed. This output is from the function print.crosstabs.
margin.p
if TRUE, print marginal total.
digits
number of digits after the decimal point to use when displaying the proportions in the crosstabs tables.
marginal.totals
if TRUE (the default if the table has more than one dimension), print the row and column totals for each two dimensional layer of the table along side the layer. Also print the layer total and the proportion each row and column is of the layer total.
chi2.test
if TRUE, (the default if the table has more than one dimension), print the result of the chi-square test for independence of all the variables in the table. Yates' correction is not used.

VALUE:

an object of class "crosstabs". This is an array of counts. It also has an attribute marginals, a list of arrays of the marginal proportions. (These arrays are stacked by the print method for crosstabs so that corresponding entries lie near each other.) It also may have an attribute na.message, giving a message that the na.action function sometimes gives when it deals with missing values in the data (e.g., na.omit will supply a na.message telling how many cases were ignored).

SEE ALSO:

, , .