Home > Enterprise >  Scrape Only English Tweets using Twitter Api in R
Scrape Only English Tweets using Twitter Api in R

Time:07-15

I have been working on a project related to Sentiment Analysis of Emojis. I have used this simple code to scrape tweets specifically on the topic "Uber" but I only want tweets in English and the code I am using gives me the tweets from all the languages. How can I scrape or customise my code So I would only get them in English?

My code:

library(lubridate)
library(tidyverse)
library(rtweet)
library(igraph)
library(here)

get_token() # Connects with Twitter API

Uber <- search_tweets("uber", n = 50)

CodePudding user response:

From the documentation ?search_tweets:

...
Further arguments passed as query parameters in request sent to Twitter's REST API. To return only English language tweets, for example, use lang = "en". For more options see Twitter's API documentation.

So:

Uber <- search_tweets("uber", n = 50, lang = "en")
  • Related