Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Introduction to R for Business Intelligence

You're reading from  Introduction to R for Business Intelligence

Product type Book
Published in Aug 2016
Publisher Packt
ISBN-13 9781785280252
Pages 228 pages
Edition 1st Edition
Languages
Author (1):
Jay Gendron Jay Gendron
Profile icon Jay Gendron
Toc

Table of Contents (19) Chapters close

Introduction to R for Business Intelligence
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
1. Extract, Transform, and Load 2. Data Cleaning 3. Exploratory Data Analysis 4. Linear Regression for Business 5. Data Mining with Cluster Analysis 6. Time Series Analysis 7. Visualizing the Datas Story 8. Web Dashboards with Shiny References
Other Helpful R Functions R Packages Used in the Book
R Code for Supporting Market Segment Business Case Calculations

Plotting with ggplot2


Wilkinson (2005) developed The Grammar of Graphics as a way of approaching data visualization by describing them as individual components working together. Wickham (2010) used this grammar to develop the ggplot2 package. In ggplot2, you can create plots by adding each component of the visualization as a layer. In this section, you will recreate a scatterplot from Chapter 4 , Linear Regression for Business that you built using base R graphics. Convert emp_size to a factor to see its effect in visualizing information:

plot_dat <- read.csv("./data/Ch7_marketing.csv") 
plot_dat$emp_size <- cut(plot_dat$employees, breaks = 3, 
          labels = c("Employees: 3 - 6", "7 - 9", "10+")) 
library(ggplot2); library(scales) 
plot <- ggplot(data = plot_dat, aes(x = marketing_total, 
               y = revenues)) 

First, you will use the ggplot() function to create a basic plot object and pass it the plot_dat dataset. Note that the command...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime