Nate
Nate

Reputation: 2193

Return tweet_ID using twitteR

I am using the twitteR package in R to search recent tweets, but it seems that the package does not allow functionality to include the IDs of the returned tweets.

Is there another package that would return tweet_id, and which can search by keyword, #hashtag or @username as twitteR can?

Can I somehow manipulate the twitteR package to allow searchTwitteR to return tweet_id?

Thanks

Upvotes: 0

Views: 58

Answers (1)

lukeA
lukeA

Reputation: 54277

Everything is already there:

library(twitteR)
# authorize...
tweets <- searchTwitter("#euro2016", n=5)
tweets[[1]]$id
# [1] "745631411227365377"
sapply(tweets, function(x) x$id)
# [1] "745631411227365377" "745631411181334528" "745631410841657344" "745631410447388672" "745631410233303040"
twListToDF(tweets)[, 2:8]
#   favorited favoriteCount replyToSN             created truncated replyToSID                 id
# 1     FALSE             0        NA 2016-06-22 14:55:56     FALSE         NA 745631411227365377
# 2     FALSE             0        NA 2016-06-22 14:55:56     FALSE         NA 745631411181334528
# 3     FALSE             0        NA 2016-06-22 14:55:56     FALSE         NA 745631410841657344
# 4     FALSE             0        NA 2016-06-22 14:55:56     FALSE         NA 745631410447388672
# 5     FALSE             0        NA 2016-06-22 14:55:56     FALSE         NA 745631410233303040

Upvotes: 1

Related Questions