How To: Check Frequency Weighting in Matrix Document Document, under "Topics"

I am trying to do some theme modeling using the R package topicmodels

I did some preprocessing using the "tm" package according to these instructions an R text file and a text search ... how to load the data .

However, when I go to run my Correlated Theme Model (CTM) using topicmodels

in R, I get the following error

 "Error in CTM...DocumentTermMatrix needs to have a term frequency weighting. 

      

I triple checked the structure of my DocumentTermMatrix, showing that it has a frequency weight:

 A document-term matrix (26 documents, 413 terms)

 Non-/sparse entries: 4804/5934
 Sparsity           : 55%
 Maximal term length: 13 
 Weighting          : term frequency - inverse document frequency (normalized) (tf-idf)

      

Any suggestions on how to get this job would be appreciated!

+3


source to share


1 answer


You need to specify the weightTf if you are using the slam package before:



m=as.simple_triplet_matrix(mm);
dtm <- as.DocumentTermMatrix(m,weighting =weightTf)

      

+3


source







All Articles