Extract tweets with specific character from a list of account

69 Views Asked by At

I want to get the timeline (10 tweets, for example) of a list of profiles, but I want to get only the tweets which contain a specific character or string.

profiles<- c("a", "b", "c", "d")
keyword <- "apple"

tweets <- get_timeline(
  user = profiles,
  q = #I DON'T KNOW WHAT TO PUT HERE TO GET TWEETS THAT CONTAIN keyword: can't use grepl()
     #because the vector should be tweets... maybe with an if statement but I can't find the syntax
  n = 10,
  since_id = NULL,
  max_id = NULL,
  home = FALSE,
  parse = TRUE,
  check = TRUE,
  retryonratelimit = NULL,
  verbose = TRUE,
  token = NULL)
1

There are 1 best solutions below

0
llrs On

You can use: q = "a OR b OR c OR d OR apple", I recommend reading the official documentation of the API about which logical operators are available and how to use them. rtweet doesn't use the twitter API v2 yet (only for the streaming endpoints at the 1.1.0 release)