0% found this document useful (0 votes)
6 views71 pages

Graphical Representations in R

This document discusses using different types of graphs in R, including dot charts, bar plots, and histograms. It provides examples of how to create dot charts to represent death rates by age, sex and location. Bar plots are demonstrated showing death rates with error bars and color coding. Histograms are generated to illustrate distributions of random Poisson data. The document shows how to customize and format various graph types in R.

Uploaded by

kadda zerrouki
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views71 pages

Graphical Representations in R

This document discusses using different types of graphs in R, including dot charts, bar plots, and histograms. It provides examples of how to create dot charts to represent death rates by age, sex and location. Bar plots are demonstrated showing death rates with error bars and color coding. Histograms are generated to illustrate distributions of random Poisson data. The document shows how to customize and format various graph types in R.

Uploaded by

kadda zerrouki
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Frédéric Bertrand ESIEA 5e année - 2012/2013

Feuille de Travaux Dirigés no 4


Les graphiques et R
Les exemples de cette feuille de travaux dirigées sont tirés de l’aide du logiciel R

1 Contenu
Nous allons nous intéresser à différents types de représentations graphiques adaptées
à la nature des variables que nous souhaitons représenter.
> library(graphics)

2 dotchart
> dotchart(VADeaths, main = "Death Rates in Virginia - 1940")

Death Rates in Virginia − 1940

Rural Male
70−74 ●
65−69 ●
60−64 ●
55−59 ●
50−54 ●

Rural Female
70−74 ●
65−69 ●
60−64 ●
55−59 ●
50−54 ●

Urban Male
70−74 ●
65−69 ●
60−64 ●
55−59 ●
50−54 ●

Urban Female
70−74 ●
65−69 ●
60−64 ●
55−59 ●
50−54 ●

10 20 30 40 50 60 70

> op <- par(xaxs = "i")


> dotchart(t(VADeaths), main = "Death Rates in Virginia - 1940",
+ xlim = c(0, 100))
> par(op)

1
Frédéric Bertrand ESIEA 5e année - 2012/2013

Death Rates in Virginia − 1940

50−54
Urban Female ●
Urban Male ●
Rural Female ●
Rural Male ●

55−59
Urban Female ●
Urban Male ●
Rural Female ●
Rural Male ●

60−64
Urban Female ●
Urban Male ●
Rural Female ●
Rural Male ●

65−69
Urban Female ●
Urban Male ●
Rural Female ●
Rural Male ●

70−74
Urban Female ●
Urban Male ●
Rural Female ●
Rural Male ●

0 20 40 60 80 100

3 barplot
> require(grDevices)
> tN <- table(Ni <- stats::rpois(100, lambda = 5))

> r <- barplot(tN, col = rainbow(20))


> lines(r, tN, type = "h", col = "red", lwd = 2)

2
Frédéric Bertrand ESIEA 5e année - 2012/2013

20
15
10
5
0

1 2 3 4 5 6 7 8 9 10

> barplot(tN, space = 1.5, axisnames = FALSE, sub = "sous-titre")


20
15
10
5
0

sous−titre

> barplot(VADeaths, plot = FALSE)

[1] 0.7 1.9 3.1 4.3

3
Frédéric Bertrand ESIEA 5e année - 2012/2013

> barplot(VADeaths, plot = FALSE, beside = TRUE)

[,1] [,2] [,3] [,4]


[1,] 1.5 7.5 13.5 19.5
[2,] 2.5 8.5 14.5 20.5
[3,] 3.5 9.5 15.5 21.5
[4,] 4.5 10.5 16.5 22.5
[5,] 5.5 11.5 17.5 23.5

> mp <- barplot(VADeaths)


> tot <- colMeans(VADeaths)
> text(mp, tot + 3, format(tot), xpd = TRUE, col = "blue")
200
150
100
50

40.48
32.74
25.18 25.28
0

Rural Male Rural Female Urban Male Urban Female

> barplot(VADeaths, beside = TRUE, col = c("lightblue",


+ "mistyrose", "lightcyan", "lavender", "cornsilk"),
+ legend = rownames(VADeaths), ylim = c(0, 100))
> title(main = "Death Rates in Virginia", [Link] = 4)

4
Frédéric Bertrand ESIEA 5e année - 2012/2013

Death Rates in Virginia

100
50−54
55−59
60−64

80
65−69
70−74
60
40
20
0

Rural Male Rural Female Urban Male Urban Female

> hh <- t(VADeaths)[, 5:1]


> mybarcol <- "gray20"

> mp <- barplot(hh, beside = TRUE, col = c("lightblue",


+ "mistyrose", "lightcyan", "lavender"), legend = colnames(VADeaths),
+ ylim = c(0, 100), main = "Death Rates in Virginia",
+ [Link] = 4, sub = "Faked upper 2*sigma error bars",
+ [Link] = mybarcol, [Link] = 1.5)
> segments(mp, hh, mp, hh + 2 * sqrt(1000 * hh/100), col = mybarcol,
+ lwd = 1.5)
> stopifnot(dim(mp) == dim(hh))
> mtext(side = 1, at = colMeans(mp), line = -2, text = paste("Mean",
+ formatC(colMeans(hh))), col = "red")

5
Frédéric Bertrand ESIEA 5e année - 2012/2013

Death Rates in Virginia

100
Rural Male
Rural Female
Urban Male

80
Urban Female
60
40
20

Mean 60.35 Mean 40.4 Mean 25.88 Mean 16.93 Mean 11.05
0

70−74 65−69 60−64 55−59 50−54

Faked upper 2*sigma error bars

> barplot(VADeaths, angle = 15 + 10 * 1:5, density = 20,


+ col = "black", legend = rownames(VADeaths))
> title(main = list("Death Rates in Virginia", font = 4))

Death Rates in Virginia


200

70−74
65−69
60−64
55−59
150

50−54
100
50
0

Rural Male Rural Female Urban Male Urban Female

> barplot(VADeaths, border = "dark blue")

6
Frédéric Bertrand ESIEA 5e année - 2012/2013

200
150
100
50
0

Rural Male Rural Female Urban Male Urban Female

Échelles logarithmiques

> barplot(tN, col = [Link](12), log = "y")


20
10
5
2
1

1 2 3 4 5 6 7 8 9 10

> barplot(tN, col = [Link](20), log = "xy")

7
Frédéric Bertrand ESIEA 5e année - 2012/2013

20
10
5
2
1

1 2 3 4 5 7 9

4 hist
> op <- par(mfrow = c(2, 2))
> hist(islands)
> utils::str(hist(islands, col = "gray", labels = TRUE))
> hist(sqrt(islands), breaks = 12, col = "lightblue",
+ border = "pink")
> r <- hist(sqrt(islands), breaks = c(4 * 0:5, 10 * 3:5,
+ 70, 100, 140), col = "blue1")
> text(r$mids, r$density, r$counts, adj = c(0.5, -0.5),
+ col = "blue3")
> sapply(r[2:3], sum)
> sum(r$density * diff(r$breaks))
> lines(r, lty = 3, border = "purple")
> par(op)

8
Frédéric Bertrand ESIEA 5e année - 2012/2013

Histogram of islands Histogram of islands


41

40

40
30

30
Frequency

Frequency
20

20
10

10
0 2 1 1 1 1 0 0 1

0
0 5000 10000 15000 0 5000 10000 15000

islands islands

Histogram of sqrt(islands) Histogram of sqrt(islands)


19
35

0.08
25
Frequency

11

Density

0.04
15

5
3
2
0 5

0.00 100 2 3 2

0 20 60 100 140 0 20 60 100 140

sqrt(islands) sqrt(islands)

> require(utils)
> str(hist(islands, breaks = 12, plot = FALSE))

List of 7
$ breaks : num [1:10] 0 2000 4000 6000 8000 10000 12000 14000 16000 18000
$ counts : int [1:9] 41 2 1 1 1 1 0 0 1
$ intensities: num [1:9] 4.27e-04 2.08e-05 1.04e-05 1.04e-05 1.04e-05 ...
$ density : num [1:9] 4.27e-04 2.08e-05 1.04e-05 1.04e-05 1.04e-05 ...
$ mids : num [1:9] 1000 3000 5000 7000 9000 11000 13000 15000 17000
$ xname : chr "islands"
$ equidist : logi TRUE
- attr(*, "class")= chr "histogram"

> str(hist(islands, breaks = c(12, 20, 36, 80, 200, 1000,


+ 17000), plot = FALSE))

List of 7
$ breaks : num [1:7] 12 20 36 80 200 1000 17000
$ counts : int [1:6] 12 11 8 6 4 7
$ intensities: num [1:6] 0.03125 0.014323 0.003788 0.001042 0.000104 ...
$ density : num [1:6] 0.03125 0.014323 0.003788 0.001042 0.000104 ...
$ mids : num [1:6] 16 28 58 140 600 9000
$ xname : chr "islands"
$ equidist : logi FALSE
- attr(*, "class")= chr "histogram"

9
Frédéric Bertrand ESIEA 5e année - 2012/2013

> hist(islands, breaks = c(12, 20, 36, 80, 200, 1000,


+ 17000), freq = TRUE, main = "WRONG histogram")

WRONG histogram

12
10
8
Frequency

6
4
2
0

0 5000 10000 15000

islands

> require(stats)
> [Link](14)
> x <- rchisq(100, df = 4)

Comparing data with a model distribution should be done with qqplot() !

> qqplot(x, qchisq(ppoints(x), df = 4))


> abline(0, 1, col = 2, lty = 2)

10
Frédéric Bertrand ESIEA 5e année - 2012/2013

15


qchisq(ppoints(x), df = 4)


10








● ●
●●

●●●
●●

●●●



5

●●




●●

●●









●●
●●

●●●

●●●
●●

●●
●●


●●●

●●

0

0 5 10 15

if you really insist on using hist() ... :

> hist(x, freq = FALSE, ylim = c(0, 0.2))


> curve(dchisq(x, df = 4), col = 2, lty = 2, lwd = 2,
+ add = TRUE)

Histogram of x
0.20
0.15
Density

0.10
0.05
0.00

0 5 10 15

11
Frédéric Bertrand ESIEA 5e année - 2012/2013

5 Boı̂tes à moustaches
5.1 boxplot d’une formule
> boxplot(count ~ spray, data = InsectSprays, col = "lightgray")
> boxplot(count ~ spray, data = InsectSprays, notch = TRUE,
+ add = TRUE, col = "blue")
25
20
15


10


5
0

A B C D E F

The last command add notches : If the notches of two plots do not overlap this is
’strong evidence’ that the two medians differ.

> boxplot(decrease ~ treatment, data = OrchardSprays,


+ log = "y", col = "bisque")

12
Frédéric Bertrand ESIEA 5e année - 2012/2013

100

50


20


10
5
2

A B C D E F G H

> rb <- boxplot(decrease ~ treatment, data = OrchardSprays,


+ col = "bisque")
> title("Comparing boxplot()s and non-robust mean +/- SD")
> mn.t <- tapply(OrchardSprays$decrease, OrchardSprays$treatment,
+ mean)
> sd.t <- tapply(OrchardSprays$decrease, OrchardSprays$treatment,
+ sd)
> xi <- 0.3 + seq(rb$n)
> points(xi, mn.t, col = "orange", pch = 18)
> arrows(xi, mn.t - sd.t, xi, mn.t + sd.t, code = 3, col = "pink",
+ angle = 75, length = 0.1)

13
Frédéric Bertrand ESIEA 5e année - 2012/2013

Comparing boxplot()s and non−robust mean +/− SD

120
100

80
60
40


20


0

A B C D E F G H

5.2 boxplot d’une matrice


> mat <- cbind(Uni05 = (1:100)/21, Norm = rnorm(100),
+ "5T" = rt(100, df = 5), Gam2 = rgamma(100, shape = 2))

> boxplot([Link](mat), main = "boxplot([Link](mat),


+ main = ...)")

14
Frédéric Bertrand ESIEA 5e année - 2012/2013

boxplot([Link](mat), main = ...)

10
8 ●

6

4


2
0
−2


−4

Uni05 Norm 5T Gam2

> par(las = 1)
> boxplot([Link](mat), main = "boxplot(*, horizontal = TRUE)",
+ horizontal = TRUE)

boxplot(*, horizontal = TRUE)

Gam2 ● ● ● ●

5T ● ●

Norm

Uni05

−4 −2 0 2 4 6 8 10

Using ’at = ’ and adding boxplots – example idea by Roger Bivand :

15
Frédéric Bertrand ESIEA 5e année - 2012/2013

> boxplot(len ~ dose, data = ToothGrowth, boxwex = 0.25,


+ at = 1:3 - 0.2, subset = supp == "VC", col = "yellow",
+ main = "Guinea Pigs' Tooth Growth", xlab = "Vitamin C dose mg",
+ ylab = "tooth length", xlim = c(0.5, 3.5), ylim = c(0,
+ 35), yaxs = "i")
> boxplot(len ~ dose, data = ToothGrowth, add = TRUE,
+ boxwex = 0.25, at = 1:3 + 0.2, subset = supp ==
+ "OJ", col = "orange")
> legend(2, 9, c("Ascorbic acid", "Orange juice"), fill = c("yellow",
+ "orange"))

Guinea Pigs' Tooth Growth


35
30
25


tooth length

20
15
10

Ascorbic acid
Orange juice
5
0

0.5 0.5 1 1 2 2

Vitamin C dose mg

6 pie
> require(grDevices)

> pie(rep(1, 24), col = rainbow(24), radius = 0.9)

16
Frédéric Bertrand ESIEA 5e année - 2012/2013

7 6
8 5
9 4

10 3

11 2

12 1

13 24

14 23

15 22

