R: Extract Matrix from DSM Object (wordspace)

as.matrix.dsm {wordspace} | R Documentation

## Extract Matrix from DSM Object (wordspace)

### Description

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

### Usage

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

### 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

### 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.

### 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.

### Author(s)

Stefan Evert (http://purl.org/stefan.evert)

### See Also

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

### Examples

    as.matrix(DSM_TermTerm)
    as.matrix(DSM_TermContext)

[Package wordspace version 0.2-6 Index]