Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

# Data Visualizing with R

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité   Chargement dans…3
×

## Consultez-les par la suite

1 sur 129 Publicité

# Data Visualizing with R

We look at various scenarios where data visualization is required and see what are the appropriate R functions/tools to use

We look at various scenarios where data visualization is required and see what are the appropriate R functions/tools to use

Publicité
Publicité

### Data Visualizing with R

1. 1. Data Visualization with Baan Bapat Baan Bapat Data Visualization with R
2. 2. Univariate Continuous Birth-weight length(bw)  2700 summary(bw) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.927 2.390 2.580 2.613 2.778 3.454 boxplot(bw, horizontal=TRUE, notch=TRUE, col="gold") qqqqqqq qq qqqq qqq qqqqq qqqqq 2.0 2.5 3.0 3.5 Baan Bapat Data Visualization with R
3. 3. Univariate Continuous Birth-weight length(bw)  2700 summary(bw) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.927 2.390 2.580 2.613 2.778 3.454 boxplot(bw, horizontal=TRUE, notch=TRUE, col="gold") qqqqqqq qq qqqq qqq qqqqq qqqqq 2.0 2.5 3.0 3.5 Baan Bapat Data Visualization with R
4. 4. Univariate Continuous Birth-weight length(bw)  2700 summary(bw) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.927 2.390 2.580 2.613 2.778 3.454 boxplot(bw, horizontal=TRUE, notch=TRUE, col="gold") qqqqqqq qq qqqq qqq qqqqq qqqqq 2.0 2.5 3.0 3.5 Baan Bapat Data Visualization with R
5. 5. Univariate Continuous Birth-weight length(bw)  2700 summary(bw) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.927 2.390 2.580 2.613 2.778 3.454 boxplot(bw, horizontal=TRUE, notch=TRUE, col="gold") qqqqqqq qq qqqq qqq qqqqq qqqqq 2.0 2.5 3.0 3.5 Baan Bapat Data Visualization with R
6. 6. Boxplot Univariate Continuous qqqqqqq qq qqqq qqqqqqqqqqqqq boxplot() q qq robustbase::adjbox() 2.0 2.5 3.0 3.5 q vioplot::vioplot() par(mfrow=c(3,1)) boxplot(bw, ...) robustbase::adjbox(bw, notch=TRUE, cex=2, col="skyblue", lwd=1.5, main="...") vioplot::vioplot(bw, col="lightgreen") title("...") Baan Bapat Data Visualization with R
7. 7. Boxplot Univariate Continuous qqqqqqq qq qqqq qqqqqqqqqqqqq boxplot() q qq robustbase::adjbox() 2.0 2.5 3.0 3.5 q vioplot::vioplot() par(mfrow=c(3,1)) boxplot(bw, ...) robustbase::adjbox(bw, notch=TRUE, cex=2, col="skyblue", lwd=1.5, main="...") vioplot::vioplot(bw, col="lightgreen") title("...") Baan Bapat Data Visualization with R
8. 8. Boxplot Univariate Continuous qqqqqqq qq qqqq qqqqqqqqqqqqq boxplot() q qq robustbase::adjbox() 2.0 2.5 3.0 3.5 q vioplot::vioplot() par(mfrow=c(3,1)) boxplot(bw, ...) robustbase::adjbox(bw, notch=TRUE, cex=2, col="skyblue", lwd=1.5, main="...") vioplot::vioplot(bw, col="lightgreen") title("...") Baan Bapat Data Visualization with R
9. 9. Boxplot Univariate Continuous qqqqqqq qq qqqq qqqqqqqqqqqqq boxplot() q qq robustbase::adjbox() 2.0 2.5 3.0 3.5 q vioplot::vioplot() par(mfrow=c(3,1)) boxplot(bw, ...) robustbase::adjbox(bw, notch=TRUE, cex=2, col="skyblue", lwd=1.5, main="...") vioplot::vioplot(bw, col="lightgreen") title("...") Baan Bapat Data Visualization with R
10. 10. Histogram Univariate Continuous Histogram of birth weight Weight (kg) Frequency 2.0 2.5 3.0 3.5 0100200300400 5 35 127 249 271 346 387 393 281 176 87 95 108 88 45 6 1 hist(bw, xlab="Weight (kg)", ylab="Frequency", labels=TRUE, ...) Baan Bapat Data Visualization with R
11. 11. Histogram & density Univariate Continuous Histogram & Density line: Birth weight Weight (kg) Probability 2.0 2.5 3.0 3.5 0.00.51.01.5 hist(..., freq=FALSE) lines(density(bw), ...) Baan Bapat Data Visualization with R
12. 12. Histogram & density Univariate Continuous Histogram & Density line: Birth weight Weight (kg) Probability 2.0 2.5 3.0 3.5 0.00.51.01.5 hist(..., freq=FALSE) lines(density(bw), ...) Baan Bapat Data Visualization with R
13. 13. Histogram & density Univariate Continuous Histogram & Density lines: Birth weight mixtures? Weight (kg) Probability 2.0 2.5 3.0 3.5 0.00.51.01.5 More breaks in hist Baan Bapat Data Visualization with R
14. 14. Histogram & density Univariate Continuous Histogram & Density lines: Birth weight mixtures? Weight (kg) Probability 2.0 2.5 3.0 3.5 0.00.51.01.5 More breaks in hist Density mixture Baan Bapat Data Visualization with R
15. 15. Histogram & density Univariate Continuous Histogram & Density lines: Birth weight mixtures? Weight (kg) Probability 2.0 2.5 3.0 3.5 0.00.51.01.5 More breaks in hist Density mixture Baan Bapat Data Visualization with R
16. 16. Histogram & adjusted boxplot Univariate Continuous Histogram, Density & Adjbox bw Density 0.00.51.01.5 q q q 2.0 2.5 3.0 3.5 Weight (kg) mat <- matrix(c(1,2)) layout(mat, height=c(0.8, 0.2)) par(mar= c(0,4,3,1), bty="n") hist(..., , axes=FALSE) axis(2) boxplot() Baan Bapat Data Visualization with R
17. 17. Histogram & adjusted boxplot Univariate Continuous Histogram, Density & Adjbox bw Density 0.00.51.01.5 q q q 2.0 2.5 3.0 3.5 Weight (kg) mat <- matrix(c(1,2)) layout(mat, height=c(0.8, 0.2)) par(mar= c(0,4,3,1), bty="n") hist(..., , axes=FALSE) axis(2) boxplot() Baan Bapat Data Visualization with R
18. 18. Histogram & adjusted boxplot Univariate Continuous Histogram, Density & Adjbox bw Density 0.00.51.01.5 q q q 2.0 2.5 3.0 3.5 Weight (kg) mat <- matrix(c(1,2)) layout(mat, height=c(0.8, 0.2)) par(mar= c(0,4,3,1), bty="n") hist(..., , axes=FALSE) axis(2) boxplot() Baan Bapat Data Visualization with R
19. 19. Histogram & adjusted boxplot Univariate Continuous Histogram, Density & Adjbox bw Density 0.00.51.01.5 q q q 2.0 2.5 3.0 3.5 Weight (kg) mat <- matrix(c(1,2)) layout(mat, height=c(0.8, 0.2)) par(mar= c(0,4,3,1), bty="n") hist(..., , axes=FALSE) axis(2) boxplot() Baan Bapat Data Visualization with R
20. 20. Histogram & adjusted boxplot Univariate Continuous Histogram, Density & Adjbox bw Density 0.00.51.01.5 q q q 2.0 2.5 3.0 3.5 Weight (kg) mat <- matrix(c(1,2)) layout(mat, height=c(0.8, 0.2)) par(mar= c(0,4,3,1), bty="n") hist(..., , axes=FALSE) axis(2) boxplot() Baan Bapat Data Visualization with R
21. 21. Histogram & adjusted boxplot Univariate Continuous Histogram, Density & Adjbox bw Density 0.00.51.01.5 q q q 2.0 2.5 3.0 3.5 Weight (kg) mat <- matrix(c(1,2)) layout(mat, height=c(0.8, 0.2)) par(mar= c(0,4,3,1), bty="n") hist(..., , axes=FALSE) axis(2) boxplot() Baan Bapat Data Visualization with R
22. 22. QQ plot – for the statistically inclined Univariate Continuous q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q qq q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q qqqq q q q q qq q q q q q q q q q q q q qq q q q q q q q q qq q qq q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q qq q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q qq q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qqq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q qq q q q q q q qq q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q qq q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qqq q q q q q q q q q q q qq q q q q q q q q qq q q q q q qq q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q qq q q q q q qq q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q qq qq q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q qqq q q q q q q q qq q q q q q qq q q q qq q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q qqq q q q q q q q q q q q q q q qqq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q qqq q q q q q q q q q q q q q q q q q q q qq q qq q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q qq q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q qq qq q q q q qq q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q qq q q qq q q q q qqq q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q qqqq q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q qq q qq q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q qq q q q q q q qq q q q q q q q q q q q q q q q qq q q q q q q qq q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q qq q q qq q q q q q q q q q q q q q qq q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q qqq q q q q q q q qq q q q q qq q q q q q q q q q q q q q qq qqq q q q q q q q qq q q q q q q q q q qq q q qq q q q q q q q q q qq q q q q q q q q q qq q q q qq q q q q q qq q qq q q q q q qq q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q qq q qq q q q q q q q q q q q q q q qq q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q qq q q q q q q q q qq q q q q q q q q q q q q q q q q qq q q q q q qq q q q q q q q q q q q q q q q q q qq q q q q q q q q q q qq q q q q q qq q q q q q q q q q q q q q qq q q q q q q q qqq q q q q q q qq q q q q q q q q q q q q q qq q q q q q q q q q q qq q q q q q q q qq q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q qq q q q q q q q q q q q qq qq q q q q q q qq qq q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q qq qq q q q q q q q q qq q qq q q q q q q q q q q q q qqq q q qqq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q qq q q q q qq q q q q q q q q q q qq q q q q q q q q qq qq q q q q −3 −2 −1 0 1 2 3 2.02.53.03.5 Normal Q−Q Plot Theoretical Quantiles SampleQuantiles qqnorm(bw, col="blue", pch=16) qqline(bw, col="red", lwd=2) Baan Bapat Data Visualization with R
23. 23. QQ plot – for the statistically inclined Univariate Continuous q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q qq q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q qqqq q q q q qq q q q q q q q q q q q q qq q q q q q q q q qq q qq q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q qq q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q qq q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qqq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q qq q q q q q q qq q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q qq q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qqq q q q q q q q q q q q qq q q q q q q q q qq q q q q q qq q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q qq q q q q q qq q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q qq qq q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q qqq q q q q q q q qq q q q q q qq q q q qq q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q qqq q q q q q q q q q q q q q q qqq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q qqq q q q q q q q q q q q q q q q q q q q qq q qq q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q qq q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q qq qq q q q q qq q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q qq q q qq q q q q qqq q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q qqqq q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q qq q qq q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q qq q q q q q q qq q q q q q q q q q q q q q q q qq q q q q q q qq q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q qq q q qq q q q q q q q q q q q q q qq q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q qqq q q q q q q q qq q q q q qq q q q q q q q q q q q q q qq qqq q q q q q q q qq q q q q q q q q q qq q q qq q q q q q q q q q qq q q q q q q q q q qq q q q qq q q q q q qq q qq q q q q q qq q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q qq q qq q q q q q q q q q q q q q q qq q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q qq q q q q q q q q qq q q q q q q q q q q q q q q q q qq q q q q q qq q q q q q q q q q q q q q q q q q qq q q q q q q q q q q qq q q q q q qq q q q q q q q q q q q q q qq q q q q q q q qqq q q q q q q qq q q q q q q q q q q q q q qq q q q q q q q q q q qq q q q q q q q qq q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q qq q q q q q q q q q q q qq qq q q q q q q qq qq q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q qq qq q q q q q q q q qq q qq q q q q q q q q q q q q qqq q q qqq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q qq q q q q qq q q q q q q q q q q qq q q q q q q q q qq qq q q q q −3 −2 −1 0 1 2 3 2.02.53.03.5 Normal Q−Q Plot Theoretical Quantiles SampleQuantiles qqnorm(bw, col="blue", pch=16) qqline(bw, col="red", lwd=2) Baan Bapat Data Visualization with R
24. 24. Univariate Categorical Topics most visited on English Wikipedia on 31 May 2013 Topic No. hits Cult 291439 Rituparno Ghosh 215843 Cat anatomy 102960 Facebook 93181 Fast & Furious 6 84014 Liberace 73162 Game of Thrones 70599 Jean-Claude Romand 70144 Game of Thrones (season 3) 69752 Arrested Development (TV series) 69573 Baan Bapat Data Visualization with R
25. 25. Barplot Univariate Categorical Arrested Development (TV) Game of Thrones (season 3) Jean−Claude Romand Game of Thrones Liberace Fast & Furious 6 Facebook Cat anatomy Rituparno Ghosh Cult 0 50000 100000 150000 200000 250000 69573 69752 70144 70599 73162 84014 93181 102960 215843 291439 n <- length(wiki) bp <- barplot(wiki, horiz=TRUE, col=topo.colors(n)) text(y=bp, x=wiki, labels=wiki, cex=0.8, pos=2) Baan Bapat Data Visualization with R
26. 26. Barplot Univariate Categorical Arrested Development (TV) Game of Thrones (season 3) Jean−Claude Romand Game of Thrones Liberace Fast & Furious 6 Facebook Cat anatomy Rituparno Ghosh Cult 0 50000 100000 150000 200000 250000 69573 69752 70144 70599 73162 84014 93181 102960 215843 291439 n <- length(wiki) bp <- barplot(wiki, horiz=TRUE, col=topo.colors(n)) text(y=bp, x=wiki, labels=wiki, cex=0.8, pos=2) Baan Bapat Data Visualization with R
27. 27. Barplot Univariate Categorical Arrested Development (TV) Game of Thrones (season 3) Jean−Claude Romand Game of Thrones Liberace Fast & Furious 6 Facebook Cat anatomy Rituparno Ghosh Cult 0 50000 100000 150000 200000 250000 69573 69752 70144 70599 73162 84014 93181 102960 215843 291439 n <- length(wiki) bp <- barplot(wiki, horiz=TRUE, col=topo.colors(n)) text(y=bp, x=wiki, labels=wiki, cex=0.8, pos=2) Baan Bapat Data Visualization with R
28. 28. Barplot – two axes Univariate Categorical Frequency Cult rnoGhosh tanatomy Facebook Furious6 Liberace ofThrones eRomand (season3) ment(TV) 1e+051500002e+052500003e+05 q q q q q q q q q q 00.20.40.60.81 Cumm.proportion pwiki <- cumsum( prop.table(wiki)) twoord.plot(lx=n, ly=wiki, rx=n, ry=pwiki, ylab=..., rylab=..., rpch=16, rylim=c(0,1), type=c("bar", "b"), lcol=..., rcol=..., xticklab=...) Baan Bapat Data Visualization with R
29. 29. Barplot – two axes Univariate Categorical Frequency Cult rnoGhosh tanatomy Facebook Furious6 Liberace ofThrones eRomand (season3) ment(TV) 1e+051500002e+052500003e+05 q q q q q q q q q q 00.20.40.60.81 Cumm.proportion pwiki <- cumsum( prop.table(wiki)) twoord.plot(lx=n, ly=wiki, rx=n, ry=pwiki, ylab=..., rylab=..., rpch=16, rylim=c(0,1), type=c("bar", "b"), lcol=..., rcol=..., xticklab=...) Baan Bapat Data Visualization with R
30. 30. Pie Univariate Categorical Arrested Development (TV) Game of Thrones (season 3) Jean−Claude Romand Game of Thrones Liberace Fast & Furious 6 Facebook Cat anatomy Rituparno Ghosh Cult pie(wiki, init.angle=90) Baan Bapat Data Visualization with R
31. 31. Exploded pie Univariate Categorical Arrested Development (TV) Game of Thrones (season 3) Jean−Claude Romand Game of ThronesLiberace Fast & Furious 6 Facebook Cat anatomy Rituparno Ghosh Cult require(plotrix) pie3D(wiki, labels=names(wiki), explode=0.1) Baan Bapat Data Visualization with R
32. 32. Exploded pie Univariate Categorical Arrested Development (TV) Game of Thrones (season 3) Jean−Claude Romand Game of ThronesLiberace Fast & Furious 6 Facebook Cat anatomy Rituparno Ghosh Cult require(plotrix) pie3D(wiki, labels=names(wiki), explode=0.1) Baan Bapat Data Visualization with R
33. 33. Dotchart Univariate Categorical Arrested Development (TV) Game of Thrones (season 3) Jean−Claude Romand Game of Thrones Liberace Fast & Furious 6 Facebook Cat anatomy Rituparno Ghosh Cult q q q q q q q q q q 100000 200000 300000 dotchart(wiki, pch=19, col=rainbow(n)) Baan Bapat Data Visualization with R
34. 34. Bivariate Categorical Hair & Eye color data on 500 odd students Baan Bapat Data Visualization with R
35. 35. Barplot Bivariate Categorical Black Brown Red Blond Hair color Eyecolorfrequency 020406080100120140 Brown Blue Hazel Green Stacked bar plot barplot( HairEyeColor) legend( x="topright", legend = attr(HairEyeColor, "dimnames")\$Eye, pch=18, col=mycols) Baan Bapat Data Visualization with R
36. 36. Barplot Bivariate Categorical Black Brown Red Blond Hair color Eyecolorfrequency 020406080100120140 Brown Blue Hazel Green Stacked bar plot barplot( HairEyeColor) legend( x="topright", legend = attr(HairEyeColor, "dimnames")\$Eye, pch=18, col=mycols) Baan Bapat Data Visualization with R
37. 37. Barplot Bivariate Categorical Black Brown Red Blond Hair color Eyecolorfrequency 020406080100120140 Brown Blue Hazel Green Stacked bar plot barplot( HairEyeColor) legend( x="topright", legend = attr(HairEyeColor, "dimnames")\$Eye, pch=18, col=mycols) Baan Bapat Data Visualization with R
38. 38. Barplot Bivariate Categorical Black Brown Red Blond Hair color Eyecolorfrequency 0102030405060 Brown Blue Hazel Green Grouped bar plot barplot(..., beside=TRUE) Baan Bapat Data Visualization with R
39. 39. Barplot Bivariate Categorical Black Brown Red Blond Hair color Eyecolorfrequency 0102030405060 Brown Blue Hazel Green Grouped bar plot barplot(..., beside=TRUE) Baan Bapat Data Visualization with R
40. 40. Mosaicplot Bivariate Categorical Hair Eye Black Brown Red Blond BrownBlueHazelGreen Mosaic grid mosaicplot( HairEyeColor) Baan Bapat Data Visualization with R
41. 41. Mosaicplot Bivariate Categorical Hair Eye Black Brown Red Blond BrownBlueHazelGreen Mosaic grid mosaicplot( HairEyeColor) Baan Bapat Data Visualization with R
42. 42. Cars data Fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973–74 models), . . . Motor Trend dataset: mtcars Baan Bapat Data Visualization with R
43. 43. Boxplot Bivariate Continuous Vs Categorical qq 4 6 8 1015202530 Cylinders Milespergallon Car Mileage ∼ cylinders boxplot(mpg ∼ cyl, data=mtcars) Baan Bapat Data Visualization with R
44. 44. Boxplot Bivariate Continuous Vs Categorical qq 4 6 8 1015202530 Cylinders Milespergallon Car Mileage ∼ cylinders boxplot(mpg ∼ cyl, data=mtcars) Baan Bapat Data Visualization with R
45. 45. Scatterplot Bivariate Continuous Vs Continuous q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q 2 3 4 5 1015202530 Car Weight MilesPerGallon Car Mileage ∼ weight with(mtcars, plot(x=wt, y=mpg, xlab="...", ylab="...", pch=19, col="darkblue") ) identify(), locator(), grid() Baan Bapat Data Visualization with R
46. 46. Scatterplot Bivariate Continuous Vs Continuous q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q 2 3 4 5 1015202530 Car Weight MilesPerGallon Car Mileage ∼ weight with(mtcars, plot(x=wt, y=mpg, xlab="...", ylab="...", pch=19, col="darkblue") ) identify(), locator(), grid() Baan Bapat Data Visualization with R
47. 47. Scatterplot Bivariate Continuous Vs Continuous q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q 2 3 4 5 1015202530 Car Weight MilesPerGallon Car Mileage ∼ weight with(mtcars, plot(x=wt, y=mpg, xlab="...", ylab="...", pch=19, col="darkblue") ) identify(), locator(), grid() Baan Bapat Data Visualization with R
48. 48. Scatterplot – ﬁtted lines Bivariate Continuous Vs Continuous q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q 2 3 4 5 1015202530 Car Weight MilesPerGallon linear model lowess abline( lsfit(x=wt, y=mpg), col="red") lines( lowess(x=wt, y=mpg), col="green") Baan Bapat Data Visualization with R
49. 49. Scatterplot – ﬁtted lines Bivariate Continuous Vs Continuous q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q 2 3 4 5 1015202530 Car Weight MilesPerGallon linear model lowess abline( lsfit(x=wt, y=mpg), col="red") lines( lowess(x=wt, y=mpg), col="green") Baan Bapat Data Visualization with R
50. 50. car::scatterplot Bivariate Continuous Vs Continuous qq 2 3 4 5 1015202530 Car Weight MilesperGallon q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q require(car) scatterplot(mpg ∼ wt, data=mtcars) Baan Bapat Data Visualization with R
51. 51. car::scatterplot Bivariate Continuous Vs Continuous qq 2 3 4 5 1015202530 Car Weight MilesperGallon q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q require(car) scatterplot(mpg ∼ wt, data=mtcars) Baan Bapat Data Visualization with R
52. 52. Bivariate boxplot – bagplot Bivariate Continuous Vs Continuous 2 3 4 5 1015202530 Car Weight MilesPerGallon q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q require(aplpack) bagplot(wt, mpg, ...) Baan Bapat Data Visualization with R
53. 53. Bivariate boxplot – bagplot Bivariate Continuous Vs Continuous 2 3 4 5 1015202530 Car Weight MilesPerGallon q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q require(aplpack) bagplot(wt, mpg, ...) Baan Bapat Data Visualization with R
54. 54. Lots of data points Bivariate Continuous Vs Continuous 4 6 8 10 12 14 16 101520 Alpha transparency x y rgb(0.2, 0.2, 0.8, 0.2) plot(..., col = rgb(0, 0.4, 0, 0.2)) Baan Bapat Data Visualization with R
55. 55. Lots of data points – hexbin Bivariate Continuous Vs Continuous 4 6 8 10 12 14 16 10 15 20 x y Hexagonal Binning 1 6 10 14 19 24 28 32 37 42 46 50 55 60 64 68 73 Counts require(hexbin) bin <- hexbin(x, y, xbins=50) plot(bin, colramp=BTY, colorcut= seq(0,1,1/16)) Baan Bapat Data Visualization with R
56. 56. Lots of data points – hexbin Bivariate Continuous Vs Continuous 4 6 8 10 12 14 16 10 15 20 x y Hexagonal Binning 1 6 10 14 19 24 28 32 37 42 46 50 55 60 64 68 73 Counts require(hexbin) bin <- hexbin(x, y, xbins=50) plot(bin, colramp=BTY, colorcut= seq(0,1,1/16)) Baan Bapat Data Visualization with R
57. 57. Lots of data points – hexbin Bivariate Continuous Vs Continuous 4 6 8 10 12 14 16 10 15 20 x y Hexagonal Binning 1 6 10 14 19 24 28 32 37 42 46 50 55 60 64 68 73 Counts require(hexbin) bin <- hexbin(x, y, xbins=50) plot(bin, colramp=BTY, colorcut= seq(0,1,1/16)) Baan Bapat Data Visualization with R
58. 58. Timeseries object Bivariate: Continuous Vs Time q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q qq q q q q q q q q q qq q q q q q q q q q q qq q q q q qqq q q q q q q q q qq q q q qq q q q q q q q qq q q q qq q q q q qq Time Temperature(degC) 1990 1992 1994 1996 1998 2000 242526272829 4 5 4 4 4 4 4 6 3 3 Sea surface temperature – El Ni˜no require(tseries) tt <- window(nino3, from=..., to=...) plot(tt) identify(...) text(...) Baan Bapat Data Visualization with R
59. 59. Timeseries object Bivariate: Continuous Vs Time q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q qq q q q q q q q q q qq q q q q q q q q q q qq q q q q qqq q q q q q q q q qq q q q qq q q q q q q q qq q q q qq q q q q qq Time Temperature(degC) 1990 1992 1994 1996 1998 2000 242526272829 4 5 4 4 4 4 4 6 3 3 Sea surface temperature – El Ni˜no require(tseries) tt <- window(nino3, from=..., to=...) plot(tt) identify(...) text(...) Baan Bapat Data Visualization with R
60. 60. Timeseries object Bivariate: Continuous Vs Time q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q qq q q q q q q q q q qq q q q q q q q q q q qq q q q q qqq q q q q q q q q qq q q q qq q q q q q q q qq q q q qq q q q q qq Time Temperature(degC) 1990 1992 1994 1996 1998 2000 242526272829 4 5 4 4 4 4 4 6 3 3 Sea surface temperature – El Ni˜no require(tseries) tt <- window(nino3, from=..., to=...) plot(tt) identify(...) text(...) Baan Bapat Data Visualization with R
61. 61. Timeseries object Bivariate: Continuous Vs Time q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q qq q q q q q q q q q qq q q q q q q q q q q qq q q q q qqq q q q q q q q q qq q q q qq q q q q q q q qq q q q qq q q q q qq Time Temperature(degC) 1990 1992 1994 1996 1998 2000 242526272829 4 5 4 4 4 4 4 6 3 3 Sea surface temperature – El Ni˜no require(tseries) tt <- window(nino3, from=..., to=...) plot(tt) identify(...) text(...) Baan Bapat Data Visualization with R
62. 62. Timeseries object Bivariate: Continuous Vs Time q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q qq q q q q q q q q q qq q q q q q q q q q q qq q q q q qqq q q q q q q q q qq q q q qq q q q q q q q qq q q q qq q q q q qq Time Temperature(degC) 1990 1992 1994 1996 1998 2000 242526272829 4 5 4 4 4 4 4 6 3 3 Sea surface temperature – El Ni˜no require(tseries) tt <- window(nino3, from=..., to=...) plot(tt) identify(...) text(...) Baan Bapat Data Visualization with R
63. 63. Timeseries object Bivariate: Continuous Vs Time q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q qq q q q q q q q q q qq q q q q q q q q q q qq q q q q qqq q q q q q q q q qq q q q qq q q q q q q q qq q q q qq q q q q qq Time Temperature(degC) 1990 1992 1994 1996 1998 2000 242526272829 4 5 4 4 4 4 4 6 3 3 Sea surface temperature – El Ni˜no require(tseries) tt <- window(nino3, from=..., to=...) plot(tt) identify(...) text(...) Baan Bapat Data Visualization with R
64. 64. The plot method Appropriately plots the object passed to it! Timeseries – decomposition nino3: Sea surface temperature of El Ni˜no plot(decompose(nino3)) 23252729 observed 25262728 trend −1.00.01.0 seasonal −1.00.00.51.0 1950 1960 1970 1980 1990 2000 random Time Decomposition of additive time series Baan Bapat Data Visualization with R
65. 65. The plot method Appropriately plots the object passed to it! Multivariate data iris: ﬂower measurements of 3 species which of the 3 species does a given ﬂower belong to? plot(iris, col=iris\$Species) Sepal.Length 2.0 3.0 4.0 q q qq q q q q q q q qq q q q q q q q q q q q q q q qq qq q q q qq q q q qq q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q qq q q q q q q qqq q q q q qq q q q q q q q q q q q q q qq q q q qq qq q q q q q q q q q q q q q qq q q qq q q q q q qqq q q q q q q qq q q q q q q q qq q qq q q q q q q q q q qq qq qq q q q qq q q q qq qq qq q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q qq q q qq q q q q q q qq q q q q qqq q q q q q q q q q q q q q qq q qq qq qq q q q q q q q qq q q q q qq q q qq q q q q q qqq q q q q 0.5 1.5 2.5 q q qq q q q q q q q qq q q q q q q q q q q q q q q qq qq q q q qq q q q qq qq qq q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q qq q q q q q q qqq q q q qqq q q q q q q q q q q q q q qq q q q qq qq q q q q q q q qq q q q q qq q q qq q q q q q q qq q q q q 4.55.56.57.5 q q qq q q q q q q q qq q qq q q q q q q q q q qq qq qq q q q qq q q q qq qq qq q q q q q q q q q q q q q q q q qqq q q q q q q q q q q q q qq q q qq q q q q q q qqq q q q qqq q q q q q q q q q q q q q qq q qq qq qq q q q q q q q qq q q q q qq q q qq q q q q q qqq q q q q 2.03.04.0 q q q q q q q q q q q q qq q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q qq q q q q q q q qq q q q q q q q q q q q q q q q qq qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q qqq q q q q q q q q Sepal.Width q q q q q q qq q q q q qq q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q qq q q q q q q q qq q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q qqq q q q q q q q q q q q q q q qq q q q q qq q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q qq q q q q q q q qq q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q qq q q q q q q qq q q q q q q q q q q q q q q q qq q q q q q q q q q qq q q q q q q qq q q q q q q q q q q q q q q qq q q q q qq q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q qq q q q q q q q qq q q q q q q q q q q q q q q q qq qq q q q q q q q q q q q q qq q q q q q q qq q q q q q q q q q q q q q q q qq q q q q q q q q q qq q q q q q qqq q q q q q q q q qqqq q q q qq q qqq q q qqq qq qq q qq qqqqqq qq qq q qqq qqqq q q q qq qq qq q q qq q q q q q qq q q qq q q q q q qq qq qq q q qq q q q q q q qq q q q q qqq q q q q q q qq q q q q q qq q qq qq qq q q q q q q q qq q q q q q q q q qq q qq qq qq qqqq q qq qq q q qqq q qqq q q qqq qqq q q qq q qqqqq q qqq q qqq qqq q q q q qq qq qq q q qq q q q q q qq q q qq q q q q q q q qq q q q q qq q q q qq q qq q q q q q qqq q q q q q qq q q q q q qq q q q qq qq q q q q q q q q q q q q q q q q q qq q qq qq qq qq q q q Petal.Length qqqqq q qqqqqqq qq qqq qqq q q qq q qqqqq qqqq qqqqqqqq q q qqqqq qq q q qq q q q q q qq q q qq q q q q q qq qq q q q q qq q q qqq q qq q q q q qqqq q q q q q q q q q q q q qq q q qqq qq q q q q q q q qq qq q q q q q q qq q q q qq q q qqq q q 1234567 qqqqq q qqqqqqq qq qqq qqqq q qq qqqqqqqqqq qqqqqqqq q q qqqqq qq q q qqq q q q q qq q q qq q q q q q qq qq qq q q qqq q qqq q qq qq q q qqqq q q q q q qq q q q q q qqq qqqq qq q q q q q q q qq qq q q q q q q qq q qq qq qq qqqq q 0.51.52.5 qqqq q q q qq q qq qq q qq q qq q q q q qq q qqqq q q qqq q q q q qq q q q q qq qq q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q qqq q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q qqq q q q q q q q q q qq q q q q q q q q q q q qq qq q q q qq q qq qq q qq q qq q q q q qq q qqqq q q qqq q q q q qq q q q q qq qq q qq q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q qq q q q q q q qq q q q q q q q q q qq q q q q q q q q q q q q qq q q qq q q q q q q q q q q qq q q q q q q q q q q q qqqqq q q qq q qq qq q qq qqq q q q q qq q qqqq q q qqqq q qq qq q q q q qqqq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qqq q q q q q q qq q q q q q q q q q qq q q q q q q q q q q q q q q q q qqq q q q q q q q q q qq q q q q q q q q q q q Petal.Width qqqqq q q qq q qq qq q qq qqq q q q q qq q qqqq q q qqqq q qq qq q q q q qqqq q qq q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q qqq q q q q q q qq q q q q q q q q q qq q q q q q q q q q q q q qq q q qqq q q q q q q q q q qq q q q q q q q q q q q 4.5 5.5 6.5 7.5 qqqq q qq qq q qqqq qqqq qq qqq qqqqqqqq qq qqq qqq qqqq qqq qq qq qq qq qq qq qqq qqqq qqq qq qqqq qqqqqqqq qqq q qqqqq qqq qqq qq q qq qqq qq qq qqq qqq qq qqq qq qq q qqq q qq qqqq qqqq qqqq qqqqqqq qq qq q qqqq q qqqq q qqq qqq qqqqq qqqqq q qqqq qqq qqq q q qq qq qq qqqq qq qq qqq qq qq qqqq q qqq qqqq qqqqq qq q qqq qqq qqq q qqqq q qq qqqqq qq qqq qq q qq qqq qqqq qqq qq qq qqqq q qqqqqqq qqqq q qq 1 2 3 4 5 6 7 qqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqqqq qq qq qqqq qqq qq qq qqq qq qq qqqq qqqqqqq qqqqqqq qqqq qqqqq q qq qqq qq qqqqqqqqqq qqq qq qq qqqq qqqqqq q qqqq qqqq qqqqqqq qqqqq qqqqqqqqqq qqqqqq qq qqq qqqqq qqqqqqqqqqqq qqqqqqq qqqq qq qq qqq qq qqqqq qq qq qqqqq qqqqq q qqqqqqqq qqq qqqqq q qq qq qqqqq qqq qq qqq qqq qqqq qqqq qq qq qqq qqqq q qqq q qqqq qq 1.0 2.0 3.0 1.02.03.0 Species Baan Bapat Data Visualization with R
66. 66. The plot method Appropriately plots the object passed to it! Linear model of “Mileage ∼ Car Weight” lm1 <- lm(mpg ∼ wt, data=mtcars) par(mfrow=c(2,2)); plot(lm1) 10 15 20 25 30 −4−202468 Fitted values Residuals q q q q q q q q q q q q q q q q q q q q q q qq q qq q q q q q Residuals vs Fitted Fiat 128 Toyota Corolla Chrysler Imperial q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q −2 −1 0 1 2 −1012 Theoretical Quantiles Standardizedresiduals Normal Q−Q Fiat 128 Toyota CorollaChrysler Imperial 10 15 20 25 30 0.00.51.01.5 Fitted values Standardizedresiduals q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q Scale−Location Fiat 128Toyota CorollaChrysler Imperial 0.00 0.05 0.10 0.15 0.20 −2−1012 Leverage Standardizedresiduals q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q Cook's distance 0.5 0.5 1 Residuals vs Leverage Chrysler ImperialToyota CorollaFiat 128 Baan Bapat Data Visualization with R
67. 67. The plot method Appropriately plots the object passed to it! Cluster cars based on their attributes hc <- hclust(dist(mtcars)) plot(hc); rect.hclust(hc, k=4) MaseratiBora ChryslerImperial CadillacFleetwood LincolnContinental FordPanteraL Duster360 CamaroZ28 HornetSportabout PontiacFirebird Hornet4Drive Valiant Merc450SLC Merc450SE Merc450SL DodgeChallenger AMCJavelin HondaCivic ToyotaCorolla Fiat128 FiatX1−9 FerrariDino LotusEuropa Merc230 Volvo142E Datsun710 ToyotaCorona Porsche914−2 Merc240D MazdaRX4 MazdaRX4Wag Merc280 Merc280C 0100200300400 Cluster Dendrogram hclust (*, "complete") dist(mtcars) Height Baan Bapat Data Visualization with R
68. 68. The plot method Appropriately plots the object passed to it! Decision tree: Given Mileage, how many cylinders does the car have? require(rpart); require(rpart.plot) rp1 <- rpart(factor(cyl) ∼ mpg, data=mtcars) prp(rp1) mpg >= 21 mpg >= 184 6 8 yes no Baan Bapat Data Visualization with R
69. 69. Financial timeseries Multivariate: Continuous Vs Time 23 24 25 26 27 YHOO [2013−04−01/2013−06−20] Last 25.35 Volume (millions): 18,811,400 10 20 30 40 Apr 01 2013 Apr 15 2013 Apr 29 2013 May 13 2013 May 28 2013 Jun 10 2013 Jun 20 2013 OLHC data of stock price require(quantmod) getSymbols( "YHOO", from="2013-04-01") chartSeries(YHOO) Baan Bapat Data Visualization with R
70. 70. Financial timeseries Multivariate: Continuous Vs Time 23 24 25 26 27 YHOO [2013−04−01/2013−06−20] Last 25.35 Volume (millions): 18,811,400 10 20 30 40 Apr 01 2013 Apr 15 2013 Apr 29 2013 May 13 2013 May 28 2013 Jun 10 2013 Jun 20 2013 OLHC data of stock price require(quantmod) getSymbols( "YHOO", from="2013-04-01") chartSeries(YHOO) Baan Bapat Data Visualization with R
71. 71. Financial timeseries Multivariate: Continuous Vs Time 23 24 25 26 27 YHOO [2013−04−01/2013−06−20] Last 25.35 Volume (millions): 18,811,400 10 20 30 40 Apr 01 2013 Apr 15 2013 Apr 29 2013 May 13 2013 May 28 2013 Jun 10 2013 Jun 20 2013 OLHC data of stock price require(quantmod) getSymbols( "YHOO", from="2013-04-01") chartSeries(YHOO) Baan Bapat Data Visualization with R
72. 72. Financial timeseries Multivariate: Continuous Vs Time 23 24 25 26 27 YHOO [2013−04−01/2013−06−20] Last 25.35 Volume (millions): 18,811,400 10 20 30 40 Apr 01 2013 Apr 15 2013 Apr 29 2013 May 13 2013 May 28 2013 Jun 10 2013 Jun 20 2013 OLHC data of stock price require(quantmod) getSymbols( "YHOO", from="2013-04-01") chartSeries(YHOO) Baan Bapat Data Visualization with R
73. 73. Complex data plotting Multivariate data, mixed modes lattice: based on the idea of conditioning on the values taken on by one or more of the variables in a data set. xyplot levelplot panel functions ggplot2: implementation of the grammar of graphics in R. data aesthetics geometry statistical operation scales facets coordinates options Baan Bapat Data Visualization with R
74. 74. Complex data plotting Multivariate data, mixed modes lattice: based on the idea of conditioning on the values taken on by one or more of the variables in a data set. xyplot levelplot panel functions ggplot2: implementation of the grammar of graphics in R. data aesthetics geometry statistical operation scales facets coordinates options Baan Bapat Data Visualization with R
75. 75. Complex data plotting Multivariate data, mixed modes lattice: based on the idea of conditioning on the values taken on by one or more of the variables in a data set. xyplot levelplot panel functions ggplot2: implementation of the grammar of graphics in R. data aesthetics geometry statistical operation scales facets coordinates options Baan Bapat Data Visualization with R
76. 76. xyplot Multivariate: Continuous Vs Continuous, by categorical Mileage Price 20000 40000 60000 0 20000 50000 qqqqqqqqq qq qqqqqqqq q 9_3 q qqqqqqqqqqqqqqqqqqq qqqqqqqqq qqq qqq qqqq q 9_3 HO 0 20000 50000 q qqq qqqqq q qqqqqqqqqq q qqqqqqq qq 9_5 q qqqqqqqq q qqqqqqqqq q 9_5 HO 0 20000 50000 q qqq 9−2X AWD qq qqqqqqqqqq qqqqqq q qqqqqqqqqqqqqqqqqqqq qqqq qqqqqq qq qqqqqqq qq AVEO qqqqqqqqqqqqqqqqqqqq qqqqqqqqqq Bonneville q qqqqqqqqqq q qqqqqqqqq qqqq qqq qqqqq qqqqqq qqq qqqqqqq qq qqqqqqqq q Cavalier qqqqqqqqqq Century qqqqqqqq qq Classic q qqqqqqqqqqq qqqqqqqqqqqqqqqqq qq qqqqqqqqqqqqq qqqqqq Cobalt 20000 40000 60000 qq qqqqqqqqqqqqq qqqq q Corvette 20000 40000 60000 qq q qqqqqqq CST−V qqqqqqqqq q CTS qqqqqqqqqq qqqq qqqq q qqqqqqqqqqq Deville qqqqq qqqqqqqq qqqqqq q G6 qqqqq qqqqqqqqqq qq qqq Grand Am qqqqqqqqqq qqqqqqqqqqqq qqqqqqqq Grand Prix qqqqqqqqq q GTO q qqqqqqqqqq q qqqqqqqq qq qq qqqqq q Impala q qqqqqqqqqqqqqqqqqq qqq qqqqqqqqqqqqqqqqqqqqqqqqqqqq Ion qqqqqqqqq q L Series qqqqqqqq qq qqqqqqqqqqqqqqqqqqqq Lacrosse 20000 40000 60000 q q qqqqqqqqqqqqqqqqqq Lesabre 20000 40000 60000 qq qqqqqqq qq q q qqqqqqqq qqqqqqqqqq qqqqqqqqqqqq qqqqqqqqqqqqqqqqq Malibu qqqqqqqqq q q qqqqqqqq q qq qqqqqqqq Monte Carlo q q qqqqqqqq qqqqqq qqq q Park Avenue qq qqqqqqq q STS−V6 qq qqqqqqqq STS−V8 qqqqqqqqqq Sunfire qqqqqqqqqqqqqqqqq qqqqqqqqq qqqq Vibe 0 20000 50000 20000 40000 60000 q qqqqqq qq q XLR−V8 Car resale price as a function of mileage and model require(lattice) xyplot(Price ∼ Mileage | Model, data=ca) Baan Bapat Data Visualization with R
77. 77. xyplot Multivariate: Continuous Vs Continuous, by categorical Mileage Price 20000 40000 60000 0 20000 50000 qqqqqqqqq qq qqqqqqqq q 9_3 q qqqqqqqqqqqqqqqqqqq qqqqqqqqq qqq qqq qqqq q 9_3 HO 0 20000 50000 q qqq qqqqq q qqqqqqqqqq q qqqqqqq qq 9_5 q qqqqqqqq q qqqqqqqqq q 9_5 HO 0 20000 50000 q qqq 9−2X AWD qq qqqqqqqqqq qqqqqq q qqqqqqqqqqqqqqqqqqqq qqqq qqqqqq qq qqqqqqq qq AVEO qqqqqqqqqqqqqqqqqqqq qqqqqqqqqq Bonneville q qqqqqqqqqq q qqqqqqqqq qqqq qqq qqqqq qqqqqq qqq qqqqqqq qq qqqqqqqq q Cavalier qqqqqqqqqq Century qqqqqqqq qq Classic q qqqqqqqqqqq qqqqqqqqqqqqqqqqq qq qqqqqqqqqqqqq qqqqqq Cobalt 20000 40000 60000 qq qqqqqqqqqqqqq qqqq q Corvette 20000 40000 60000 qq q qqqqqqq CST−V qqqqqqqqq q CTS qqqqqqqqqq qqqq qqqq q qqqqqqqqqqq Deville qqqqq qqqqqqqq qqqqqq q G6 qqqqq qqqqqqqqqq qq qqq Grand Am qqqqqqqqqq qqqqqqqqqqqq qqqqqqqq Grand Prix qqqqqqqqq q GTO q qqqqqqqqqq q qqqqqqqq qq qq qqqqq q Impala q qqqqqqqqqqqqqqqqqq qqq qqqqqqqqqqqqqqqqqqqqqqqqqqqq Ion qqqqqqqqq q L Series qqqqqqqq qq qqqqqqqqqqqqqqqqqqqq Lacrosse 20000 40000 60000 q q qqqqqqqqqqqqqqqqqq Lesabre 20000 40000 60000 qq qqqqqqq qq q q qqqqqqqq qqqqqqqqqq qqqqqqqqqqqq qqqqqqqqqqqqqqqqq Malibu qqqqqqqqq q q qqqqqqqq q qq qqqqqqqq Monte Carlo q q qqqqqqqq qqqqqq qqq q Park Avenue qq qqqqqqq q STS−V6 qq qqqqqqqq STS−V8 qqqqqqqqqq Sunfire qqqqqqqqqqqqqqqqq qqqqqqqqq qqqq Vibe 0 20000 50000 20000 40000 60000 q qqqqqq qq q XLR−V8 Car resale price as a function of mileage and model require(lattice) xyplot(Price ∼ Mileage | Model, data=ca) Baan Bapat Data Visualization with R
78. 78. xyplot Multivariate: Continuous Vs Continuous, by categorical Mileage Price 20000 40000 60000 0 20000 50000 qqqqqqqqq qq qqqqqqqq q 9_3 q qqqqqqqqqqqqqqqqqqq qqqqqqqqq qqq qqq qqqq q 9_3 HO 0 20000 50000 q qqq qqqqq q qqqqqqqqqq q qqqqqqq qq 9_5 q qqqqqqqq q qqqqqqqqq q 9_5 HO 0 20000 50000 q qqq 9−2X AWD qq qqqqqqqqqq qqqqqq q qqqqqqqqqqqqqqqqqqqq qqqq qqqqqq qq qqqqqqq qq AVEO qqqqqqqqqqqqqqqqqqqq qqqqqqqqqq Bonneville q qqqqqqqqqq q qqqqqqqqq qqqq qqq qqqqq qqqqqq qqq qqqqqqq qq qqqqqqqq q Cavalier qqqqqqqqqq Century qqqqqqqq qq Classic q qqqqqqqqqqq qqqqqqqqqqqqqqqqq qq qqqqqqqqqqqqq qqqqqq Cobalt 20000 40000 60000 qq qqqqqqqqqqqqq qqqq q Corvette 20000 40000 60000 qq q qqqqqqq CST−V qqqqqqqqq q CTS qqqqqqqqqq qqqq qqqq q qqqqqqqqqqq Deville qqqqq qqqqqqqq qqqqqq q G6 qqqqq qqqqqqqqqq qq qqq Grand Am qqqqqqqqqq qqqqqqqqqqqq qqqqqqqq Grand Prix qqqqqqqqq q GTO q qqqqqqqqqq q qqqqqqqq qq qq qqqqq q Impala q qqqqqqqqqqqqqqqqqq qqq qqqqqqqqqqqqqqqqqqqqqqqqqqqq Ion qqqqqqqqq q L Series qqqqqqqq qq qqqqqqqqqqqqqqqqqqqq Lacrosse 20000 40000 60000 q q qqqqqqqqqqqqqqqqqq Lesabre 20000 40000 60000 qq qqqqqqq qq q q qqqqqqqq qqqqqqqqqq qqqqqqqqqqqq qqqqqqqqqqqqqqqqq Malibu qqqqqqqqq q q qqqqqqqq q qq qqqqqqqq Monte Carlo q q qqqqqqqq qqqqqq qqq q Park Avenue qq qqqqqqq q STS−V6 qq qqqqqqqq STS−V8 qqqqqqqqqq Sunfire qqqqqqqqqqqqqqqqq qqqqqqqqq qqqq Vibe 0 20000 50000 20000 40000 60000 q qqqqqq qq q XLR−V8 Car resale price as a function of mileage and model require(lattice) xyplot(Price ∼ Mileage | Model, data=ca) Baan Bapat Data Visualization with R
79. 79. xyplot Multivariate: Continuous Vs Continuous, by categorical Mileage Price 20000 40000 60000 0 20000 50000 qqqqqqqqq qq qqqqqqqq q 9_3 q qqqqqqqqqqqqqqqqqqq qqqqqqqqq qqq qqq qqqq q 9_3 HO 0 20000 50000 q qqq qqqqq q qqqqqqqqqq q qqqqqqq qq 9_5 q qqqqqqqq q qqqqqqqqq q 9_5 HO 0 20000 50000 q qqq 9−2X AWD qq qqqqqqqqqq qqqqqq q qqqqqqqqqqqqqqqqqqqq qqqq qqqqqq qq qqqqqqq qq AVEO qqqqqqqqqqqqqqqqqqqq qqqqqqqqqq Bonneville q qqqqqqqqqq q qqqqqqqqq qqqq qqq qqqqq qqqqqq qqq qqqqqqq qq qqqqqqqq q Cavalier qqqqqqqqqq Century qqqqqqqq qq Classic q qqqqqqqqqqq qqqqqqqqqqqqqqqqq qq qqqqqqqqqqqqq qqqqqq Cobalt 20000 40000 60000 qq qqqqqqqqqqqqq qqqq q Corvette 20000 40000 60000 qq q qqqqqqq CST−V qqqqqqqqq q CTS qqqqqqqqqq qqqq qqqq q qqqqqqqqqqq Deville qqqqq qqqqqqqq qqqqqq q G6 qqqqq qqqqqqqqqq qq qqq Grand Am qqqqqqqqqq qqqqqqqqqqqq qqqqqqqq Grand Prix qqqqqqqqq q GTO q qqqqqqqqqq q qqqqqqqq qq qq qqqqq q Impala q qqqqqqqqqqqqqqqqqq qqq qqqqqqqqqqqqqqqqqqqqqqqqqqqq Ion qqqqqqqqq q L Series qqqqqqqq qq qqqqqqqqqqqqqqqqqqqq Lacrosse 20000 40000 60000 q q qqqqqqqqqqqqqqqqqq Lesabre 20000 40000 60000 qq qqqqqqq qq q q qqqqqqqq qqqqqqqqqq qqqqqqqqqqqq qqqqqqqqqqqqqqqqq Malibu qqqqqqqqq q q qqqqqqqq q qq qqqqqqqq Monte Carlo q q qqqqqqqq qqqqqq qqq q Park Avenue qq qqqqqqq q STS−V6 qq qqqqqqqq STS−V8 qqqqqqqqqq Sunfire qqqqqqqqqqqqqqqqq qqqqqqqqq qqqq Vibe 0 20000 50000 20000 40000 60000 q qqqqqq qq q XLR−V8 xyplot(Price ∼ Mileage | Model, data=ca, panel = function(x, y){ panel.xyplot(x, y) panel.lmline(x, y, span=1, col="red")}) Baan Bapat Data Visualization with R
80. 80. xyplot Multivariate: Continuous Vs Continuous, by categorical Mileage Price 20000 40000 60000 0 20000 50000 qqqqqqqqq qq qqqqqqqq q 9_3 q qqqqqqqqqqqqqqqqqqq qqqqqqqqq qqq qqq qqqq q 9_3 HO 0 20000 50000 q qqq qqqqq q qqqqqqqqqq q qqqqqqq qq 9_5 q qqqqqqqq q qqqqqqqqq q 9_5 HO 0 20000 50000 q qqq 9−2X AWD qq qqqqqqqqqq qqqqqq q qqqqqqqqqqqqqqqqqqqq qqqq qqqqqq qq qqqqqqq qq AVEO qqqqqqqqqqqqqqqqqqqq qqqqqqqqqq Bonneville q qqqqqqqqqq q qqqqqqqqq qqqq qqq qqqqq qqqqqq qqq qqqqqqq qq qqqqqqqq q Cavalier qqqqqqqqqq Century qqqqqqqq qq Classic q qqqqqqqqqqq qqqqqqqqqqqqqqqqq qq qqqqqqqqqqqqq qqqqqq Cobalt 20000 40000 60000 qq qqqqqqqqqqqqq qqqq q Corvette 20000 40000 60000 qq q qqqqqqq CST−V qqqqqqqqq q CTS qqqqqqqqqq qqqq qqqq q qqqqqqqqqqq Deville qqqqq qqqqqqqq qqqqqq q G6 qqqqq qqqqqqqqqq qq qqq Grand Am qqqqqqqqqq qqqqqqqqqqqq qqqqqqqq Grand Prix qqqqqqqqq q GTO q qqqqqqqqqq q qqqqqqqq qq qq qqqqq q Impala q qqqqqqqqqqqqqqqqqq qqq qqqqqqqqqqqqqqqqqqqqqqqqqqqq Ion qqqqqqqqq q L Series qqqqqqqq qq qqqqqqqqqqqqqqqqqqqq Lacrosse 20000 40000 60000 q q qqqqqqqqqqqqqqqqqq Lesabre 20000 40000 60000 qq qqqqqqq qq q q qqqqqqqq qqqqqqqqqq qqqqqqqqqqqq qqqqqqqqqqqqqqqqq Malibu qqqqqqqqq q q qqqqqqqq q qq qqqqqqqq Monte Carlo q q qqqqqqqq qqqqqq qqq q Park Avenue qq qqqqqqq q STS−V6 qq qqqqqqqq STS−V8 qqqqqqqqqq Sunfire qqqqqqqqqqqqqqqqq qqqqqqqqq qqqq Vibe 0 20000 50000 20000 40000 60000 q qqqqqq qq q XLR−V8 xyplot(Price ∼ Mileage | Model, data=ca, panel = function(x, y){ panel.xyplot(x, y) panel.lmline(x, y, span=1, col="red")}) Baan Bapat Data Visualization with R
81. 81. xyplot Multivariate: Continuous Vs Continuous, by categorical Mileage Price 20000 40000 60000 0 20000 50000 qqqqqqqqq qq qqqqqqqq q 9_3 q qqqqqqqqqqqqqqqqqqq qqqqqqqqq qqq qqq qqqq q 9_3 HO 0 20000 50000 q qqq qqqqq q qqqqqqqqqq q qqqqqqq qq 9_5 q qqqqqqqq q qqqqqqqqq q 9_5 HO 0 20000 50000 q qqq 9−2X AWD qq qqqqqqqqqq qqqqqq q qqqqqqqqqqqqqqqqqqqq qqqq qqqqqq qq qqqqqqq qq AVEO qqqqqqqqqqqqqqqqqqqq qqqqqqqqqq Bonneville q qqqqqqqqqq q qqqqqqqqq qqqq qqq qqqqq qqqqqq qqq qqqqqqq qq qqqqqqqq q Cavalier qqqqqqqqqq Century qqqqqqqq qq Classic q qqqqqqqqqqq qqqqqqqqqqqqqqqqq qq qqqqqqqqqqqqq qqqqqq Cobalt 20000 40000 60000 qq qqqqqqqqqqqqq qqqq q Corvette 20000 40000 60000 qq q qqqqqqq CST−V qqqqqqqqq q CTS qqqqqqqqqq qqqq qqqq q qqqqqqqqqqq Deville qqqqq qqqqqqqq qqqqqq q G6 qqqqq qqqqqqqqqq qq qqq Grand Am qqqqqqqqqq qqqqqqqqqqqq qqqqqqqq Grand Prix qqqqqqqqq q GTO q qqqqqqqqqq q qqqqqqqq qq qq qqqqq q Impala q qqqqqqqqqqqqqqqqqq qqq qqqqqqqqqqqqqqqqqqqqqqqqqqqq Ion qqqqqqqqq q L Series qqqqqqqq qq qqqqqqqqqqqqqqqqqqqq Lacrosse 20000 40000 60000 q q qqqqqqqqqqqqqqqqqq Lesabre 20000 40000 60000 qq qqqqqqq qq q q qqqqqqqq qqqqqqqqqq qqqqqqqqqqqq qqqqqqqqqqqqqqqqq Malibu qqqqqqqqq q q qqqqqqqq q qq qqqqqqqq Monte Carlo q q qqqqqqqq qqqqqq qqq q Park Avenue qq qqqqqqq q STS−V6 qq qqqqqqqq STS−V8 qqqqqqqqqq Sunfire qqqqqqqqqqqqqqqqq qqqqqqqqq qqqq Vibe 0 20000 50000 20000 40000 60000 q qqqqqq qq q XLR−V8 xyplot(Price ∼ Mileage | Model, data=ca, panel = function(x, y){ panel.xyplot(x, y) panel.lmline(x, y, span=1, col="red")}) Baan Bapat Data Visualization with R
82. 82. xyplot Multivariate: Continuous Vs Continuous, by categorical Mileage Price 20000 40000 60000 0 20000 50000 qqqqqqqqq qq qqqqqqqq q 9_3 q qqqqqqqqqqqqqqqqqqq qqqqqqqqq qqq qqq qqqq q 9_3 HO 0 20000 50000 q qqq qqqqq q qqqqqqqqqq q qqqqqqq qq 9_5 q qqqqqqqq q qqqqqqqqq q 9_5 HO 0 20000 50000 q qqq 9−2X AWD qq qqqqqqqqqq qqqqqq q qqqqqqqqqqqqqqqqqqqq qqqq qqqqqq qq qqqqqqq qq AVEO qqqqqqqqqqqqqqqqqqqq qqqqqqqqqq Bonneville q qqqqqqqqqq q qqqqqqqqq qqqq qqq qqqqq qqqqqq qqq qqqqqqq qq qqqqqqqq q Cavalier qqqqqqqqqq Century qqqqqqqq qq Classic q qqqqqqqqqqq qqqqqqqqqqqqqqqqq qq qqqqqqqqqqqqq qqqqqq Cobalt 20000 40000 60000 qq qqqqqqqqqqqqq qqqq q Corvette 20000 40000 60000 qq q qqqqqqq CST−V qqqqqqqqq q CTS qqqqqqqqqq qqqq qqqq q qqqqqqqqqqq Deville qqqqq qqqqqqqq qqqqqq q G6 qqqqq qqqqqqqqqq qq qqq Grand Am qqqqqqqqqq qqqqqqqqqqqq qqqqqqqq Grand Prix qqqqqqqqq q GTO q qqqqqqqqqq q qqqqqqqq qq qq qqqqq q Impala q qqqqqqqqqqqqqqqqqq qqq qqqqqqqqqqqqqqqqqqqqqqqqqqqq Ion qqqqqqqqq q L Series qqqqqqqq qq qqqqqqqqqqqqqqqqqqqq Lacrosse 20000 40000 60000 q q qqqqqqqqqqqqqqqqqq Lesabre 20000 40000 60000 qq qqqqqqq qq q q qqqqqqqq qqqqqqqqqq qqqqqqqqqqqq qqqqqqqqqqqqqqqqq Malibu qqqqqqqqq q q qqqqqqqq q qq qqqqqqqq Monte Carlo q q qqqqqqqq qqqqqq qqq q Park Avenue qq qqqqqqq q STS−V6 qq qqqqqqqq STS−V8 qqqqqqqqqq Sunfire qqqqqqqqqqqqqqqqq qqqqqqqqq qqqq Vibe 0 20000 50000 20000 40000 60000 q qqqqqq qq q XLR−V8 xyplot(Price ∼ Mileage | Model, data=ca, panel = function(x, y){ panel.xyplot(x, y) panel.lmline(x, y, span=1, col="red")}) Baan Bapat Data Visualization with R
83. 83. xyplot Multivariate: Continuous Vs Continuous, by categorical Mileage Price 20000 40000 60000 0 20000 50000 qqqqqqqqq qq qqqqqqqq q 9_3 q qqqqqqqqqqqqqqqqqqq qqqqqqqqq qqq qqq qqqq q 9_3 HO 0 20000 50000 q qqq qqqqq q qqqqqqqqqq q qqqqqqq qq 9_5 q qqqqqqqq q qqqqqqqqq q 9_5 HO 0 20000 50000 q qqq 9−2X AWD qq qqqqqqqqqq qqqqqq q qqqqqqqqqqqqqqqqqqqq qqqq qqqqqq qq qqqqqqq qq AVEO qqqqqqqqqqqqqqqqqqqq qqqqqqqqqq Bonneville q qqqqqqqqqq q qqqqqqqqq qqqq qqq qqqqq qqqqqq qqq qqqqqqq qq qqqqqqqq q Cavalier qqqqqqqqqq Century qqqqqqqq qq Classic q qqqqqqqqqqq qqqqqqqqqqqqqqqqq qq qqqqqqqqqqqqq qqqqqq Cobalt 20000 40000 60000 qq qqqqqqqqqqqqq qqqq q Corvette 20000 40000 60000 qq q qqqqqqq CST−V qqqqqqqqq q CTS qqqqqqqqqq qqqq qqqq q qqqqqqqqqqq Deville qqqqq qqqqqqqq qqqqqq q G6 qqqqq qqqqqqqqqq qq qqq Grand Am qqqqqqqqqq qqqqqqqqqqqq qqqqqqqq Grand Prix qqqqqqqqq q GTO q qqqqqqqqqq q qqqqqqqq qq qq qqqqq q Impala q qqqqqqqqqqqqqqqqqq qqq qqqqqqqqqqqqqqqqqqqqqqqqqqqq Ion qqqqqqqqq q L Series qqqqqqqq qq qqqqqqqqqqqqqqqqqqqq Lacrosse 20000 40000 60000 q q qqqqqqqqqqqqqqqqqq Lesabre 20000 40000 60000 qq qqqqqqq qq q q qqqqqqqq qqqqqqqqqq qqqqqqqqqqqq qqqqqqqqqqqqqqqqq Malibu qqqqqqqqq q q qqqqqqqq q qq qqqqqqqq Monte Carlo q q qqqqqqqq qqqqqq qqq q Park Avenue qq qqqqqqq q STS−V6 qq qqqqqqqq STS−V8 qqqqqqqqqq Sunfire qqqqqqqqqqqqqqqqq qqqqqqqqq qqqq Vibe 0 20000 50000 20000 40000 60000 q qqqqqq qq q XLR−V8 xyplot(Price ∼ Mileage | Model, data=ca, panel = function(x, y){ panel.xyplot(x, y) panel.lmline(x, y, span=1, col="red")}) Baan Bapat Data Visualization with R
84. 84. xyplot Multivariate: Continuous Vs Several Categorical variety BarleyYield(bushels/acre) 20 30 40 50 60 Svansota N o.462 M anchuria N o.475 Velvet Peatland G labron N o.457 W isconsin N o.38 Trebi q qq q qqq q q q Grand Rapids 20 30 40 50 60 q qq q q qq qq q Duluth 20 30 40 50 60 q q q q qqq qq q University Farm 20 30 40 50 60 q qq q qqq qq q Morris 20 30 40 50 60 q q q q q qq q q q Crookston 20 30 40 50 60 q qq q q qq q q q Waseca q 1931 1932 xyplot(yield ∼ variety | site, data = barley, groups = year, pch = c(21,22), layout = c(1,6), stack = TRUE, auto.key = list(space = "right"), ylab = "Barley Yield (bushels/acre)", scales = list(x = list(rot = 45))) Baan Bapat Data Visualization with R
85. 85. xyplot Multivariate: Continuous Vs Several Categorical variety BarleyYield(bushels/acre) 20 30 40 50 60 Svansota N o.462 M anchuria N o.475 Velvet Peatland G labron N o.457 W isconsin N o.38 Trebi q qq q qqq q q q Grand Rapids 20 30 40 50 60 q qq q q qq qq q Duluth 20 30 40 50 60 q q q q qqq qq q University Farm 20 30 40 50 60 q qq q qqq qq q Morris 20 30 40 50 60 q q q q q qq q q q Crookston 20 30 40 50 60 q qq q q qq q q q Waseca q 1931 1932 xyplot(yield ∼ variety | site, data = barley, groups = year, pch = c(21,22), layout = c(1,6), stack = TRUE, auto.key = list(space = "right"), ylab = "Barley Yield (bushels/acre)", scales = list(x = list(rot = 45))) Baan Bapat Data Visualization with R
86. 86. xyplot Multivariate: Continuous Vs Several Categorical variety BarleyYield(bushels/acre) 20 30 40 50 60 Svansota N o.462 M anchuria N o.475 Velvet Peatland G labron N o.457 W isconsin N o.38 Trebi q qq q qqq q q q Grand Rapids 20 30 40 50 60 q qq q q qq qq q Duluth 20 30 40 50 60 q q q q qqq qq q University Farm 20 30 40 50 60 q qq q qqq qq q Morris 20 30 40 50 60 q q q q q qq q q q Crookston 20 30 40 50 60 q qq q q qq q q q Waseca q 1931 1932 xyplot(yield ∼ variety | site, data = barley, groups = year, pch = c(21,22), layout = c(1,6), stack = TRUE, auto.key = list(space = "right"), ylab = "Barley Yield (bushels/acre)", scales = list(x = list(rot = 45))) Baan Bapat Data Visualization with R
87. 87. xyplot Multivariate: Continuous Vs Several Categorical variety BarleyYield(bushels/acre) 20 30 40 50 60 Svansota N o.462 M anchuria N o.475 Velvet Peatland G labron N o.457 W isconsin N o.38 Trebi q qq q qqq q q q Grand Rapids 20 30 40 50 60 q qq q q qq qq q Duluth 20 30 40 50 60 q q q q qqq qq q University Farm 20 30 40 50 60 q qq q qqq qq q Morris 20 30 40 50 60 q q q q q qq q q q Crookston 20 30 40 50 60 q qq q q qq q q q Waseca q 1931 1932 xyplot(yield ∼ variety | site, data = barley, groups = year, pch = c(21,22), layout = c(1,6), stack = TRUE, auto.key = list(space = "right"), ylab = "Barley Yield (bushels/acre)", scales = list(x = list(rot = 45))) Baan Bapat Data Visualization with R
88. 88. xyplot Multivariate: Continuous Vs Several Categorical variety BarleyYield(bushels/acre) 20 30 40 50 60 Svansota N o.462 M anchuria N o.475 Velvet Peatland G labron N o.457 W isconsin N o.38 Trebi q qq q qqq q q q Grand Rapids 20 30 40 50 60 q qq q q qq qq q Duluth 20 30 40 50 60 q q q q qqq qq q University Farm 20 30 40 50 60 q qq q qqq qq q Morris 20 30 40 50 60 q q q q q qq q q q Crookston 20 30 40 50 60 q qq q q qq q q q Waseca q 1931 1932 xyplot(yield ∼ variety | site, data = barley, groups = year, pch = c(21,22), layout = c(1,6), stack = TRUE, auto.key = list(space = "right"), ylab = "Barley Yield (bushels/acre)", scales = list(x = list(rot = 45))) Baan Bapat Data Visualization with R
89. 89. xyplot Multivariate: Continuous Vs Several Categorical variety BarleyYield(bushels/acre) 20 30 40 50 60 Svansota N o.462 M anchuria N o.475 Velvet Peatland G labron N o.457 W isconsin N o.38 Trebi q qq q qqq q q q Grand Rapids 20 30 40 50 60 q qq q q qq qq q Duluth 20 30 40 50 60 q q q q qqq qq q University Farm 20 30 40 50 60 q qq q qqq qq q Morris 20 30 40 50 60 q q q q q qq q q q Crookston 20 30 40 50 60 q qq q q qq q q q Waseca q 1931 1932 xyplot(yield ∼ variety | site, data = barley, groups = year, pch = c(21,22), layout = c(1,6), stack = TRUE, auto.key = list(space = "right"), ylab = "Barley Yield (bushels/acre)", scales = list(x = list(rot = 45))) Baan Bapat Data Visualization with R
90. 90. xyplot Multivariate: Continuous Vs Several Categorical variety BarleyYield(bushels/acre) 20 30 40 50 60 Svansota N o.462 M anchuria N o.475 Velvet Peatland G labron N o.457 W isconsin N o.38 Trebi q qq q qqq q q q Grand Rapids 20 30 40 50 60 q qq q q qq qq q Duluth 20 30 40 50 60 q q q q qqq qq q University Farm 20 30 40 50 60 q qq q qqq qq q Morris 20 30 40 50 60 q q q q q qq q q q Crookston 20 30 40 50 60 q qq q q qq q q q Waseca q 1931 1932 xyplot(yield ∼ variety | site, data = barley, groups = year, pch = c(21,22), layout = c(1,6), stack = TRUE, auto.key = list(space = "right"), ylab = "Barley Yield (bushels/acre)", scales = list(x = list(rot = 45))) Baan Bapat Data Visualization with R
91. 91. ggplot qplot: iris Multivariate data iris: ﬂower measurements of 3 species qplot( Sepal.Length, Petal.Length, data = iris, color = Species, size=Petal.Width, alpha=I(0.7)) 2 4 6 5 6 7 8 Sepal.Length Petal.Length Species setosa versicolor virginica log(Petal.Width) −2 −1 0 Baan Bapat Data Visualization with R
92. 92. qplot several time series Growth of Orange trees qplot(age, circumference, data = Orange, geom = c("point", "line"), colour = Tree) q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q 50 100 150 200 400 800 1200 1600 age circumference Tree q q q q q 3 1 5 2 4 Baan Bapat Data Visualization with R
93. 93. qplot Diamond: price, caret & cut qplot(carat, price, data=diamonds, colour=cut, geom=c("point", "smooth")) defaults + layers + scales + coordinate system Layer = data + mapping + geom + stat + position Baan Bapat Data Visualization with R
94. 94. qplot Diamond: price, caret & cut qplot(carat, price, data=diamonds, colour=cut, geom=c("point", "smooth")) defaults + layers + scales + coordinate system Layer = data + mapping + geom + stat + position Baan Bapat Data Visualization with R
95. 95. qplot Diamond: price, caret & cut qplot(carat, price, data=diamonds, colour=cut, geom=c("point", "smooth")) defaults + layers + scales + coordinate system Layer = data + mapping + geom + stat + position Baan Bapat Data Visualization with R
96. 96. Human Development and Corruption UNDP Corruption Perception and Human Development Data Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United States Australia Norway 0.4 0.6 0.8 1.0 2.5 5.0 7.5 Corruption Perception Index 2011 (10 = least) HumanDevelopmentIndex2011(1=best) Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA HDI Vs CPI Country Region Baan Bapat Data Visualization with R
97. 97. Human Development and Corruption 0.4 0.6 0.8 2.5 5.0 7.5 CPI HDI Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA pc1 <- ggplot(dat, aes(x=CPI, y=HDI, color=Region)) pc1 <- pc1 + geom point(shape=9) Baan Bapat Data Visualization with R
98. 98. Human Development and Corruption 0.4 0.6 0.8 2.5 5.0 7.5 CPI HDI Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA pc1 <- ggplot(dat, aes(x=CPI, y=HDI, color=Region)) pc1 <- pc1 + geom point(shape=9) Baan Bapat Data Visualization with R
99. 99. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United StatesAustralia Norway 0.4 0.6 0.8 2.5 5.0 7.5 CPI HDI Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA labs <- c("Chad",... pc2 <- pc1 + geom text(aes(label = Country), color="black", size=3, hjust=1.1, data= dat[dat\$Country %in% labs,]) Baan Bapat Data Visualization with R
100. 100. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United StatesAustralia Norway 0.4 0.6 0.8 2.5 5.0 7.5 CPI HDI Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA labs <- c("Chad",... pc2 <- pc1 + geom text(aes(label = Country), color="black", size=3, hjust=1.1, data= dat[dat\$Country %in% labs,]) Baan Bapat Data Visualization with R
101. 101. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United StatesAustralia Norway 0.4 0.6 0.8 2.5 5.0 7.5 CPI HDI Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA labs <- c("Chad",... pc2 <- pc1 + geom text(aes(label = Country), color="black", size=3, hjust=1.1, data= dat[dat\$Country %in% labs,]) Baan Bapat Data Visualization with R
102. 102. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United StatesAustralia Norway 0.4 0.6 0.8 2.5 5.0 7.5 CPI HDI Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA labs <- c("Chad",... pc2 <- pc1 + geom text(aes(label = Country), color="black", size=3, hjust=1.1, data= dat[dat\$Country %in% labs,]) Baan Bapat Data Visualization with R
103. 103. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United StatesAustralia Norway 0.4 0.6 0.8 2.5 5.0 7.5 CPI HDI Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA labs <- c("Chad",... pc2 <- pc1 + geom text(aes(label = Country), color="black", size=3, hjust=1.1, data= dat[dat\$Country %in% labs,]) Baan Bapat Data Visualization with R
104. 104. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United StatesAustralia Norway 0.4 0.6 0.8 1.0 2.5 5.0 7.5 CPI HDI Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA pc3 <- pc2 + geom smooth( method="lm", color="black", formula = y ∼ poly(x, 2)) Baan Bapat Data Visualization with R
105. 105. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United StatesAustralia Norway 0.4 0.6 0.8 1.0 2.5 5.0 7.5 CPI HDI Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA pc3 <- pc2 + geom smooth( method="lm", color="black", formula = y ∼ poly(x, 2)) Baan Bapat Data Visualization with R
106. 106. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United StatesAustralia Norway 0.4 0.6 0.8 1.0 2.5 5.0 7.5 CPI HDI Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA pc3 <- pc2 + geom smooth( method="lm", color="black", formula = y ∼ poly(x, 2)) Baan Bapat Data Visualization with R
107. 107. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United StatesAustralia Norway 0.4 0.6 0.8 1.0 2.5 5.0 7.5 CPI HDI Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA pc3 <- pc2 + geom smooth( method="lm", color="black", formula = y ∼ poly(x, 2)) Baan Bapat Data Visualization with R
108. 108. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United States Australia Norway 0.4 0.6 0.8 1.0 2.5 5.0 7.5 Corruption Perception Index 2011 (10 = least) HumanDevelopmentIndex2011(1=best) Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA pc4 <- pc3 + theme bw() + scale x continuous( ...) + scale y continuous( ...) + theme( legend.position = "top", legend.direction = "horizontal") Baan Bapat Data Visualization with R
109. 109. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United States Australia Norway 0.4 0.6 0.8 1.0 2.5 5.0 7.5 Corruption Perception Index 2011 (10 = least) HumanDevelopmentIndex2011(1=best) Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA pc4 <- pc3 + theme bw() + scale x continuous( ...) + scale y continuous( ...) + theme( legend.position = "top", legend.direction = "horizontal") Baan Bapat Data Visualization with R
110. 110. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United States Australia Norway 0.4 0.6 0.8 1.0 2.5 5.0 7.5 Corruption Perception Index 2011 (10 = least) HumanDevelopmentIndex2011(1=best) Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA pc4 <- pc3 + theme bw() + scale x continuous( ...) + scale y continuous( ...) + theme( legend.position = "top", legend.direction = "horizontal") Baan Bapat Data Visualization with R
111. 111. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United States Australia Norway 0.4 0.6 0.8 1.0 2.5 5.0 7.5 Corruption Perception Index 2011 (10 = least) HumanDevelopmentIndex2011(1=best) Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA pc4 <- pc3 + theme bw() + scale x continuous( ...) + scale y continuous( ...) + theme( legend.position = "top", legend.direction = "horizontal") Baan Bapat Data Visualization with R
112. 112. Human Development and Corruption Chad Afghanistan Nigeria Bhutan India Cape Verde Indonesia China Ecuador Saint Lucia KuwaitBahrain Italy Hong Kong United States Australia Norway 0.4 0.6 0.8 1.0 2.5 5.0 7.5 Corruption Perception Index 2011 (10 = least) HumanDevelopmentIndex2011(1=best) Region Americas APAC East Eur & Central Asia EU & West Eur MENA SSA pc4 <- pc3 + theme bw() + scale x continuous( ...) + scale y continuous( ...) + theme( legend.position = "top", legend.direction = "horizontal") Baan Bapat Data Visualization with R
113. 113. igraph 1 2 3 4 5 67 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 Statistical network analysis igraphdemo( "cohesive") Social network of friendships between 34 members of a karate club at a US university in the 1970s Baan Bapat Data Visualization with R
114. 114. RgoogleMaps bm1 <- GetMap(center=c(lat, long), zoom=9, maptype="terrain", destfile="bm1.png", NEWMAP=FALSE) qloc: a data frame with lat, long and attribute to be plotted with(qloc, PlotOnStaticMap(bm1, lat=lat, lon=lon, pch=19, cex=xx, col=rgb(...))) Baan Bapat Data Visualization with R
115. 115. RgoogleMaps bm1 <- GetMap(center=c(lat, long), zoom=9, maptype="terrain", destfile="bm1.png", NEWMAP=FALSE) qloc: a data frame with lat, long and attribute to be plotted with(qloc, PlotOnStaticMap(bm1, lat=lat, lon=lon, pch=19, cex=xx, col=rgb(...))) Baan Bapat Data Visualization with R
116. 116. RgoogleMaps bm1 <- GetMap(center=c(lat, long), zoom=9, maptype="terrain", destfile="bm1.png", NEWMAP=FALSE) qloc: a data frame with lat, long and attribute to be plotted with(qloc, PlotOnStaticMap(bm1, lat=lat, lon=lon, pch=19, cex=xx, col=rgb(...))) Baan Bapat Data Visualization with R
117. 117. sp Plotting spatial data Swiss Language Regions french german italian require(sp) url( "http://gadm.org/ data/rda/ CHE adm1.RData") language <- c("german", ...) col = terrain.color(. . . ) spplot(gadm, ”language”, col.regions=col) Baan Bapat Data Visualization with R
118. 118. sp Plotting spatial data Swiss Language Regions french german italian require(sp) url( "http://gadm.org/ data/rda/ CHE adm1.RData") language <- c("german", ...) col = terrain.color(. . . ) spplot(gadm, ”language”, col.regions=col) Baan Bapat Data Visualization with R
119. 119. sp Plotting spatial data Swiss Language Regions french german italian require(sp) url( "http://gadm.org/ data/rda/ CHE adm1.RData") language <- c("german", ...) col = terrain.color(. . . ) spplot(gadm, ”language”, col.regions=col) Baan Bapat Data Visualization with R
120. 120. sp Plotting spatial data Swiss Language Regions french german italian require(sp) url( "http://gadm.org/ data/rda/ CHE adm1.RData") language <- c("german", ...) col = terrain.color(. . . ) spplot(gadm, ”language”, col.regions=col) Baan Bapat Data Visualization with R
121. 121. sp Plotting spatial data Swiss Language Regions french german italian require(sp) url( "http://gadm.org/ data/rda/ CHE adm1.RData") language <- c("german", ...) col = terrain.color(. . . ) spplot(gadm, ”language”, col.regions=col) Baan Bapat Data Visualization with R
122. 122. Choropleth Choropleth: Plotting unemployment data on US map packages: rgdal, colorschemes & RColorBrewer 15 lines of code Baan Bapat Data Visualization with R
123. 123. Interactive Visualization R + Ggobi require(rggobi) ggobi(iris) R + iplots shiny ui.R server.R runApp(¡directory¿) R + Google Chart Tools require(googleVis) demo(googleVis) World Bank country indicators data gvisMotionChart(. . . ) Baan Bapat Data Visualization with R
124. 124. Interactive Visualization R + Ggobi require(rggobi) ggobi(iris) R + iplots shiny ui.R server.R runApp(¡directory¿) R + Google Chart Tools require(googleVis) demo(googleVis) World Bank country indicators data gvisMotionChart(. . . ) Baan Bapat Data Visualization with R
125. 125. Interactive Visualization R + Ggobi require(rggobi) ggobi(iris) R + iplots shiny ui.R server.R runApp(¡directory¿) R + Google Chart Tools require(googleVis) demo(googleVis) World Bank country indicators data gvisMotionChart(. . . ) Baan Bapat Data Visualization with R
126. 126. Interactive Visualization R + Ggobi require(rggobi) ggobi(iris) R + iplots shiny ui.R server.R runApp(¡directory¿) R + Google Chart Tools require(googleVis) demo(googleVis) World Bank country indicators data gvisMotionChart(. . . ) Baan Bapat Data Visualization with R
127. 127. Success Stories Flying in the USA Glaciers melt as mountains warm Soda, pop, coke, . . . ? Baan Bapat Data Visualization with R
128. 128. Success Stories Baan Bapat Data Visualization with R
129. 129. Thank you! Baan Bapat Data Visualization with R