Skip to content

Instantly share code, notes, and snippets.

@noamross
Created August 14, 2017 23:43
Show Gist options
  • Save noamross/fcbf1086b49f891f5d102a4528066cbe to your computer and use it in GitHub Desktop.
Save noamross/fcbf1086b49f891f5d102a4528066cbe to your computer and use it in GitHub Desktop.
A visit to Durham
library(rtweet) #rtweet API creds should already be set up
library(stringi)
library(dplyr)
friends = get_friends(user="noamross")
followers = get_followers("noamross")
tweeps_id = distinct(bind_rows(friends, followers))
tweeps_info = lookup_users(tweeps_id$user_id)
# A regex for a visit to Durham
nc_regex = "(\\bNC\\b|North Carolina|Durham|Raleigh|\\bUNC\\b|University of North Carolina|Chapel Hill|\\bDuke\\b|\\,\\sNC\\b)"
nc_tweeps_info = tweeps_info %>%
filter(stri_detect_regex(paste(name, screen_name, location, description),
nc_regex, case_insensitive=TRUE))
nc_tweeps_info %>%
dplyr::select(name, screen_name, description, location) %>%
arrange(location)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment