# NOT RUN {
# Generate a matrix containing data for 10 categorical
# variables with levels 1, 2, 3.
mat <- matrix(sample(3, 500, TRUE), 10)
# Now assume that the first 25 columns correspond to
# cases and the remaining 25 columns to cases. Then
# a vector containing the class labels is given by
cl <- rep(1:2, e=25)
# and the matrices summarizing the numbers of subjects
# showing the respective levels at the different variables
# are computed by
cases <- rowTables(mat[, cl==1])
controls <- rowTables(mat[,cl==2])
# To obtain the ChiSquare values call
rowChisq2Class(cases, controls)
# This leads to the same results as
rowChisqStats(mat, cl)
# or
rowChisqMultiClass(cases, controls)
# or
listTab <- list(cases, controls)
rowChisqMultiClass(listTables = listTab)
# }
Run the code above in your browser using DataLab