library(twitteR)
## Warning: package 'twitteR' was built under R version 3.5.3
library(ROAuth)
## Warning: package 'ROAuth' was built under R version 3.5.3
library(base64enc)
library(httpuv)
## Warning: package 'httpuv' was built under R version 3.5.3
cred <- OAuthFactory$new(consumerKey="WbRiXIgVtyCJoJ5xvPFSb4Bj9 ",
consumerSecret="9kNUFBNGq1WtOnpY9ggzImmZ0A6I6nzIOXfqTJO7wJxUXJrkrU ",
requestURL="https://api.twitter.com/oauth/request_token",
accessURL="https://api.twitter.com/oauth/access_token",
authURL="https://api.twitter.com/oauth/authorize")
save(cred, file="twitter authentication.Rdata")
load("twitter authentication.Rdata")
setup_twitter_oauth("WbRiXIgVtyCJoJ5xvPFSb4Bj9",
"9kNUFBNGq1WtOnpY9ggzImmZ0A6I6nzIOXfqTJO7wJxUXJrkrU",
"2524690621-D1gbIXODKhxXkdbns3fUyf004ij713h6aHwlkaq", ##### Access token
"lZ3ZOcMzHgUKsQ2X5mOWZKvo9mw5SsEw1zlqq4EO31LXH") ##### Access token secret key
## [1] "Using direct authentication"
Tweets <- userTimeline('BillGAtes', n = 100)
TweetsDF <- twListToDF(Tweets)
write.csv(TweetsDF, "BillGates.csv")
BillGates_tweets <- searchTwitter('BillGates', n=1000, lang="en", resultType = 'recent')
class(BillGates_tweets)
## [1] "list"
BillGates_tweets[1:20]
## [[1]]
## [1] "immatrl: hey @BillGates I know u been busy and shit but u know, u kinda could help the whole planet so why don't u just give… https://t.co/2Ka6gyv7Bf"
##
## [[2]]
## [1] "lovereignssupr1: @thereal_truther @Untriv_Pursuit @BillGates .. actually you're the perfect person to ask. May I inquire: what are… https://t.co/zbwQhM73LV"
##
## [[3]]
## [1] "KiranG32468907: @GcReforms @SenatorDurbin @SenateDems @KamalaHarris @BradSmi @JeffBezos @BillGates @iamjohnoliver @TheDailyShow… https://t.co/E7PezK9zfo"
##
## [[4]]
## [1] "GreekUte: @BillGates this is an amazing invention!! Maybe Moses West can help your foundation fix the water crisis.… https://t.co/dmFkOmcUO2"
##
## [[5]]
## [1] "Just4TheCause: RT @Untriv_Pursuit: @BillGates Ummmm ... Science is neither a belief nor magic. And for a global scientific funder like yourself to refer t…"
##
## [[6]]
## [1] "JuliaMeseure: @BillGates Would like to read yr notes"
##
## [[7]]
## [1] "lovereignssupr1: @thereal_truther @Untriv_Pursuit @BillGates I was making a joke. Carry on!"
##
## [[8]]
## [1] "RajgureVijay: @BillGates @GlobalFund Good work"
##
## [[9]]
## [1] "PatrickEnrigh20: @InsideVaccines @uknowmorethani @Untriv_Pursuit @BillGates He’s right up there with Thomas Edison and Louis Pasteu… https://t.co/d9l9hE7UoA"
##
## [[10]]
## [1] "chachomanopapa: @xijingping @PutinRF @washingtonpost @uriminzok @nbc @DerSPIEGEL @lemondefr @CNN @MSNBC @realDonaldTrump @Twitter… https://t.co/y4eEo4MVW4"
##
## [[11]]
## [1] "webdad3: Watching the #BillGates netflix show. \n\nI wish I enjoyed reading and was good at it."
##
## [[12]]
## [1] "thereal_truther: @lovereignssupr1 @Untriv_Pursuit @BillGates So you're saying a random Twitter user understands science better than… https://t.co/yx8GZPNQBj"
##
## [[13]]
## [1] "SIverySendBooks: @BillGates @GlobalFund @marklevinshow @usedgov @realBestyDeVos @SenStabenow @ChelseaClinton @SenatorCollins… https://t.co/4t3ck5cMUN"
##
## [[14]]
## [1] "thereal_truther: @PatrickEnrigh20 @Untriv_Pursuit @BillGates I don't have much understanding of money outside of the massive profits… https://t.co/nfYDPd4vKx"
##
## [[15]]
## [1] "TierneyWillia15: @BillGates there are real issues to be address in the world - and judging others and other countries too much- his… https://t.co/5Q0J9T2Qo3"
##
## [[16]]
## [1] "patatpqs13: @JeffBezos @BillGates D question all will have is R we 2 small 2 even consider&Y would U ever pic a Ma&Pa&that U mu… https://t.co/6AlMbsStmu"
##
## [[17]]
## [1] "PatrickEnrigh20: @thereal_truther @Untriv_Pursuit @BillGates A tweet made by a person who understands money far more than he underst… https://t.co/xnd40jzUPn"
##
## [[18]]
## [1] "AR25460413: Its for a great purpose! The tools to build up peace and serenity and to recycle every thing we can, to reinvent th… https://t.co/4YM8gn1fJr"
##
## [[19]]
## [1] "LetUsFallov: Good night, @POTUS @WhiteHouse @realDonaldTrump @HillaryClinton @BillClinton @BarackObama @JeffBezos @BillGates… https://t.co/M4ayjiJ5r6"
##
## [[20]]
## [1] "MazymMary: @Untriv_Pursuit @BillGates False idol"
BillGates_txt <- sapply(BillGates_tweets, function(x) x$getText())
str(BillGates_txt)
## chr [1:1000] "hey @BillGates I know u been busy and shit but u know, u kinda could help the whole planet so why don't u just "| __truncated__ ...
library(tm)
## Warning: package 'tm' was built under R version 3.5.3
## Loading required package: NLP
library(SnowballC)
BillGates_corpus <- Corpus(VectorSource(BillGates_txt))
inspect(BillGates_corpus[10])
## <<SimpleCorpus>>
## Metadata: corpus specific: 1, document level (indexed): 0
## Content: documents: 1
##
## [1] @xijingping @PutinRF @washingtonpost @uriminzok @nbc @DerSPIEGEL @lemondefr @CNN @MSNBC @realDonaldTrump @Twitter… https://t.co/y4eEo4MVW4
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 3.5.3
## -- Attaching packages --------------------------- tidyverse 1.2.1 --
## v ggplot2 3.2.1 v purrr 0.3.2
## v tibble 2.1.3 v dplyr 0.8.3
## v tidyr 1.0.0 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.4.0
## Warning: package 'ggplot2' was built under R version 3.5.3
## Warning: package 'tibble' was built under R version 3.5.3
## Warning: package 'tidyr' was built under R version 3.5.3
## Warning: package 'readr' was built under R version 3.5.3
## Warning: package 'purrr' was built under R version 3.5.3
## Warning: package 'dplyr' was built under R version 3.5.3
## Warning: package 'forcats' was built under R version 3.5.3
## -- Conflicts ------------------------------ tidyverse_conflicts() --
## x ggplot2::annotate() masks NLP::annotate()
## x dplyr::filter() masks stats::filter()
## x dplyr::id() masks twitteR::id()
## x dplyr::lag() masks stats::lag()
## x dplyr::location() masks twitteR::location()
BillGates_clean <- tm_map(BillGates_corpus, removePunctuation)
## Warning in tm_map.SimpleCorpus(BillGates_corpus, removePunctuation):
## transformation drops documents
BillGates_clean <- tm_map(BillGates_clean, content_transformer(tolower))
## Warning in tm_map.SimpleCorpus(BillGates_clean,
## content_transformer(tolower)): transformation drops documents
BillGates_clean <- tm_map(BillGates_clean, removeWords, stopwords("english"))
## Warning in tm_map.SimpleCorpus(BillGates_clean, removeWords,
## stopwords("english")): transformation drops documents
BillGates_clean <- tm_map(BillGates_clean, removeNumbers)
## Warning in tm_map.SimpleCorpus(BillGates_clean, removeNumbers):
## transformation drops documents
BillGates_clean <- tm_map(BillGates_clean, stemDocument)
## Warning in tm_map.SimpleCorpus(BillGates_clean, stemDocument):
## transformation drops documents
BillGates_clean <- tm_map(BillGates_clean, stripWhitespace)
## Warning in tm_map.SimpleCorpus(BillGates_clean, stripWhitespace):
## transformation drops documents
inspect(BillGates_clean[3])
## <<SimpleCorpus>>
## Metadata: corpus specific: 1, document level (indexed): 0
## Content: documents: 1
##
## [1] gcreform senatordurbin senatedem kamalaharri bradsmi jeffbezo billgat iamjohnoliv thedailyshow… httpstcoepezkzfo
class(BillGates_clean)
## [1] "SimpleCorpus" "Corpus"
######## term document matrix
tdm <- TermDocumentMatrix(BillGates_clean)
tdm
## <<TermDocumentMatrix (terms: 3023, documents: 1000)>>
## Non-/sparse entries: 10524/3012476
## Sparsity : 100%
## Maximal term length: 40
## Weighting : term frequency (tf)
tdm_rmsparse <- removeSparseTerms(x = tdm, sparse = 0.98 )
tdm_rmsparse
## <<TermDocumentMatrix (terms: 70, documents: 1000)>>
## Non-/sparse entries: 3745/66255
## Sparsity : 95%
## Maximal term length: 15
## Weighting : term frequency (tf)
tdm <- as.matrix(tdm_rmsparse)
tdm[1:20,1:20]
## Docs
## Terms 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## billgat 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 1
## help 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## just 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## know 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## untrivpursuit 0 1 0 0 1 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1
## … 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0
## jeffbezo 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0
## can 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
## belief 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## funder 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## global 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## like 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## magic 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## neither 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## refer 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## scienc 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
## scientif 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## t… 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## ummmm 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## globalfund 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0
v <- sort(rowSums(tdm), decreasing=T)
head(v)
## billgat globalfund … can work world
## 736 211 165 104 94 73
s <- rowSums(tdm)
s_sub <- subset(s,s > 10)
barplot(s_sub,col = rainbow(10),las = 3)

