Return the proportion of sparseness of a document-feature matrix, equal
to the proportion of cells that have zero counts.
Arguments
- x
the document-feature matrix
Examples
dfmat <- dfm(data_corpus_inaugural)
#> Warning: 'dfm.corpus()' is deprecated. Use 'tokens()' first.
sparsity(dfmat)
#> [1] 0.9183823
sparsity(dfm_trim(dfmat, min_termfreq = 5))
#> [1] 0.7850806