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))