dtm_matrix: Sparse Matrix

Description Usage Arguments Examples

View source: R/features.R

Description

Creates a simple sparse matrix of document_term_matrix object.

Usage

1
2
3
4
dtm_matrix(dtm, density)

## S3 method for class 'dtm'
dtm_matrix(dtm, density = c("sparse", "dense"))

Arguments

dtm

An object of class document_term_matrix as returned by document_term_matrix.

density

Whether to return a dense or sparse matrix.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
init_textanalysis()

# build document
doc1 <- string_document("First document.")
doc2 <- string_document("Second document.")

corpus <- corpus(doc1, doc2)

update_lexicon(corpus)
m <- document_term_matrix(corpus)
dtm_matrix(m) # sparse
dtm_matrix(m, "dense") # dense

## End(Not run)

news-r/textanalysis documentation built on Nov. 4, 2019, 9:40 p.m.