Book Image

R Data Analysis Projects

Book Image

R Data Analysis Projects

Overview of this book

R offers a large variety of packages and libraries for fast and accurate data analysis and visualization. As a result, it’s one of the most popularly used languages by data scientists and analysts, or anyone who wants to perform data analysis. This book will demonstrate how you can put to use your existing knowledge of data analysis in R to build highly efficient, end-to-end data analysis pipelines without any hassle. You’ll start by building a content-based recommendation system, followed by building a project on sentiment analysis with tweets. You’ll implement time-series modeling for anomaly detection, and understand cluster analysis of streaming data. You’ll work through projects on performing efficient market data research, building recommendation systems, and analyzing networks accurately, all provided with easy to follow codes. With the help of these real-world projects, you’ll get a better understanding of the challenges faced when building data analysis pipelines, and see how you can overcome them without compromising on the efficiency or accuracy of your systems. The book covers some popularly used R packages such as dplyr, ggplot2, RShiny, and others, and includes tips on using them effectively. By the end of this book, you’ll have a better understanding of data analysis with R, and be able to put your knowledge to practical use without any hassle.
Table of Contents (15 chapters)
Title Page
About the Author
About the Reviewer
Customer Feedback


This book is for readers who want to leverage the R platform for their data analysis projects/problems. We introduce readers to different R packages for various data analysis purposes and help them use the right package for the right task. A complete project built from scratch in each chapter will help readers better understand building end-to-end predictive analytics solutions. This book covers a variety of topics, including building deep learning networks in R, graph mining, streaming data analysis, sentiment classification, and recommender systems.

What this book covers

Chapter 1, Association Rule Mining, builds recommender systems with transaction data. We identify cross-sell and upsell opportunities.

Chapter 2, Fuzzy Logic Induced Content-Based Recommendation, addresses the cold start problem in the recommender system. We handle the ranking problem with multi-similarity metrics using a fuzzy sets approach.

Chapter 3, Collaborative Filtering, introduces different approaches to collaborative filtering for recommender systems.

Chapter 4Taming Time Series Data Using Deep Neural Networks, introduces MXNet R, a package for deep learning in R. We leverage MXNet to build a deep connected network to predict stock closing prices.

Chapter 5, Twitter Text Sentiment Classification Using Kernel Density Estimates, shows ability to process Twitter data in R. We introduce delta-tfidf, a new metric for sentiment classification. We leverage the kernel density estimate based Naïve Bayes algorithm to classify sentiments.

Chapter 6, Record Linkage - Stochastic and Machine Learning Approaches, covers the problem of master data management and how to solve it in R using the recordLinkage package.

Chapter 7, Streaming Data Clustering Analysis in R, introduces a package stream for handling streaming data in R, and the clustering of streaming data, as well as the online/offline clustering model.

Chapter 8, Analyzing and Understanding Networks Using R, covers the igraph package for performing graph analysis in R. We solve product network analysis problems with graph algorithms.

What you need for this book

Base R must be installed. The code in this book was written using R version 3.4.1 (2017-06-30), single candle, on a Mac OS darwin15.6.0. They should be compatible with Linux and Windows operating systems. RStudio Version 0.99.491 was used as an editor to write and compile R code.

Who this book is for

If you are looking for a book that takes you all the way through the practical applications of advanced and effective analytics methodologies in R, then this is the book for you. A fundamental understanding of R and the basic concepts of data analysis are all you need to get started with this book.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

Any command-line input or output is written as follows:

zero.matrix.gup <- mx.nd.zeros(c(3,3), mx.gpu(0))

New terms and important words are shown in bold.

Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button moves you to the next screen."


Warnings or important notes appear like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply email [email protected], and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at If you purchased this book elsewhere, you can visit and register to have the files emailed directly to you. You can download the code files by following these steps:

  1. Log in or register to our website using your email address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at We also have other code bundles from our rich catalog of books and videos available at Check them out!


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title. To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at [email protected] with a link to the suspected pirated material. We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.