# NOT RUN {
# Generate a matrix containing data for 10 categorical
# variables with levels 1, 2, 3.
mat <- matrix(sample(3, 500, TRUE), 10)
rowFreqs(mat)
# leads to the same results as
rowTables(mat) / ncol(mat)
# If mat contains missing values
mat[sample(500, 20)] <- NA
# then
rowFreqs(mat)
# leads to the same result as
rowTables(mat) / rowSums(!is.na(mat))
# }
Run the code above in your browser using DataLab