Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
R Data Analysis Cookbook, Second Edition
R Data Analysis Cookbook, Second Edition

R Data Analysis Cookbook, Second Edition: Customizable R Recipes for data mining, data visualization and time series analysis , Second Edition

Arrow left icon
Profile Icon Kuntal Ganguly Profile Icon Viswanathan Profile Icon Viswa Viswanathan
Arrow right icon
$9.99 $43.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.3 (4 Ratings)
eBook Sep 2017 560 pages 2nd Edition
eBook
$9.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Kuntal Ganguly Profile Icon Viswanathan Profile Icon Viswa Viswanathan
Arrow right icon
$9.99 $43.99
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.3 (4 Ratings)
eBook Sep 2017 560 pages 2nd Edition
eBook
$9.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$9.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

R Data Analysis Cookbook, Second Edition

What's in There - Exploratory Data Analysis

In this chapter, you will cover:

  • Creating standard data summaries
  • Extracting a subset of a dataset
  • Splitting a dataset
  • Creating random data partitions
  • Generating standard plots, such as histograms, boxplots, and scatterplots
  • Generating multiple plots on a grid
  • Creating plots with the lattice package
  • Creating charts that facilitate comparisons
  • Creating charts that help to visualize possible causality

Introduction

Exploratory analysis techniques are one part of the larger process of collecting data, learning from data, acting on data, and exploring data to uncover a meaningful pattern. The Exploratory Data Analysis (EDA) is a crucial step to take before diving into advanced analytics and machine learning, as it provides the context needed to develop an appropriate model for the problem at hand and to correctly interpret its results through visualization techniques to tease apart hidden patterns. In this chapter, we will discuss some of EDA's most common and essential practices, in order to summarize and visualize data so that the task of finding trends and patterns becomes causally easier.

Creating standard data summaries

In this recipe, we summarize the data using summary functions.

Getting ready

If you have not already downloaded the files for this chapter, do it now and ensure that the auto-mpg.csv file is in your R working directory.

How to do it...

Read the data from auto-mpg.csv, which includes a header row and columns separated by the default "," symbol.

  1. Read the data from auto-mpg.csv and convert cylinders to factor:
> auto  <- read.csv("auto-mpg.csv", header = TRUE,     stringsAsFactors = FALSE) 
> # Convert cylinders...

Extracting a subset of a dataset

In this recipe, we discuss two ways to subset data. The first approach uses the row and column indices/names and the other uses the subset() function.

Getting ready

Download the files for this chapter and store the auto-mpg.csv file in your R working directory. Read the data using the following command:

> auto <- read.csv("auto-mpg.csv", stringsAsFactors=FALSE) 

The same subsetting principles apply for vectors, lists, arrays, matrices, and data frames. We illustrate with data frames.

How to do it...

The following steps extract...

Splitting a dataset

When we have categorical variables, we often want to create groups corresponding to each level and to analyze each group separately to reveal some significant similarities and differences between them.

The split function divides data into groups based on a factor or vector. The unsplit() function reverses the effect of split.

Getting ready

Download the files for this chapter and store the auto-mpg.csv file in your R working directory. Read the file using the read.csv command and save in the auto variable:

> auto <- read.csv("auto-mpg.csv", stringsAsFactors=FALSE) 

How to do it...

...

Creating random data partitions

Analysts need an unbiased evaluation of the quality of their machine learning models. To get this, they partition the available data into two parts. They use one part to build the machine learning model and retain the remaining data as hold out data. After building the model, they evaluate the model's performance on the hold out data. This recipe shows you how to partition data. It separately addresses the situations when the target variable is numeric and when it is categorical. It also covers the process of creating two partitions or three.

Getting ready

If you have not already done so, make sure that the BostonHousing.csv and boston-housing-classification.csv files from the code files...

Generating standard plots, such as histograms, boxplots, and scatterplots

Before even embarking on any numerical analyses, you may want to get a good idea about the data through a few quick plots. The base R system supports basic graphics, so for more advanced plots requirement, we generally use lattice and ggplot packages. In this recipe we will cover the simplest form of basic graphs.

Getting ready

