“polarity” function in R – Suggested use of `sentSplit` function.

Below is a warning message that came up while using “polarity” function of “qdap” package for Sentiment Analysis in R.

Warning message:

Some rows contain double punctuation.  Suggested use of `sentSplit` function.

Reason:

As it sounds obvious with the warning message, there are punctuations in the data that need to be cleaned up before words can be parsed for sentiment analysis.

R line of code that gave error is

> sentiments = polarity(dataframe.name$column.name) 

Fix:

Include cleanup functions as suggested below, before the data is passed to “polarity” function.

> library(tm)
> sentiments = polarity(removePunctuation(removeNumbers(tolower
(dataframe.name$column.name))))
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s