Search Twitter Followers in R

I would like to see user profiles of Twitter followers using R (followers> 100000). Although twitteR is a great package, it has problems working with high levels of followers, since it is necessary to implement a sleep procedure to avoid exceeding speed limits. I'm a relative newbie here and wondered how you can loop into the repeater id object by entering follower IDs in batches of 100 (since this is the maximum Twitter API can be processed at the same time)?

Edit: added (Twitter) library code (plyr) maxTwitterIds = 100 sleeptime = 500 # sec

user<-getUser("[username]")
followers<-zz$getFollowerIDs()
ids_matrix = matrix(zz, nrow = maxTwitterIds, ncol = length(zz) / maxTwitterIds)
followers<-zz$getFollowerIDs()
#note: for smaller lists of followers it is possible to use the command "lookupUsers(zz)     at this point
foll<-getTwitterInfoForListIds = function(id_list) {
    return(lapply(id_list, 

names <- sapply(foll,name)
sn<sapply(foll,screenName)
id<-sapply(foll,id)
verified<-sapply(foll,erified)
created<-sapply(foll,created)
statuses<-sapply(foll,statusesCount)
follower<-sapply(foll,followersCount)
friends<-sapply(foll,friendsCount)
favorites<-sapply(foll,favoritesCount)
location<-sapply(foll,location)
url<-sapply(foll,url)
description<-sapply(foll,description)
last_status<-sapply(foll,lastStatus)))
}
alldata = alply(, 2, function(id_set) {
    info = getTwitterInfoForListIds(id_set)
    Sys.sleep(sleeptime)   
    return(info)
})
+5
source share
1 answer

, twitteR. , , . .

library(plyr)

# Some constants
maxTwitterIds = 100
sleeptime = 1 # sec

# Get the id of the twitter followers of person X    
ids = getTwitterFollowers("x") # I'll use ids = 1:1000
ids_matrix = matrix(ids, nrow = maxTwitterIds, 
                         ncol = length(ids) / maxTwitterIds)

getTwitterInfoForListIds = function(id_list) {
    return(lapply(id_list, getTwitterInfo))
}

# Find the information you need from each id
alldata = alply(ids_matrix, 2, function(id_set) {
    info = getTwitterInfoForListIds(id_set)
    Sys.sleep(sleeptime)   
    return(info)
})

, , , ( ), , -, .

0

All Articles