-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjo_04_wordcloud.R
41 lines (27 loc) · 946 Bytes
/
jo_04_wordcloud.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# raw_yt_comments <- all videos with all comments
# yt_comments <- all videos with more than 100 comments
library(dplyr)
library(stringr)
load("data.Rdata")
# -------------- wordcloud -------------
# -- comparison cloud ---
library(reshape2)
tidy_yt_comments %>%
inner_join(get_sentiments("bing"), by = "word") %>%
count(word, sentiment, sort = TRUE) %>%
acast(word ~ sentiment, value.var = "nn", fill = 0) %>%
comparison.cloud(colors = c("#F8766D", "#00BFC4"),
max.words = 100)
# -- wordcloud --
library(wordcloud)
library(stringr)
library(viridis)
library(tm)
words <- toString(yt_comments$com_text) %>%
str_split(pattern = " ", simplify = TRUE)
set.seed(1645)
# wordcloud <- wordcloud(words, colors = viridis::viridis_pal(end = 0.8)(10),
# min.freq = 800, random.color = TRUE, max.words = 100,
# scale = c(3.5,.03))
wordcloud
save.image("data.Rdata")