conv2Freq: Conversion from Matrix to Frequency Distribution

Description Usage Arguments Value Author(s) Examples

Description

This function convert matrix to frequency distribution.

Usage

1
conv2Freq(tmpMatrix, wordClass, breaks)

Arguments

tmpMatrix

Matrix.

wordClass

Classes of each row of matrix.

breaks

Class devision vector.

Value

Frequency distribution matrix.

Author(s)

Masaaki TAKADA

Examples

 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)
  }

smdc documentation built on May 1, 2019, 8:48 p.m.