我已经阅读了其他问题,但我仍然不知道如何解析Facebook中的Facebook图形搜索结果。我的主要目标是转换类似数据框的内容,以分析某些列。解析Facebook中的JSON结果R
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")
UPDATE: 感谢@ 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
有人可以帮我吗?
如果我想包含“count”,嵌套在“likes”中?让我们看看:
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
有人可以帮我吗?
谢谢@ user1609452。 后fbData < - fromJSON(数据)我得到 '错误在fromJSON(内容,处理程序,default.size,深度,的allowComments,: 无效JSON输入' –
与rjson包,当我打fbData < - fromJSON(数据)返回“Error in fromJSON(data):意想不到的转义字符'pos'130处的'o'有任何想法如何在”data“字符对象中替换”\“,在getURL后面? –