0

I'm using package "wordcloud" with description "Word Cloud" from the R Packages repository. When I create wordcloud from some random text, some words are omitted automatically as they should not be a part of wordcloud. Now, I want to add more words like "this" and "that" to the package so they get excluded from wordcloud as well.

Currently, these words are being excluded from text: "is, to, be, I, not, a, of, out, but, who, here, how, in, some, so, that, it, because, against, Oh, by"

Grimlock
  • 1,033
  • 1
  • 9
  • 23
  • You could improve your question. Please read [how to provide minimal reproducible examples in R](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example#answer-5963610). Then edit & improve it accordingly. Or at least respect that for future postings. A good post usually provides minimal input data, the desired output data & code tries - all copy-paste-run'able in a new/clean R session. – lukeA Oct 07 '16 at 14:37
  • 1
    I will keep this in mind from now on. – Grimlock Oct 07 '16 at 14:42

1 Answers1

2

If you don't have to many words to be removed, you can do

set.seed(1)
library(wordcloud)
stopwords <- c("my", "foo", "buzz")
txt <- "hello world. hello my world again. Foo bar fizz buzz."
clean <- gsub(paste(stopwords, collapse="|"), "", txt, ignore.case = TRUE)
par(mfrow = c(1,2))
wordcloud(txt)
wordcloud(clean)

enter image description here

lukeA
  • 53,097
  • 5
  • 97
  • 100
  • Can you look at a new question I just asked? it is somewhat similar to this one. [link](http://stackoverflow.com/questions/39921598/how-to-remove-words-from-wordcloud-r-package-so-that-they-can-be-included-in-the) – Grimlock Oct 07 '16 at 16:23