16 21
17 20
18 19

> [Link] <- c(0.12, 0.3, 0.26, 0.16, 0.04, 0.12)


> names([Link]) <- c("Blueberry", "Cherry", "Apple",
+ "Boston Cream", "Other", "Vanilla Cream")

> pie([Link])

Cherry

Blueberry

Apple
Vanilla Cream

Other

Boston Cream

17
Frédéric Bertrand ESIEA 5e année - 2012/2013

> pie([Link], col = c("purple", "violetred1", "green3",


+ "cornsilk", "cyan", "white"))

Cherry

Blueberry

Apple
Vanilla Cream

Other

Boston Cream

> pie([Link], col = gray(seq(0.4, 1, length = 6)))

Cherry

Blueberry

Apple
Vanilla Cream

Other

Boston Cream

> pie([Link], density = 10, angle = 15 + 10 * 1:6)

18
Frédéric Bertrand ESIEA 5e année - 2012/2013

Cherry

Blueberry

Apple
Vanilla Cream

Other

Boston Cream

> pie([Link], clockwise = TRUE, main = "pie(*, clockwise=TRUE)")


> segments(0, 0, 0, 1, col = "red", lwd = 2)
> text(0, 1, "[Link] = 90", col = "red")

pie(*, clockwise=TRUE)

[Link] = 90

Vanilla Cream Blueberry

Other

Boston Cream
Cherry

Apple

> n <- 200


> pie(rep(1, n), labels = "", col = rainbow(n), border = NA,

19
Frédéric Bertrand ESIEA 5e année - 2012/2013

+ main = "Rainbow")

Rainbow

7 Tableaux de contingence
7.1 balloonplot
> library(gdata)
> library(gtools)
> library(gplots)

> balloonplot([Link](HairEyeColor[, , Sex = "Male"]),


+ dotsize = 10)
> balloonplot([Link](HairEyeColor[, , Sex = "Female"]),
+ dotsize = 10)

20
Frédéric Bertrand ESIEA 5e année - 2012/2013

Balloon Plot for x by y.


Area is proportional to Freq.

x Black Brown Red Blond

Brown 32 53 ●
10 ●
3 98

Blue ●
11 50 ●
10 30 101

Hazel ●
10 25 ●7 ●5 47

Green ●
3 15 ●7 ●8 33

56 143 34 46 279

7.2 assocplot
## Aggregate over sex :

> x <- [Link](HairEyeColor, c(1, 2))


> x

> assocplot(x, main = "Relation between hair and eye color")

21
Frédéric Bertrand ESIEA 5e année - 2012/2013

Relation between hair and eye color

Brown
Eye

Blue
Hazel
Green

Black Brown Red Blond

Hair

7.3 mosaicplot
> mosaicplot(Titanic, main = "Survival on the Titanic",
+ color = TRUE)

Survival on the Titanic

1st 2nd 3rd Crew


Child Adult Child Adult Child Adult Child Adult
No
Male
Yes
Sex

No
Female
Yes

Class

## Formula interface for tabulated data :

22
Frédéric Bertrand ESIEA 5e année - 2012/2013

> mosaicplot(~Sex + Age + Survived, data = Titanic, color = TRUE)

Titanic

Male Female
No Yes No Yes

Child
Age

Adult

Sex

> mosaicplot(HairEyeColor, shade = TRUE)

HairEyeColor

Black Brown Red Blond


Male Female Male Female Male
Female Male Female
>4
2:4
Brown

0:2
−2:0
Eye

−4:−2
<−4
Blue

Standardized
Residuals:
Hazel
Green

Hair

## Independence model of hair and eye color and sex. Indicates that ## there are
more blue eyed blonde females than expected in the case ## of independence and
too few brown eyed blonde females. ## The corresponding model is :

23
Frédéric Bertrand ESIEA 5e année - 2012/2013

> fm <- loglin(HairEyeColor, list(1, 2, 3))


> pchisq(fm$pearson, fm$df, [Link] = FALSE)

> mosaicplot(HairEyeColor, shade = TRUE, margin = list(1:2,


+ 3))

HairEyeColor

Black Brown Red Blond


Male Female Male Female Male
Female Male Female

>4
2:4
Brown

0:2
−2:0
Eye

−4:−2
<−4
Blue

Standardized
Residuals:
Hazel
Green

Hair

## Model of joint independence of sex from hair and eye color. Males ## are un-
derrepresented among people with brown hair and eyes, and are ## overrepresented
among people with brown hair and blue eyes. ## The corresponding model is :

> fm <- loglin(HairEyeColor, list(1:2, 3))


> pchisq(fm$pearson, fm$df, [Link] = FALSE)

## Formula interface for raw data : visualize cross-tabulation of numbers ## of


gears and carburettors in Motor Trend car data.

> mosaicplot(~gear + carb, data = mtcars, color = TRUE,


+ las = 1)

24
Frédéric Bertrand ESIEA 5e année - 2012/2013

mtcars

3 4 5

2
carb

6
8

gear

# color recycling

> mosaicplot(~gear + carb, data = mtcars, color = 2:3,


+ las = 1)

mtcars

3 4 5

2
carb

6
8

gear

25
Frédéric Bertrand ESIEA 5e année - 2012/2013

7.4 splineplot
## treatment and improvement of patients with rheumatoid arthritis

> treatment <- factor(rep(c(1, 2), c(43, 41)), levels = c(1,


+ 2), labels = c("placebo", "treated"))
> improved <- factor(rep(c(1, 2, 3, 1, 2, 3), c(29, 7,
+ 7, 13, 7, 21)), levels = c(1, 2, 3), labels = c("none",
+ "some", "marked"))

## (dependence on a categorical variable)

> (spineplot(improved ~ treatment))

1.0
marked

0.8
some

0.6
improved

0.4
none

0.2
0.0

placebo treated

treatment

## applications and admissions by department at UC Berkeley ## (two-way


tables)

> (spineplot([Link](UCBAdmissions, c(3, 2)),


+ main = "Applications at UCB"))

26
Frédéric Bertrand ESIEA 5e année - 2012/2013

Applications at UCB

1.0
Female

0.8
0.6
Gender

Male

0.4
0.2
0.0
A B C D E F

Dept

> (spineplot([Link](UCBAdmissions, c(3, 1)),


+ main = "Admissions at UCB"))

Admissions at UCB
1.0
Rejected

0.8
0.6
Admit

0.4
Admitted

0.2
0.0

A B C D E F

Dept

## NASA space shuttle o-ring failures

27
Frédéric Bertrand ESIEA 5e année - 2012/2013

> fail <- factor(c(2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1,


+ 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1), levels = c(1,
+ 2), labels = c("no", "yes"))
> temperature <- c(53, 57, 58, 63, 66, 67, 67, 67, 68,
+ 69, 70, 70, 70, 70, 72, 73, 75, 75, 76, 76, 78,
+ 79, 81)

## (dependence on a numerical variable)

> (spineplot(fail ~ temperature))

1.0
0.8
yes

0.6
fail

0.4
no

0.2
0.0

50 60 70 75 80

temperature

> (spineplot(fail ~ temperature, breaks = 3))

28
Frédéric Bertrand ESIEA 5e année - 2012/2013

1.0
0.8
yes

0.6
fail

0.4
no

0.2
0.0
50 60 70 80

temperature

> (spineplot(fail ~ temperature, breaks = quantile(temperature)))

1.0
0.8
yes

0.6
fail

0.4
no

0.2
0.0

53 67 70 75 81

temperature

## highlighting for failures

> spineplot(fail ~ temperature, ylevels = 2:1)

29
Frédéric Bertrand ESIEA 5e année - 2012/2013

1.0
0.8
no

0.6
fail

0.4
yes

0.2
0.0
50 60 70 75 80

temperature

7.5 cdplot (Conditional Density Plots)


NASA space shuttle o-ring failures

> fail <- factor(c(2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1,


+ 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1), levels = 1:2,
+ labels = c("no", "yes"))
> temperature <- c(53, 57, 58, 63, 66, 67, 67, 67, 68,
+ 69, 70, 70, 70, 70, 72, 73, 75, 75, 76, 76, 78,
+ 79, 81)

> cdplot(fail ~ temperature)

30
Frédéric Bertrand ESIEA 5e année - 2012/2013

1.0
0.8
yes

0.6
fail

0.4
no

0.2
0.0
55 60 65 70 75 80

temperature

> cdplot(fail ~ temperature, bw = 2)

1.0
0.8
yes

0.6
fail

0.4
no

0.2
0.0

55 60 65 70 75 80

temperature

> cdplot(fail ~ temperature, bw = "SJ")

31
Frédéric Bertrand ESIEA 5e année - 2012/2013

1.0
0.8
yes

0.6
fail

0.4
no

0.2
0.0
55 60 65 70 75 80

temperature

compare with spinogram on the same graph


> layout(1:2)
> cdplot(fail ~ temperature)
> (spineplot(fail ~ temperature, breaks = 3))
> layout(1)
0.8
yes
fail

0.4
no

0.0

55 60 65 70 75 80

temperature
0.8
yes
fail

0.4
no

0.0

50 60 70 80

temperature

32
Frédéric Bertrand ESIEA 5e année - 2012/2013

highlighting for failures

> cdplot(fail ~ temperature, ylevels = 2:1)

1.0
0.8
no

0.6
fail

0.4
yes

0.2
0.0
55 60 65 70 75 80

temperature

scatter plot with conditional density

> cdens <- cdplot(fail ~ temperature, plot = FALSE)

> plot(I([Link](fail) - 1) ~ jitter(temperature, factor = 2),


+ xlab = "Temperature", ylab = "Conditional failure probability")
> lines(53:81, 1 - cdens[[1]](53:81), col = 2)

33
Frédéric Bertrand ESIEA 5e année - 2012/2013

1.0
● ● ● ● ●● ●

0.8
Conditional failure probability

0.6
0.4
0.2
0.0

● ● ● ● ● ●● ● ● ● ●
● ● ● ●

55 60 65 70 75 80

Temperature

8 Plot factor variables


> require(grDevices)
> plot(PlantGrowth)
3.0

● ● ●● ● ●● ● ● ●
2.5
group

2.0

● ● ● ● ● ● ● ● ● ●
1.5
1.0

● ●● ● ●●
● ● ● ●

3.5 4.0 4.5 5.0 5.5 6.0

weight

34
Frédéric Bertrand ESIEA 5e année - 2012/2013

> plot(weight ~ group, data = PlantGrowth)

6.0
5.5 ●
weight

5.0
4.5
4.0
3.5

ctrl trt1 trt2

group

> plot(cut(weight, 2) ~ group, data = PlantGrowth)


1.0
0.8
(4.95,6.31]

0.6
cut(weight, 2)

0.4
(3.59,4.95]

0.2
0.0

ctrl trt1 trt2

group

passing ”...” to spineplot() eventually :

35
Frédéric Bertrand ESIEA 5e année - 2012/2013

> plot(cut(weight, 3) ~ group, data = PlantGrowth, col = hcl(c(0,


+ 120, 240), 50, 70))

1.0
(5.4,6.31]

0.8
0.6
cut(weight, 3)

(4.5,5.4]

0.4
0.2
(3.59,4.5]

0.0
ctrl trt1 trt2

group

9 Matrix plot
> pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species",
+ pch = 21, bg = c("red", "green3", "blue")[unclass(iris$Species)])

36
Frédéric Bertrand ESIEA 5e année - 2012/2013

Anderson's Iris Data −− 3 species


2.0 3.0 4.0 0.5 1.5 2.5
● ● ●
● ● ● ● ● ●●● ●●●●

7.5

●● ● ●

● ● ● ●●●● ● ●
● ● ●

●●
● ●●●●●● ●● ● ●

● ● ●
●● ● ●● ●
●●● ●●●
●● ●
●● ●● ●● ●●●

6.5
●●●
● ● ● ● ●● ●● ●●● ● ● ●
●●
●●
● ●●●● ●●●●●● ●
● ● ●
●● ●
●●
● ●●●●●
●● ●●●● ● ● ●● ● ●
[Link] ●

●●●
●●

●●●
●●●

● ●
● ●
●●●
●●
●●


●● ●


● ●
● ●●●●


●● ●


●● ● ● ● ● ●●● ● ●
●●

●●●● ●
● ●●● ● ●●
● ●● ●● ●

5.5

●●●●●●●● ● ●●
● ●●●
● ● ●
● ●● ●
● ● ● ●
●●

●●

●● ●● ●
● ●

●● ●
● ● ●●
●●
●●●● ● ●


●●
●● ●●● ● ●●
●●
●● ● ●
● ●●● ●●●●
● ●● ●
●●
●● ● ●●● ●
●●● ● ● ●

●●● ● ● ●
●●
●● ● ●
●● ● ●

4.5
● ●● ● ● ●●
● ●●

●●
● ● ●●● ●●

● ● ●
● ● ●
4.0

● ● ●
● ● ●
● ●● ●
● ● ●● ●
●●● ●● ●●● ● ●
● ●● ● ● ●
● ●● ● ●● ● ●● ●
●●● ● ●●●
● ●● ●
● ● ●●● ● ● ●● ●●
●●● ● ●● ●●● ● ●●
● ●● ●
●● ● ●
● ●● ●●● ● [Link] ●

●●
●● ●●
● ●●
●●● ●●●
● ●

● ●
●● ● ● ●

3.0

