I am trying to do some very basic text analysis with the tm package and get some tf-idf scores; I\'m running OS X (though I\'ve tried this on Debian Squeeze with the same result
If you look at the DocumentTermMatrix
help page, an at the example, you will see that the control
argument is specified this way :
data(crude)
dtm <- DocumentTermMatrix(crude,
control = list(weighting = function(x) weightTfIdf(x, normalize = FALSE),
stopwords = TRUE))
So, the weighting is specified with the list element named weighting
, not weight
. And you can specify this weighting by passing a function name or a custom function, as in the example. But the following works too :
data(crude)
dtm <- DocumentTermMatrix(crude, control = list(weighting = weightTfIdf))