Learn R Programming

wordspace (version 0.2-8)

as.matrix.dsm: Extract Matrix from DSM Object (wordspace)

Description

Extract the co-occurrence or score matrix from a DSM object.

Usage

# S3 method for dsm
as.matrix(x, what = c("auto", "M", "S"), ...)

Value

Either the raw co-occurrence matrix or the score matrix of the DSM x.

Note that unlike other as.matrix methods, a sparse matrix in canonical DSM format may be returned.

Arguments

x

an object of class dsm

what

whether to extract the raw co-occurrence matrix (M) or the score matrix (S). The default option auto prefers the score matrix if both are available.

...

any additional arguments are ignored

Author

Stephanie Evert (https://purl.org/stephanie.evert)

Details

This function ensures that the row and column names of the matrix are consistent with the row/column information tables of the DSM. For faster access to the matrix, simply use x$M or x$S directly.

See Also

dsm, dim.dsm, dimnames.dsm, dsm.is.canonical

Examples

Run this code
as.matrix(DSM_TermTerm)
as.matrix(DSM_TermContext)

Run the code above in your browser using DataLab