Created
October 21, 2017 11:19
-
-
Save Jianghao/f7816c44ec4fbee6149b14256a57c367 to your computer and use it in GitHub Desktop.
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
library(foreach) | |
library(doSNOW) | |
cl <- makeCluster(20) | |
registerDoSNOW(cl) | |
start.time <- Sys.time() | |
pb <- txtProgressBar(max = length(users.sub), style = 3) | |
progress <- function(n) setTxtProgressBar(pb, n) | |
opts <- list(progress = progress) | |
fddf <- foreach(u = 1:length(users.sub), .options.snow = opts) %dopar% { | |
access_token <- access_tokens[u %% 10 + 1] | |
uid <- users.sub[u] | |
curl.string <- setCurl(uid = uid, access_token = access_token) | |
json <- curlJSON(curl.string = curl.string) | |
df <- json2df(json = json, fddf.blank = fddf.blank) | |
return(df) | |
} | |
close(pb) | |
fddf <- bind_rows(fddf) %>% filter(!is.na(id)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment