Sagehen_47
Sagehen_47

Reputation: 11

Getting loop error in R with vader package

I am trying to run the code below but I am getting an error

no loop for break/next, jumping to top level.

The problem seems to be with vader_df, but I am not sure what is going wrong or how I can fix it. vader_df is supposed to take a vector of text and return a dataframe of sentiment analysis for the text (although that clearly isn't happening here!).

Any help is appreciated.

library(vader)
library(tidyverse)
library(billboard)

data(lyrics)

lyrics <- lyrics %>%
  rename(song_lyrics = lyrics)

sentiment_lyrics <- vader_df(lyrics$song_lyrics, neu_set = F)

Upvotes: 1

Views: 227

Answers (1)

help-info.de
help-info.de

Reputation: 7298

Please note you have a dataset of 5701 records.

> summary(lyrics)
    title              artist              year           song_lyrics       
 Length:5701        Length:5701        Length:5701        Length:5701       
 Class :character   Class :character   Class :character   Class :character  
 Mode  :character   Mode  :character   Mode  :character   Mode  :character  

Analyzing 100 of these song_lyrics takes almost 38 seconds on my machine (Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz 3.60 GHz). This means about 36 minutes for all data sets.

> format(Sys.time(), "%a %b %d %X %Y")
[1] "Di Nov 23 15:47:57 2021"
> sentiment_lyrics <- vader_df(lyrics$song_lyrics[1:100], neu_set = TRUE)
> format(Sys.time(), "%a %b %d %X %Y")
[1] "Di Nov 23 15:48:35 2021"

For me the vader_df function processes only using neu_set = TRUE for this test case.

If it is possible for your requirements, just count the neutral words by the default value neu_set = TRUE and gradually increase the processed number of texts.

Upvotes: 0

Related Questions