R: Turn a document term matrix into a term co-occurrence matrix

Dtm2Tcm {textmineR} | R Documentation

## Turn a document term matrix into a term co-occurrence matrix

### Description

Turn a document term matrix, whose rows index documents and whose columns index terms, into a term co-occurrence matrix. A term co-occurrence matrix's rows and columns both index terms. See `details`, below.

### Usage

    Dtm2Tcm(dtm)

### Arguments

`dtm` | A document term matrix, generally of class `dgCMatrix`, though other classes, such as `dgTMatrix`, may also work without issue.

### Value

Returns a square `dgCMatrix` whose rows and columns both index terms. The i, j entries of this matrix represent the count of term j across documents containing term i. Note that, while square, this matrix is not symmetric.

### Examples

    data(nih_sample_dtm)

    tcm <- Dtm2Tcm(nih_sample_dtm)

[Package textmineR version 3.0.5 Index]