library(wordcloud)
## Warning: package 'wordcloud' was built under R version 3.5.3
## Loading required package: RColorBrewer
windows()
wordcloud(words = BillGates_clean,random.order = F,col = rainbow(30),random.color = F,
max.freq =80,scale = c(3,1),rot.per = 0.5,max.words =100 )
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter
## Warning in strwidth(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in strheight(words[i], cex = size[i], ...): "max.freq" is not a
## graphical parameter
## Warning in text.default(x1, y1, words[i], cex = size[i], offset = 0, srt =
## rotWord * : "max.freq" is not a graphical parameter

BillGates_clean <- tm_map(BillGates_clean, removeWords, c("...","billgat","sapink","mani"))
## Warning in tm_map.SimpleCorpus(BillGates_clean, removeWords, c("...",
## "billgat", : transformation drops documents
#emotion mining
library(syuzhet)
## Warning: package 'syuzhet' was built under R version 3.5.3
library(lubridate)
## Warning: package 'lubridate' was built under R version 3.5.3
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
library(ggplot2)
library(scales)
##
## Attaching package: 'scales'
## The following object is masked from 'package:syuzhet':
##
## rescale
## The following object is masked from 'package:purrr':
##
## discard
## The following object is masked from 'package:readr':
##
## col_factor
library(dplyr)
library(reshape2)
##
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
##
## smiths
txt = readLines(file.choose())
txt <- iconv(txt, "UTF-8")
?iconv
## starting httpd help server ...
## done
x <- get_nrc_sentiment(txt)

