I'm using Rapidminer, and after a Wordlist to Data operator, I want to create a word cloud with Execute R using the script below. I get the R execution failure: "no applicable method for 'TermDoumentMatrix' applied to an object of class \"c('data.table', data.frame')\".
The datatable has a column of words, a column of document occurrences, and a column of word occurrences.
Can anyone advise please how I resolve the error?
rm_main = function(data)
{
wordcloud::wordcloud(data, scale=c(5,0.5), max.words=100, random.order=FALSE,
rot.per=0.35, use.r.layout=FALSE, colors="Dark2")
}
Passing the whole data frame
data
as 1st argument towordcloud
does not work. (In fact it would work, if it was an object of typetermDocumentMatrix
, which is part of R'stm
package, but that's another story; however that's what the error message is about.) From within RapidMiner you have to specify the words and their frequency as 1st and 2nd parameter respectively.So you could use something like
Here's an example process, which creates a word cloud, saves it to "c:\mywordcloud.pdf" and opens it (on Windows) with the default application that is associated with .pdf files: