-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreddit.R
30 lines (25 loc) · 825 Bytes
/
reddit.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
# Libraries
library(RedditExtractoR)
library(radarchart)
library(tm)
library(syuzhet)
# Getting Reddit Data
links <- reddit_urls(search_terms = "CLOV", page_threshold = 20)
# User network plot
content <- reddit_content(links$URL[1])
user <- user_network(content, include_author = T, agg = TRUE)
user$plot
graph <- construct_graph(content, plot = TRUE)
# Sentiment analysis
com <- iconv(content$comment, to = 'utf-8-mac')
clov <- get_nrc_sentiment(com)
# Radar chart
x1 <- data.frame(Clover=100*colSums(clov)/sum(clov))
x2 <- data.frame(AMC=100*colSums(amc)/sum(amc))
x3 <- data.frame(GameStop=100*colSums(gme)/sum(gme))
z <- cbind(x1, x2, x3)
labs <- rownames(z)
chartJSRadar(z,
labs = labs,
labelSize = 40,
main = 'AMC Vs CLOV Vs GME: Sentiment Analysis of Reddit Comments')