如何解决如何根据R中的条件绘制比较云?
我的Twitter数据的“文字”和“国家/地区”列,并希望绘制一个字云,其中的颜色会因国家/地区而异。类似于此处的第二个单词云:https://quanteda.io/articles/pkgdown/examples/plotting.html
# create a table with tweets and Country
tweets_country <- uk_tweets %>%
select(Country,text)
# combine tweets by country
tweets_country <- tweets_country %>%
group_by(Country) %>%
summarise(text = paste(text,collapse = " "))
# remove unknown locations
tweets_country <- tweets_country[-c(5),]
# create a corpus
corp_tweets <- corpus(tweets_country) %>%
print(corp_tweets)
# change document names to each country
docid <- paste(tweets_country$Country,sep = " ")
docnames(corp_tweets) <- docid
print(corp_tweets)
corp_sub <- corpus_subset(corp_tweets,Country %in% c('England','Scotland','Northern Island','Wales'))
dfmat2 <- dfm(corpus_subset(corp_sub,Country %in% c("England","Scotland","Northern Island","Wales")),remove = stopwords("english"),remove_punct = TRUE,groups = "Country") %>%
dfm_trim(min_termfreq = 3)
extplot_wordcloud(dfmat2,comparison = TRUE,max_words = 300,color = c("blue","red","green","purple"))
我尝试了多个代码,每次我得到一个不同的错误(包括创建语料库时的错误)时,也会出现此错误: 不建议使用“ structure(NULL,*)”,因为NULL不能具有属性。 请考虑使用“ structure(list(),*)”。x [[length(x)]]中的错误: 尝试在integerOneIndex中选择少于一个元素
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。