我正在尝试循环使用searchTwitter按天搜索。如果我硬编码从那以后的日期,我不会收到错误,但是如果我尝试使用向量,我遇到了这个错误。任何人都可以帮忙解释问题的原因吗?
> time_period
[1] "2013-01-01" "2013-01-02" "2013-01-03" "2013-01-04" "2013-01-05"
> hashtag1.list <- searchTwitter(hashtag1, n=5, lang = NULL, retryOnRateLimit=100, since = time_period[i], until = time_period[i], cainfo="cacert.pem")
Error in strsplit(since, " ") : non-character argument
答案 0 :(得分:0)
问题很可能是time_period
实际上不应该采用日期格式。查看searchTwitter
的代码会显示:
since_date = strsplit(since, " ")[[1]][1]
这是你的代码陷入困境的地方。您可以很容易地看到,如果time_period
不是字符格式,则会产生错误。
> time_period <- c("2013-01-01", "2013-01-02", "2013-01-03", "2013-01-04")
> strsplit(time_period, " ")
[[1]]
[1] "2013-01-01"
[[2]]
[1] "2013-01-02"
...
> strsplit(as.Date(time_period), " ")
Error in strsplit(as.Date(time_period), " ") : non-character argument