ATMathew
ATMathew

Reputation: 12856

Generating a data frame of all Twitter followers and their location Using TwitteR

I'm new to the twitter package and am trying to geterate a data frame which is comprised of users who follow me, their location, and number of tweets.

name    location       tweets
sfih    Denver, CO     100 
oiho    Italy          503
seih    Space          205
soei    Hell           1

After reading the twitteR documentation, I saw that there are various methods for getting the user name of followers and getting individual tweets from them. (getUser, getName, etc) I'm wondering if there is a quick single line command to get all users that follow me.

Thank You!

Upvotes: 1

Views: 1686

Answers (1)

daroczig
daroczig

Reputation: 28612

Sure, from the twitteR documentation it can be seen that you can easily call those methods for given user. E.g.:

> getUser('daroczig')$getFollowers()
[[1]]
[1] "ThankToHouseUS"

[[2]]
[1] "RCommunity"

[[3]]
[1] "gnome_tips"

Update: and based on the above you could also easily fetch all required information from all user classes with a one-liner, eg.:

> t(sapply(getUser('daroczig')$getFollowers(), function(x) c(x$name, x$location, x$statusesCount)))
     [,1]                [,2]                  [,3]  
[1,] "Thank To House US" "Dallas, TX"          "47"  
[2,] "R Community"       "Surabaya, Indonesia" "64"  
[3,] "Rodrick Jacquez"   ""                    "1326"

Upvotes: 3

Related Questions