map twitter followers R

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:

Map Twitter Followers with R

In this script we can find the function twitterMap.

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

 

Twitter Map

 

Julian Hillebrand

During my time at university and learning about the basics of economics I started heavily exploring the possibilities and changes caused by digital disruptions and the process of digital transformation, whereby I focused on the importance of data and data analytics and combination with marketing and management.
My personal focus of interest lies heavily on technology, digital marketing and data analytics. I made early acquaintance with programming and digital technology and never stop being interested in following the newest innovations.

I am an open, communicative and curious person. I enjoy writing, blogging and speaking about technology.

  • Pingback: An experiment with R |   Nuno Paixão()

  • MónicaNarro

    Hi, great post.Thank you for sharing
    When I follow your exact procedure , R shows:

    Getting data from Twitter, this may take a moment.
    Getting geographic (latitude/longitude) of Twitter users.
    Plotting results.
    Warning messages lost:
    1: In if (plotType == “both”) { :
    the condition has length> 1 and only the first element will be used
    2: In if (plotType == “followers”) { :
    the condition has length> 1 and only the first element will be used
    3: In if (plotType == “following”) { :
    the condition has length> 1 and only the first element will be used

    Could you help me?

  • Chris Sofianou

    Hello, also getting the same error:

    Warning messages:
    1: In if (plotType == “both”) { :
    the condition has length > 1 and only the first element will be used
    2: In if (plotType == “followers”) { :
    the condition has length > 1 and only the first element will be used
    3: In if (plotType == “following”) { :
    the condition has length > 1 and only the first element will be used
    >

    Any ideas?

    • Chris Sofianou

      Seem to have figured it out, the script requires the plotType to be defined, by adding:

      plotType=”followers”
      plotType=”following”
      plotType=”both”

      it resolves the issue.

      • Hey
        thanks for your solution.

        Regards

  • lee

    Hi Julian and Chris

    Can you tell me where to add
    plotType=”followers”
    plotType=”following”
    plotType=”both”

    do we need to add all them all?

    Thank you in advance!!!