-
-
Save jananiravi/cfb11283d02a52fba7e096be44019942 to your computer and use it in GitHub Desktop.
A visit to Michigan | Finding 'persons of interest' | Twitter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Orig tweeps author: stephlocke | |
# Adapted to find data scientists in the Michigan, East Lansing area! | |
library(rtweet) #rtweet API creds should already be set up | |
library(stringi) | |
library(tidyverse) | |
friends = get_friends(user="gdequeiroz ") #stephlocke #JennyBryan #hadleywickham | |
followers = get_followers("gdequeiroz") #janani137 | |
tweeps_id = distinct(bind_rows(friends, followers)) | |
tweeps_info = lookup_users(tweeps_id$user_id) | |
# A regex for a visit to Michigan (location filter) | |
mi_regex = "(Michigan|michigan|Lansing|lansing|Grand Rapids|Ann Arbor|Detroit|msu|umich|MSU|UMich|, mi$)" | |
mi_tweeps_info = tweeps_info %>% | |
filter(stri_detect_regex(paste(name, screen_name, location, description), | |
mi_regex, case_insensitive=TRUE)) | |
# A regex for data scientists (keyword filter) | |
ds_regex = "(data science|Data Science|datascience|DataScience|R4DS|r4ds)" | |
## Michigan Data Scientists among friends/followers of XYZ | |
persons_of_interest <- mi_tweeps_info %>% | |
# filter(stri_detect_regex(paste(name, screen_name, location, description), | |
# ds_regex, case_insensitive=TRUE)) %>% | |
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