1

I was able to run the code below to extract tweets using the hashtag "rstats".

Now is there a way to extract tweets for ONLY '#rstats". So that '#rstats' is the only hashtag in the tweet?

I want to scrape tweets that have ONE and only ONE specific hashtag..

I was thinking something like using a count function to count hashtags where it equals 1 and equals a specific 'hashtag value"

## search for 500 tweets using the #rstats hashtag
rstats_tweets <- search_tweets(q = "#rstats",
                           n = 500)
# view the first 3 rows of the dataframe
head(rstats_tweets, n = 3)
Phil
  • 7,287
  • 3
  • 36
  • 66
FredNina
  • 11
  • 3
  • `library(stringr)` provides some useful functions for string operations. For example `str_count(df, content, "#")` counts the `#` for every value of column `content` in data.frame `df`. For a more precise answer, please provide a a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) or [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) with a sample input and your expected output. This is needed to create, test and verify possible solutions. – Martin Gal Oct 23 '21 at 22:45
  • @MartinGal Thanks. Will look into that. I also edited my question. Cheers – FredNina Oct 24 '21 at 12:44

0 Answers0