I am working on a sentiment analysis on Twitter, using rtweet package on Rstudio.
At first, I wanted to get 1000 tweets from Twitter using this function from rtweet package which worked fine:
Onlinesc <- search_tweets("online schooling", n=1000, include_rts = FALSE, retryonratelimit = TRUE)
Onlinesc$text
After that, no matter how many times I change the number of tweets I want to view, it sill displays the same 1000 tweets it displayed previously. I think it is saved somewhere in the program and is preventing the console from showing new results.
What I've tried:
- Clearing the environment and history of Rstudio every time before I run the code
- Creating a new R script
- Restarting Rstudio and my computer
- Reloading packages
- I used a function from twitteR package to extract Tweets but ended up facing the same issue
- Regenerated my Twitter developer tokens and updated my Twitter Oauth several times
I am using Rstudio Version 1.3.1093
Any help will be highly appreciated :)
I'm assuming this has to do with the retryonratelimit argument.
I ran your code for retrieving 1000 tweets and saw that the df it produced was 1408 tweets long. Keeping the code the same, but changing n to 500, it produced an identical dataframe of 1408 tweets instead of 500.
I don't know what's up with getting 999 tweets instead of 1000 in the first call of my code with retryonratelimit set to false, but my call specifying n=500 got me 500 tweets just fine.
Here's my code.