--- title: "ab-top_tweets" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{ab-top_tweets} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 5, out.width = "50%", fig.align = "center" ) ``` ```{r setup} library(tweetrbot) library(readr) ``` ## Example dataset ```{r} rds_file <- system.file("complete_tweets_rspatial.rds", package = "tweetrbot") all_tweets <- read_rds(rds_file) ``` ## Top retweets In this vignette, I do not really post the tweet. I only retrieve its content. - Update stored tweets information ```{r, eval=FALSE} # get last month data # In this saved dataset, last month is April last_month_tweets <- all_tweets %>% filter_month(the_month = 4, the_year = 2020) # update rds data (not run in this example to not modify raw data) # and return last_month updated last_month_updated <- update_data( path = rds_file, statuses = last_month_tweets$status_id, return_all = FALSE, overwrite = TRUE) ``` - Find top tweets ```{r, eval=FALSE} output <- top_tweets(all_tweets = last_month_updated, post_tweet = FALSE, top_number = 5) ``` ```{r, eval=TRUE, echo=FALSE} # Data not really updated in this vignette because would need Twitter credentials output <- all_tweets %>% filter_month(the_month = 4, the_year = 2020) %>% top_tweets(post_tweet = FALSE, top_number = 5) ``` - Show stats ```{r} output$number_contributors output$top_retweet output$number_tweets ``` ```{r, results='asis'} output$text_tweet ```