format_sparsity.Rd
format_sparsity(x, threshold = 0.01, digits = 3, nsmall = 1)
x | input sparsity value, ranging from 0 to 1.0 |
---|---|
threshold | value below which the decimal places will be rounded and printed with an inequality |
digits |
|
nsmall |
|
character
value for inserting into the dfm print output
s <- c(.9, .99, .999, .9999, .99999, .1, .01, .001, .0001, .000001, .0000001, .00000001, .000000000001, sparsity(dfm(data_corpus_inaugural)), sparsity(dfm(data_corpus_irishbudget2010)), .12312431242134) for (i in s) print(paste0(format(i, width = 10), ": ", quanteda:::format_sparsity(i)))#> [1] " 0.9: (90.0% sparse)" #> [1] " 0.99: (99.0% sparse)" #> [1] " 0.999: (99.9% sparse)" #> [1] " 0.9999: (99.99% sparse)" #> [1] " 0.99999: (>99.99% sparse)" #> [1] " 0.1: (10.0% sparse)" #> [1] " 0.01: (1.0% sparse)" #> [1] " 0.001: (0.1% sparse)" #> [1] " 1e-04: (0.01% sparse)" #> [1] " 1e-06: (<0.01% sparse)" #> [1] " 1e-07: (<0.01% sparse)" #> [1] " 1e-08: (<0.01% sparse)" #> [1] " 1e-12: (<0.01% sparse)" #> [1] " 0.9176184: (91.8% sparse)" #> [1] " 0.8117982: (81.2% sparse)" #> [1] " 0.1231243: (12.3% sparse)"#> Document-feature matrix of: 1,000 documents, 1,000 features (<0.01% sparse).#> Document-feature matrix of: 10,000 documents, 10,000 features (>99.99% sparse).