如何在 wordcloud R 包中添加更多可以在输出中排除的单词?
How to add more words into wordcloud R package that can be excluded in the output?
我正在使用来自 R 包存储库的包 "wordcloud" 和描述 "Word Cloud"。当我从一些随机文本创建 wordcloud 时,一些单词会自动省略,因为它们不应该是 wordcloud 的一部分。现在,我想在包中添加更多像 "this" 和 "that" 这样的词,这样它们也可以从 wordcloud 中排除。
目前,这些字词已从文本中排除:"is, to, be, I, not, a, of, out, but, who, here, how, in, some, so, that, it, because, against, Oh, by"
如果你不需要删除太多的话,你可以这样做
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)
我正在使用来自 R 包存储库的包 "wordcloud" 和描述 "Word Cloud"。当我从一些随机文本创建 wordcloud 时,一些单词会自动省略,因为它们不应该是 wordcloud 的一部分。现在,我想在包中添加更多像 "this" 和 "that" 这样的词,这样它们也可以从 wordcloud 中排除。
目前,这些字词已从文本中排除:"is, to, be, I, not, a, of, out, but, who, here, how, in, some, so, that, it, because, against, Oh, by"
如果你不需要删除太多的话,你可以这样做
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)