trinker/sentimentr

valence_shifters not found

MsPhotonUIUC opened this issue · 1 comments

I am getting this issue when I run my code:

simple code:
emotion(text, emotion_dt = lexicon::hash_nrc_emotions,
valence_shifters_dt = lexicon::hash_valence_shifters,
drop.unused.emotions = FALSE, un.as.negation = TRUE,
un.as.negation.warn = isTRUE(all.equal(valence_shifters_dt,
lexicon::hash_nrc_emotions)), n.before = 5, n.after = 2)

Error:
Error in all.equal(valence_shifters_dt, lexicon::hash_nrc_emotions) :
object 'valence_shifters_dt' not found

How do I import/access the valence shifters lexicon?

Because you copied arguments from the function which allows other arguments to be self referenced (e.g., valence_shifters_dt) but not when you add them as an argument after the = sign.

If you swap the valence_shifters_dt for lexicon::hash_valence_shifters inside the all.equal then this works:

text <- "i hate grilled cheese!"

emotion(text, emotion_dt = lexicon::hash_nrc_emotions,
valence_shifters_dt = lexicon::hash_valence_shifters,
drop.unused.emotions = FALSE, un.as.negation = TRUE,
un.as.negation.warn = isTRUE(all.equal(lexicon::hash_valence_shifters,
lexicon::hash_nrc_emotions)), n.before = 5, n.after = 2)