Description Usage Arguments Value Author(s) Examples
This function convert matrix to frequency distribution.
1 | conv2Freq(tmpMatrix, wordClass, breaks)
|
tmpMatrix |
Matrix. |
wordClass |
Classes of each row of matrix. |
breaks |
Class devision vector. |
Frequency distribution matrix.
Masaaki TAKADA
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## The function is currently defined as
function (tmpMatrix, wordClass, breaks)
{
freqDist <- matrix(0, nrow = length(breaks) - 1, ncol = ncol(tmpMatrix))
for (tmp in rownames(tmpMatrix)) {
cat <- wordClass[tmp]
if (!is.na(cat)) {
freqDist[cat, ] <- freqDist[cat, ] + tmpMatrix[tmp,
]
}
}
colnames(freqDist) <- colnames(tmpMatrix)
if (!is.null(names(breaks))) {
rownames(freqDist) <- names(breaks)[2:length(breaks)]
}
return(freqDist)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.