● ●● ● ●●
●● ●
● ●●●●● ●
● ●● ●● ● ● ●●
●● ●●● ● ●● ●●● ●●●● ●● ●● ●●●● ●
●●●●●●●
●●●●●● ● ●●● ●●●●●●● ●●●●
● ●● ●●●●● ● ● ● ● ● ●●●● ● ● ● ●●● ●
●●● ●●●●● ● ● ● ●●● ●●
●●● ● ● ● ●●●● ●●●●● ●
● ●● ●● ●● ●●
● ●●● ● ●●● ● ●●
● ●● ● ● ● ●● ● ● ● ● ● ●
● ● ●●● ● ● ● ● ● ●● ● ● ● ● ● ●●●●
● ● ●●● ●●
● ● ● ● ● ● ●● ● ● ●
●● ● ● ● ● ●
2.0

● ● ●

1 2 3 4 5 6 7
● ● ● ●●●●
●● ● ● ●

●●● ● ●●● ●●● ● ●
● ● ●● ●●● ●● ●
● ●
●● ●●● ● ●●● ●
●●●●
● ●
●●● ●●
●● ●● ● ● ●
● ●
●●●
●● ● ●●
●●
● ● ● ●● ●
●●● ● ●● ●
●●
●●●
●● ●● ●
●●●● ● ● ● ● ● ● ●●
●●● ●● ● ● ●
●●●
● ●●● ●
● ●●●● ●● ●●●
●●●●●●●● ● ●●


●●



●●●● ●●●
●●

●●
●●●

●●●●●●●● ●●
●● ●● ●●
●●
●●● ● ●●

●●●
●●
● ●



●●●
●● ● ●●●●
● ●●
●●
●●●
●●
●● ●

[Link] ●
●●●●
●●

●●●●●

●●
● ● ● ● ●

● ● ●

● ●●●●●
● ● ●●
●● ●
●● ●
●●●
●●●
●●●●●
●●●
●●
●●
●● ● ●●
●● ●● ●●
●●●●
●●●
● ●
●● ●
●●●●●●●● ●
● ●
●●

●●
●●●
●●

●●●●● ● ● ●
● ● ● ●●



2.5

● ● ● ● ● ●●●
● ● ● ● ● ● ● ●
● ● ●●● ● ● ●●● ● ●●
●●●●● ●
●● ● ● ● ● ●● ●
● ●●● ● ● ● ●● ● ●
●●●● ●
●● ● ●● ● ● ● ● ● ●●
●● ●●
● ●● ● ● ●● ●
●● ●
●●●●●●● ● ●● ● ●●●●●● ●
●● ●●●●●
● ● ● ● ● ●
1.5

● ● ● ● ● ●● ●● ● ●
● ● ●● ●●●● ● ● ● ● ●●●●● ●● ●
●●●

● ● ●● ● ● ●●●●●●● ● ●●●● ●
● ●●
●●● ●●●● ●
● ●● ●
● ● ●●●●
●●
●●● ●
● ●
●●


●●
●●
●●●●


[Link]
●● ● ●● ● ● ●●● ●● ●●●●●
0.5

● ● ●
● ● ●
●● ● ● ● ●●● ● ●●●
●●
●● ● ●● ● ● ● ●● ● ●●●


● ●●●
●●
●●●●●●● ● ●●●●
●●●●●●●● ● ● ●●●●
●●
●●
● ●● ● ●● ● ● ●●●

4.5 5.5 6.5 7.5 1 2 3 4 5 6 7

formula method
> pairs(~Fertility + Education + Catholic, data = swiss,
+ subset = Education < 20, main = "Swiss data, Education < 20")

Swiss data, Education < 20


5 10 15

● ● ● ●●●
90

● ●
● ●
● ● ● ● ●● ●

80

● ●● ● ●

● ● ● ●
● ●
Fertility ●





● ●




● ●
70

● ● ● ●
● ● ● ●
● ● ●
● ● ●
● ●●●● ●● ●

● ●
● ●
● ●
60

● ●
● ● ● ●
● ●

● ●
15

● ●

● ● ● ● ●●
● ● ●● ● ●
●●● ●
● ●
Education
10

● ● ●●
● ● ● ● ●
● ● ● ● ●●● ●
●● ●● ●● ● ●●● ● ●● ●
● ●● ● ● ●●
● ● ● ●
5

● ● ● ● ●● ●

● ●● ● ●
● ●
100

● ●● ●● ● ● ● ● ●●
● ●●●●
● ● ●
●● ● ● ● ●
● ●
● ●
80
60

Catholic
40

● ●
● ●
20

● ●
● ● ●●
● ● ●●
● ●● ● ● ● ● ● ●
● ● ●
●● ● ●

●● ●
● ●●
●●● ●●● ●
● ●
● ●
0

60 70 80 90 0 20 40 60 80 100

> pairs(USJudgeRatings)

37
Frédéric Bertrand ESIEA 5e année - 2012/2013

6.0 5 8 6.0 5 8 5 8 5 8
● ● ● ● ● ● ● ● ● ● ●

●●●● ●● ●● ●● ●
●●● ●● ●● ●● ●● ●● ●● ●●

6 9
CONT ● ●●●●● ● ● ●●●
●● ●●
● ●● ●●●● ●● ●●●
●●● ●●●●●●

●●
●●
● ●
●●
● ●
●●
●● ●●
●●
●●●●

●● ●●●
●●●

●● ●●●●●
●●
● ●●●●● ●●
●●
● ●
●● ●
●●●


●●●
●● ●● ●
●●●
●●●
●● ●
●●
●●●●●
●● ●●
●●●
● ●
● ●●


● ●●●●●●●●

● ●●
●●
●●
●●●
●● ●●

●●●● ●●
●●


● ● ●●●●


● ●●

● ●● ●●●
●● ●●● ●●●●●
●●●●
●●

●●●
● ●●●●
●●●

●●
● ●● ●

● ●●●● ● ●
●●●


●●
●● ● ●●
●●●

●●

●● ●●●

● ●
●●
●●
● ●● ●

●●
●●
●●●

● ● ●●
●●

●●

●●
●●
● ●●
●●
●●
●●

●●
● ● ●●
● ●● ●

●●
● ●
● ●●●●

●●●

● ●
●●● ●●● ●●● ●● ●
●● ● ● ●
● ● ●
● ●● ●●● ●
●●

●●
● ●
● ●
● ●

● ●●
●●

● ●●●
● ●●●
● ●
● ●
● ●●●

● ●●
●●● ●●

● ●●
●●●

●● ● ●

●●
● ● ●●
● ●●

●●
●● ● ●●●
●●
● ● ●

● ●●
●●
●● ●●
●●
● ●●●
● ●●
● ●●●●
●●●●
●●●●
●●
● ●●
● ●●●


●● ●
●●●




●●
● ●●





●●



●● ●●●●


●●

●●
● ●
●●


●●

●●
● ●
●●

●●
●●
● ●
●●

●●

● ●●


●●
●● ●● ●


●●
● ●
●●



●●

●●●●●● INTG ●●
●● ●●●●●
●● ● ●●●●● ●●
● ●● ●● ●
●●●
●●●● ●
●●●● ● ●
●●
● ●
● ●●● ●●

●●●●●
● ● ●● ●● ●

● ●●●●● ●●●●●
●● ●●●● ●
●●

●●● ●●

●●
●● ●
●●●
● ●●

●●

6.0
● ●● ● ●● ●● ● ● ● ● ●● ●●
●● ● ●● ● ● ●● ●● ●● ●● ● ●

●●●



●●
●● ●
● ●●

●●
● ● ●
●●
● ●●
● ●



●● ●●●
●●

●● ●●
●●
●●
● ●

●●

●●
● ●

●●
●●

● ●●

● ●
●● ●
●●

● ●●
●●

●● ●

● ●●●●● ●●●●●●● ● ●●● ●●● ●●● ●● ●●
● ●

●● ● ● ● ●● ● ● ● ● ● ●●●

5 8
●●

● ●
●● ●●

●●

● ●●
●●● ●●
●●●● ●●●

●●
●●
●● ●●
●●●

●● ●●●

●● ●
●●●

●● ●
●●●
●●● ●●●●

●● ●
●●

●● ●
●●● ●
●●
● DMNR ●●●
●●● ●●●



●● ●●●



●● ●
●●


●●
● ●●●
●●
●● ● ●
●●●● ●●
●●●


●●
●●
● ●
● ●



●● ● ●
●●
● ●
●●● ● ●●● ●● ●


●●●● ●
●●
●●
●●●
● ●●●

●● ● ●● ● ●●●●●

●● ● ●●

●● ● ●
● ●● ●● ●● ●
●● ●
●● ●● ●
● ● ● ● ● ● ●● ●

●●●

●●
●● ● ●●


●● ●●

● ●



●● ●
●●
● ●●
●● ●●
●● ●●
● ●● ●

● ●
●●
8 ●●
●●●
●● ●●●




●●● ●●

●●


●●●








●● ●








●● ●●



● ●●●

●● ●




●●




●●
● ●







●●

●●●

●●●●
●●

●●●●
●●


●●●
●●
●●
●● ●
●●●●●
●●●

DILG ●
●●
●●



● ●
●●●


●● ●


● ●
●●

● ● ●●



● ●●


● ●
●●●
●●
●●
● ●
●●
●●


●● ● ●● ●
● ●● ●

●● ●

●●●

● ●
●●
● ●● ●


●●
●●
● ●●● ●●
●●● ●
●● ●
● ●●●●●●
●● ●● ●● ●
● ●
● ●● ●● ●● ●● ●● ●

5

●●●
●● ● ●
● ●
●●● ●● ●
●● ●● ● ● ●●
● ●●
● ●●●
● ●




●●●● ●●●
●●
●●
●●
● ●●●
● ●
●● ●

●●● ●

●●
●● ●●

●●● ●●

●●
●● ●●●
● ● ●●



● ● ●● ●
●●●

●●●

●●

● ●● ●●●

●●
●●
●● ●
●●●●
●●
● ●●
●●● ●


●●

● ●●

●● ●

●●
●●
● ●●

●●
●● ●

●●
●●
● ●

●●


● ●●
●●●

●●
●●
●●●●● ●● ●
●●
●● ●●●●
● ● ●●
●● CFMG ●●


● ●
●●

● ●
●●
●● ●●
●● ● ●
● ●●●
●●
● ●●

●●

●●● ● ●●
●●● ●●
●● ●● ●●

●● ●


●● ●
●●
●● ● ●● ●●
●●● ●●
●●● ●
●●● ●●
●●●

5.5
● ● ●● ● ● ● ● ● ● ● ●●
●●● ●● ● ●● ●●● ●

● ●●
● ●●
● ●
●● ●●● ● ●● ●●


●●● ●
● ●
●●


● ●

●● ●
●●
● ●
●●

● ●
●●
● ●●
●●
● ●●
●● ●●●
● ●●

● ●

●●

●●
●●
● ●

● ●●●
●●


●●
● ● ●
●●●
●●

●● ●


●● ●


●●
● ●●


●● ●
●●


● ●●

●● ●
●●


● ●
●●


● ●

●●

●●
●● ● ● ● ● ● ● ●
●●
●● ●●●● ● ●
●●
●●
●●

●●
●●
●●
●●

●●
●●


●●
● ●

●●



● DECI ●
●●● ●



●●● ●●

● ● ●



●●● ●



●●

● ●
●●

●●
●●
● ●●● ●●
● ●●● ●

●● ●●
● ●●● ●
●● ●

●●

● ●

●●
● ●●●
●● ●
●●
●●

●● ● ●●●●● ●● ●●● ●● ●●●● ●●●● ●●● ●● ●●● ●●●
6.0

●● ● ● ● ● ● ●
●●● ●● ● ●● ●●● ●●

● ●●


●●
● ●●

● ●●
●● ● ●●


●●

●● ●● ●● ● ●● ● ● ●



●●●● ● ●●●●
●●

●● ●●
●●
●●●● ●
●●
● ●●


●●
● ●

●●●

● ●
●●
● ●

●●
●●
● ●

●●●
● ●●
●●
● ●●

●●


● ●●
● ●● ●
● ● ● ●●

8

●●


●●●●
●● ●●●







● ●
●●●

● ●●


●● ●●



●●
●● ●●


●●● ●●
●●
● ●
●●
●●
● ●



●● ●



● ●●



● ●●
● ●●●●
●●
● ●
●●
●●●
● ●

●●

● ●
●●
●● ●●


●●


● PREP ●●


● ●●
● ●● ●●● ● ●
●●
●●
●●
●●● ●


●●● ●●●●
● ●● ●
● ● ● ●●
● ●●● ●●●●
●●
●●●

● ●●
● ●
●● ●
●● ●
● ●●●

5
● ● ● ● ● ● ● ● ● ● ●

●● ●● ●● ● ●● ● ● ● ●
●●
●● ● ●
●● ●●●
●●
●●


● ● ●●
●●●

●● ●
●●



● ●●●
●●

●● ●●

●●●
● ●●


● ●●


● ●●
●●●
● ●●
● ●●


●●


●● ●
● ● ● ●●
● ●

● ●
● ●
● ●
● ●● ●
●●
8

●●

● ● ●



●●● ●
●●

● ●

●● ●●

● ● ●

●●
●● ●●
● ●
●● ●●
● ●
●●
● ●

●●

●●
●●● ●● ●
●●
●●
● ●
●● ●
●●●
●●
●● ●●
●●● ●

●●

● ●●
●●


●● ●●●
● FAMI ●
●●
● ●● ●● ●
●● ●●
●●
●●
●●

● ● ● ●●● ●
●● ●

●● ●

●● ●● ●● ●
●● ●●
●● ●
●●
●● ●●● ●●●● ●●
● ●● ●
● ●●● ●● ●● ●● ●●●● ●●
●●
●● ●● ● ●● ● ●
● ● ●● ●● ● ●
5

● ● ● ●
●● ●● ● ●
●● ●
● ●● ●● ●● ● ●

●●

●●●
●● ●●●●



