Jake
Jake

Reputation: 21

Sentiment Analysis Of A Dataset With Multiple NewsPaper Articles

I'm trying to call get_nrc_sentiment in R but getting the following error:

Error in get_nrc_sentiment(Test) : Data must be a character vector.

Can anyone see what I'm doing wrong?

library("RDSTK")
library("readr")
library("qdap")
library("syuzhet")
library("ggplot2")

library(readxl)
Test <- read_excel("Test.xlsx")
View(Test)

scores = get_nrc_sentiment(Test) //throwing error

Upvotes: 0

Views: 241

Answers (1)

xilliam
xilliam

Reputation: 2259

I suspect that the Test.xlsx file your are reading in has multiple columns. In that case, the Test object would not be a character vector, but a dataframe. Putting the dataframe object into the get_nrc_sentiment() causes the error. You can check test with class(Test) to determine what kind of R object it is.

Upvotes: 1

Related Questions