使用 group by [duplicate] 计算单词总数

问题描述 投票:0回答:0

我想通过

id
来计算文本组中的单词总数:

df <- data.frame(id=rep(1:3, 2), tx=c("test one. test two", "this is a test. again test", "test two", "test three times", 
                                      "test, in a future time point", "test has completed, at the final time point"))

如何实现这样的结果:

id  word count
1   7
2   12
3   10

我看了另一篇文章Count the number of all words in a string但它没有显示如何按组计算单词。

r string text data-manipulation counting
© www.soinside.com 2019 - 2024. All rights reserved.