Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@naupaka
Forked from noamross/find_local_tweeps.R
Created September 11, 2017 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naupaka/c26f61457b942e313179e835547c8dcf to your computer and use it in GitHub Desktop.
Save naupaka/c26f61457b942e313179e835547c8dcf 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