I want to count the total number of words in text group by 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"))
How do I achieve a result like this:
id word count
1 7
2 12
3 10
I looked at the other post Count the number of all words in a string but it doesn't show how to count words by groups.