Skip to content

Instantly share code, notes, and snippets.

@rer145
Created November 16, 2017 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rer145/edb11422ad6ceffe220b9002fa4624d0 to your computer and use it in GitHub Desktop.
Save rer145/edb11422ad6ceffe220b9002fa4624d0 to your computer and use it in GitHub Desktop.
Using wordcloud2 to make dynamic wordclouds
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