Description Usage Arguments Value Author(s) See Also Examples
Computes the frequencies of the levels that the categorical variables in a matrix show.
1 2 |
x |
a matrix in which each row represents a categorical variable (e.g., a SNP)
and each column an observation, where the variables are assumed to show the
levels specified by |
levels |
vector specifying the levels that the categorical variables in |
divide.by.n |
should the numbers of observations showing the respective levels
be divided by the total number of observations, i.e.\ by |
affy |
logical specifying whether the SNPs in |
includeNA |
should a column be added to the output matrix containing the number of missing values for each variable? |
useNN |
character specifying whether missing values can also be coded by |
check |
should it be checked whether some of the variables show other levels than the one
specified by |
A matrix with the same number of rows as x
containing for each variable the numbers
of observations showing the levels specified by levels
.
Holger Schwender, holger.schwender@udo.edu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## 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))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.