●● ● ●

●● ●●●

● ● ●
●●

● ●●●
● ●●

●● ●
●●
●● ●
● ●●

● ●
●●

8
●● ● ● ● ●● ●
● ● ●
●● ● ● ●
● ●● ●

●●

●●●●
● ●
●●
●●
●●●



●●
●● ●

●●

●●
●●
● ● ●
●●● ●

●●
●●

●●
● ●● ●●●
●●


● ● ●●

●●● ●
●●
●●● ●
●● ●●●

●●
● ●







● ●
●● ●●

●●● ●●
●●● ●

●●●
● ●
●●● ●

●●
●●● ●
●●●
● ●●
●●
● ORAL ●●
● ●●●●
● ●●
● ●● ●●● ● ● ● ●●● ●● ●● ●● ●
● ●
●●●● ●● ● ●● ●●
●● ●
●● ● ●● ●●

●●● ●●●● ●

5
● ●

●● ●● ●● ● ●● ● ● ● ●
●●
●●
●● ● ●
●●
●●



● ●●
●●●

●● ●●

●● ●●●
●●



● ●●


●●●
● ●●


● ●●


● ●
●●

● ●●●
● ●

●●

●●
8


●●
●●●
● ● ●●●

●●● ●●●
●●
● ●
●● ●


● ● ●●● ●
● ●
●● ●● ●●
● ●


●●
●● ●●

●● ● ●
●● ●● ●
●● ●
●●
● ●

● ● ●● ● ●●

● ●
●●●●● ●
●●



●●● ●●
●●●


● ●




● ●




●●

● ●●




●●
●● ●


●●
● ●





●●

● WRIT ●●
●●


●●
● ●●

●●

●●● ● ●●● ●●● ●●● ●
● ● ●
●●● ●●● ●●
● ●
●●
● ●●●● ●●●
●● ●● ● ● ●● ●● ●
5

● ● ● ● ● ●


●●

●●
●● ● ●●



●● ●●
●●


● ●●

● ●●

●●


● ●
●●


●● ●●
●●
●● ●●

●●
● ●
●●
● ●●
●●● ●
●●●
●●
●●
●●●
●●●● ●●●


●●●
●● ●
●●●

● ●●

●●
●●
●●

●●
● ● ●

●●

●●

● ●
●●

●●


●●


●● ●●●

●●


●●

● ●●

●● ●


●●● ●
●●●●

●●
● ●



●●●

●● ●
●●

●●


●● ●●




●●●●

8
● ● ● ●● ●●
● ● ●
● ●●
●● ● ●
●● ●●● ●● ●●

●●●● ● ●
●●●●●

●● ●


● ●
●● ●● ●

●●

● ●●

●●
● ●●
●●●●
●●
●●●●● ●●
●●●●● ●●●●●
●● PHYS ● ●●●
●●
●● ● ●● ● ●● ● ● ● ● ● ● ●●
● ● ● ● ● ● ● ● ● ● ●

5
● ● ● ● ● ● ● ● ● ● ●

●●● ● ●●
● ●
● ●● ●


●● ●●
● ●●
● ●● ●
● ●●● ●

●●●

●●
●● ●●



●●
●●●

● ●●
●●

● ●

●●



● ●




● ●

●●

● ●
●●



● ●



● ●
●●
● ●●



●● ● ● ●
● ●
● ●

8

●●●
●●
● ● ●


● ● ● ●
● ●●●●
● ●●
●●●● ●●
● ● ●
●● ●●●● ●
●● ●● ●●

●● ●● ●●●
●● ●●

● ●● ●●
● ● ●●●●● ●●
● ●●

●● ●●
●●
●● ●● ● ●
● ● ●●●
● ●●●

●●
●●●
●● ●
●●
●●● ●●
● ●

●●● ●●●● ●●●● ●


● ●
●●

●● ●


● ●
●●
● ●●●
●● RTEN
● ●● ●● ● ● ●● ●● ● ● ● ●
●●●● ●●
●● ●●
●● ●●● ●●
● ●●

● ●●
● ●●
● ●
●● ●
●●● ●●●●
5

● ● ●

6 9 5 8 5.5 5 8 5 8 5 8

put histograms on the diagonal

> [Link] <- function(x, ...) {


+ usr <- par("usr")
+ [Link](par(usr))
+ par(usr = c(usr[1:2], 0, 1.5))
+ h <- hist(x, plot = FALSE)
+ breaks <- h$breaks
+ nB <- length(breaks)
+ y <- h$counts
+ y <- y/max(y)
+ rect(breaks[-nB], 0, breaks[-1], y, col = "cyan",
+ ...)
+ }

> pairs(USJudgeRatings[1:5], panel = [Link], cex = 1.5,


+ pch = 24, bg = "light blue", [Link] = [Link],
+ [Link] = 2, [Link] = 2)

38
Frédéric Bertrand ESIEA 5e année - 2012/2013

6.0 7.5 9.0 5 6 7 8 9

CONT

6 7 8 9
9.0
INTG
7.5
6.0

5 6 7 8 9
DMNR
9

DILG
8
7
6
5

8.5
CFMG

7.0
5.5
6 7 8 9 5 6 7 8 9 5.5 7.0 8.5

put (absolute) correlations on the upper panels, with size proportional to the corre-
lations.

> [Link] <- function(x, y, digits = 2, prefix = "",


+ [Link]) {
+ usr <- par("usr")
+ [Link](par(usr))
+ par(usr = c(0, 1, 0, 1))
+ r <- abs(cor(x, y))
+ txt <- format(c(r, 0.123456789), digits = digits)[1]
+ txt <- paste(prefix, txt, sep = "")
+ if (missing([Link]))
+ [Link] <- 0.8/strwidth(txt)
+ text(0.5, 0.5, txt, cex = [Link] * r)
+ }

> pairs(USJudgeRatings, [Link] = [Link], [Link] =


+ [Link])

39
Frédéric Bertrand ESIEA 5e année - 2012/2013

6.0 5 8 6.0 5 8 5 8 5 8

6 9
CONT 0.13 0.15 0.14 0.087

0.012
0.011
0.012
0.026
0.034
0.044
0.054
●●●
●●
● ●


●●
●●●●
●●●●
●●
●●
●●

●●●●
●●●

INTG 0.96 0.87 0.81 0.80 0.88 0.87 0.91 0.91 0.74 0.94

6.0

●●

●●●



●●
●● ●
● ●●

●●

●●●● ●●

5 8
●●
●●● ●●

●●

●● ●

●●● ●
●●


DMNR 0.84 0.81 0.80 0.86 0.84 0.91 0.89 0.79 0.94
●●● ● ●
●●

●● ● ●●

● ●

●●●

●●
●● ● ●●


●● ●●


8 ●●
●●●
●● ●●●




●●● ●●

●●


●●●
●●●●
●●

●●

● ●●
●●


●●


●●
●●
●● ●
●●●●●
●●●

DILG 0.96 0.96 0.98 0.96 0.95 0.96 0.81 0.93
●● ● ●● ● ●● ●
●● ●● ●●
5


●●
●●●
●● ● ●●●

●●
● ● ●
●●
●●
● ●●●


●●
●●


●●
●●
●●
●●



●●●


●●
● ●●

●●

●●
●●

● ●●



●●

●●
●●
●●●●● ●● ●
●●
●● ●●●●
● ● ●
●●
●● CFMG 0.98 0.96 0.94 0.95 0.94 0.88 0.93
●●● ● ●●
●●● ●●
●● ●● ●●
●●

5.5
● ● ●● ●
●●● ●● ● ●● ●●●


●●● ●
● ●


●●
● ●

●● ●
●●
● ●
●●



●●
●●
● ●

● ●●●

●●
●●
●●
● ●
●●●
●●

●● ●


●● ●


●●

●● ● ●
●●●●●●● ●
●●


●●

●●
● ●●
●●
●●

●●
● ●

●●
● ●

●●



● DECI 0.96 0.94 0.95 0.95 0.87 0.92
●●
●● ●●● ●●
● ●●● ● ●

●● ●●

●● ● ●●●●● ●● ●●● ●●
6.0

●● ● ● ●
●●● ●● ● ●● ●●● ●●

●● ●● ●● ● ●● ●



●●●● ● ●●●●
●●

●● ●●
●●
●●●● ●
●●
● ●●


●●
● ●

●●●


● ●●
● ●● ●

8

●●


●●●●
●● ●●●







● ●
●●●

● ●●


●● ●●





●● ●●


●●
●●
●● ●●
●● ●●

●●●
●●
● ●
●●
●●●







● ●
●●


● ●●


●●


● PREP 0.99 0.98 0.99 0.85 0.95
●●● ● ●●●● ●●●● ●
●●
● ●
●●
● ●
●●

5
● ● ● ● ● ●

●●
● ●
●● ●● ●
● ●●
● ●●
● ●
●●

●●
●● ● ●
●● ●●●
●●
●●



● ● ●●
●●●●

●● ●
●●


●● ●●
●●
●●

●● ●●




●●
● ●●



8

●●

● ● ●



●●● ●
●●

● ●

●● ●●


● ● ●

●●
●● ●●

●●

●●
●●● ●● ●
●●
●●
● ●
●● ●
●●●
●●
●● ●●
●●● ●

●●

● ●●
●●


●● ●●●
● FAMI 0.98 0.99 0.84 0.94
●●

● ● ● ●●● ●
●● ●

●● ●

●● ●●
●● ●●● ●●●● ●●
● ●● ●
● ●●●
● ●●
●● ●● ● ●● ● ● ●
5


●● ● ● ●
●●

●● ●

●● ●
●● ●



●● ●
●●
● ●●
●● ●●

●●
● ●
● ●●
●● ●●● ●●● ●●●
● ●●
● ●
● ●●

8
●● ● ●●●● ● ● ● ● ●● ●● ●


●●

●●●●
● ● ●●
●●



●●
●● ●

●●

●●
●●
● ● ●
●●● ●

●●

●●


●●● ●●
●●
●●



●● ●●

●●● ●
●●
● ●

● ●
●●
●●


●●

●●● ●●
●●● ●

●●●
● ●
●●●
● ●

●●●● ●
●●●
● ●●
●●
● ORAL 0.99 0.89 0.98
●●●● ●● ●●● ●
●● ● ● ●●● ●● ●●
●● ● ●● ●● ●
●● ● ●● ●●

5

●● ●● ●● ● ●● ● ●
●●
●●
●● ● ●
●●
●●



● ●●
●●●

●● ●●●

● ●●●●



● ●●

●●●
● ●●


● ●●


● ●
●●


8


●●
●●●
● ● ●●●


●●● ●●●
●●

● ●●
● ●●



●●● ●

●●
●● ●●
● ●●
●● ●
●●
●●

●● ●
●●●●● ●●●

●●●
●●

● ●
●●●●●
●●
● ●●
●●●
● ● ●

●●

● ●●
●●●

●● ●●

● ●


● ●


● WRIT 0.86 0.97
●● ● ●● ●● ●●● ●
●●● ●
●●
●●
● ●


● ● ●●● ●●● ●●● ●
● ● ●
●● ●●● ● ●
●●
●● ●● ● ● ●● ●● ●●
5

● ● ●


●●

●●
●● ● ●●



●● ●●
●●


● ●●

● ●

●●


● ●●

●●
● ●●
●●
●● ●●

●●
● ●
●●
● ●●
●●●
●●
●●
●●●
●●●● ●●●


●●●
● ●
●●●

● ●●

●●
●●
●●

●●
● ● ●

●●

●●

● ●
●●

●●


●●



●● ●●●

●●
●●



●● ●●

●● ●


●●● ●
●●●●

●●
● ●



●●●

●● ●
●●

●●


●●

8

● ●● ●
● ● ●
●● ●●
● ●● ●
● ● ●
●●
● ●
● ●●●
●● ●●
●● ●●

●●●● ● ●●●●● ●● ●
● ● ●
●● ●● ● ●●

● ●
●●

● ●
●●●● ●●●●● ●
●●●●● ●●●●
●● PHYS 0.91
●● ● ●● ● ●● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ●

5
● ● ● ● ● ● ● ● ● ●

●●● ● ●●
● ●
● ●● ●

●● ●●
● ●●
● ●● ●
● ●●● ●

●●●

●●
●● ●●




●●
●●●

● ●●
●●
● ●

●●




● ●




● ●

●●

● ●
●●


● ●



● ●
●●
● ●●



●● ● ● ●
● ●
● ●

8

●●●
●●
● ● ●


● ● ● ●
● ●●●●
● ●●●●● ●●
● ● ●
●● ●●●● ●
●● ●● ●●

●● ●● ●●●
●● ●●

● ●● ●●
● ● ●● ●
●● ●●
● ●

●● ●●
●●
●● ●● ● ●
● ● ●●●
● ●●●

●●
●●●
●● ●
●●
●●● ●●
● ●
●●● ● ●●
●● ●
●●●● ●


● ●
●●

●● ●

● ●
●●
● ●●●
●● RTEN
● ●● ●● ●● ● ●● ●● ● ●● ● ●
●●●● ●●
●● ●●
●● ●●● ●●
● ●

●● ●●
● ●●
● ●
●● ●
●●● ●●●●
5

● ● ●

6 9 5 8 5.5 5 8 5 8 5 8

10 Simplepanel plots
> pairs(swiss, panel = [Link], pch = ".")

0 40 80 0 20 40 15 25
40 60 80

Fertility
80

Agriculture
40
0

30

Examination
5 15
40

Education
20
0

80

Catholic
40
0
25

[Link]
15

40 60 80 5 15 30 0 40 80

40
Frédéric Bertrand ESIEA 5e année - 2012/2013

