Text Mining, Scraping and Sentiment Analysis with R

Learn how to use Twitter social media data for your R text mining work.
4.1 (141 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
1,999 students enrolled Bestselling in Scraping
Take This Course
  • Lectures 35
  • Length 3 hours
  • Skill Level Expert Level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works


Find online courses made by experts from around the world.


Take your courses with you and learn anywhere, anytime.


Learn and practice real-world skills and achieve your goals.

About This Course

Published 2/2015 English

Course Description

Are you an advanced R user, looking to expand your R toolbox?

Are you interested in social media sentiment analysis?

Do you want to learn how you can get and use Twitter data for your R analysis?

Do you want to learn how you can systematically find related words (keywords) to a search term using Twitter and R?

Are you interested in creating visualizations like wordclouds out of text data?

Do you want to learn which R packages you can use for web scraping and text analysis purposes?

If YES came to your mind to some of those points – this course might be tailored towards your needs!

This course will teach you anything you need to know about how to handle social media data in R. We will use Twitter data as our example dataset.

During this course we will take a walk through the whole text analysis process of Twitter data.

At first you will learn which packages are available for social media analysis.

You will learn how to scrape social media (Twitter) data and get it into your R session.

After that we will filter, clean and structure our text corpus.

The next step is the visualization of the text data via wordclouds and dendrograms.

And in the last section we will do a whole sentiment analysis by using a common word lexicon.

All of those steps are accompanied by exercise sessions so that you can check if you can put the information to work.

According to the teaching principles of R Tutorials every section is enforced with exercises for a better learning experience. You can download the code pdf of every section to try the presented code on your own.

If you are not yet on an advanced level in R programming, we would highly recommend our R Level 1 course. The Level 1 course covers all the basic coding strategies that are essential for your day to day programming. R features like functions and apply are covered in the Level 1 course and are also needed for this course.

What R you waiting for?


What are the requirements?

  • intermediate R knowledge is required (R Level 1 course)
  • R program ready on your computer
  • basic understanding of social media and web technologies

What am I going to get from this course?

  • use R for social media mining
  • get data from Twitter to do text analysis
  • perform web scraping tasks using the twitteR package
  • know which packages to use for web scraping
  • get R and Twitter connected
  • know how to perform a sentiment analysis in R
  • plot text data visualizations

Who is the target audience?

  • everybody interested in social media analysis
  • everybody interested in using R for web scraping
  • everybody interested in sentiment analysis
  • everybody interested in text analysis
  • everybody interested in enlarging their R toolbox

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.


Section 1: Introduction
Welcome to the r-tutorials Social Media Mining Course

Those are the packages you can use in R for natural language processing tasks.

Interface Info

Packages for web related tasks like scraping.

Course Links
Course Script
17 pages
10 pages

This worksheet contains the exercises and solutions. Note that there is also the yahoo finance screenshot for exercise 2 available as download.

Section 2: Scraping and Text Mining

You will learn how to get a Twitter developer account and which info you need to get from that account.

Important: Connection Information

In this video I will show you the needed R code to get the scraping process going.

Alternative Authentication

In case the standard way to connect to Twitter does not work, here is an alternative code.


We will use the searchTwitter function to scrape data from Twitter.


In this video I will show you how to clean a text corpus (punctuation, space, stopwords) with the "tm" package. We will also do some transformations for easier text mining.


Let`s plot a wordcloud with our data!


In this video I will show you how to get a document term matrix from your corpus. I will also show you how you can extract the most frequent terms from your data.


We will create a dendrogram and we will also identify the term groups in the data.

Exercise - Quiz
7 questions
Exercise: Text Mining
Solution: Text Mining Part 1
Solution: Text Mining Part 2
Further R Exercises
Section 3: Working with Strings - gsub and the Regular Expression syntax
Regular Expressions and gsub for sentiment analysis - handling of scraped data
Working with Strings - Introduction
Working with Strings - gsub
Working with Strings - gsub advanced
Regular Expression Overview
2 pages
Working with Strings - Library Stringr
Exercise and Solution: Strings in R
Code Section: Strings
Section 4: Sentiment Analysis

You will learn the theory behind a sentiment analysis and I will also walk you through a simple example.


We will take a closer look at our main function for sentiment analysis.


We will get Tweets to compare the sentiment on 4 different countries.


We will score our Tweets and visualize the data.

Exercise: Sentiment Analysis
Solution: Sentiment Analysis

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

R-Tutorials Training, Data Science Education

R-Tutorials is your provider of choice when it comes to analytics training courses! Try it out – our 30,000+ students love it.

We focus on Data Science tutorials. Offering several R courses for every skill level, we are Udemy's number one R training provider. On top of that courses on Tableau, Excel and a Data Science career guide are available.

All of our courses contain exercises to give you the opportunity to try out the material on your own. You will also get downloadable script pdfs to recap the lessons.

The courses are taught by our main instructor Martin – trained biostatistician and enthusiastic data scientist / R user.

Should you have any questions, you are invited to check out our website, you can open a discussion in the course or you can simply drop us a pm.

We are there to help you boost your career with analytics training – Just learn and enjoy.

Ready to start learning?
Take This Course