R:我的循环一遍又一遍地返回相同的值

时间:2017-07-19 23:24:57

标签: r while-loop rfacebook

如果有人能帮助我,我会很感激,我正在努力解决但却没有成功!

我有一个带有ID列表的数据框。使用“Rfacebook”软件包,我应用“getPost”函数来接收我需要的所有数据。但是,当我进行循环时,只返回一个结果并重复几十次。

我的代码(使用后贡献进行编辑)

#final is a value in environment with all IDs that I need to do the getPost
verificador <- 1
listap <- c()
listap2 <- c()
p <- list()

while (verificador <= length(final)) {
  p[[verificador]] <- getPost(final[[verificador]], token, comments = F, reactions = T, n.reactions = 50000, api = NULL)
  verificador = verificador + 1
}

final(IDS列表):

 [1] "193944443965876_1884261211600849"
 [2] "193944443965876_1884261211600849"
 [3] "193944443965876_1884261211600849"
 [4] "193944443965876_1884261211600849"
 [5] "193944443965876_1884261211600849"
 [6] "193944443965876_1884261211600849"
 [7] "193944443965876_1884261211600849"
 [8] "193944443965876_1884261211600849"
... continue

循环结果:

[[1]]
          from_id from_name
1 193944443965876       XYZ
                                                                                                                                                                                                                                                                                                                                                                        message
1 O lugar de uma t-shirt linda nunca será no fundo do armário! 
              created_time  type
1 2017-07-09T18:52:47+0000 video
                                                         link
1 https://www.facebook.com/XYZ/videos/1884261211600849/
                                id likes_count
1 193944443965876_1884261211600849        2729
  comments_count shares_count
1             69           44

[[2]]
          from_id from_name
1 193944443965876       XYZ
                                                                                                                                                                                                                                                                                                                                                                        message
1 O lugar de uma t-shirt linda nunca será no fundo do armário!
              created_time  type
1 2017-07-09T18:52:47+0000 video
                                                         link
1 https://www.facebook.com/XYZ/videos/1884261211600849/
                                id likes_count
1 193944443965876_1884261211600849        2729
  comments_count shares_count
1             69           44

continue...

0 个答案:

没有答案