I'm fairly new to R. I'm trying to do a sentiment analysis using the bing lexicon. I've tried to find a solution for my problem, but I wasn't able to apply it to my data.
I'm trying to count the positive words in my data, which consists of 401 hotel reviews. Each review has its own row. I want my output to be columns of the review ID, the review itself, and the count of how many positive words are for each ID.
This is my code so far.
pos.wordcount <- function(id,review,count)
{
for(i in 1:401)
reviews.pos <- Corpus(VectorSource(reviews$Reviews[1]))
id <- c(1:401)
sentence <- reviews$Reviews[1:401]
id.reviews <- data.frame(id,sentence)
pos.wordcount <- str_count(sentence,as.character(bing.pos))
return(pos.wordcount)
}
I haven't been able to go much further because I get this error: Error: no function to return from, jumping to top level