> pairs(swiss, panel = [Link], lwd = 2, cex = 1.5,


+ col = "blue")

0 40 80 0 20 40 15 25
● ● ● ●● ● ●●● ●●
● ● ● ●
●●●●● ●● ●● ●● ● ● ● ●
●● ●●●●
●● ●●● ●●●
●●

40 60 80
● ●●● ●●● ● ● ●●●●● ●
● ● ●● ●● ●●
● ●●●
● ●● ●
● ●
●●● ●
● ●●●
● ●●
● ●● ●

●●●●
●●
● ●●

● ●
●● ●●




● ●
●●
Fertility ●●● ●●● ●●
●●●
● ●●●●●●



●● ● ●●


●●

● ● ●


●●●●
●● ● ●
●●●●
●●●
● ●
●●● ●● ●●●
●● ●●●●●●


● ●
●● ●
● ●● ● ●
● ● ●● ●
● ●● ●●
● ● ● ● ●

● ●● ● ●
●●
● ●

●● ●
● ●●●●
80

● ●●●● ●● ● ●
●●

●●● ●●● ●● ● ●● ●●
●●
●●

● ● ●
● ●●
●●
●●●●●●

●●●●●●
● ●● ● ●●●●

●●
● ●● ●●●
●●
● ●

●● ●

●●●●●
● ●
● ● ● ●● ● Agriculture ●

● ● ● ● ●
●●
●●● ● ●● ● ●●●
● ●
●● ●●
●●●
40

●● ● ●● ●●●●● ●
● ● ● ●
● ●
● ●
● ● ● ●● ●
● ●

● ● ●●

● ●●●●
● ● ●●● ●● ●●● ● ●● ●●
●● ● ●
●●●●
● ● ● ● ● ● ● ● ●●
0

● ● ●● ● ● ● ● ● ●
● ● ●● ●● ●● ●

30

●● ●● ●●● ●● ● ● ●●●
● ●●●
● ●
●●●●
● ●● ● ●●
●● ●●●
● ● ●
●●
●● ● ●●●●

●●●● ● ● Examination ●●●● ●
● ● ● ●●●●●
● ●● ●●● ● ●
●●
●●●● ● ●●
●●● ● ●

● ●● ●

●●●●

5 15
●●●
●● ●●
● ●●
●●● ●

●● ●
●●
●●●● ●● ●● ●●
● ● ● ● ● ●●●●● ●
●●●● ● ● ●● ●●
● ●● ●
●●● ● ● ● ●●
● ●
●●
●● ● ●●● ●
● ●
● ●
● ● ● ●
● ● ●●
● ● ● ● ●
40

● ●●
● ●
●● ● ● ●● ● Education ●● ●● ●●● ●
20

●● ●● ●● ●● ● ●
●●●●
●●●●● ●● ●●
●●●
●●● ●●●
●●
● ● ●● ●● ●
●●● ●●

●●●
● ●●
●●
● ●●● ●● ●●● ● ●● ●●●●●●
● ●



●●
● ● ●●●
● ●●
● ● ●
●●
● ●●
●●

●●
●●
●●●●●
● ● ● ●

● ●●●●●● ● ●●●●●●●


● ●● ●●
●●●●● ●

●●
● ●

●●
●●
● ●
●●●



●●


●●●
●●
0

●●●●
●●●
●●
●●
● ●●●
●●● ●●●● ●●
●●●
● ●●
●●●●
●● ●
●●
●●
●●
●● ●●
●●●
●●● ●
●● ●●

● ●● ● ●●● ● ●

80
● ● ● ● ●
● ● ● ● Catholic ●
● ● ● ● ●

40
● ● ● ● ●
●● ● ● ● ● ● ● ● ● ●●
● ● ●
●●● ●●●●●

●● ●● ● ●●
● ●● ●●

●●● ●
●● ●



●●●
●●


●●

● ●
● ● ● ●

●●
●●●
● ● ●●
●●●●
●●
● ● ● ●
●●


●●

●● ● ●●●
●●

●●●

● ●●

0
● ● ● ● ●
25

● ● ●● ●
● ●●
●● ●●●● ● ●●
● ●●● ●●
●●
● ●● ●

●●
● ● ●● ●

● ● ● ● ●●
● ●
●●● ●●
●●●
● ●
●●●
●●●●●● ●●●●●
●●●●● ●
●●● ●● ●
●● ●
●●●
●●●●● ●

●●

●●
●●●● ●
● ●


●●● ● ● ●
● ●
● ● ● ● ● ● ● ●
●●
● ● ●●●● ● ● ● ●● ●

●● ● ●●●●● ● ● ●●
● ●●●● ●
●● ● ●
● ●
●● ●● ●● [Link]
●●● ● ●
● ● ●
● ● ● ●● ● ● ●● ●●● ● ●
15

● ● ● ● ●
● ● ● ● ●

40 60 80 5 15 30 0 40 80

11 jitter
> require(stats)
> with(faithful, {
+ plot(density(eruptions, bw = 0.15))
+ rug(eruptions)
+ rug(jitter(eruptions, amount = 0.01), side = 3,
+ col = "light blue")
+ })

41
Frédéric Bertrand ESIEA 5e année - 2012/2013

[Link](x = eruptions, bw = 0.15)

0.6
0.5
0.4
Density

0.3
0.2
0.1
0.0

1 2 3 4 5

N = 272 Bandwidth = 0.15

12 curves
> plot(qnorm)
2
1
qnorm (x)

0
−1
−2

0.0 0.2 0.4 0.6 0.8 1.0

42
Frédéric Bertrand ESIEA 5e année - 2012/2013

> plot(qlogis, main = "The Inverse Logit : qlogis()")


> abline(h = 0, v = 0:2/2, lty = 3, col = "gray")

The Inverse Logit : qlogis()

4
2
qlogis (x)

0
−2
−4

0.0 0.2 0.4 0.6 0.8 1.0

> curve(sin, -2 * pi, 2 * pi)


1.0
0.5
sin (x)

0.0
−0.5
−1.0

−6 −4 −2 0 2 4 6

> curve(tan, main = "curve(tan) --> same x-scale as previous plot")

43
Frédéric Bertrand ESIEA 5e année - 2012/2013

curve(tan) −−> same x−scale as previous plot

1.4
1.2
1.0
0.8
tan (x)

0.6
0.4
0.2
0.0

0.0 0.2 0.4 0.6 0.8 1.0

> op <- par(mfrow = c(2, 2))


> curve(x^3 - 3 * x, -2, 2)
> curve(x^2 - 2, add = TRUE, col = "violet")
> plot(cos, -pi, 3 * pi)
> plot(cos, xlim = c(-pi, 3 * pi), n = 1001, col = "blue",
+ add = TRUE)
> chippy <- function(x) sin(cos(x) * exp(-x/2))
> curve(chippy, -8, 7, n = 2001)
> plot(chippy, -8, -5)

44
Frédéric Bertrand ESIEA 5e année - 2012/2013

1.0
2

0.5
1
x^3 − 3 * x

cos (x)

0.0
0
−1

−1.0
−2

−2 −1 0 1 2 −2 0 2 4 6 8

x x
1.0

1.0
0.5

0.5
chippy (x)

chippy (x)
0.0

0.0
−1.0

−1.0

−5 0 5 −8.0 −7.0 −6.0 −5.0

x x

> for (ll in c("", "x", "y", "xy")) curve(log(1 + x),


+ 1, 100, log = ll, sub = paste("log= '", ll, "'",
+ sep = ""))
> par(op)
4
3
log(1 + x)

2
1

0 20 40 60 80 100

x
log= ''

45
Frédéric Bertrand ESIEA 5e année - 2012/2013

13 loess (régression non-paramétrique)


> [Link] <- loess(dist ~ speed, cars)
> predict([Link], [Link](speed = seq(5, 30, 1)),
+ se = TRUE)

$fit
[1] 7.810489 10.041808 12.567960 15.369183 18.425712 21.828039
[7] 25.539675 29.350386 33.230660 37.167935 41.205226 45.055736
[13] 48.355889 49.824812 51.986702 56.445263 62.008703 68.529340
[19] 76.193111 85.142467 95.323096 NA NA NA
[25] NA NA

$[Link]
[1] 7.568539 5.943649 4.976453 4.515801 4.316362 4.030120 3.750561
[8] 3.715593 3.776298 4.091044 4.708759 4.244697 4.035236 3.752765
[15] 4.004017 4.056945 4.005540 4.065234 4.579053 5.948757 8.300416
[22] NA NA NA NA NA

$[Link]
[1] 15.29233

$df
[1] 44.62733

to allow extrapolation

> cars.lo2 <- loess(dist ~ speed, cars,


+ control = [Link](surface = "direct"))
> predict(cars.lo2, [Link](speed = seq(5, 30, 1)),
+ se = TRUE)

$fit
[1] 7.741006 9.926596 12.442424 15.281082 18.425712
[6] 21.865315 25.713413 29.350386 33.230660 37.167935
[11] 41.205226 45.781544 48.355889 50.067148 51.986702
[16] 56.445263 62.025404 68.569313 76.193111 85.053364
[21] 95.300523 106.974661 120.092581 134.665851 150.698545
[26] 168.190283

$[Link]
[1] 7.565991 5.959097 5.012013 4.550013 4.321596 4.119331
[7] 3.939804 3.720098 3.780877 4.096004 4.714469 4.398936
[13] 4.040129 4.184257 4.008873 4.061865 4.033998 4.078904
[19] 4.584606 5.952480 8.306901 11.601911 15.792480 20.864660
[25] 26.823827 33.683999

46
Frédéric Bertrand ESIEA 5e année - 2012/2013

$[Link]
[1] 15.31087

$df
[1] 44.55085

> plot([Link], xlab = "Speed", ylab = "Dist", pch = "+")


> lines(seq(min(cars$speed), max(cars$speed), 0.1), predict([Link],
+ [Link](speed = seq(min(cars$speed), max(cars$speed),
+ 0.1)), se = TRUE)$fit, col = "red", lwd = 2)
120

+
100

+
+ +
80

+
+
+ +
+ +
Dist

60

+
+ + + +
+ +
+ + +
+ + +
40

+ + + + +
+
+
+ + +
+ + + +
+
20

+ + + + +
+
+ +
+ +
0

5 10 15 20 25

Speed

> plot(cars.lo2, xlab = "Speed", ylab = "Dist", pch = "+",


+ xlim = c(min(cars$speed) - 5, max(cars$speed) +
+ 5))
> lines(seq(min(cars$speed) - 5, max(cars$speed) + 5,
+ 0.1), predict(cars.lo2, [Link](speed = seq(min(cars$speed) -
+ 5, max(cars$speed) + 5, 0.1)), se = TRUE)$fit, col = "blue",
+ lwd = 2)
> lines(seq(min(cars$speed) - 5, max(cars$speed) + 5,
+ 0.1), predict([Link], [Link](speed = seq(min(cars$speed) -
+ 5, max(cars$speed) + 5, 0.1)), se = TRUE)$fit, col = "red",
+ lwd = 2)

47
Frédéric Bertrand ESIEA 5e année - 2012/2013

120
+

100
+
+ +
80
+
+
+ +
+ +
Dist

60

+
+ + + +
+ +
+ ++
+++
40

+ ++ ++
+
+
+++
++++
+
20

+ +++ +
+
+ +
+ +
0

0 5 10 15 20 25 30

Speed

14 density estimation
> require(graphics)
> plot(density(c(-20, rep(0, 98), 20)), xlim = c(-4, 4))

[Link](x = c(−20, rep(0, 98), 20))


0.3
Density

0.2
0.1
0.0

−4 −2 0 2 4

N = 100 Bandwidth = 1.019

48
Frédéric Bertrand ESIEA 5e année - 2012/2013

> d <- density(faithful$eruptions, bw = "sj")


> d

Call:
[Link](x = faithful$eruptions, bw = "sj")

Data: faithful$eruptions (272 obs.); Bandwidth 'bw' = 0.14

x y
Min. :1.180 Min. :0.0001834
1st Qu.:2.265 1st Qu.:0.0422638
Median :3.350 Median :0.1709243
Mean :3.350 Mean :0.2301726
3rd Qu.:4.435 3rd Qu.:0.4134348
Max. :5.520 Max. :0.5945634

> plot(d)

[Link](x = faithful$eruptions, bw = "sj")


0.6
0.5
0.4
Density

0.3
0.2
0.1
0.0

2 3 4 5

N = 272 Bandwidth = 0.14

> plot(d, type = "n")


> polygon(d, col = "wheat")
> x <- xx <- faithful$eruptions
> x[[Link] <- sample(length(x), 10)] <- NA
> doR <- density(x, bw = 0.15, [Link] = TRUE)
> lines(doR, col = "blue")
> points(xx[[Link]], rep(0.01, 10))

49
Frédéric Bertrand ESIEA 5e année - 2012/2013

[Link](x = faithful$eruptions, bw = "sj")

0.6
0.5
0.4
Density

0.3
0.2
0.1
0.0

● ● ● ● ● ●● ● ●●

2 3 4 5

N = 272 Bandwidth = 0.14

> fe <- sort(faithful$eruptions)


> dw <- density(unique(fe), weights = table(fe)/length(fe),
+ bw = d$bw)
> utils::str(dw)

List of 7
$ x :
num [1:512] 1.18 1.19 1.2 1.21 1.21 ...
$ y :
num [1:512] 0.000183 0.000223 0.00027 0.000328 0.000397 ...
$ bw :
num 0.14
$ n :
int 126
$ call :
language [Link](x = unique(fe), bw = d$bw,
weights = table(fe)/length(fe))
$ [Link]: chr "unique(fe)"
$ [Link] : logi FALSE
- attr(*, "class")= chr "density"

