0

如果有人可以帮助我,我将不胜感激,我正在尝试解决但没有成功!

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

我的代码(在贡献后编辑)

#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
}

最终(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...
4

0 回答 0