nets
May 16, 2020, 4:57pm
1
I am trying to extract tweets from a particular country but I see the tweets returned seem to be from all over. here is my code:
# fetch tweets from Nigeria using the keywords covid-19 and coronavirus
covid_tweets <- searchTwitter( c('covid-19', 'coronavirus'),
'en',
lookup_coords("nigeria"))
cderv
May 16, 2020, 5:32pm
2
lookup_coords
will use google geocoding API if the location is not already included in the package. See ?rtweet::lookup_coords
You must have an API KEY and enable billing on GCP.
See
opened 07:16AM - 21 Jun 18 UTC
closed 09:06PM - 15 Feb 21 UTC
documentation
location
Hi please help I am having errors trying to search by geo location in rtweet
… here is my code
search_tweets("economy", n=100, geocode = lookup_coords("uk"))
the error is
Error in if (interactive) { : argument is not interpretable as logical
however it works if the search location is USA. please help!!!
and
opened 03:24AM - 06 Feb 20 UTC
closed 01:31PM - 27 Feb 21 UTC
documentation
location
<!-- If you've encountered a likely bug in rtweet, please take a few seconds to …
look through existing issues for a similar issue. If you don't see a related
issue, please complete the prompts below to make it easier to replicate and
[hopefully] resolve your issue. -->
### Problem
I was trying to collect tweets from Australia using my Twitter API
### Expected behavior
I expected to get tweets the same way as I get if I enter USA but the data frame returns empty
When I type lookup_coords("australia") it gives NULL. and the same applies to other countries such as Canada for example.
### Reproduce the problem
``` r
rt3 <- search_tweets(
"lang:en", geocode = lookup_coords("australia"), apikey="my google API key", n = 100
)
```
### rtweet version
``` r
## copy/paste output
packageVersion("rtweet")
```
### Session info
``` r
## copy/paste output
sessionInfo()
```
### Token
<!-- run the code below and copy/paste the output. if you don't feel comfortable
sharing that information, then share the first 3-4 characters for the
oauth_app ($APP_NAME$) and key ($KEY$) as they appear in the printed output
#> <Token>
#> <oauth_endpoint>
#> request: https://api.twitter.com/oauth/request_token
#> authorize: https://api.twitter.com/oauth/authenticate
#> access: https://api.twitter.com/oauth/access_token
#> <oauth_app> {{$APP_NAME$}}
#> key: {{$KEY$}}****************
#> secret: <hidden>
#> <credentials> oauth_token, oauth_token_secret
-->
``` r
## copy/paste output
rtweet::get_token()
```
<!-- If you think the problem may be related to features/limitations of
Twitter's API, you can find more information about Twitter's APIs here:
https://developer.twitter.com/en/docs.html -->
See the doc about Geocoding API
I think this is why you don't get what you want.
Is lookup_coords("nigeria")
resulting with a list containing coordinates ?
If none, then the API does not return anything I thing...
You can check also the result of
jsonlite::fromJSON(glue::glue("https://maps.googleapis.com/maps/api/geocode/json?key={key}&address=nigeria", key = Sys.getenv("GOOGLE_MAPS_KEY")))
Hope it helps
nets
June 1, 2020, 11:41pm
3
thanks @cderv . I still struggled with it so I just went ahead to do a live stream of tweets that contain the word 'Nigeria'
system
Closed
June 22, 2020, 11:41pm
4
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.