R twitteR searchTwitter geocode warning/error

半世苍凉 提交于 2019-12-20 06:33:22

问题


I'm trying to pull tweets using the twitteR package, but I'm having an issue getting them through the searchTwitter function when I specify a geocode the way they have it in their docs. Please see code below:

    #Oauth code (successful authentication)

    keyword = "the"
    statuses = searchTwitter(keyword, n=100, lang="en",sinceID = NULL, geocode="39.312957, -76.618119, 10km",retryOnRateLimit=10)

Code works perfectly when I leave out geocode="39.312957, -76.618119, 10km",, but when I include it, I get the following:

    Warning message:
    In doRppAPICall("search/tweets", n, params = params, retryOnRateLimit = retryOnRateLimit,  :
    100 tweets were requested but the API can only return 0

I thought maybe my formatting was wrong but based on the twitteR CRAN page the string is in the right format (I also tried switching between km and mi).

Has anyone else experienced this or know a better way to search for a specific geocode? Would they have deprecated the geocode functionality?

I'm looking for tweets from Baltimore so if there is a better way to do so, I'm all ears. (By the way, I want to avoid trying to pull all tweets and then filter myself because I think I will hit the data limit fairly quickly and miss out on what I'm looking for)

Thanks!


回答1:


I believe you need to remove the spaces in the geocode parameter:

statuses = searchTwitter(keyword, n=100, lang="en",sinceID = NULL, geocode="39.312957,-76.618119,10km",retryOnRateLimit=10)

FWIW You can use the Twitter desktop client "Develop" console to test out URLs before committing them into scripts.




回答2:


Had the same issue. Your parameters are in the correct order, but you must avoid any whitespace within the geocode. Also, 10km might be too little a radius for the accuracy of the coordinates given, might want to try with 12mi.



来源:https://stackoverflow.com/questions/22668255/r-twitter-searchtwitter-geocode-warning-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!