Skip to contents

Convert a quanteda::dfm of counts to the document-level word proportions expected by OpTop::optimal_topic().

Usage

as_optop_weighted_dfm(x)

Arguments

x

A quanteda::dfm object.

Value

A quanteda::dfm with rows weighted to document-level proportions.

Examples

dfmat <- quanteda::dfm(quanteda::tokens(c(doc1 = "a a b", doc2 = "b c")))
as_optop_weighted_dfm(dfmat)
#> Document-feature matrix of: 2 documents, 3 features (33.33% sparse) and 0 docvars.
#>       features
#> docs           a         b   c
#>   doc1 0.6666667 0.3333333 0  
#>   doc2 0         0.5000000 0.5