我已经阅读了其他问题,但我仍然不知道如何在 R 中解析 Facebook Graph Search 结果。我的主要目标是转换为数据框之类的东西,以分析一些列。
library(RCurl)
library(RJSONIO)
library(rjson)
data <- getURL("https://graph.facebook.com/search?q=flamengo&type=post&limit=1000", cainfo="cacert.perm")
#if you don't have "cacert.perm" file, do as follow
#download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.perm")
更新:谢谢@user1609452
现在如果我想包含嵌套在“喜欢”中的“计数”怎么办?让我展示:
names(fbData$data[[1]])
[1] "id" "from" "message" "actions" "privacy"
[6] "type" "created_time" "updated_time" "shares" "likes"
names(fbData$data[[1]]$likes)
[1] "data" "count"
在这种情况下,我应该如何设置 match.fun 参数?
likes <- lapply(fbData$data[[1]]$likes,name='count')
Error in match.fun(FUN) : no "FUN" argument, no pattern
likes <- lapply(fbData$data[[1]]$likes,'[[',name='count')
Error in FUN(X[[2L]], ...) : index out of bounds
有人能帮助我吗?
如果我想包含“计数”,嵌套在“喜欢”中?让我展示:
names(fbData$data[[1]])
[1] "id" "from" "message" "actions" "privacy"
[6] "type" "created_time" "updated_time" "shares" "likes"
names(fbData$data[[1]]$likes)
[1] "data" "count"
在这种情况下,我应该如何设置 match.fun 参数?
likes <- lapply(fbData$data[[1]]$likes,name='count')
Error in match.fun(FUN) : no "FUN" argument, no pattern
likes <- lapply(fbData$data[[1]]$likes,'[[',name='count')
Error in FUN(X[[2L]], ...) : index out of bounds
有人能帮助我吗?