r语言 - 使用twitteR包检索带有maxID的用户时间轴,给出意外结果



我试图检索一个帐户的整个时间轴,阅读twitter API后,我写了以下代码:

healthLeadersTimeline <- twListToDF(userTimeline("HealthLeaders", n=200, includeRts=TRUE, retryOnRateLimit=180))
write.table(healthLeadersTimeline, "health.csv", sep=",", row.names=FALSE)
maxID <- getMaxID(last(healthLeadersTimeline)$id)
healthLeadersTimeline <- twListToDF(userTimeline("HealthLeader", n=200, maxID=maxID, includeRts=TRUE, retryOnRateLimit=180))
write.table(healthLeadersTimeline, "health.csv", sep=",", append=TRUE, col.names=FALSE, row.names=FALSE)

和getMaxID的实现如下:

getMaxID <- function (tweetID) {
  lastID <- as.numeric(tweetID)
  maxID <- toString(lastID -1)
  return(maxID)
}

这个推特账号显然有超过400条推文。但在第二次调用时间轴时,我只能检索到35条推文。我在这里做错了什么?

你没有做错什么,除了可能没有阅读文档:)。3200是你可以从一个时间轴上正式获得的帖子的最大数量。