Compute entropy of documents or features

textstat_entropy(x, margin = c("documents", "features"), base = 2)

Arguments

x

a dfm

margin

character indicating for which margin to compute entropy

base

base for logarithm function

Examples

textstat_entropy(data_dfm_lbgexample)
#> R1 R2 R3 R4 R5 V1 #> 3.386943 3.386943 3.386943 3.386943 3.386943 3.386943
textstat_entropy(data_dfm_lbgexample, "features")
#> A B C D E F G H #> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.1686609 0.1708952 0.4371120 #> I J K L M N O P #> 0.6476138 1.0338027 1.4131631 1.5669101 1.5996467 1.5656144 1.5806321 1.6267307 #> Q R S T U V W X #> 1.6414915 1.6034693 1.5561626 1.5311306 1.4979274 1.3664642 1.1291805 1.0439334 #> Y Z ZA ZB ZC ZD ZE ZF #> 1.0338027 1.0726302 1.0458291 0.7876499 0.5357150 0.3435197 0.1708952 0.1686609 #> ZG ZH ZI ZJ ZK #> 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000