0

I am using document term matrix of tm package in R. I faced an error saying:

Doc <- DocumentTermMatrix(Data)
Error in UseMethod("TermDocumentMatrix", x) : 

no applicable method for 'TermDocumentMatrix' applied to an object of class "table"

I tried data frame, data table, matrix and table but I faced the error again and again. Could you please tell me what should I do?

codewario
  • 19,553
  • 20
  • 90
  • 159
user36729
  • 545
  • 5
  • 30

1 Answers1

0

You missed a step... you have to create a "corpus" first...

library("tm")
txt <- c("some text", "here in this", "vector as an example")
corpus <- Corpus(VectorSource(txt))
tdm <- TermDocumentMatrix(corpus)
cory
  • 6,529
  • 3
  • 21
  • 41