I am currently doing sentiment analysis of twitter.
I cannot display the tweets and error says argument is of length zero. using shiny dashboard. what is wrong with this:
TABLE DATA
library(reshape)
sentimentAnalyser<-function(result)
{
#Creating a copy of result data frame
test1=result[[1]]
test2=result[[2]]
test3=result[[3]]
#Creating three different data frames for Score, Positive and Negative
#Removing text column from data frame
test1$text=NULL
test2$text=NULL
test3$text=NULL#Storing the first row(Containing the sentiment scores) in variable q osc=test1[1,] psc=test2[1,] nsc=test3[1,] oosc=melt(osc, var="Score") ppsc=melt(psc, var="Positive") nnsc=melt(nsc, var="Negative") oosc["Score"] = NULL ppsc["Positive"] = NULL nnsc["Negative"] = NULL #Creating data frame table1 = data.frame(Text=result[[1]]$text, Score=oosc) table2 = data.frame(Text=result[[2]]$text, Score=ppsc) table3 = data.frame(Text=result[[3]]$text, Score=nnsc) #Merging three data frames into one final_table=data.frame(Text=table1$Text, Score=table1$value, Positive=table2$value, Negative=table3$value) return(final_table)
}
percentage<-function(final_table)
{
#Positive Percentage#Renaming posSc=final_table$Positive negSc=final_table$Negative #Adding column final_table$PosPercent = posSc/ (posSc+negSc) #Replacing Nan with zero pp = final_table$PosPercent pp[is.nan(pp)] <- 0 final_table$PosPercent = pp*100 #Negative Percentage #Adding column final_table$NegPercent = negSc/ (posSc+negSc) #Replacing Nan with zero nn = final_table$NegPercent nn[is.nan(nn)] <- 0 final_table$NegPercent = nn*100 #write.csv(table_final,file="SentiAnalysis.csv",append = FALSE) return(final_table)
}
wordDatabase()twtList<-reactive({twtList<-searchTwitter(input$celebrityname, n=input$maxTweets, lang="en") })
tweets<-reactive({tweets<-TweetFrame(twtList() )})result<-reactive({result<-score.sentiment(tweets(), pos.words, neg.words, .progress='none')})
final_table<-reactive({final_table<-sentimentAnalyser( result() )})
table_final_percentage<-reactive({table_final_percentage<-percentage(final_table() )})output$tabledata<-renderTable(table_final_percentage())