0

I am trying to get tweets that were tweeted from a specific location e.g. 'LA' using the rtweet package. I know the twitteR package used to have something of the sort like:

a<-searchTwitter("sydney", n=100, geocode='-33.871841,151.206709, 10000mi')

where you could even specify the radius.

Is there a way to do add that functionality to the rtweet stream?

kanataki
  • 433
  • 2
  • 21

1 Answers1

0

From rtweet:

library(rtweet)
rt <- search_tweets(
  "lang:en", geocode = lookup_coords("usa"), n = 10000
)

Stream example from the help page:

stream_tweets(
  "realdonaldtrump,trump",
  timeout = 60 * 60 * 24 * 7,
  file_name = "tweetsabouttrump.json",
  parse = FALSE,
  lookup_coords("usa")
)

But you'll need a Google Maps API Key for lookup_coords (See here).

More here and here.

RLave
  • 8,144
  • 3
  • 21
  • 37
  • On the stream tweets section, what if I just wanted to collect the tweets without filtering on anything. Just any tweets being tweeted from the USA. Can I have an empty string there? – kanataki Aug 23 '18 at 10:21
  • yes, just remove everything you don't need. In this case `"realdonaldtrump,trump"` – RLave Aug 23 '18 at 10:34