Skip to content

filtering out unwanted words in a Term Document Matrix

1 message · Ingo Feinerer

#
You can directly subset the matrix, e.g.:

library(tm)
data(crude)
m <- TermDocumentMatrix(crude)
z <- m[c("oil", "zone"),]
inspect(z)

Ensure that you only try to subset for terms occurring in the matrix
as otherwise it will not work. You can get all terms via Terms(m).

Best regards,
  Ingo Feinerer