library(twitteR)
library(ggplot2)
library(syuzhet)
# FIll the space with your credentials in the twitter developer
appname <- " "
key <- " "
secret <- " "
access<-" "
access_secret=" "
setup_twitter_oauth(key, secret, access, access_secret)
tweets_tech <- searchTwitter("#BUDGET_2023", n=100,lang = "en")
## data cleaning
tech_tweets <- twListToDF(tweets_tech)
tech_text<- tech_tweets$text
tech_text<- tolower(tech_text)
tech_text <- gsub("rt", "", tech_text)
tech_text <- gsub("@\\w+", "", tech_text)
tech_text <- gsub("[[:punct:]]", "", tech_text)
#getting emotions using in-built function
mysentiment_tech<-get_nrc_sentiment((tech_text))
#calculationg total score for each sentiment
Sentimentscores_tech<-data.frame(colSums(mysentiment_tech[,]))
names(Sentimentscores_tech)<-"Score"
Sentimentscores_tech<-cbind("sentiment"=rownames(Sentimentscores_tech),Sentimentscores_tech)
rownames(Sentimentscores_tech)<-NULL
#*************************************************************************************
ggplot(data=Sentimentscores_tech,aes(x=sentiment,y=Score))+
geom_bar(aes(fill=sentiment),stat = "identity")+
theme(legend.position="none")+
xlab("Sentiments")+ylab("scores")+ggtitle("Budget 2023")
l=get_nrc_sentiment('ugly')
o=get_nrc_sentiment('delay')
p=get_nrc_sentiment('trust')
p1=get_nrc_sentiment('happy')
p2=get_nrc_sentiment('sad')
p2=get_nrc_sentiment('joy')
library(twitteR)
library(ggplot2)
library(syuzhet)
# FIll the space with your credentials in the twitter developer
appname <- " "
key <- " "
secret <- " "
access<-" "
access_secret=" "
setup_twitter_oauth(key, secret, access, access_secret)
tweets_tech <- searchTwitter("#BUDGET_2023", n=100,lang = "en")
## data cleaning
tech_tweets <- twListToDF(tweets_tech)
tech_text<- tech_tweets$text
tech_text<- tolower(tech_text)
tech_text <- gsub("rt", "", tech_text)
tech_text <- gsub("@\\w+", "", tech_text)
tech_text <- gsub("[[:punct:]]", "", tech_text)
#getting emotions using in-built function
mysentiment_tech<-get_nrc_sentiment((tech_text))
#calculationg total score for each sentiment
Sentimentscores_tech<-data.frame(colSums(mysentiment_tech[,]))
names(Sentimentscores_tech)<-"Score"
Sentimentscores_tech<-cbind("sentiment"=rownames(Sentimentscores_tech),Sentimentscores_tech)
rownames(Sentimentscores_tech)<-NULL
#*************************************************************************************
ggplot(data=Sentimentscores_tech,aes(x=sentiment,y=Score))+
geom_bar(aes(fill=sentiment),stat = "identity")+
theme(legend.position="none")+
xlab("Sentiments")+ylab("scores")+ggtitle("Budget 2023")
l=get_nrc_sentiment('ugly')
o=get_nrc_sentiment('delay')
p=get_nrc_sentiment('trust')
p1=get_nrc_sentiment('happy')
p2=get_nrc_sentiment('sad')
p2=get_nrc_sentiment('joy')
library(twitteR)
library(ggplot2)
library(syuzhet)
# FIll the space with your credentials in the twitter developer
appname <- " "
key <- " "
secret <- " "
access<-" "
access_secret=" "
setup_twitter_oauth(key, secret, access, access_secret)
tweets_tech <- searchTwitter("#BUDGET_2023", n=100,lang = "en")
## data cleaning
tech_tweets <- twListToDF(tweets_tech)
tech_text<- tech_tweets$text
tech_text<- tolower(tech_text)
tech_text <- gsub("rt", "", tech_text)
tech_text <- gsub("@\\w+", "", tech_text)
tech_text <- gsub("[[:punct:]]", "", tech_text)
#getting emotions using in-built function
mysentiment_tech<-get_nrc_sentiment((tech_text))
#calculationg total score for each sentiment
Sentimentscores_tech<-data.frame(colSums(mysentiment_tech[,]))
names(Sentimentscores_tech)<-"Score"
Sentimentscores_tech<-cbind("sentiment"=rownames(Sentimentscores_tech),Sentimentscores_tech)
rownames(Sentimentscores_tech)<-NULL
#*************************************************************************************
ggplot(data=Sentimentscores_tech,aes(x=sentiment,y=Score))+
geom_bar(aes(fill=sentiment),stat = "identity")+
theme(legend.position="none")+
xlab("Sentiments")+ylab("scores")+ggtitle("Budget 2023")
l=get_nrc_sentiment('ugly')
o=get_nrc_sentiment('delay')
p=get_nrc_sentiment('trust')
p1=get_nrc_sentiment('happy')
p2=get_nrc_sentiment('sad')
p2=get_nrc_sentiment('joy')
library(twitteR)
library(ggplot2)
library(syuzhet)
# FIll the space with your credentials in the twitter developer
appname <- " "
key <- " "
secret <- " "
access<-" "
access_secret=" "
setup_twitter_oauth(key, secret, access, access_secret)
tweets_tech <- searchTwitter("#BUDGET_2023", n=100,lang = "en")
## data cleaning
tech_tweets <- twListToDF(tweets_tech)
tech_text<- tech_tweets$text
tech_text<- tolower(tech_text)
tech_text <- gsub("rt", "", tech_text)
tech_text <- gsub("@\\w+", "", tech_text)
tech_text <- gsub("[[:punct:]]", "", tech_text)
#getting emotions using in-built function
mysentiment_tech<-get_nrc_sentiment((tech_text))
#calculationg total score for each sentiment
Sentimentscores_tech<-data.frame(colSums(mysentiment_tech[,]))
names(Sentimentscores_tech)<-"Score"
Sentimentscores_tech<-cbind("sentiment"=rownames(Sentimentscores_tech),Sentimentscores_tech)
rownames(Sentimentscores_tech)<-NULL
#*************************************************************************************
ggplot(data=Sentimentscores_tech,aes(x=sentiment,y=Score))+
geom_bar(aes(fill=sentiment),stat = "identity")+
theme(legend.position="none")+
xlab("Sentiments")+ylab("scores")+ggtitle("Budget 2023")
l=get_nrc_sentiment('ugly')
o=get_nrc_sentiment('delay')
p=get_nrc_sentiment('trust')
p1=get_nrc_sentiment('happy')
p2=get_nrc_sentiment('sad')
p2=get_nrc_sentiment('joy')
library(twitteR)
library(ggplot2)
library(syuzhet)
library(tm)
# FIll the space with your credentials in the twitter developer
appname <- " "
key <- " "
secret <- " "
access<-" "
access_secret=" "
setup_twitter_oauth(key, secret, access, access_secret)
tweets_tech <- searchTwitter("BUDGET 2023", n=100,lang = "en")
a <- twListToDF(tweets_tech)
# library(tm)
corpus = iconv(a$text, "latin1", "UTF-8")
corpus<- Corpus(VectorSource(corpus))
# corpus==>Documents/Docs
# VectorSource==>vector
# a$text==> row/records
toSpace <- content_transformer(function (x , pattern ) gsub(pattern, " ", x))
docs=corpus
docs <- tm_map(docs, toSpace, "/")
docs <- tm_map(docs, toSpace, "@")
docs <- tm_map(docs, toSpace, "\\|")
corpus=docs
corpus<- tm_map(corpus,tolower)
corpus<-tm_map(corpus,removePunctuation)# remove puntuations like , .
corpus<- tm_map(corpus,removeNumbers)
cleanset<-tm_map(corpus,removeWords,stopwords('english'))# remove common words
removeURL<- function(x)gsub('http[[:alnum:]]=','',x)
cleanset<-tm_map(cleanset,content_transformer(removeURL))
x=cleanset
tdm2<-TermDocumentMatrix(cleanset)
tdm2 # display information
tdm2<-as.matrix(tdm2)
write.csv(tdm2,"tdm2.csv")
library(syuzhet)
data=read.csv("tdm2.csv")
mysentiment_tech<-get_nrc_sentiment((data$X))
#calculationg total score for each sentiment
Sentimentscores_tech<-data.frame(colSums(mysentiment_tech[,]))
names(Sentimentscores_tech)<-"Score"
Sentimentscores_tech<-cbind("sentiment"=rownames(Sentimentscores_tech),Sentimentscores_tech)
rownames(Sentimentscores_tech)<-NULL
#*************************************************************************************
ggplot(data=Sentimentscores_tech,aes(x=sentiment,y=Score))+
geom_bar(aes(fill=sentiment),stat = "identity")+
theme(legend.position="none")+
xlab("Sentiments")+ylab("scores")+ggtitle("Budget 2023")