forked from gargvikram07/SMMR_Twitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
comparisonCloud.R
31 lines (24 loc) · 1.02 KB
/
comparisonCloud.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
meru = paste(MeruTweetsCleaned, collapse=" ")
ola = paste(OlaTweetsCleaned, collapse=" ")
tfs = paste(TaxiForSureTweetsCleaned, collapse=" ")
uber = paste(UberTweetsCleaned, collapse=" ")
# put everything in a single vector
all = c(meru, ola, tfs, uber)
# remove stop-words
require(tm)
require(wordcloud)
all = removeWords(all,stopwords("english"))
all = removeWords(all,c("ola", "code", "app", "download", "sign","earn", "olacabs", "referral"))
all = removeWords(all,c("meru", "booking", "cabs"))
all = removeWords(all,c("you", "your", "team", "address", "taxiforsure","taxi","for","sure"))
all = removeWords(all,c("blame", "news", "uber", "delhi"))
# create corpus
corpus = Corpus(VectorSource(all))
# create term-document matrix
tdm = TermDocumentMatrix(corpus)
# convert as matrix
tdm = as.matrix(tdm)
# add column names
colnames(tdm) = c("MeruCabs", "OlaCabs", "TaxiForSure", "UberIndia")
# comparison cloud
comparison.cloud(tdm, random.order=FALSE,colors = c("#00B2FF", "red", "#FF0099", "#6600CC"), title.size=1.5, max.words=500)