我使用包smappR进行twitter收获和分析。在此循环中使用函数getTimeline(https://github.com/SMAPPNYU/smappR/blob/master/R/get-timeline.R)时:
#import excel-file with twitter usernames
riksdagsledamoter <- read.xlsx("lista_riksdagsledamoter_twitter.xlsx", sheetIndex=1)
# delete MPs with out twitter account
twitterusers <- riksdagsledamoter[!(is.na(riksdagsledamoter$twitterusername)), ]
row.names(twitterusers) <- seq(nrow(twitterusers))
names(twitterusers) <- c("twitterusername", "name", "parti") #convertering to vector
twitterusersvector <- as.vector(twitterusers$twitterusername)
for(i in 1:length(twitterusersvector)){
user <- twitterusersvector[i]
# user <- twitterusers$twitterusername[i]
# rov <- as.vector(user)
getTimeline(screen_name = user,
filename = "pa324.json", # where tweets will be stored
n=3200, ## number of tweets to download (max is 3,200)
oauth_folder = "~/Dropbox/Privat/R/credentials",
sleep=10, )
if ( file.info("pa324.json")$size > 120000000 ){
tweetsToMongo(file.name="pa324.json", ns="xxxx.yyyy",
host="192.168.x.x", username="", password="")
file.remove("pa324.json")
}
}
我收到此错误:
Error in json.data[[tweets]] : attempt to select less than one element
我用Google搜索并尝试过:
row.names(twitterusers) <- seq(nrow(twitterusers))
没有任何帮助。可能有什么不对?