Learn R Programming

cna (version 0.1-3)

truthTab: Generate a truth table

Description

truthTab builds a truth table from an input table, which essentially means that duplicated rows are removed and the number of occurrences of each unique row is stored.

Usage

truthTab(x, frequency = NULL, switch = FALSE, case.cutoff = 0)

## S3 method for class 'truthTab': print(x, row.names = FALSE, show.cases = TRUE, ...)

Arguments

x
The input table. Must be a data frame or matrix with 0 and 1 as entries or something that is coerced to 0 and 1 by as.integer, i.e. logicals are also possible. NA's are not allowed.
frequency
Numeric vector of length nrow(x). All elements must be nonegative, NA's are not allowed.
switch
Vector (integer, logical or character) specifying the columns in x to be switched, i.e. 0 is replaced by 1 are vice versa.
case.cutoff
Minimum number of occurrences of a combination of the factors in x. Combinations with fewer than case.cutoff occurrences are removed.
show.cases
Logical value specifying whether the attribute cases is printed.
row.names, ...
Are passed to print.data.frame.

Value

  • truthTab returns a data frame with additional class truthTab and attributes no.of.cases and cases.

Details

The input table is reduced by removing duplicated rows, so that each row of the resulting truth table corresponds to a combination of the factors in x. The number of occurrences and enumeration of the cases (taken from rownames(x)) are saved in attributes no.of.cases and cases, respectively.

See Also

A general overview of the facilities in the cna package is given in cna-package.