0

I started having problems with extracting tweets with twitteR package: I don't get "location" (that's stated in user's profile) in the output anymore and I need it for my further analysis. I am using the exact same code as before. Can anyone help?

TweetFrame <- function(searchTerm, maxTweets) 
{
tweetList <- searchTwitter(searchTerm, n = maxTweets, lang = "en")

tweetDF <- do.call("rbind", lapply(tweetList, as.data.frame))

return(tweetDF[order(as.integer(tweetDF$created)), ])
}



tweetDF <-
TweetFrame("#climate OR climate change OR global warming", 20)

Before I would get a data frame with 20 objects and 19 variables, but now it returns only 16 variables.

location should be after latitude

Michael Harper
  • 14,721
  • 2
  • 60
  • 84
  • That package hasn't been updated since 2015. Probably the twitter API has changed. I recommend the `rtweet` package. – jsta Mar 20 '18 at 20:27
  • @jsta thanks that may be a good option! I also found a way around this - fist get a data frame with screenNames and then access users' locations from there (using lookupUsers). –  Mar 20 '18 at 22:09
  • 1
    @airielo you may want to share you solution as an answer to the question in case others encounter this problem – Michael Harper Mar 21 '18 at 06:22
  • lookup<-lookupUsers(tweetDF$screenName) tweets_df<-twListToDF(lookup) new_DF<-merge(x = tweetDF, y = tweets_df, by= "screenName", all.x = TRUE) then you can access new_DF$location –  Mar 21 '18 at 10:51

0 Answers0