user2543622
user2543622

Reputation: 6766

r twitteR package - pulling twits where user was tagged

I understand that I can pull twits from R using below two methods

searchTwitter("abc")#pulls all twits that contain keyword 'abc'
searchTwitter("from:abc") #pulls all twits from user 'abc'
  1. I want to pull twits where user was mentioned or tagged. In twitter, while writing a twit another user is mentioned or tagged by putting @ before the user's name. To achieve my goal should i use searchTwitter("abc") or should I use 'searchTwitter("@abc")'?

  2. Is there a single command that could give me twits from the user abc as well as all twits where abc was tagged? I can always do two different searches - one searchTwitter("abc") and searchTwitter("@abc") (provided @abc returns all twits where user abc was mentioned or tagged) and then remove duplicate twtis. But I want to avoid that as it would involve a lot of duplication of twits. Twitter allows to pull only 18000 twits per 15 minutes and I would like to avoid pulling same tweets twice.

Upvotes: 0

Views: 75

Answers (1)

jessefleri
jessefleri

Reputation: 109

You can pull all tweets from a single user using userTimeline('user_name'). You can define the number of tweets to query by adding n=number after the you define a users handle.

Example:

userTimeline('StackOverflow',n=5)

[[1]]
[1] "StackOverflow: @szalapski Hi Patrick! I just asked and our team says it's on their list to update the data AND make future updates… "

[[2]]
[1] "StackOverflow: If you want to see the code, check out Julia’s blog post below. @IBMcloud #DSX "

[[3]]
[1] "StackOverflow: Interested in text mining? Check out how Stack Overflow data scientist @juliasilge implements topic modeling using… "

[[4]]
[1] "StackOverflow: @martindaniel4 @Google "

[[5]]
[1] "StackOverflow: @Koprowski_it \xed��\xed�\u008d"

The query will also return https links but they had to be deleted for the post to go through here.

The book R and Data Mining: Examples and Case Studies by Yanchang Zhao has some excellent examples if your looking for a textbook walk through.

Upvotes: 2

Related Questions