Niall Kelly
2014-May-12 14:17 UTC
[R] Creating Twitter network - rate limits being exceeded - cannot figure why
Hi everyone. This is my first ever ask for help, having searched archives and the package help, CRAN, and stackoverflow, and having spent 3 days on this. I am using a modified version of Pablo Barbera's code (https://github.com/pablobarbera/workshop/blob/master/code/02_analysis_twitter_nyu.R) to graph the Twitter follower network for an individual and those they follow. The rate limit is 15 calls/15mins for friends/ids. However, my code is constantly exceeding that. I have published my code here: https://github.com/BuaCh41Ll/Twitter_network/blob/master/map_twitter_user_network.R I would be grateful for any hints on how to resolve the rate limit issue. I suspect that the issue is within the while loop (copied below) while (length(ir_pol.users) > length(follow.list)) { user <- ir_pol.users[ir_pol.users %in% names(follow.list) == FALSE], 1) user <- getUser(user) user.n <- user$screenName following <- user$getFriends() friends <- as.character(lapply(following, function(x) x$getScreenName())) follow.list[[user.n]] <- friends descriptions <- as.character(lapply(following, function(x) x$getDescription())) ir_pol <- extract.irishpolitics(descriptions) new.users <- lapply(following[ir_pol], function(x) x$getScreenName()) new.users <- as.character(new.users) ir_pol.users <- unique(c(ir_pol.users, new.users)) limit <- getCurRateLimitInfo()[47, 3] while (limit == "0") { Sys.sleep(901) limit <- getCurRateLimitInfo()[47, 3] } print(ir_pol.users) } Fingers crossed that my first post is appropriate to the group and my apologies if I have erred in its construction. Niall