Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wordcloud package: get "Error in strwidth(...) : invalid 'cex' value"

Tags:

tm

I am using the tm and wordcloud packages in R 2.15.1. I am trying to make a word cloud from a DTM. Here is the code:

library(wordcloud)
thedtmsparse = inspect(sparse)
trymatrix = t(thedtmsparse)
colnames(trymatrix) = c()
comparison.cloud(trymatrix, max.words=15, random.order=FALSE)

I get the following error from the last command:

Error in strwidth(words[i], cex = size[i], ...) : invalid 'cex' value

I have used the same code on another DTM where it worked fine and I got the word cloud. Can somebody tell me a fix for the error?

Ravi

like image 499
user1667628 Avatar asked Sep 13 '12 06:09

user1667628


1 Answers

You haven't provided reproducible code (probably a big reason no one answered your question), so I can only venture to guess what the problem might be.

I faced this same error, so I'll share my experience. The problem was I had NA's instead of 0's in my term document matrix. Simply fixing that fixed that problem.

like image 149
sph21 Avatar answered Oct 13 '22 09:10

sph21