我正在从kaggle复制以下代码
我收到错误均值错误:未找到对象“得分”对于我的一生,我无法弄清楚,我是r的新手,我正在练习代码,请帮助
calculate_sentiment <- function(review_text)
{
sentiment_lines = review_text %>%
unnest_tokens(word, text) %>%
inner_join(get_sentiments("afinn"), by = "word") %>%
group_by(postID) %>%
summarize(sentiment = mean(score),words = n()) %>%
ungroup() %>%
filter(words >= 5) %>%
arrange(desc(sentiment))
return(sentiment_lines)
}
sentiment_lines = calculate_sentiment(scripts)
由于缺少可复制的示例,我想您可能会在这里找到答案:https://www.kaggle.com/ambarish/seinfeld-text-mining-wordembeddings-modelling
行:846-851。更具体地说,在850行中:
summarize(score = sum(score * n) / sum(n)) %>%
尝试使用上面的函数中的代码来代替您的代码。