Created
November 16, 2017 02:18
-
-
Save rer145/edb11422ad6ceffe220b9002fa4624d0 to your computer and use it in GitHub Desktop.
Using wordcloud2 to make dynamic wordclouds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(gutenbergr) | |
library(tidytext) | |
library(dplyr) | |
library(wordcloud2) | |
dracula<-gutenberg_download(345) | |
dracula$gutenberg_id<-NULL | |
dracula<-dracula%>% | |
unnest_tokens(word, text) | |
bing<-get_sentiments('bing') | |
dracula<-inner_join(dracula, bing) | |
words<-dracula%>% | |
group_by(word)%>% | |
summarize(count=n())%>% | |
arrange(count) | |
# Triangle shaped wordcloud | |
wordcloud2(words, shape='triangle', backgroundColor='black') | |
# Wordcloud in the shape of an image | |
wordcloud2(words, fig='bat.jpg') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment