9/25/2023 4 Comments Search tweets by date![]() If that date is after the conference started, request more tweets. So check the earliest date in your tweet data frame. One thing to remember: If you’re following a conference hashtag during a conference, you will want to pull enough tweets to get the whole conference. If you’ve been following along, you should have your own interactive table that can search, sort, and filter conference or topic tweets. And it’s not necessary to search and sort the tweets you can always click to the original tweet and see clickable links there.įinally, I can run my customized reactable() code on the new tweet table data: reactable(tweet_table_data, filterable = TRUE, searchable = TRUE, bordered = TRUE, striped = TRUE, highlight = TRUE, showSortable = TRUE, defaultSortOrder = "desc", defaultPageSize = 25, showPageSizeOptions = TRUE, pageSizeOptions = c(25, 50, 75, 100, 200), columns = list( DateTime = colDef(defaultSortOrder = "asc"), User = colDef(defaultSortOrder = "asc"), Tweet = colDef(html = TRUE, minWidth = 190, resizable = TRUE), Likes = colDef(filterable = FALSE, format = colFormat(separators = TRUE)), RTs = colDef(filterable = FALSE, format = colFormat(separators = TRUE)), URLs = colDef(html = TRUE) ) ) Once my function works, I use purrr::map_chr() again to iterate over each item in the column: tweet_table_data$URLs <- purrr::map_chr(tweet_table_data$URLs, make_url_html)ĭon’t worry if you don’t understand this part, since it’s really more about purrr and list columns than rtweet and reactable. I run purrr::map_chr() on the URL value if there are two or more URLs so that each URL gets its own HTML then I paste them together and collapse them into a single character string to appear in the table. Using the glue package, that would be rendered like this: glue::glue(" To construct a URL, I need to know the format of a tweet, which if you look at any tweet on the Twitter website, you can see is. tweet_df > although it could be any character or characters. There are more arguments you can use to customize your search, but let’s start with a basic search: 200 tweets with the #rstudioconf hashtag, without retweets. So you’ll want to make sure to save tweets you pull now that you might want in the future. ![]() You won’t be able to search two weeks after a conference to get those tweets. ![]() Unlike the Twitter website, you can’t use rtweet to search for tweets from a conference last year. While you can receive up to 18,000 tweets within 15 minutes, there is an important restriction when using the Twitter API to search for a word or phrase: search results only go back six to nine days unless you pay for a premium Twitter API account. It takes several arguments, including the query, such as #rstudioconf or #rstats whether you want to include retweets and the number of tweets to return. To search for tweets with a specific hashtag (or phrase that is not a hashtag), you use the intuitively named s earch_tweets() function. But to start, the easier way is, well, easier. If you’re going to use rtweet a lot, you’ll probably want to do that. You can go to to see the other method, which involves setting up a Twitter developer account and a new project to generate authorization credentials. Renviron file so you don’t have to re-authorize in the future. After that, an authorization token will be stored in your. If there aren’t credentials stored on your system, a browser window should open asking you to authorize the request. The easiest way is to simply request some tweets. Michael Kearney, who wrote rtweet, gives rtweet users two choices.
4 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |