r - dplyr mutate 抛出 "Error: invalid subscript type ' 闭包'"错误

标签 r dplyr sentimentr

我正在尝试将情感R中的sentiment_by与dplyr的mutate一起使用

这例如有效: content <- mutate(content, word_count = sentiment_by(story)$word_count)

但是

这例如有效: content.sd <- mutate(content, word_count = sentiment_by(story)$sd)

给出错误错误:invalid subscript type 'closure'

但是sentiment_by(content$story[1])作品

任何帮助将不胜感激。

最佳答案

您可以使用以下内容代替

content <- mutate(content, stdev = sentiment_by(story)[["sd"]])

关于r - dplyr mutate 抛出 "Error: invalid subscript type ' 闭包'"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42537071/

相关文章:

r - 使用 dplyr 管道将 for 循环的输出提取到 R 中的数据帧中

r - 尝试将单词列表与 R 中的句子列表匹配时出现性能问题

r - 通过R中的方式组合具有重复ID的行

r - 从 auto.arima 生成的漂移模型(预测包)获取一步预测时出错

r - 更改列的顺序

r - 创建一个列,该列采用另一列的第一个值,后续值是前一个值的缩放比例

r - Group_by 然后用 dplyr 过滤

r - 根据多行条件过滤掉案例