Spaces in wordcloud

↘锁芯ラ 提交于 2019-12-05 11:53:08

You asked two questions:

  1. You can control the capitalisation (or not) by specifying a control argument to TermDocumentMatrix
  2. No doubt there is an argument somewhere to control the ~, but here is an easy workaround: Use gsub to change ~ to white space in the step just before plotting.

Some code:

corpus <- Corpus(VectorSource(y))
tdm <- TermDocumentMatrix(corpus, control=list(tolower=FALSE)) ## Edit 1

m <- as.matrix(tdm)
v <- sort(rowSums(m), decreasing = TRUE)
d <- data.frame(word = names(v), freq = v)
d$word <- gsub("~", " ", d$word) ## Edit 2

wordcloud(d$word, d$freq)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!