我有一个推文数据框。给定的推文有多个句子。当我使用感测者的感悟函数时,它会为每个函数返回一个分数,如下所示:
sentiment(as.character(tweets$text[1]))$sentiment
>>> [1] 0.2474874 0.0000000
但是如果我想要整个推文的一个分数,我可以通过取平均分来实现这个效果
mean(sentiment(as.character(tweets$text[1]))$sentiment)
>>>[1] 0.1237437
所以,我想我可以将相同的逻辑应用于整个数据帧
tweets$sentiment <- mean(sentiment(as.character((tweets$text)))$sentiment)
但是...这将为所有推文返回相同的值。如果我放弃mean()
我会得到NULL
,因为有太多的句子/乐谱需要解压。
如何获得分配给数据框每一行的单个值?