dgrtwo / tidy-text-mining

Manuscript of the book "Tidy Text Mining with R" by Julia Silge and David Robinson
http://tidytextmining.com
Other
1.31k stars 806 forks source link

How to filter certain words from retweet count #57

Closed tneyazi closed 5 years ago

tneyazi commented 5 years ago

I am trying to filter certain words from retweet count since i am working with mix of English and non-English tweets. Some of the words typed in English do not make sense. I used the following code, but its not working

word_by_rts %>% filter(str_detect(word_by_rts == "hrs") %>% arrange(desc(retweetCount))

The above code is written after

word_by_rts %>% filter(uses >= 5) %>% arrange(desc(retweetCount))

Could you please help>

juliasilge commented 5 years ago

Thanks so much for your interest in the book @tneyazi!

I am having a bit of trouble following your question. Are you saying you are encountering an error using code and data from the book, or using your own data?

One thing to notice is that the dataframe word_by_rts does not contain a column called word_by_rts. You might want to use a line of code that looks more like filter(str_detect(word == "hrs").

tneyazi commented 5 years ago

Thanks very much for the reply @juliasilge. This is now resolved.
Sorry that i made such a basic error.

juliasilge commented 5 years ago

No problem at all!