The w orld of data v is u ali z ation DATA VISU AL IZATION IN R - - PowerPoint PPT Presentation

the w orld of data v is u ali z ation
SMART_READER_LITE
LIVE PREVIEW

The w orld of data v is u ali z ation DATA VISU AL IZATION IN R - - PowerPoint PPT Presentation

The w orld of data v is u ali z ation DATA VISU AL IZATION IN R Ron Pearson Instr u ctor Graphical tools help u s u nderstand a dataset O u r abilit y to interpret pa erns is a ke y strength T w o basic t y pes of data v is u ali z ations :


slide-1
SLIDE 1

The world of data visualization

DATA VISU AL IZATION IN R

Ron Pearson

Instructor

slide-2
SLIDE 2

DATA VISUALIZATION IN R

Graphical tools help us understand a dataset

Our ability to interpret paerns is a key strength Two basic types of data visualizations: Exploratory visualizations help us understand the data Explanatory visualizations help us share our understanding with others R supports both types of visualizations

slide-3
SLIDE 3

DATA VISUALIZATION IN R

Exploratory data visualizations

Helps you see what is in your data Level of detail: Keep as much detail as possible Practical limit: How much can you see and interpret?

slide-4
SLIDE 4

DATA VISUALIZATION IN R

Exploratory data visualizations

# Exploratory plot of ChickWeight data frame plot(ChickWeight)

slide-5
SLIDE 5

DATA VISUALIZATION IN R

Explanatory data visualizations

Shows others what you’ve found in your data Requires editorial decisions: Highlight the key features you want to emphasize Eliminate extraneous details

slide-6
SLIDE 6

DATA VISUALIZATION IN R

Explanatory data visualizations

slide-7
SLIDE 7

DATA VISUALIZATION IN R

Explanatory data visualizations

slide-8
SLIDE 8

DATA VISUALIZATION IN R

Four graphics systems in R

Base graphics: Easiest to learn and focus of this course Grid graphics: powerful set of modules for building other tools Laice graphics: general purpose system based on grid graphics

ggplot2 : the grammar of graphics

slide-9
SLIDE 9

DATA VISUALIZATION IN R

Base graphics example

library(MASS) plot(UScereal$sugars, UScereal$Calories) title("plot(UScereal$sugars, UScereal$calories)")

slide-10
SLIDE 10

DATA VISUALIZATION IN R

Base graphics example

slide-11
SLIDE 11

DATA VISUALIZATION IN R

Near equivalent in grid graphics

# Get the data and load the grid package library(MASS) x <- UScereal$sugars y <- UScereal$calories library(grid) # This is the grid code required to generate the plot pushViewport(plotViewport()) pushViewport(dataViewport(x, y)) grid.rect() grid.xaxis() grid.yaxis() grid.points(x, y) grid.text("UScereal$calories", x = unit(-3, "lines"), rot = 90) grid.text("UScereal$sugars", y = unit(-3, "lines"), rot = 0) popViewport(2)

slide-12
SLIDE 12

DATA VISUALIZATION IN R

Near equivalent in grid graphics

slide-13
SLIDE 13

DATA VISUALIZATION IN R

Conditional scatterplot example from lattice graphics

library(MASS) library(lattice) xyplot(MPG.city ~ Horsepower | Cylinders, data = Cars93)

slide-14
SLIDE 14

DATA VISUALIZATION IN R

Conditional scatterplot example from lattice graphics

slide-15
SLIDE 15

DATA VISUALIZATION IN R

Example ggplot2 plot

library(MASS) library(ggplot2) title <- "ggplot2 plot of \n UScereal$calories vs. \n UScereal$sugars" basePlot <- ggplot(UScereal, aes(x = sugars, y = calories)) basePlot + geom_point(shape = as.character(UScereal$shelf), size = 3) + annotate("text", label = title, x = 3, y = 400, colour = "red")

slide-16
SLIDE 16

DATA VISUALIZATION IN R

Example ggplot2 plot

slide-17
SLIDE 17

Let's practice!

DATA VISU AL IZATION IN R

slide-18
SLIDE 18

A preview of some more and less useful techniques

DATA VISU AL IZATION IN R

Ron Pearson

Instructor

slide-19
SLIDE 19

DATA VISUALIZATION IN R

Scatterplots in base graphics

library(MASS) plot(Boston$rm, Boston$medv, main = "Scatterplot")

slide-20
SLIDE 20

DATA VISUALIZATION IN R

Scatterplots in base graphics

slide-21
SLIDE 21

DATA VISUALIZATION IN R

Scatterplots in base graphics

slide-22
SLIDE 22

DATA VISUALIZATION IN R

Scatterplots in base graphics

slide-23
SLIDE 23

DATA VISUALIZATION IN R

Sunflowerplots in base graphics

library(MASS) sunflowerplot(Boston$rad, Boston$tax, main = "Sunflowerplot")

slide-24
SLIDE 24

DATA VISUALIZATION IN R

Sunflowerplots in base graphics

slide-25
SLIDE 25

DATA VISUALIZATION IN R

Boxplots on base graphics

library(MASS) boxplot(crim ~ rad, data = Boston, log = "y", las = 1 main = "Boxplot", xlab = "rad", ylab = "crim")

slide-26
SLIDE 26

DATA VISUALIZATION IN R

Boxplots on base graphics

slide-27
SLIDE 27

DATA VISUALIZATION IN R

Mosaicplots in base graphics

mosaicplot(cyl ~ gear, data = mtcars, main = "Mosaicplot")

slide-28
SLIDE 28

DATA VISUALIZATION IN R

Some plot types are more useful than others

slide-29
SLIDE 29

DATA VISUALIZATION IN R

Base R plots can be enhanced in many ways

High level functions like plot() Features can be added to a plot The points() function adds points The lines() function adds lines, usually curved The text() function adds labels Using dierent colors - Chapter 5 covers this in detail

slide-30
SLIDE 30

DATA VISUALIZATION IN R

Base R plots can be enhanced in many ways

slide-31
SLIDE 31

DATA VISUALIZATION IN R

Base R plots can be enhanced in many ways

slide-32
SLIDE 32

DATA VISUALIZATION IN R

Base R plots can be enhanced in many ways

The par() function sets many graphic parameters One useful parameter is mfrow , which sets up plot arrays This is discussed in Chapter 4

slide-33
SLIDE 33

DATA VISUALIZATION IN R

Base R plots can be enhanced in many ways

slide-34
SLIDE 34

DATA VISUALIZATION IN R

Base R plots can be enhanced in many ways

slide-35
SLIDE 35

Let's practice!

DATA VISU AL IZATION IN R