Map Twitter Followers with R

Hello everybody,
today we´re going to put our followers and people we follow on a map and visualize them this way.
This is very easy because of Jeff Leek who wrote a nice little R script we can use today.

But before the fun begins we have to go through the oAuth process as described in this post.

Ok now we can go on:
We have to define the script by Jeff Leek as our source. We do it with:


The map function

In this script we can find the function twitterMap.

twitterMap <- function(userName,userLocation=NULL,fileName=“twitterMap.pdf”,nMax = 1000,plotType=c(“followers”,“both”,“following”))

You can see this function has different parameters.

“userName” is the user whose follower and people he´s following we want to visualize.
“userLocation” has to be defined when this user did not specify his location in his twitter profile.
“fileName” is the name of the file the generated map is saved to and “nMax” is the limit of how many followers are used. So if i have 2000 followers, now just 1000 are visualized on the map.
Last but not least we can define the “plotType” to “followers”, “both” and “following”; so if we want to see the follower, the people i´m following or both on the map.

And that`s it.
I used the following parameters to create the map of the followers of @socialmedia2day

twitterMap("socialmedia2day", fileName="Map_socialmedia2day.pdf", nMax=3000)

Twitter Map


One thought on “Map Twitter Followers with R

  1. Pingback: An experiment with R |   Nuno Paixão

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s