Skip to content

Instantly share code, notes, and snippets.

@jamesthomson
Created March 17, 2017 12:21
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 jamesthomson/cfb31282653fd4ec686c8c5a7a368d56 to your computer and use it in GitHub Desktop.
Save jamesthomson/cfb31282653fd4ec686c8c5a7a368d56 to your computer and use it in GitHub Desktop.
clean up twitter following
library(twitteR)
#twitter authorisation
consumer_key = ''
consumer_secret = ''
access_token = ''
access_secret = ''
setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)
user<-getUser("inspirationinf")
user$getFollowersCount()
user$getFriendsCount()
followers<-user$getFollowers()
following<-user$getFriends()
followers_list<-NULL
for(i in 1:length(followers)){followers_list<-c(followers_list, followers[[i]]$screenName)}
following_list<-NULL
for(i in 1:length(following)){following_list<-c(following_list, following[[i]]$screenName)}
#people i follow that dont follow me
pifdfm<-following_list[!following_list%in%followers_list]
#posts by a user
last_tweet<-NULL
for(i in 1:length(pifdfm)){last_tweet<-c(last_tweet, max(twListToDF(userTimeline(pifdfm[i]))$created))}
pifdfm[as.POSIXct(last_tweet, origin="1970-01-01")<as.POSIXct((Sys.Date()-182),origin="1970-01-01")]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment