I am trying to use nrguimaraes's VADER sentiment tool on R to get the sentiment scores of several tweets. The description of the tool and how to install it is described here: https://rdrr.io/github/nrguimaraes/sentimentSetsR/man/getVaderRuleBasedSentiment.html
However, when I try to process more than one element, it comes out with an error. I would like to edit the function so that it is able to handle several elements.
The function is:
function (text, compound = TRUE)
{
text <- iconv(text, to = "UTF-8")
text <- gsub("\\p{So}|\\p{Cn}", "", text, perl = TRUE)
text <- gsub("\\s+", " ", text)
if (is.na(text)) {
return(NA)
}
if (text == "" || text == " ") {
return(NA)
}
return(PolarityScores(text, compound))
}
So when I run
getVaderRuleBasedSentiment(file$text)
The error comes out as
Warning message:
In if (is.na(text)) { :
the condition has length > 1 and only the first element will be used
I'm wondering how I can edit this function to be able to handle data that has several rows of texts, such as when you collect tweets using Rtweet.