0

I have already generated a termDocumentMatrix as showed below:

> tmm
[[1]]
<<DocumentTermMatrix (documents: 18, terms: 4886)>>
Non-/sparse entries: 11956/75992
Sparsity           : 86%
Maximal term length: 25
Weighting          : term frequency (tf)

Then I want to convert it to numeric matrix, it shows an error. The command I use is:

matrix<-data.matrix(tmm)

Then the matrix become a list like this:

list(i = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,                                                                                       

Where did I got wrong?

micstr
  • 5,080
  • 8
  • 48
  • 76
user3746295
  • 101
  • 2
  • 11
  • 1
    What version of `tm` are you using? Did you try just `as.matrix`? – MrFlick Jul 17 '14 at 17:33
  • Actually, taking another look there the `[[1]]` indicates you probably don't have a document term matrix, you have a **list** that has a document term matrix. What about `as.matrix(tmm[[1]])`. – MrFlick Jul 18 '14 at 01:03

1 Answers1

0

You could try this

matrix <- as.matrix(inspect(tmm))
Vishnu
  • 23
  • 4