Sanil Mhatre walks us through a sentiment analysis scenario in R:
Comments closedSentiments can be classified as positive, neutral or negative. They can also be represented on a numeric scale, to better express the degree of positive or negative strength of the sentiment contained in a body of text.
This example uses the Syuzhet package for generating sentiment scores, which has four sentiment dictionaries and offers a method for accessing the sentiment extraction tool developed in the NLP group at Stanford. The
get_sentiment
function accepts two arguments: a character vector (of sentences or words) and a method. The selected method determines which of the four available sentiment extraction methods will be used. The four methods aresyuzhet
(this is the default),bing
,afinn
andnrc
. Each method uses a different scale and hence returns slightly different results. Please note the outcome ofnrc
method is more than just a numeric score, requires additional interpretations and is out of scope for this article. The descriptions of theget_sentiment
function has been sourced from : https://cran.r-project.org/web/packages/syuzhet/vignettes/syuzhet-vignette.html?