Do you know who your favorite person on Twitter is? Probably!

Did you ever want to quantify that statement? Probably not!

Are you curious to find out who someone else’s favorite Twitter user is? Now you can with R!

The code below is brought to you by Namita and her hilarious tweet:

Load packages

library(tidyverse)
library(rtweet)

Get Twitter API key

create_token(
  app = "app_name",
  consumer_key = "consumer_key",
  consumer_secret = "consumer_secret",
  access_token = "access_token",
  access_secret = "access_secret"
)

Grab data

twitter_handle <- "eeysirhc"

get_favorites(twitter_handle, n = 3000) %>% 
  group_by(screen_name) %>% 
  tally(sort = TRUE, name = '# of tweets liked') %>% 
  slice(1:10)
## # A tibble: 10 x 2
##    screen_name  `# of tweets liked`
##    <chr>                      <int>
##  1 jackiecchu                    26
##  2 drob                          22
##  3 eywu                          21
##  4 DanLeibson                    16
##  5 dataandme                     14
##  6 CMastication                  13
##  7 JHTScherck                    13
##  8 lauralippay                   13
##  9 DataChaz                      11
## 10 nick_eubanks                  10

Future article: grabbing the top 10 favorite users of my top 10 favorite users and then creating a network graph to identify strong/weak relationships.