2. Slide 2Slide 2Slide 2 www.edureka.co/r-for-analytics
Have a basic understanding of Data Visualization as a field
Create basic and advanced Graphs in R
Change colors or use custom palettes
Customize graphical parameters
Learn basics of Grammar of Graphics
Spatial analysis Visualization
What will you learn today?
3. Slide 3Slide 3Slide 3 www.edureka.co/r-for-analytics
Part 1 : What is Data Visualization ?
• Study of the visual representation of data
• More than pretty graphs
• Gives insights
• Helps decision making
• Accurate and truthful
Why Data Visualization?
"Lies, damned lies, and statistics" is a phrase describing the persuasive power of numbers, particularly the use
of statistics to bolster weak argument
Cue to Anscombe-Case Study
Source- Anscombe (1973) http://www.sjsu.edu/faculty/gerstman/StatPrimer/anscombe1973.pdf
Data Visualization In R
4. Slide 4Slide 4Slide 4 www.edureka.co/r-for-analytics
> cor(mtcars)
Part 2 : Does This Make Sense?
Data Visualization In R
5. Slide 5Slide 5Slide 5 www.edureka.co/r-for-analytics
Part 2 : Does This Make Better Sense?
• Library(corrgram)
• Corrgram(mtcars) RED is negative BLUE is positive
• Darker the color, more the correlation
Data Visualization In R
6. Slide 6Slide 6Slide 6 www.edureka.co/r-for-analytics
Part 3 : Basic graphs in R (Which one should we use and when?)
• Pie Chart (never use them)
• Scatter Plot (always use them?)
• Line Graph (Linear Trend)
• Bar Graphs (When are they better than Line graphs?)
• Sunflower plot (overplotting)
• Rug Plot
• Density Plot
• Histograms (Give us a good break!)
• Box Plots
Basic graphs in R
7. Slide 7Slide 7Slide 7 www.edureka.co/r-for-analytics
Part 3 : Basic graphs in R
• Plot(iris)
• Plot the entire object
• See how variables behave with each other
Basic graphs in R
8. Slide 8Slide 8Slide 8 www.edureka.co/r-for-analytics
Part 3 Basic graphs in R
• Plot(iris$Sepal.Length, iris$Species)
• Plot two variables at a time to closely examine relationship
Basic graphs in R
9. Slide 9Slide 9Slide 9 www.edureka.co/r-for-analytics
Part 3 Basic graphs in R
• Plot(iris$Species, iris$Sepal.Length)
• Plot two variables at a time
• Order is important
Hint- Keep factor variables to X axis Box Plot- Five
Numbers! minimum, first quartile, median,
third quartile, maximum.
Basic graphs in R
10. Slide 10Slide 10Slide 10 www.edureka.co/r-for-analytics
Part 3 : Basic graphs in R
• Plot(iris$Sepal.Length)
• Plot one variable
Scatterplot
Basic graphs in R
11. Slide 11Slide 11Slide 11 www.edureka.co/r-for-analytics
Part 3 : Basic graphs in R
• Plot(iris$Sepal.Length, type='l')
• Plot with type='l'
• Used if you need trend (usually with
respect to time)
Line graph
Basic graphs in R
12. Slide 12Slide 12Slide 12 www.edureka.co/r-for-analytics
Part 3 : Basic graphs in R
• Plot(iris$Sepal.Length, type='h') Graph
Basic graphs in R
13. Slide 13Slide 13Slide 13 www.edureka.co/r-for-analytics
Part 3 Basic graphs in R
• Barplot(iris$Sepal.Length)
Bar graph
Basic graphs in R
14. Slide 14Slide 14Slide 14 www.edureka.co/r-for-analytics
Part 3 Basic graphs in R
• Pie(table(iris$Species))
• Pie graph
• NOT Recommended
Basic graphs in R
15. Slide 15Slide 15Slide 15 www.edureka.co/r-for-analytics
Part 3 : Basic graphs in R
• Hist(iris$Sepal.Length)
Basic graphs in R
16. Slide 16Slide 16Slide 16 www.edureka.co/r-for-analytics
Part 3 : Basic graphs in R
• Hist(iris$Sepal.Length,breaks=20)
Basic graphs in R
17. Slide 17Slide 17Slide 17 www.edureka.co/r-for-analytics
Part 3 : Basic graphs in R
• Plot(density(iris$Sepal.Length)
Basic graphs in R
18. Slide 18Slide 18Slide 18 www.edureka.co/r-for-analytics
Part 3 : Basic graphs in R
• Boxplot(iris$Sepal.Length)
Boxplot
Basic graphs in R
19. Slide 19Slide 19Slide 19 www.edureka.co/r-for-analytics
Part 3 : Basic graphs in R
Boxplot with Rug
• Boxplot(iris$Sepal.Length)
• Rug(iris$Sepal.Length,side=2)
Adds a rug representation (1-d plot) of the data to the plot.
Basic graphs in R
27. Slide 27Slide 27Slide 27 www.edureka.co/r-for-analytics
Part 4 Advanced Graphs
• Hexbin for over plotting
(many data points at same) library(hexbin)
plot(hexbin(iris$Species,iris$Sepal.Length))
Advanced Graphs
28. Slide 28Slide 28Slide 28 www.edureka.co/r-for-analytics
Part 4 Advanced Graphs
• Hexbin for over plotting(many data points are same)
library(hexbin)
plot(hexbin(mtcars$mpg,mcars$cyl))
Advanced Graphs
29. Slide 29Slide 29Slide 29 www.edureka.co/r-for-analytics
Part 4 : Advanced Graphs
• Tabplot for visual summary of a dataset
library(tabplot)
tableplot(iris)
Advanced Graphs
30. Slide 30Slide 30Slide 30 www.edureka.co/r-for-analytics
Part 4 : Advanced Graphs
• Tabplot for visual summary of a dataset
library(tabplot)
tableplot(mtcars)
Advanced Graphs
31. Slide 31Slide 31Slide 31 www.edureka.co/r-for-analytics
Part 4 Advanced Graphs
• Tabplot for visual summary of a dataset
• Can summarize a lot of data relatively fast
library(tabplot)
library(ggplot)
tableplot(diamonds)
Advanced Graphs
32. Slide 32Slide 32Slide 32 www.edureka.co/r-for-analytics
Part 4 : Advanced Graphs
• Vcd for categorical data
• Mosaic
library(vcd)
mosaic(HairEyeColor)
Advanced Graphs
33. Slide 33Slide 33Slide 33 www.edureka.co/r-for-analytics
Part 4 : Advanced Graphs
• Vcd for categorical data
• Mosaic
library(vcd)
mosaic(Titanic)
Advanced Graphs
34. Slide 34Slide 34Slide 34 www.edureka.co/r-for-analytics
Part 4 : Lots of Graphs in R
heatmap(as.matrix(mtcars))
Advanced Graphs
35. Slide 35Slide 35Slide 35 www.edureka.co/apache-Kafka
Get Certified in R Analytics from Edureka
Edureka's Mastering Data Analytics with R course:
• An Online course covering Techniques of Regression, Predictive Analytics, Data Mining and Sentiment Analysis.
• Online Live Courses: 24 hours
• Assignments: 30 hours
• Project: 25 hours
• Lifetime Access + 24 X 7 Support
Go to www.edureka.co/r-for-analytics
Batch starts from 10th October (Weekend Batch)
36. Slide 36Slide 36Slide 36 www.edureka.co/r-for-analytics
Thank You
Questions/Queries/Feedback
Recording and presentation will be made available to you within 24 hours