head(x,n=20)
## anger anticipation disgust fear joy sadness surprise trust negative
## 1 0 0 0 0 0 0 0 0 0
## 2 0 0 0 0 0 0 0 0 0
## 3 0 0 0 0 0 0 0 0 0
## 4 0 0 0 0 0 0 0 0 0
## 5 0 0 0 0 0 0 0 0 0
## 6 0 0 0 0 0 0 0 0 0
## 7 0 0 0 0 0 0 0 0 0
## 8 0 0 0 0 0 0 0 0 0
## 9 0 0 0 0 0 0 0 0 0
## 10 0 0 0 0 0 0 0 0 0
## 11 0 0 0 0 0 0 0 0 0
## 12 0 0 0 0 0 0 0 0 0
## 13 0 0 0 0 0 0 0 0 0
## 14 0 0 0 0 0 0 0 0 0
## 15 0 0 0 0 0 0 0 0 0
## 16 0 0 0 0 0 0 0 0 0
## 17 0 0 0 0 0 0 0 0 0
## 18 0 0 0 0 0 0 0 0 0
## 19 0 0 0 0 0 0 0 0 0
## 20 0 0 0 0 0 0 0 0 0
## positive
## 1 0
## 2 0
## 3 0
## 4 0
## 5 0
## 6 0
## 7 0
## 8 0
## 9 0
## 10 0
## 11 0
## 12 0
## 13 0
## 14 0
## 15 0
## 16 0
## 17 0
## 18 0
## 19 0
## 20 0
example<-get_sentences(txt)
nrc_data<-get_nrc_sentiment(example)
# Bar plot for emotion mining
windows()
barplot(colSums(nrc_data), las = 2, col = rainbow(10), ylab = 'Count', main = 'Emotion scores')

sentiment_nrc<-get_sentiment(example,method="nrc")
# Most Negative and Positive tweet
negative<-example[which.min(sentiment_nrc)]
positive<-example[which.max(sentiment_nrc)]