If you have not already done so, download the data files for this chapter and ensure that they are available in your R environment's working directory, and run the following commands:

> auto <- read.csv("auto-mpg.csv") 
>
> auto$cylinders <- factor(auto$cylinders, levels = c(3,4,5,6,8), labels...

Generating multiple plots on a grid

We often want to see plots side by side for comparisons. This recipe shows how we can achieve this.

Getting ready

If you have not already done so, download the data files for this chapter and ensure that they are available in your R environment's working directory. Once this is done, run the following commands:

> auto <- read.csv("auto-mpg.csv") 
> cylinders <- factor(cylinders, levels = c(3,4,5,6,8), labels = c("3cyl", "4cyl", "5cyl", "6cyl", "8cyl"))
> attach(auto)

How to do it...

...

Creating plots with the lattice package

The lattice package produces Trellis plots to capture multivariate relationships in the data. Lattice plots are useful for looking at complex relationships between the variables in a dataset. For example, we may want to see how y changes with x across various levels of z. Using the lattice package, we can draw histograms, boxplots, scatterplots, dot plots, and so on. Both plotting and annotation are done in one single call.

Getting ready

Download the files for this chapter and store the auto-mpg.csv file in your R working directory. Read the file using the read.csv function and save in the auto variable. Convert cylinders into a factor variable:

> auto <- read.csv("auto-mpg...

Creating charts that facilitate comparisons

In large datasets, we often gain good insights by examining how different segments behave. The similarities and differences can reveal interesting patterns. This recipe shows how to create graphs that enable such comparisons with different variable types.

Getting ready

If you have not already done so, download the book's files for this chapter and save the daily-bike-rentals.csv file in your R working directory. Read the data into R using
the following command and check the packages needed too:


> library(dplyr)

> bike <- read.csv("daily-bike-rentals.csv")
> bike$season <- factor(bike$season, levels = c(1,2,3,4),labels = c("Spring", "Summer...

Creating charts that help to visualize possible causality

When presenting data, rather than merely presenting information, we usually want to present an explanation of some phenomenon. Visualizing hypothesized causality helps to communicate our ideas clearly.

Getting ready

If you have not already done so, download the book's files for this chapter and save the hourly-bike-rentals.csv file in your R working directory. Read the data into R as follows:

> library(lattice)
> bike <- read.csv("daily-bike-rentals.csv")
> bike$season <- factor(bike$season, levels = c(1,2,3,4),
labels = c("Spring", "Summer", "Fall", "Winter"))
> bike$weathersit <- factor(bike...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Analyse your data using the popular R packages like ggplot2 with ready-to-use and customizable recipes
  • Find meaningful insights from your data and generate dynamic reports
  • A practical guide to help you put your data analysis skills in R to practical use

Description

Data analytics with R has emerged as a very important focus for organizations of all kinds. R enables even those with only an intuitive grasp of the underlying concepts, without a deep mathematical background, to unleash powerful and detailed examinations of their data. This book will show you how you can put your data analysis skills in R to practical use, with recipes catering to the basic as well as advanced data analysis tasks. Right from acquiring your data and preparing it for analysis to the more complex data analysis techniques, the book will show you how you can implement each technique in the best possible manner. You will also visualize your data using the popular R packages like ggplot2 and gain hidden insights from it. Starting with implementing the basic data analysis concepts like handling your data to creating basic plots, you will master the more advanced data analysis techniques like performing cluster analysis, and generating effective analysis reports and visualizations. Throughout the book, you will get to know the common problems and obstacles you might encounter while implementing each of the data analysis techniques in R, with ways to overcoming them in the easiest possible way. By the end of this book, you will have all the knowledge you need to become an expert in data analysis with R, and put your skills to test in real-world scenarios.

Who is this book for?

This book is for data scientists, analysts and even enthusiasts who want to learn and implement the various data analysis techniques using R in a practical way. Those looking for quick, handy solutions to common tasks and challenges in data analysis will find this book to be very useful. Basic knowledge of statistics and R programming is assumed.

What you will learn

  • Acquire, format and visualize your data using R
  • Using R to perform an Exploratory data analysis
  • Introduction to machine learning algorithms such as classification and regression
  • Get started with social network analysis
  • Generate dynamic reporting with Shiny
  • Get started with geospatial analysis
  • Handling large data with R using Spark and MongoDB
  • Build Recommendation system- Collaborative Filtering, Content based and Hybrid
  • Learn real world dataset examples- Fraud Detection and Image Recognition

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 20, 2017
Length: 560 pages
Edition : 2nd
Language : English
ISBN-13 : 9781787125315
Category :
Languages :
Concepts :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Sep 20, 2017
Length: 560 pages
Edition : 2nd
Language : English
ISBN-13 : 9781787125315
Category :
Languages :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 158.97
R Data Analysis Projects
$54.99
R Data Mining
$48.99
R Data Analysis Cookbook, Second Edition
$54.99
Total $ 158.97 Stars icon
Banner background image

Table of Contents

13 Chapters
Acquire and Prepare the Ingredients - Your Data Chevron down icon Chevron up icon
What's in There - Exploratory Data Analysis Chevron down icon Chevron up icon
Where Does It Belong? Classification Chevron down icon Chevron up icon
Give Me a Number - Regression Chevron down icon Chevron up icon
Can you Simplify That? Data Reduction Techniques Chevron down icon Chevron up icon
Lessons from History - Time Series Analysis Chevron down icon Chevron up icon
How does it look? - Advanced data visualization Chevron down icon Chevron up icon
This may also interest you - Building Recommendations Chevron down icon Chevron up icon
It's All About Your Connections - Social Network Analysis Chevron down icon Chevron up icon
Put Your Best Foot Forward - Document and Present Your Analysis Chevron down icon Chevron up icon
Work Smarter, Not Harder - Efficient and Elegant R Code Chevron down icon Chevron up icon
Where in the World? Geospatial Analysis Chevron down icon Chevron up icon
Playing Nice - Connecting to Other Systems Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.3
(4 Ratings)
5 star 50%
4 star 0%
3 star 0%
2 star 25%
1 star 25%
Amazon Customer Oct 02, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The R Data Analysis Cookbook 2nd Edition is primarily focused on real life data analysis and data science activities performed by data analyst/data scientist using R and offers succinct examples on a variety of data analysis topics such as data cleaning & munging, exploratory analysis, vectorized operations, regression, classification, advance clustering, deep learning (image recognition), geospatial analysis, social network analysis, handling large dataset in R with Spark and MongoDB. I enjoyed the section dealing with classification, image recognition and R with distrbuted system. This book does not provide introduction to R language (as it assume the readers to have basic knowledge in R as prerequisite). Although the book provide brief explanation of the machine learning algorithms used in the recipes, with equation, how it works along with its pros/cons, but it doesn't explain in details or great depth about each of the machine learning algorthim. For such information, you will have to look elsewhere such as "Beginning R Programming" and "Machine Learning: An Algorithmic Perspective". Overall it a very good book and hits the road running, if you just have basic knowledge of R programming.
Amazon Verified review Amazon
John DCousta Oct 16, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is for data analyst and aspiring data science professionals who are familiar with basics of R and want to expand their skill set in data analysis activities (without diving too much into mathematics/statistical jargon)- data cleaning & munging, eda, machine learning such as- regression, classification, advance clustering, deep learning (image recognition), handling large dataset in R with Spark.
Amazon Verified review Amazon
Leonardo Damasceno Dec 11, 2017
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Did not like. Too superficial. Treat each topic as 'cake recipe'.
Amazon Verified review Amazon
Dimitri Shvorob Dec 07, 2017
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Looking at the five-star reviews, I notice that "John DCousta" has only reviewed, and given five-star reviews, to Ganguly's two (Packt) books, and "Alessandro Breschi" - whose profile initially had name "Sunith Shetty" - has similarly only reviewed, and given five-star reviews, to three Packt books, one of them plagiarized. In all likelihood, both reviews are fake. Another thing you should know is that Ganguly's other book, "Learning Generative Adversarial Networks", is plagiarized. Even if this one isn't - which I think is unlikely - you should not support a plagiarist by buying his books.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.