我有一个问题构建一个循环,通过追加循环的结果给我一个表。我怎样才能用append和loop构造一个表?
现在它正在水平添加列(变量),而不是垂直添加行。
可能追加不正确的功能?或者有没有办法让它垂直追加? 也许我只是觉得我在制作一张桌子,但实际上是其他的一些结构呢?
我找到的解决方案使用rbind,但我没有弄清楚如何使用rbind函数设置循环。
for (i in 1:3) {
users.humansofnewyork = append(users.humansofnewyork, getPost((humansofnewyork$id[i]) , token, n = 500, comments = TRUE,likes = TRUE, n.likes=500, n.comments=500))
}
非常感谢您的回复。不幸的是,没有任何解决方案奏效。
这就是全码:
#start the libaries
library(Rfacebook)
library(Rook)
library(igraph)
#browse to facebook and ask for token
browseURL("https://developers.facebook.com/tools/explorer")
token <- "...copy and paste token"
#get Facebook fanpage "humansofnewyork" with post id
humansofnewyork <- getPage("humansofnewyork", token, n=500)
users.humansofnewyork = c()
for (i in 1:3) {
users.humansofnewyork = append(users.humansofnewyork, getPost((humansofnewyork$id[i]) , token, n = 500, comments = TRUE,likes = TRUE, n.likes=500, n.comments=500))
}