Sentiment Analysis in R

Are there any R packages that focus on sentiment analysis? I have a small survey where users can write a comment about their experience of using a web-tool. I ask for a numerical ranking, and there is the option of including a comment.

What is the best way of assessing the positivity or negativity of the comment? I want to compare the numerical ranking that the user provides, using R.

R packages for sentiment analysis include sentimentr and sentimentanalysis found on CRAN. Another way to do sentiment analysis is to use Viral Hearts API found here.

These packages allow have Bayesian classifiers such as Naive Bayes to help you in classifying emotions or positivity/negativity of your comments.

This here is sample implementation of how to do this in R:

# Create small vectors for happy and sad words (useful in aggregate(...) function)
positive <- c('happy', 'well-off', 'good', 'happiness')
negative <- c('sad', 'bad', 'miserable', 'terrible')

# Words to test sentiment
test <- c('I am a very happy person.', 'I am a very sad person', 
'I’ve always understood happiness to be appreciation. There is no greater happiness than appreciation for what one has- both physically and in the way of relationships and ideologies. The unhappy seek that which they do not have and can not fully appreciate the things around them. I don’t expect much from life. I don’t need a high paying job, a big house or fancy cars. I simply wish to be able to live my life appreciating everything around me. 
')
#Classify is the name for the packages object
 2. Naive Bayes
out <- classify.naivebayes(test)
out

This is highly subjective. The best way is the one that has the best performance in your dynamic. However, an objective approach is an exhaustive approach because it generalizes well.

Have a wide list of positive and negative words so that you can cater to all possibilities. You can use this resource on sentiment lists.