Facebook bimodal network created using SocialMediaLab (Star Wars Facebook Page)SocialMediaLab is an R package that provides a suite of tools for collecting and constructing networks from social media data. It provides easy-to-use functions for collecting data across popular platforms (Facebook, Twitter, and YouTube) and generating different types of networks for analysis.

SocialMediaLab was created by Tim Graham (who is also the maintainer of the package) and Robert Ackland. A major contribution was also made by Chung-hong Chan from the Journalism and Media Studies Centre at the University of Hong Kong.

The package can be found on CRAN  and the development version is available on github.

Note that due to Instagram API changes effective 1 June 2016, SocialMediaLab can no longer provide access to Instagram data.

The present page provides some R scripts to help get you started using SocialMediaLab and also information on associated training workshops and obtaining API access (Facebook, Twitter, YouTube).  This page has the following sections:

R helper scripts/tutorials

Absolute Beginner's Guide to the SocialMediaLab Package in R (for version 0.20.1): pdf, Rmd

SocialMediaLab Tutorial (for version 0.20.1): pdf, Rmd

Topic modeling of tweets in R: a tutorial and methodology

SocialMediaLab Tutorial for International Communication Association 2017 Conference: pdf, Rmd

Training workshops using SocialMediaLab

The following are archived web pages for previous training workshops on network and text analysis involving the use of SocialMediaLab and other R packages. We are providing these workshop pages in the hope that they will be useful, but please note that we cannot provide assistance with the content of the workshops. Also note that the SocialMediaLab package has changed over time so it is best to look at the most recently-held workshops.

Obtaining API access (Facebook, Twitter, YouTube)

With SocialMediaLab, you can collect network and text data from Facebook, Twitter, YouTube and Facebook. However for these data sources you will require access to the respective application programming interfaces (APIs). This section provides some information on how to get these API credentials (note: the APIs associated web pages do change periodically, so the information below may not be up-to-date).

  • Twitter
    To access the Twitter API, you need to have a Twitter account.  When logged into Twitter, then go to the Twitter Apps site, and press the "Create a new app" button.  You need to fill in some information including the name of the app e.g. "BigDataCourse", description (whatever you want), website (again, you can put anything here).  You do not need to supply the "Callback URL".  After agreeing to terms and conditions and (if you haven't already done so) supplying a valid phone number in your Twitter profile, your app will be created.  Go to the "Keys and Access Tokens" tab.  The "API Key" and "API Secret" will need to be supplied to SocialMediaLab.  You should also generate the Access Token and Token Secret - by supplying these to SocialMediaLab, you will avoid having to authenticate via a browser.  For more on Twitter apps, see the Twitter Developers Site.
  • YouTube
    To access the YouTube API, you need to have a Google account.  When logged into Google, then go to the Google APIs Console and create a project (if you already don't have one).  Then go to the APIs&auth->APIs link on the LHS and on the API Library tab, select and enable YouTube Data API.  This API should then appear in the Enabled APIs tab.  Then go to APIs&auth->Credentials and generate a Public API access key.  The API key then needs to be supplied to SocialMediaLab.
  • Facebook
    To access the Facebook API, you need to have a Facebook account and you also need a Facebook developer account.  When logged into Facebook then go to the Facebook Developers Site and go to the "MyApps" page.  There, click on the "Add a New App" button.  You are then asked to select a platform to get started (iOS, Android, Facebook Canvas, WWW), and you select "Website". In the "Site URL" field enter "http://localhost:1410/" and save the changes (if you can't find this, it is located in the Settings for your newly created App). Then you get to a page where you are asked to supply a display name - e.g. "BigDataCourse" and choose a category (this is for commercial applications...you can select whatever) and then you press "create App ID".  After getting through the CAPTCHA, you should see a page with your newly-created App.  The App ID and the App Secret are what you need to supply to SocialMediaLab.
  • Instagram [no longer available]
    Note that due to Instagram API changes effective 1 June 2016, SocialMediaLab can no longer provide access to Instagram data. The following notes are provided as a record, and we hope to regain access to the Instagram API in the future.
    To access the Instagram API, you need an Instagram account. Go to the Instagram Developers Page and click "Register Your Application". Choose some app name (e.g. "myInstagramApp"), write a small description, and a website (it doesn't have to be your own). You now have to enter an OAuth redirect URI. You need to enter "http://localhost:1410/". After you click register you will be taken to the Manage Clients page. If not, click this Manage Clients link in the top menu. Your app will have (among other things) a "client ID" and "client secret". This is what you will need to supply to SocialMediaLab.