MaelKubli / RTwitterV2

R functions for Twitter's v2 API
MIT License
46 stars 6 forks source link

Location filter #3

Closed kavyanjalik closed 3 years ago

kavyanjalik commented 3 years ago

Hello, Thanks a lot for your support with the R package. Wanted to ask if it is possible to set the location filter to download tweets only from selected countries? Thank you!

MaelKubli commented 3 years ago

Hi

This is possible via the Query you enter. The only thing you need to keep in mind is that only small percentage of Tweets have geo-tagged information associated with them. Thus, relying only on geo-tagged Tweets alone might introduce some bias in your dataset.

You can do this by entering a search query with the longitude, latitude and the radius like this: The Radius has to be smaller than 25 miles according to twitters docu

library(RTwitterV2)

Bearer_Token <- ""

query <- '"New York" point_radius:[-73.942859 40.629653 10mi]'

tmp <- full_archive_search(token = Bearer_Token, search_query = query, n = 1500)

I will probably add a param for the search function soon which will make it easier to use this feature.

Ther are other possible ways to restrict the search to location with the following operators:

kavyanjalik commented 3 years ago

Thank you so much! Yes, I agree with the bias in the dataset, which I will keep in mind.

MaelKubli commented 3 years ago

Added a new function (v0.2.1) to make it easier to search for tweets within a Country (place_country), point_radius and bounding_box.