> stopifnot([Link](d[1:3], dw[1:3]))

> fit <- density(xx)


> N <- 1e+06
> [Link] <- rnorm(N, sample(xx, size = N, replace = TRUE),
+ fit$bw)
> plot(fit)
> lines(density([Link]), col = "blue")

50
Frédéric Bertrand ESIEA 5e année - 2012/2013

[Link](x = xx)

0.5
0.4
0.3
Density

0.2
0.1
0.0

1 2 3 4 5 6

N = 272 Bandwidth = 0.3348

> (kernels <- eval(formals([Link])$kernel))

[1] "gaussian" "epanechnikov" "rectangular" "triangular"


[5] "biweight" "cosine" "optcosine"

> plot(density(0, bw = 1), xlab = "", main = "R's density() kernels


+ with bw = 1")
> for (i in 2:length(kernels)) lines(density(0, bw = 1,
+ kernel = kernels[i]), col = i)
> legend(1.5, 0.4, legend = kernels, col = seq(kernels),
+ lty = 1, cex = 0.8, [Link] = 1)

51
Frédéric Bertrand ESIEA 5e année - 2012/2013

R's density() kernels with bw = 1

0.4
gaussian
epanechnikov
rectangular
triangular
biweight
0.3
cosine
optcosine
Density

0.2
0.1
0.0

−3 −2 −1 0 1 2 3

> plot(density(0, from = -1.2, to = 1.2, width = 2, kernel =


+ "gaussian"), type = "l", ylim = c(0, 1), xlab = "",
+ main = "R's density() kernels with width = 1")
> for (i in 2:length(kernels)) lines(density(0, width = 2,
+ kernel = kernels[i]), col = i)
> legend(0.6, 1, legend = kernels, col = seq(kernels),
+ lty = 1)

52
Frédéric Bertrand ESIEA 5e année - 2012/2013

R's density() kernels with width = 1

1.0
gaussian
epanechnikov
rectangular

0.8
triangular
biweight
cosine
optcosine
0.6
Density

0.4
0.2
0.0

−1.0 −0.5 0.0 0.5 1.0

> (RKs <- cbind(sapply(kernels, function(k) density(kernel = k,


+ [Link] = TRUE))))

[,1]
gaussian 0.2820948
epanechnikov 0.2683282
rectangular 0.2886751
triangular 0.2721655
biweight 0.2699746
cosine 0.2711340
optcosine 0.2684756

> 100 * round(RKs["epanechnikov", ]/RKs, 4)

[,1]
gaussian 95.12
epanechnikov 100.00
rectangular 92.95
triangular 98.59
biweight 99.39
cosine 98.97
optcosine 99.95

> bw <- [Link](precip)


> plot(density(precip, bw = bw), main = "same sd bandwidths,
+ 7 different kernels")

53
Frédéric Bertrand ESIEA 5e année - 2012/2013

> for (i in 2:length(kernels)) lines(density(precip, bw = bw,


+ kernel = kernels[i]), col = i)

same sd bandwidths, 7 different kernels

0.030
0.020
Density

0.010
0.000

0 20 40 60 80

N = 70 Bandwidth = 3.938

> h.f <- sapply(kernels, function(k) density(kernel = k,


+ [Link] = TRUE))
> (h.f <- (h.f["gaussian"]/h.f)^0.2)

gaussian epanechnikov rectangular triangular biweight


1.0000000 1.0100567 0.9953989 1.0071923 1.0088217
cosine optcosine
1.0079575 1.0099458

> plot(density(precip, bw = bw), main = "equivalent bandwidths,


+ 7 different kernels")
> for (i in 2:length(kernels)) lines(density(precip, bw = bw,
+ adjust = h.f[i], kernel = kernels[i]), col = i)
> legend(55, 0.035, legend = kernels, col = seq(kernels),
+ lty = 1)

54
Frédéric Bertrand ESIEA 5e année - 2012/2013

equivalent bandwidths, 7 different kernels

gaussian

0.030
epanechnikov
rectangular
triangular
biweight
cosine
optcosine
0.020
Density

0.010
0.000

0 20 40 60 80

N = 70 Bandwidth = 3.938

15 Radar plots
> require(grDevices)
> stars(mtcars[, 1:7], [Link] = c(14, 2), main = "Motor Trend Cars :
+ stars(*, full = F)", full = FALSE)

55
Frédéric Bertrand ESIEA 5e année - 2012/2013

Motor Trend Cars : stars(*, full = F)

Mazda RX4 Wag Hornet 4 Drive Valiant


Mazda RX4 Datsun 710 Hornet Sportabout

Merc 240D Merc 280 Merc 450SE


Duster 360 Merc 230 Merc 280C

Merc 450SLC Lincoln Continental Fiat 128


Merc 450SL Cadillac Fleetwood Chrysler Imperial

Toyota Corolla Dodge Challenger Camaro Z28


Honda Civic Toyota Corona AMC Javelin

Fiat X1−9 Lotus Europa Ferrari Dino


Pontiac Firebird Porsche 914−2 Ford Pantera L
hp
drat disp
wt cyl
Volvo 142E qsec mpg
Maserati Bora

> stars(mtcars[, 1:7], [Link] = c(14, 1.5), main = "Motor Trend Cars :
+ full stars()", [Link] = FALSE)

Motor Trend Cars : full stars()

Mazda RX4Mazda RX4 WagDatsun 710 Hornet 4 Drive


Hornet Sportabout Valiant

Duster 360 Merc 240D Merc 230 Merc 280 Merc 280C Merc 450SE

Merc 450SL Merc 450SLC


Cadillac Fleetwood
Lincoln Continental
Chrysler Imperial Fiat 128

Honda Civic Toyota CorollaToyota Corona


Dodge Challenger
AMC Javelin Camaro Z28

Pontiac Firebird Fiat X1−9 Porsche 914−2Lotus EuropaFord Pantera LFerrari Dino

disp
cyl
hp
mpg
Maserati Bora Volvo 142E drat
qsec
wt

> stars(mtcars[, 1:7], locations = c(0, 0), radius = FALSE,


+ [Link] = c(0, 0), main = "Motor Trend Cars", lty = 2)

56
Frédéric Bertrand ESIEA 5e année - 2012/2013

Motor Trend Cars


disp

cyl

hp

mpg

drat

qsec

wt

> palette(rainbow(12, s = 0.6, v = 0.75))


> stars(mtcars[, 1:7], len = 0.8, [Link] = c(12, 1.5),
+ main = "Motor Trend Cars", [Link] = TRUE)

Motor Trend Cars

Mazda RX4 Wag Hornet 4 Drive Valiant


Mazda RX4 Datsun 710 Hornet Sportabout

Merc 240D Merc 280 Merc 450SE


Duster 360 Merc 230 Merc 280C

Merc 450SLC Lincoln Continental Fiat 128


Merc 450SL Cadillac Fleetwood Chrysler Imperial

Toyota Corolla Dodge Challenger Camaro Z28


Honda Civic Toyota Corona AMC Javelin

Fiat X1−9 Lotus Europa Ferrari Dino


Pontiac Firebird Porsche 914−2 Ford Pantera L

cyl
disp
mpg
Volvo 142E hp
Maserati Bora qsec
drat
wt

> stars(mtcars[, 1:7], len = 0.6, [Link] = c(1.5, 0),


+ main = "Motor Trend Cars", [Link] = TRUE,

57
Frédéric Bertrand ESIEA 5e année - 2012/2013

+ [Link] = TRUE, nrow = 4, cex = 0.7)

Motor Trend Cars

Mazda RX4 Wag Hornet 4 Drive Valiant Merc 240D


Mazda RX4 Datsun 710 Hornet Sportabout Duster 360

Merc 280 Merc 450SE Merc 450SLC Lincoln Continental


Merc 230 Merc 280C Merc 450SL Cadillac Fleetwood

Fiat 128 Toyota Corolla Dodge Challenger Camaro Z28


Chrysler Imperial Honda Civic Toyota Corona AMC Javelin

Fiat X1−9 Lotus Europa Ferrari Dino Volvo 142E


Pontiac Firebird Porsche 914−2 Ford Pantera L Maserati Bora
disp cyl
mpg
hp
qsec
drat wt

> USJudge <- apply(USJudgeRatings, 2, function(x) x/max(x))


> Jnam <- [Link](USJudgeRatings)
> Snam <- abbreviate(substring(Jnam, 1, regexpr("[,.]",
+ Jnam) - 1), 7)
> stars(USJudge, labels = Jnam, scale = FALSE, [Link] = c(13,
+ 1.5), main = "Judge not ...", len = 0.8)

58
Frédéric Bertrand ESIEA 5e année - 2012/2013

Judge not ...

ALEXANDER,J.M. BERDON,R.I. BURNS,E.B.


AARONSON,L.H. ARMENTANO,A.J. BRACKEN,J.J. CALLAHAN,R.J.

COHEN,S.S. DANNEHY,J.F. DEVITA,H.J. GRILLO,A.E.


DALY,J.J. DEAN,H.H. DRISCOLL,P.J.

HAMILL,E.C. HULL,T.C. LEVISTER,R.L.


HADDEN,[Link]. HEALEY.A.H. LEVINE,I. MARTIN,L.F.

MCGRATH,J.F. MISSAL,H.M. NARUK,H.J. O'SULLIVAN,T.J.


MIGNONE,A.F. MULVEY,H.M. O'BRIEN,F.J.

RUBINOW,J.E. SATANIELLO,A.G. SHEA,[Link].


PASKEY,L. SADEN.G.A. SHEA,D.M. SIDOR,W.J.

SPEZIALE,J.A. STAPLETON,J.F. TIERNEY,[Link]. WRIGHT,D.B.


SPONZO,M.J. TESTO,R.J. WALL,R.A.

CFMGDILGDMNR
DECI INTG
PREP CONT
ZARRILLI,K.J. FAMI RTEN
ORALWRITPHYS

> stars(USJudge, labels = Snam, scale = FALSE, [Link] = c(13,


+ 1.5), radius = FALSE)

ALEXAND BERDON BURNS


AARONSO ARMENTA BRACKEN CALLAHA

COHEN DANNEHY DEVITA GRILLO


DALY DEAN DRISCOL

HAMILL HULL LEVISTE


HADDEN HEALEY LEVINE MARTIN

MCGRATH MISSAL NARUK O'SULLI


MIGNONE MULVEY O'BRIEN

RUBINOW SATANIE SHEA


PASKEY SADEN SHEA SIDOR

SPEZIAL STAPLET TIERNEY WRIGHT


SPONZO TESTO WALL
CFMG DILG DMNR
DECI INTG
PREP CONT
ZARRILL FAMI RTEN
ORALWRITPHYS

> loc <- stars(USJudge, labels = NULL, scale = FALSE,


+ radius = FALSE, [Link] = TRUE, [Link] = c(13,

59
Frédéric Bertrand ESIEA 5e année - 2012/2013

+ 1.5), main = "Judge not ...", len = 1.2)


> text(loc, Snam, col = "blue", cex = 0.8, xpd = TRUE)

Judge not ...

AARONSO ALEXAND ARMENTA BERDON BRACKEN BURNS CALLAHA

COHEN DALY DANNEHY DEAN DEVITA DRISCOL GRILLO

HADDEN HAMILL HEALEY HULL LEVINE LEVISTE MARTIN

MCGRATHMIGNONE MISSAL MULVEY NARUK O'BRIEN O'SULLI

PASKEY RUBINOW SADEN SATANIE SHEA SHEA SIDOR

SPEZIAL SPONZO STAPLET TESTO TIERNEY WALL WRIGHT

DILG
CFMG DMNR
ZARRILL DECI INTG
PREP CONT
FAMI RTEN
ORAL PHYS
WRIT

> stars(USJudge, [Link] = TRUE, scale = FALSE,


+ [Link] = c(13, 1.5))

ALEXANDER,J.M. BERDON,R.I. BURNS,E.B.


AARONSON,L.H. ARMENTANO,A.J. BRACKEN,J.J. CALLAHAN,R.J.

COHEN,S.S. DANNEHY,J.F. DEVITA,H.J. GRILLO,A.E.


DALY,J.J. DEAN,H.H. DRISCOLL,P.J.

HAMILL,E.C. HULL,T.C. LEVISTER,R.L.


HADDEN,[Link]. HEALEY.A.H. LEVINE,I. MARTIN,L.F.

MCGRATH,J.F. MISSAL,H.M. NARUK,H.J. O'SULLIVAN,T.J.


MIGNONE,A.F. MULVEY,H.M. O'BRIEN,F.J.

RUBINOW,J.E. SATANIELLO,A.G. SHEA,[Link].


PASKEY,L. SADEN.G.A. SHEA,D.M. SIDOR,W.J.

SPEZIALE,J.A. STAPLETON,J.F. TIERNEY,[Link]. WRIGHT,D.B.


SPONZO,M.J. TESTO,R.J. WALL,R.A.
DILG DMNR
CFMG INTG
DECI CONT
PREP RTEN
ZARRILLI,K.J. FAMI PHYS
ORAL WRIT

60
Frédéric Bertrand ESIEA 5e année - 2012/2013

> stars(USJudgeRatings, locations = c(0, 0), scale = FALSE,


+ radius = FALSE, [Link] = 1:10, [Link] = c(0,
+ 0), main = "US Judges rated")

US Judges rated

CFMGDILGDMNR
DECI INTG
PREP CONT
FAMI RTEN
ORALWRITPHYS

> stars(USJudgeRatings[1:10, ], locations = 0:1, scale = FALSE,


+ [Link] = TRUE, [Link] = 0, [Link] = 1:10,
+ [Link] = 0:1, main = "US Judges 1-10 ")

61
Frédéric Bertrand ESIEA 5e année - 2012/2013

US Judges 1−10

DILG DMNR
CFMG INTG
DECI CONT
PREP RTEN
FAMI PHYS
ORAL WRIT

> palette("default")
> stars(cbind(1:16, 10 * (16:1)), [Link] = TRUE,
+ main = "A Joke -- do *not* use symbols on 2D data!")

A Joke −− do *not* use symbols on 2D data!

62
Frédéric Bertrand ESIEA 5e année - 2012/2013

16 Steam and leaf


> stem(islands)

The decimal point is 3 digit(s) to the right of the |

0 | 00000000000000000000000000000111111222338
2 | 07
4 | 5
6 | 8
8 | 4
10 | 5
12 |
14 |
16 | 0

> stem(log10(islands))

The decimal point is at the |

1 | 1111112222233444
1 | 5555556666667899999
2 | 3344
2 | 59
3 |
3 | 5678
4 | 012

17 Conditioning plots
> coplot(lat ~ long | depth, data = quakes)

63
Frédéric Bertrand ESIEA 5e année - 2012/2013

Given : depth
100 200 300 400 500 600

165 170 175 180 185 165 170 175 180 185


●●
●● ●
●● ●
●●●

● ● ●●●

−15

● ●
●● ● ●●●● ●● ● ●


●●●● ●

●●
● ●●●
● ● ● ●●● ● ● ●● ● ●●● ●
●● ●●●●●●
● ●● ● ●
●●

●●●●● ● ●● ●
●●




●●● ●●● ●

●●


● ●
●●
●●

●●








●●



● ● ●
●●



●●
●●●●




●●●
●●● ● ●
●●









●● ●●


●●




●●
●●

●●
●●●
●●
●●
● ● ●


●●

●● ● ●●


●●

●●


●●
●●
●●
● ●●● ●●


●●





●●●●
● ●

















●●

●●●●●
●●
●● ●●
●●●●
● ●

●●


●●
●● ●● ●●●●●

●●● ●●
●●
●●


●●
● ● ●
●●●
●●

● ●●
●●
●●



●● ●●

−25

●●
●●


● ● ● ● ●
●●

●●


●●
● ● ●●●


●●

●●
● ●

● ●
●●●
●●
●●●●
● ●
●●
●●

●● ●● ●●●
●●●
●●● ●● ●●
● ●● ● ●




●● ●


●●

●●●
●●●
● ●●

●● ● ●

−35
● ●


lat

●● ● ●●

●● ●

●●




●● ●●

●●●● ●
● ●●

●●●●● ●●●●
●●

●●




●●
●●
● ● ● ●●● ●
−15

● ●● ●●

● ●

●●
● ●●● ●●● ●
●●

● ●●●●
●● ●

● ●● ● ●●




●●
●●
● ●●● ●





●●
●●●● ●●





●●
●●● ●
●●●●●●

●●
● ●●●


●●

● ●●●
●●






●●●

● ●●
●●●●

●●
● ●

●●●●
● ●●
● ●●●

●●
●● ●● ●● ● ● ● ●● ●●●● ●●●
● ● ●●
● ● ●●●●
●●



●●
●●
● ● ●●● ●●

●●● ● ● ● ●● ●


●●●

● ●
●●
●● ● ● ●


●● ●

●●


● ● ●●●
●●●
●●
●●








●●
●● ●●●

●●●

●●
● ●●
●● ●

●●
●●●
●●
●● ●● ●●
●●
● ●
●●●
● ●● ●

●● ● ●
● ●●●

●● ●
●● ●●●
●●
● ●●●
●●●●● ●●● ●
●●● ●●


●●●
●●●●●● ●●


●●●●
● ● ●●●●
● ●●


●●
●●
●●

●●●●

●●●●●●● ●
●●●● ●
●●
−25

●● ●
● ●
●●
●●● ●

●●● ●● ●


●●● ●● ●●



● ●
●● ● ●●●




●●

●●
● ●
●●●●
●●● ●
●●
●●●
● ● ●
●●
●●● ●
● ●

●●
●●●● ●●


●● ●
● ●●●●
●●●
● ●
● ●●● ●


●●
● ●
●● ●
●●● ● ●● ●

●●● ●● ●●● ●
● ●●

−35

●●●● ● ●●
●● ● ● ●
●● ● ●

● ●
●●
●● ●● ●● ●●

165 170 175 180 185

long

> [Link] <- [Link](quakes$depth, number = 4,


+ overlap = 0.1)
> coplot(lat ~ long | depth, data = quakes, given.v = [Link],
+ rows = 1)

Given : depth
100 200 300 400 500 600

165 175 185 165 175 185


−10


● ● ●


●●
●● ●


●●●

●●● ●
●● ●

●●●● ●

●● ●
● ●
● ●

● ● ●

● ● ● ●
● ●
● ● ●
●●
● ● ● ●
−15

●●● ●

● ● ●
● ● ● ●●● ●



● ●●●
●●
● ●
●●


●● ●

●●
● ●
●●
●●





● ●●●



●●

●●

● ●●
● ●●
●●


●●●
●● ● ●● ●

●●
● ●●●●●●●
●●

● ●●●●
● ●
●● ●
●● ●● ● ●


● ●
●●

●●●●● ● ● ●●●●




● ●●
● ●●
●● ●●●●
●●●●
● ●●●

●●
● ●● ●





●●











● ●
●● ●●
● ●

● ● ●

● ●●
● ● ● ●

● ● ●● ● ●●● ● ●
−20

● ●●●

●● ●● ●
●●● ●
● ●
●●
●●●

● ● ●
●●●
●●


● ● ● ● ● ● ● ●●



● ● ● ● ●

● ●● ● ●
●●
●●
●● ●●●




● ●
●●




●● ●●










●● ● ●
●●









● ●●●● ●●● ●●● ●●
●● ●● ●
●●
●●



● ●●


● ● ●●●●




● ●
●●
● ●








●●●●●
●● ● ●● ●● ● ● ●●
●●●

●●

● ●●
●●●●● ●●


●●
●●
● ●●● ● ●
●● ●●


●●●
●●
● ●
● ●
●● ●●

●●
●● ●●
●●



● ●●
● ●
● ●● ●

lat

●●
● ● ●
● ●●
●●
−25

● ● ●
●●
● ●●

● ●


●●






●●●

● ●
● ●●
● ●●●
● ●● ●●


●●●
● ●● ●●




●●
● ●●●
●●



● ●
●●● ●





●●●●● ●●

● ● ●● ●
●●
−30

●●● ●●
● ●


●●● ●● ●●●


●● ●

●●
● ● ●
●● ●●●●
●●
●● ● ●● ●
−35

●● ●

● ●

● ●

● ●●

165 175 185 165 175 185

long

64
Frédéric Bertrand ESIEA 5e année - 2012/2013

> [Link] <- lat ~ long | depth * mag


> coplot([Link], data = quakes)

Given : depth
100 200 300 400 500 600

165 180 165 180 165 180




●● ●

●● ●


●● ●




●● ● ●
●●
● ● ● ●
●●
● ●● ● ●

●●
● ●●●
●●● ●
● ●
●● ●
●●
● ●

● ●
●●
●● ●●● ●●
● ● ●
● ● ● ● ●

−20
● ●● ● ●
● ● ●●●
●●


●●





●●● ●
● ●
●●
●●
●●

●●
● ●
●●


●●●
●●




● ●●●





●●

● ●

●●







● ●

●●







● ● ● ● ●


●●



●●
● ●



●●

● ●
●●

● ●


●●

●●
● ●●

● ●
●●●
●●●
●●
● ●●●
●●
●●

● ●●●
● ●

●●● ●



●●●● ●●


●●●
●● ●






●●●
● ●


●●

● ●
● ●
●● ● ●
● ●●
●●

● ●
● ●●
● ●

−35
●●
●●

● ●
● ●
●●● ●
●●

● ●

● ●
● ●

6.0



●●
● ● ●
●● ●

●● ●





● ●
●●

● ●● ●
● ●●●





●● ●●
●●●

●●● ●●




●● ● ●●●









● ● ●●






● ●
●●


● ●
●●
−20

● ●● ●
●●
● ● ●● ●
●●
● ●
●● ● ●

● ●●
● ●●

●● ●

●●


●●
● ●●
●● ●
● ● ●
● ●●
●●
● ●● ●
●●
● ●●
● ●●

●●

●●

●●●
●●
● ●●







●●
●●
● ●








● ●●●
● ●●

●●● ●●●● ●
●●
●●
●●

●●●




●●
● ●●

● ●
● ●


● ●●● ●


●● ● ●



●● ●●●
● ●● ● ●●
● ●


●●
●●
● ●
● ●

●●● ● ●
●●
●● ●●

●●
●● ●

●●
●● ●
●● ●
● ●
●●
● ● ●●
● ●
●● ●

●●● ●●● ● ●
−35




●● ●
● ●

●●

● ● ● ●
●●
● ●●●
● ●


●● ●
● ●


●● ●


● ●



● ●


●● ●
● ●
● ●●

●●
● ●
● ●



● ●

● ●●
● ●●● ● ●● ●●
●●
●● ●●●
●●

● ●●● ●●●
●● ●● ●
●● ● ●●●● ●●

5.5
● ● ● ● ● ● ● ●
● ●

−20
●●
● ●
●●
● ● ●●●
● ●
● ●

● ●
●● ●●
● ●● ● ●
●●
● ●

●●

●●
●● ● ●

●● ●●● ●
● ●
●●● ● ●●●
● ● ●
●●

● ●●
●●
●● ●
● ● ●
● ●●

Given : mag
● ●● ● ●
●●
●● ● ●

●●● ● ●
● ●
●●
● ●●



●●

●●
●● ●●

● ●
● ●●
● ● ●●
● ●

● ● ●●
●●●
● ●



●●● ●












● ●


●●




● ●●
●●●

●● ●●
●●
● ●●● ●
●●●
● ●●
● ●
● ●
●● ●● ●
●●
●●● ●● ●●● ●

● ●

●●● ●●●● ●
● ●

−35
●●


● ●
●● ●●

● ● ●
lat


● ●●
● ●


●●
● ●

●● ●
● ●

●● ●
●●
● ●
● ● ●● ●


● ●


●●●● ●


● ●
●●●
● ●


● ●
●●●
● ●●● ●
● ●
● ●● ● ●
● ●● ● ●
●● ● ●●● ● ●

−20

● ●● ●
●●
● ●●
● ●
● ●

●● ●


●●


● ●●● ●●
●● ●●

● ●●●

●●





● ●●
●●●
●●




● ●
●●

●●

●●

● ●









● ●






● ●●

● ●●● ●

5.0

●● ●●
●● ● ●●
● ● ● ●●
●●
● ●●
●●


● ●
● ●

●● ● ●

●●● ●●
●● ●

●● ●●
●● ●


●●● ●
●●●

● ●



●● ●

● ● ● ●
●● ●
●●


● ●●● ●●● ●
● ●●
● ●
−35


● ●●●
● ●●●

● ●

●●
● ●


●● ●

●●
● ●

●● ●

●● ●
●●
● ●

● ● ●●

● ●

●●●●
●● ●


● ●
●●
●●
● ●●
● ●
●●

●● ●●

●●
●●● ●●

●●● ●
● ● ●●
●● ● ●● ● ● ●●
●●● ●● ● ● ●

−20
● ●● ●● ●
● ●
● ● ●

●●
● ●

● ●●●
● ●
●● ●

●●

●● ●●
●●

●●

● ●● ● ●●
● ●
● ● ●●●
●●



● ● ●

●●



●●
●● ● ●






●●


●●


● ●






●●● ●

●●







● ● ● ● ●
● ● ●●
●●

● ● ●●
●●●

● ●●
●●

● ●
●●

●●●

● ●
●●●
● ●
● ●

●●

● ●
● ●


●●

●● ●

●●
● ●● ● ●
●●



● ●●

●●
● ●●
● ●
●● ●●
●● ●● ●

4.5

●● ●

●●
●● ●●

●● ●
● ●●
● ●●

●● ●
● ●
● ● ●

−35
● ●
● ●● ●● ●



● ●


● ●

●● ●
● ●
●● ●
●● ●
● ● ●●
● ●
●●
●● ●●

● ●
●●

●●
● ●●
● ●

●●

●● ●●
●● ●
● ●●
●● ●

●● ●
●● ● ●
● ●

●●●●
● ●●

● ● ●
−20

● ● ●● ● ●●● ●
● ●●
●●●
● ●

● ●●
●●
●●
●●●


● ●●●
●●
●●
● ● ●●
●●



●●
●● ● ●● ●
● ● ●● ●

●● ●
● ●
●●

●●

● ● ●


●●



●●
●●
● ●●

●●● ●●


●●


●● ●
●●
●●
●● ●
●●
●●

● ●

●●
●● ●


●●

●●● ●●
● ●●●

● ●●
●●
● ●●● ●●


●●●
● ●


●●● ●







●●
●●

●●




● ●

●●








●●



●●
●●
●●
● ●

●● ●●

● ●
●● ●
● ●
●● ● ●
●●

● ●●

●● ●
● ●
−35

4.0
●● ●●
● ●

165 180 165 180 165 180

long

> coplot([Link], data = quakes, number = c(4, 7), [Link] = c(TRUE,


+ FALSE))

Given : depth
100 200 300 400 500 600

165 175 185 165 175 185



●●● ●


●●● ●●●

●●●

● ● ●
● ● ●● ●
●●●

●●
● ●● ●●●
●●
●● ●●
●● ●●●● ●●
● ● ●
● ●● ●
−35 −20

●● ● ● ● ● ● ●

●● ●●
●●●
●● ●
●● ●

● ●●●●

●●●●●
● ●●
● ● ●●
●●
●●●
●●●
● ● ●●
●●

●●


●●
●●●

● ● ●●●
●●●
● ●●●

●●●●●
● ●
●●●
●● ●
●●●●
●●● ●

●●●
●●●● ●●
●●
●●

●●●
●●●●

● ● ●
● ● ●

●● ●
●● ●



●●●

●●
● ●

●●

● ●●● ● ●●●

●●●● ●●● ●●
●● ● ●
●●●●● ● ●



●●● ●●
●●




●●
● ●


●●
●● ●●

●●


●●● ● ●
●● ●
●● ●● ●



●●


●●● ●●
● ●●

●●
●● ●●
●●● ●●●●●
●●
● ●● ●●●
● ●
● ●● ● ●
● ● ●
−35 −20

● ●● ● ●
● ●

●●● ●●●
●●

● ● ●●


●●●
● ●●

●●●●● ●●
● ●●
●●
●●●●
●●● ●●
●●








●●● ●● ● ●

●●
●● ●●
●● ●
● ●
●● ●●● ● ●
●●
●●
●●


●● ●

● ●
●●

● ● ●●

●●● ● ●
●●

●●
●● ● ●
●●





●●●


●● ●●● ●
●● ●● ●
●●●●
●●

●●● ●●● ●
●●● ●
●●●
● ●
●●●● ●
●●




●●
● ●●
● ● ●
● ● ●●● ●




●●
●● ●


●●
●● ●●●

●●●
● ● ●●
● ●

● ●●
●●

●●



●●
●● ●●●●

●●
● ●

●● ●●●●●
● ●

●● ●●●
●●
● ● ● ● ●
●●
−35 −20

● ●● ● ●● ●● ● ●
● ●

●● ● ●●●

●●●
●●
● ●● ● ●● ●
●● ●●
●●
●●
●●● ● ●

●●
●●


● ●●
●●
●● ●●

● ●●●● ● ●
●●● ●
●●●


●●





●●



●●

●●● ●
● ●●●
● ●
● ● ●
●●● ● ●
●●●●● ●●
●●

●● ●
● ●
●●








●● ●
●●●●

●●














●●●
● ●

●● ●● ●
●●

●●
● ●●
● ● ● ●●
● ●
●●
●●
●● ●● ● ●
●● ●● ●● ●●
Given : mag


●●


● ●●
● ●



●●
●●
● ●

●●●
● ●●
●●● ● ●
●● ● ●●

● ●● ●
●●

●●
● ●
●●● ●●
●● ●

●● ●●●●
●●
● ●●
● ●●●●●●
● ●
●●●
● ● ● ●● ●●●
●● ● ● ●●
−35 −20

● ● ●●
● ●
● ●
●● ●
●● ●
● ●



●●
●● ● ●● ●


●●
●●●
●●● ●●



●● ●● ●●●
● ●




●●
●●
● ●●● ●●

● ●
●●
●●●


●●
●● ●
●●
●●
●●●



●●

●●
●● ●● ● ●● ●
●●●

●●●●● ●
●●



●●
●●

lat

●●●● ●●
● ●●
●● ●● ●●
●● ●● ●
●● ●
●●
●●
●● ●●
● ●● ●

●●






●●
●● ● ●●
●●









●●
●●

●●●

● ●●
● ●
●●● ●
● ●●●●
● ●●●

●●

●●● ●
●●

● ● ●●

●●
● ●●●
●● ●●
●●

●●



●●●● ●

●● ●● ●
●● ● ●●
●● ●● ●●

● ●●
● ●



●●●● ●

● ●
● ●
●●

●● ●


●● ● ●● ●



●●
● ●●●
●●●● ●

●● ●●●●
●●
●●●●
● ●● ●●
● ●●● ● ●●●
●●
● ● ● ●●● ● ●
●● ● ●
−35 −20

● ●
●● ● ●●
●●● ●
●● ●
●●●


● ● ● ●●● ●●
●●
●●● ●
●●

● ●●●●
●●
● ●●● ●

● ● ●●
● ●
●●


●●
●●
●●
● ●

●●
●●●
●● ●
● ● ●● ●

●●●●
●●

●●
●●●
●●● ●
●●

●●●
●●
●●

●●
●●
●●



●●
● ●

●●



●●
●●






●●



●● ●
●●●●
●●
● ●
● ●
● ●

●●●● ●●

●●
●●
●●
● ●
●●

● ●●
●●

●●









●● ●●●
●● ● ●


●●
●●●● ●●●


●●●

●●





●●

●● ●

●●
●●● ●● ●

●● ●
● ● ●●●●
●● ●●●● ●
● ●
●●



●● ●●
● ● ●●●●
● ●



● ●

● ● ●●
●●
●● ●

●● ● ●

●●
●● ●●●●●● ●

●● ●●●●
●●●
●●● ● ●●●●
●●●●● ● ●● ●● ●
−35 −20


●●
● ●● ●
●●● ●
●●
●●
● ● ●

●●
●● ● ●
● ●● ●


●●

●●

●● ●● ●

●●
● ●●
● ●

●● ●●●●

● ● ●●

● ● ●●●

●●●● ● ● ●●●●
●●●
●●

●●
●●
●●● ● ●

●●

●●
●●

●●●
●●
●● ●
●●







●●


●●●
●● ● ●


●●


●●
●●
● ●

●●
● ●
●●


●●


●●






●●
●●


●●●



●●●
●●

●●●

● ●● ●
●●
●●●


● ● ●
●●
● ●●

● ●
● ● ●


●●● ●

●● ●●● ●●



● ●


● ● ●
●●

● ●
●●
● ●


● ●●●

●●● ●
● ●●●●●

●●
●●
● ●●●
●●●●●
● ● ● ●●●●
−35 −20


● ●● ●
●●●
● ●
●●

●●● ●

●●
●●

●●●
● ●

●● ●●●
●●



●●

● ●
● ●

●● ●
● ●
● ●●
●●
●● ●●●●
● ●
●●

●● ● ● ● ●●●
●●●

●●
●●●


● ● ●
●●●

●●●
●●


● ●


● ●
● ●
●●



●●

●●●

●●●
●●● ●●
●●
● ●



●●●● ●
●●

●●●


●●

●●

● ●●

●●
●●

●●
●●●



●● ●

●● ● ●●
●●


● ●

●● ●●
●●●

●●

●●●
● ●●● ●

● ●●
● ●●

● ● ● ●
● ●

165 175 185 165 175 185

long

65
Frédéric Bertrand ESIEA 5e année - 2012/2013

> coplot([Link], data = quakes, number = c(3, 7), overlap = c(-0.5,


+ 0.1))
Given : depth
100 200 300 400 500 600

165 175 185 165 175 185



●● ●
●● ●● ●
●●●
●● ● ● ●● ●●●

● ●●●
● ●● ●
−35 −20

● ● ● ●
●●●

●●●
●● ● ●●
●● ●
●●
●●

● ●●●●●●●
● ● ●●
●●
● ●●● ●●●




●● ●
●● ●●
●●

●●
●●
●●●

● ●

●●● ●●

● ●

●●



●●●
● ●●●

●● ●●
● ● ●

●●
● ● ●● ●
●● ●

6.0
● ●

−35 −20
● ● ● ●●● ●●
●●

●●● ● ●●●

●● ●
● ● ●● ●●●

●●
●● ●● ●●●

●●● ● ●●
●●●

●●
●●● ●● ●


● ●●
●● ● ●

● ●●
●●● ●

●●●●

●●
● ●
●●

●● ● ●

● ●●
●●

●●


●● ●●
●● ●●●


● ●
−35 −20

● ● ●
● ● ●●
●●

●● ●●● ●
● ● ●●● ●

●●

●●
●●
●●●● ●●●
● ●
● ●● ●●●

●●
●●●● ●●

●●
●●


●●
●●
● ●

5.5
● ● ●
●●●●
● ●●●●
●● ●●●
●● ●●

Given : mag
●●
●●


●● ●
● ●
●● ● ●●


● ●●
● ●
● ●
● ●●●

−35 −20
● ● ● ● ●
● ●●
●●●
●●

● ●
● ●●
● ● ●
●●
●●
● ●
●● ●


●●


lat


●● ●●
●● ●●
● ●

●●
●● ● ●●

●●
● ●●●● ●

●●
●● ●

●● ●●

5.0


●●● ●
● ●

● ●
●● ● ●
● ●●●●● ● ●
● ●●●● ●

−35 −20

● ● ● ● ●●

● ● ●
●●
●●
●●
● ●
● ●● ●
●●
● ●● ●●
●●●



● ●

●●

●●





● ● ●
● ●●●


● ●●●● ●
●● ●

●● ●●●
● ●
● ●


● ●●●
● ●

●●●


●●●●●
●●●●● ● ●●

−35 −20
● ●●● ● ●

●● ●●


●●●
●●● ●●●





●●
●●

● ●● ● ●
●●●●
●●●
● ●

4.5
● ●● ●
●●●
●●
● ●



●●


●●
●●●
● ●● ● ●
●●

●●


●●● ●●
●●●● ●●
● ●

●● ●
●●●


● ●●●

● ●

●●
● ●
●●●● ●●●●● ●
−35 −20

●● ●
●●●●
●●●●

●●
● ●●

●●

●●

●● ●
● ●
●●
●● ●
●●

●● ●●

●●
●●
●●
●● ● ●●● ●

●●
●●
●●


●● ● ●

●● ●
● ●●●

● ●●
●●

4.0
165 175 185

long

> Index <- seq(length = nrow(warpbreaks))


> coplot(breaks ~ Index | wool * tension, data = warpbreaks,
+ [Link] = 0:1)
Given : wool
0 10 20 30 40 50
70
60
50


40


30

● ●

● ●
20

● ●●
● ● ●
● ●●

10


70

Given : tension
60
50
breaks


40

● ●
●●
30

● ●
● ●

20

● ●
● ●● ●


10
70



60


●●
50


40


L
30

● ●
●●
● ● ● ●
20

● ●

10

0 10 20 30 40 50

Index

66
Frédéric Bertrand ESIEA 5e année - 2012/2013

> coplot(breaks ~ Index | wool * tension, data = warpbreaks,


+ col = "red", bg = "pink", pch = 21, [Link] = c(fac = "light blue"))

> with([Link](state.x77), {
+ coplot([Link] ~ Income | Illiteracy * [Link],
+ number = 3, panel = function(x, y, ...) [Link](x,
+ y, span = 0.8, ...))
+ })

> with([Link](state.x77), {
+ coplot([Link] ~ [Link] | Income * [Link],
+ panel = [Link])
+ })

18 persp
> require(grDevices)
> x <- seq(-10, 10, length = 30)
> y <- x
> f <- function(x, y) {
+ r <- sqrt(x^2 + y^2)
+ 10 * sin(r)/r
+ }
> z <- outer(x, y, f)
> z[[Link](z)] <- 1
> op <- par(bg = "white")

> persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue")

67
Frédéric Bertrand ESIEA 5e année - 2012/2013

y
x

> res <- persp(x, y, z, theta = 30, phi = 30, expand = 0.5,
+ col = "lightblue", ltheta = 120, shade = 0.75, ticktype =
+ "detailed", xlab = "X", ylab = "Y", zlab = "Sinc( r )")
> round(res, 3)

[,1] [,2] [,3] [,4]


[1,] 0.087 -0.025 0.043 -0.043
[2,] 0.050 0.043 -0.075 0.075
[3,] 0.000 0.074 0.042 -0.042
[4,] 0.000 -0.273 -2.890 3.890

> xE <- c(-10, 10)


> xy <- [Link](xE, xE)
> points(trans3d(xy[, 1], xy[, 2], 6, pmat = res), col = 2,
+ pch = 16)
> lines(trans3d(x, y = 10, z = 6 + sin(x), pmat = res),
+ col = 3)
> phi <- seq(0, 2 * pi, len = 201)
> r1 <- 7.725
> xr <- r1 * cos(phi)
> yr <- r1 * sin(phi)
> lines(trans3d(xr, yr, f(xr, yr), res), col = "pink",
+ lwd = 2)

68
Frédéric Bertrand ESIEA 5e année - 2012/2013

8
6 ●
Sinc(

4
10
2
r)

0 5
−2
−10 ●
0

Y
−5
0 −5
X
5

10 −10

> z <- 2 * volcano


> x <- 10 * (1:nrow(z))
> y <- 10 * (1:ncol(z))
> par(bg = "slategray")
> persp(x, y, z, theta = 135, phi = 30, col = "green3",
+ scale = FALSE, ltheta = -120, shade = 0.75, border = NA,
+ box = FALSE)
> par(op)

69
Frédéric Bertrand ESIEA 5e année - 2012/2013

Table des matières


1 Contenu 1

2 dotchart 1

3 barplot 2

4 hist 8

5 Boı̂tes à moustaches 12
5.1 boxplot d’une formule . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.2 boxplot d’une matrice . . . . . . . . . . . . . . . . . . . . . . . . . . 14

6 pie 16

7 Tableaux de contingence 20
7.1 balloonplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.2 assocplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
7.3 mosaicplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.4 splineplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
7.5 cdplot (Conditional Density Plots) . . . . . . . . . . . . . . . . . . . 30

8 Plot factor variables 34

70
Frédéric Bertrand ESIEA 5e année - 2012/2013

9 Matrix plot 36

10 Simplepanel plots 40

11 jitter 41

12 curves 42

13 loess (régression non-paramétrique) 46

14 density estimation 48

15 Radar plots 55

16 Steam and leaf 63

17 Conditioning plots 63

18 persp 67

71

You might also like