conv2Freq {smdc} | R Documentation |
This function convert matrix to frequency distribution.
conv2Freq(tmpMatrix, wordClass, breaks)
tmpMatrix |
Matrix. |
wordClass |
Classes of each row of matrix. |
breaks |
Class devision vector. |
Frequency distribution matrix.
Masaaki TAKADA
## 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) }