R Chapter 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

> library(HH)

Loading required package: lattice


Loading required package: grid
Loading required package: latticeExtra
Loading required package: multcomp
Loading required package: mvtnorm
Loading required package: survival
Loading required package: TH.data
Loading required package: MASS

Attaching package: ‘TH.data’

The following object is masked from ‘package:MASS’:

geyser

Loading required package: gridExtra

> library(ISwR)

Attaching package: ‘ISwR’

The following object is masked from ‘package:survival’:

lung
> Modified <- c(1037, 1047, 1066, 1048, 1059, 1073, 1070, 1040)
> length(Modified)
[1] 8
> summary(Modified)
Min. 1st Qu. Median Mean 3rd Qu. Max.
1037 1045 1054 1055 1067 1073
> mean(Modified)
[1] 1055
> sd(Modified)
[1] 13.87701
> var(Modified)
[1] 192.5714

> quantile(Modified)
0% 25% 50% 75% 100%
1037.00 1045.25 1053.50 1067.00 1073.00
> min(Modified)
[1] 1037
> median(Modified)
[1] 1053.5
> IQR(Modified)
[1] 21.75
> max(Modified)
[1] 1073

> plot(Modified, 1:8, main = "Sample Mean = 1,055", xlab =


"Tensile strength (psi)", ylab = "", type = "n", yaxt = "n", frame =
FALSE)
> points(Modified, rep(1, 8), pch = 16, col = "green")
> points(mean(Modified), 1, pch = 17)
> AluminumLithium <- c(105, 97, 245, 163, 207, 134, 218, 199,
160, 196, 221, 154, 228, 131, 180, 178, 157, 151, 175, 201, 183,
153, 174, 154, 190, 76, 101, 142, 149, 200, 186, 174, 199, 115, 193,
167, 171, 163, 87, 176, 121, 120, 181, 160, 194, 184, 165, 145, 160,
150, 181, 168, 158, 208, 133, 135, 172, 171, 237, 170, 180, 167,
176, 158, 156, 229, 158, 148 ,150, 118, 143, 141, 110, 133, 123,
146, 169, 158, 135, 149)

> length(AluminumLithium)
[1] 80
> summary(AluminumLithium)
Min. 1st Qu. Median Mean 3rd Qu. Max.
76.0 144.5 161.5 162.7 181.0 245.0
> mean(AluminumLithium)
[1] 162.6625
> sd(AluminumLithium)
[1] 33.77324
> var(AluminumLithium)
[1] 1140.631

> stem(AluminumLithium)

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

6|6
8 | 77
10 | 15058
12 | 013133455
14 | 12356899001344678888
16 | 00033577890112445668
18 | 0011346034699
20 | 01788
22 | 1897
24 | 5
> BatchYield <- c(61, 63, 64, 65, 65, 66, 70, 71, 71, 73, 75, 77, 78,
78, 79, 81, 83, 84, 84, 87, 88, 88, 92, 93, 95)/100
> length(BatchYield)
[1] 25
> summary(BatchYield)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.6100 0.7000 0.7800 0.7724 0.8400 0.9500
> mean(BatchYield)
[1] 0.7724
> sd(BatchYield)
[1] 0.1015004
> var(BatchYield)
[1] 0.01030233

> stem(BatchYield)

The decimal point is 1 digit(s) to the left of the |

6 | 134556
7 | 011357889
8 | 1344788
9 | 235

> sd(AluminumLithium)/sqrt(length(AluminumLithium))
[1] 3.775963

> GolfBallDistance <- c(291.5, 269.6, 270.7, 277.5, 279.0, 267.8,


283.7, 271.0, 261.9, 282.6, 274.4, 266.6, 274.0, 278.0, 267.3, 272.1,
281.7, 271.5, 258.9, 270.0, 290.2, 283.6, 285.2, 272.5, 283.5, 269.7,
282.2, 289.7, 293.2, 265.2, 276.4, 269.6, 275.5, 271.7, 271.2, 278.5,
274.1, 271.1, 267.1, 277.7, 272.0, 277.8, 272.1, 280.8, 268.5, 277.3,
264.5, 256.9, 255.0, 275.5, 268.7, 287.8, 261.3, 265.6, 277.1, 280.5,
281.0, 274.5, 269.7, 272.2, 281.6, 267.6, 274.0, 260.1, 266.2, 270.8,
273.2, 286.2, 281.9, 270.0, 281.6, 292.6, 279.3, 272.5, 266.4, 267.7,
274.4, 273.9, 269.6, 271.0, 276.3, 273.4, 281.0, 281.3, 271.5, 255.1,
281.6, 268.5, 279.8, 284.3, 285.9, 284.4, 293.1, 263.0, 280.3, 276.4,
273.7, 262.6, 269.9, 268.4)
> length(GolfBallDistance)
> summary(GolfBallDistance)
Min. 1st Qu. Median Mean 3rd Qu. Max.
255.0 269.6 273.8 274.5 280.9 293.2
> mean(GolfBallDistance)
[1] 274.476
> sd(GolfBallDistance)
[1] 8.324943
> var(GolfBallDistance)
[1] 69.30467

> hist(GolfBallDistance, col = "green")

> Strikeouts <- c(8, 12, 9, 5, 17, 10, 8, 8, 8, 10, 5, 4, 11, 8, 13, 11, 8,
6, 10, 5, 7, 9, 8, 15, 11, 14, 11, 12, 16, 6, 8, 7, 17, 9, 8)
> length(Strikeouts)
[1] 35
> summary(Strikeouts)
Min. 1st Qu. Median Mean 3rd Qu. Max.
4.000 8.000 9.000 9.543 11.000 17.000
> mean(Strikeouts)
[1] 9.542857
> sd(Strikeouts)
[1] 3.381114
> var(Strikeouts)
[1] 11.43193

> table(Strikeouts)
Strikeouts
4 5 6 7 8 9 10 11 12 13 14 15 16 17
1 3 2 2 9 3 3 4 2 1 1 1 1 2

> hist(Strikeouts, col = "green")

> hist(Strikeouts, breaks = 3.5:17.5, col = "green")


> HullLossesMillionDepartures <- c(6.54, 6.46, 5.84, 3.94, 2.64,
2.57, 1.90, 1.40, 1.34, 1.29, 1.29, 1.23, 0.97, 0.96, 0.80, 0.77, 0.59,
0.49, 0.46, 0.43, 0.41, 0.39)
> length(HullLossesMillionDepartures)
[1] 22
> summary(HullLossesMillionDepartures)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.390 0.635 1.260 1.941 2.402 6.540
> mean(HullLossesMillionDepartures)
[1] 1.941364
> sd(HullLossesMillionDepartures)
[1] 1.968783
> var(HullLossesMillionDepartures)
[1] 3.876108

> plot(HullLossesMillionDepartures, type = "h", col = "green", lend


= 1, lwd = 15, main = "Aircraft Accident", xlab = "Aircraft type",
ylab = "Hull losses per million departures")

> bx <- boxplot(AluminumLithium)


> bxp(bx, boxfill = "green", main = "Aluminum-Lithium Alloy",
xlab = "Box-and-whisker plot", ylab = "Compressive strength (psi)")

> Original <- c(1030, 1035, 1020, 1049, 1028, 1026, 1019, 1010)
> length(Original)
[1] 8
> summary(Original)
Min. 1st Qu. Median Mean 3rd Qu. Max.
1010 1020 1027 1027 1031 1049
> mean(Original)
[1] 1027.125
> sd(Original)
[1] 11.71614
> var(Original)
[1] 137.2679
> Modified <- c(1037, 1047, 1066, 1048, 1059, 1073, 1070, 1040)
> length(Modified)
[1] 8
> summary(Modified)
Min. 1st Qu. Median Mean 3rd Qu. Max.
1037 1045 1054 1055 1067 1073
> mean(Modified)
[1] 1055
> sd(Modified)
[1] 13.87701
> var(Modified)
[1] 192.5714

> RubberCompounds <- c(Original, Modified)


> Factor <- c(rep("Original", 8), rep("Modified", 8))

> bx <- boxplot(RubberCompounds ~ Factor)


> bxp(bx, boxfill = "green", main = "O-Rings", xlab = "Rubber
Compounds", ylab = "Tensile strength (psi)")

> plot(1:80, AluminumLithium, main = "lowess(1:80,


AluminumLithium)", xlab = "time", ylab = "Compressive strength
(psi)", type = "b", pch = 16, col = "green")
> lines(lowess(1:80, AluminumLithium), col = 2)

> WolferSunspot <- c(101, 82, 66, 35, 31, 7, 20, 92, 154, 125, 85,
68, 38, 23, 10, 24, 83, 132, 131, 118, 90, 67, 60, 47, 41, 21, 16, 6, 4,
7, 14, 34, 45, 43, 48, 42, 28, 10, 8, 2, 0, 1, 5, 12, 14, 35, 46, 41, 30,
24, 16, 7, 4, 2, 8, 17, 36, 50, 62, 67, 71, 48, 28, 8, 13, 57, 122, 138,
103, 86, 63, 37, 24, 11, 15, 40, 62, 98, 124, 96, 66, 64, 54, 39, 21, 7,
4, 23, 55, 94, 96, 77, 59, 44, 47, 30, 16, 7, 37, 74)
> length(WolferSunspot)
[1] 100
> summary(WolferSunspot)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.00 15.75 39.50 46.93 67.00 154.00
> mean(WolferSunspot)
[1] 46.93
> sd(WolferSunspot)
[1] 37.36504
> var(WolferSunspot)
[1] 1396.147

> plot(1770:1869, WolferSunspot, main = "lowess(1770:1869,


WolferSunspot)", xlab = "Year", ylab = "Number", type = "b", pch =
16, col = "green")
> lines(lowess(1770:1869, WolferSunspot), col = 2)

> stem(WolferSunspot)

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

0 | 01224445677777888001234456667
2 | 011334448800145567789
4 | 01123456778804579
6 | 0223466778147
8 | 2356024668
10 | 138
12 | 245128
14 | 4
> UnitedKingdomAirline <- c(7.269, 6.775, 7.819, 8.371, 9.069,
10.248, 11.030, 10.882, 10.333, 9.109, 7.685, 7.682, 8.350, 7.829,
8.829, 9.948, 10.638, 11.253, 11.424, 11.391, 10.665, 9.396, 7.775,
7.933, 8.186, 7.444, 8.484, 9.864, 10.252, 12.282, 11.637, 11.577,
12.417, 9.637, 8.094, 9.280, 8.334, 7.899, 9.994, 10.078, 10.801,
12.953, 12.222, 12.246, 13.281, 10.366, 8.730, 9.614, 8.639, 8.772,
10.894, 10.455, 11.179, 10.588, 10.794, 12.770, 13.812, 10.857,
9.290, 10.925, 9.491, 8.919, 11.607, 8.852, 12.537, 14.759, 13.667,
13.731, 15.110, 12.185, 10.645, 12.161, 10.840, 10.436, 13.589,
13.402, 13.103, 14.933, 14.147, 14.057, 16.234, 12.389, 11.594,
12.772)

> length(UnitedKingdomAirline)
[1] 84
> summary(UnitedKingdomAirline)
Min. 1st Qu. Median Mean 3rd Qu. Max
6.775 8.902 10.642 10.685 12.228 16.234
> mean(UnitedKingdomAirline)
[1] 10.68464
> sd(UnitedKingdomAirline)
[1] 2.121408
> var(UnitedKingdomAirline)
[1] 4.500373

> plot(1:84, UnitedKingdomAirline, main = "lowess(1:84,


UnitedKingdomAirline)", xlab = "Month", ylab = "Millions of
Miles", type = "b", pch = 16, col = "green")
> lines(lowess(1:84, UnitedKingdomAirline), col = 2)
> stem(UnitedKingdomAirline)

The decimal point is at the |

6|8
7 | 347788899
8 | 123445678899
9 | 1133456699
10 | 0123344566678889999
11 | 023446666
12 | 2222344588
13 | 01346778
14 | 1189
15 | 1
16 | 2

> PullStrength <- c(9.95, 24.45, 31.75, 35.00, 25.02, 16.86, 14.38,
9.60, 24.35, 27.50, 17.08, 37.00, 41.95, 11.66, 21.65, 17.89, 69.00,
10.30, 34.93, 46.59, 44.88, 54.12, 56.63, 22.13, 21.15)
> WireLength <- c(2, 8, 11, 10, 8, 4, 2, 2, 9, 8, 4, 11, 12, 2, 4, 4, 20,
1, 10, 15, 15, 16, 17, 6, 5)
> DieHeight <- c(50, 110, 120, 550, 295, 200, 375, 52, 100, 300,
412, 400, 500, 360, 205, 400, 600, 585, 540, 250, 290, 510, 590,
100, 400)
> WireBond <- cbind(PullStrength, WireLength, DieHeight)
> WireBond
PullStrength WireLength DieHeight
[1,] 9.95 2 50
[2,] 24.45 8 110
[3,] 31.75 11 120
[4,] 35.00 10 550
[5,] 25.02 8 295
[6,] 16.86 4 200
[7,] 14.38 2 375
[8,] 9.60 2 52
[9,] 24.35 9 100
[10,] 27.50 8 300
[11,] 17.08 4 412
[12,] 37.00 11 400
[13,] 41.95 12 500
[14,] 11.66 2 360
[15,] 21.65 4 205
[16,] 17.89 4 400
[17,] 69.00 20 600
[18,] 10.30 1 585
[19,] 34.93 10 540
[20,] 46.59 15 250
[21,] 44.88 15 290
[22,] 54.12 16 510
[23,] 56.63 17 590
[24,] 22.13 6 100
[25,] 21.15 5 400

> summary(WireBond)
PullStrength WireLength DieHeight
Min. : 9.60 Min. : 1.00 Min. : 50.0
1st Qu. :17.08 1st Qu. : 4.00 1st Qu.:200.0
Median :24.45 Median: 8.00 Median:360.0
Mean :29.03 Mean : 8.24 Mean :331.8
3rd Qu.:37.00 3rd Qu.:11.00 3rd Qu.:500.0
Max. :69.00 Max. :20.00 Max. :600.0
> bx <- boxplot(PullStrength)
> bxp(bx, boxfill = "green", main = "Box-and-Whisker Plot", ylab =
"Pull strength (Y)")

> bx <- boxplot(WireLength)


> bxp(bx, boxfill = "green", main = "Box-and-Whisker Plot", ylab =
"Wire length (X1)")

> bx <- boxplot(DieHeight)


> bxp(bx, boxfill = "green", main = "Box-and-Whisker Plot", ylab =
"Die height (X2)")

> plot(WireLength, PullStrength, main = "lowess(WireLength,


PullStrength)", xlab = "Wire length (X1)", ylab = "Pull strength
(Y)", pch = 16, col = "green")
> lines(lowess(WireLength, PullStrength), col = 2)

> plot(DieHeight, PullStrength, main = "lowess(DieHeight,


PullStrength)", xlab = "Die height (X2)", ylab = "Pull strength (Y)",
pch = 16, col = "green")
> lines(lowess(DieHeight, PullStrength), col = 2)

> pairs(WireBond, main = "Scatterplot Matrix for the Wire Bond


Data", pch = 16, col = "green")

> cor(WireBond)
PullStrength WireLength DieHeight
PullStrength 1.0000000 0.9818118 0.4928666
WireLength 0.9818118 1.0000000 0.3784127
DieHeight 0.4928666 0.3784127 1.0000000
> Anomaly <- c(-0.11, -0.13, -0.01, -0.04, -0.42, -0.23, -0.25, -0.45,
-0.23, 0.04, -0.22, -0.55, -0.40, -0.39, -0.32, -0.32, -0.27, -0.15, -
0.21, -0.25, -0.05, -0.05, -0.30, -0.35, -0.42, -0.25, -0.15, -0.41, -
0.30, -0.31, -0.21, -0.25, -0.33, -0.28, -0.02, 0.06, -0.20, -0.46, -0.33,
-0.09, -0.15, -0.04, -0.09, -0.16, -0.11, -0.15, 0.04, -0.05, 0.01, -0.22,
-0.03, 0.03, 0.04, -0.11, 0.05, -0.08, 0.01, 0.12, 0.15, -0.02, 0.14,
0.11, 0.10, 0.06, 0.10, -0.01, 0.01, 0.12, -0.03, -0.09, -0.17, -0.02,
0.03, 0.12, -0.09, -0.09, -0.18, 0.08, 0.10, 0.05, -0.02, 0.10, 0.05,
0.03, -0.25, -0.15, -0.07, -0.02, -0.09, 0.00, 0.04, -0.10, -0.05, 0.18, -
0.06, -0.02, -0.21, 0.16, 0.07, 0.13, 0.27, 0.40, 0.10, 0.34, 0.16, 0.13,
0.19, 0.35, 0.42, 0.28, 0.49, 0.44, 0.16, 0.18, 0.31, 0.47, 0.36, 0.40,
0.71, 0.43, 0.41, 0.56, 0.70, 0.66, 0.60)

> length(Anomaly)
[1] 125
> summary(Anomaly)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-0.55000 -0.18000 -0.02000 -0.00632 0.12000 0.71000
> mean(Anomaly)
[1] -0.00632
> sd(Anomaly)
[1] 0.2566048
> var(Anomaly)
[1] 0.06584603

> plot(1880:2004, Anomaly, main = "lowess(1880:2004,


Anomaly)", xlab = "Year", ylab = "Temperature anomaly", type =
"b", pch = 16, col = "green")
> lines(lowess(1880:2004, Anomaly), col = 2)
> CO2Conc <- c(290.7, 291.2, 291.7, 292.1, 292.6, 293.0, 293.3,
293.6, 293.8, 294.0, 294.2, 294.3, 294.5, 294.6, 294.7, 294.8, 294.9,
295.0, 295.2, 295.5, 295.8, 296.1, 296.5, 296.8, 297.2, 297.6, 298.1,
298.5, 298.9, 299.3, 299.7, 300.1, 300.4, 300.8, 301.1, 301.4, 301.7,
302.1, 302.4, 302.7, 303.0, 303.4, 303.8, 304.1, 304.5, 305.0, 305.4,
305.8, 306.3, 306.8, 307.2, 307.7, 308.2, 308.6, 309.0, 309.4, 309.8,
310.0, 310.2, 310.3, 310.4, 310.4, 310.3, 310.2, 310.1, 310.1, 310.1,
310.2, 310.3, 310.5, 310.7, 311.1, 311.5, 311.9, 312.4, 313.0, 313.6,
314.2, 314.9, 315.8, 316.6, 317.3, 318.1, 318.7, 319.2, 320.0, 321.1,
322.0, 322.9, 324.2, 325.2, 326.1, 327.2, 328.8, 329.7, 330.7, 331.8,
333.3, 334.6, 336.9, 338.7, 339.9, 341.1, 342.8, 344.4, 345.9, 347.2,
348.9, 351.5, 352.9, 354.2, 355.6, 356.4, 357.0, 358.9, 360.9, 362.6,
363.8, 366.6, 368.3, 369.5, 371.0, 373.1, 375.6, 377.4)

> length(CO2Conc)
[1] 125
> summary(CO2Conc)
Min. 1st Qu. Median Mean 3rd Qu. Max.
290.7 300.1 310.2 317.3 328.8 377.4
> mean(CO2Conc)
[1] 317.2776
> sd(CO2Conc)
[1] 22.94719
> var(CO2Conc)
[1] 526.5735

> plot(1880:2004, CO2Conc, main = "lowess(1880:2004,


CO2Conc)", xlab = "Year", ylab = "CO2 concentration", type = "b",
pch = 16, col = "green")
> lines(lowess(1880:2004, CO2Conc), col = 2)

> plot(CO2Conc, Anomaly, main = "lowess(CO2Conc, Anomaly)",


xlab = "CO2 concentration", ylab = "Temperature anomaly", pch =
16, col = "green")
> lines(lowess(CO2Conc, Anomaly), col = 2)
> cor(CO2Conc, Anomaly)
[1] 0.8523341

> Foam <- c(6.3, 4.4, 3.9, 5.1, 5.6, 4.6, 4.8, 6.5, 8.7, 8.3, 5.1, 3.3,
5.9, 7.7, 7.1, 5.5, 6.3, 4.3, 4.6, 3.4, 6.4, 5.5, 4.7, 4.1)
> Scent <- c(5.3, 4.9, 5.3, 4.2, 5.1, 4.7, 4.8, 4.5, 4.3, 3.9, 4.3, 5.4,
5.7, 6.6, 4.4, 5.6, 5.4, 5.5, 4.1, 5.0, 5.4, 5.3, 4.1, 4.0)
> Color <- c(4.8, 3.5, 4.8, 3.1, 5.5, 5.1, 4.8, 4.3, 3.9, 4.7, 4.5, 4.3,
7.2, 6.7, 5.8, 5.6, 4.8, 5.5, 4.3, 3.4, 6.6, 5.3, 5.0, 4.1)
> Residue <- c(3.1, 3.9, 4.7, 3.6, 5.1, 4.1, 3.3, 5.2, 2.9, 3.9, 3.6, 3.6,
4.1, 5.6, 4.1, 4.4, 4.6, 4.1, 3.1, 3.4, 4.8, 3.8, 3.7, 4.0)
> Region <- c(rep(1, 12), rep(2, 12))
> Quality <- c(91, 87, 82, 83, 83, 84, 90, 84, 97, 93, 82, 84, 87, 80,
84, 84, 82, 79, 81, 83, 81, 84, 83, 80)
> Shampoo <- cbind(Foam, Scent, Color, Residue, Region, Quality)
> Shampoo
Foam Scent Color Residue Region Quality
[1,] 6.3 5.3 4.8 3.1 1 91
[2,] 4.4 4.9 3.5 3.9 1 87
[3,] 3.9 5.3 4.8 4.7 1 82
[4,] 5.1 4.2 3.1 3.6 1 83
[5,] 5.6 5.1 5.5 5.1 1 83
[6,] 4.6 4.7 5.1 4.1 1 84
[7,] 4.8 4.8 4.8 3.3 1 90
[8,] 6.5 4.5 4.3 5.2 1 84
[9,] 8.7 4.3 3.9 2.9 1 97
[10,] 8.3 3.9 4.7 3.9 1 93
[11,] 5.1 4.3 4.5 3.6 1 82
[12,] 3.3 5.4 4.3 3.6 1 84
[13,] 5.9 5.7 7.2 4.1 2 87
[14,] 7.7 6.6 6.7 5.6 2 80
[15,] 7.1 4.4 5.8 4.1 2 84
[16,] 5.5 5.6 5.6 4.4 2 84
[17,] 6.3 5.4 4.8 4.6 2 82
[18,] 4.3 5.5 5.5 4.1 2 79
[19,] 4.6 4.1 4.3 3.1 2 81
[20,] 3.4 5.0 3.4 3.4 2 83
[21,] 6.4 5.4 6.6 4.8 2 81
[22,] 5.5 5.3 5.3 3.8 2 84
[23,] 4.7 4.1 5.0 3.7 2 83
[24,] 4.1 4.0 4.1 4.0 2 80

> summary(Shampoo)
Foam Scent Color Residue Region Quality
Min. :3.300 Min. :3.900 Min. :3.1 Min. :2.900 Min. :1.0 Min. :79.00
1st Qu.:4.550 1st Qu.:4.300 1st Qu. :4.3 1st Qu. :3.600 1st Qu.:1.0 1st Qu.:82.00
Median:5.300 Median:4.950 Median:4.8 Median:3.950 Median:1.5 Median:83.50
Mean :5.504 Mean :4.908 Mean :4.9 Mean :4.029 Mean :1.5 Mean :84.50
3rd Qu.:6.325 3rd Qu.:5.400 3rd Qu.:5.5 3rd Qu.:4.450 3rd Qu.:2.0 3rd Qu.:84.75
Max. :8.700 Max. :6.600 Max. :7.2 Max. :5.600 Max. :2.0 Max. :97.00
> pairs(Shampoo, main = "Scatterplot Matrix for the Shampoo
Data", pch = 16, col = "green")

> cor(Shampoo)
Foam Scent Color Residue Region Quality
Foam 1.000000000 0.002193385 0.3284925 0.1931525 -0.03233183 0.5122369
Scent 0.002193385 1.000000000 0.5987719 0.4995952 0.27825817 -0.2516592
Color 0.328492547 0.598771887 1.0000000 0.5241356 0.45776149 -0.1938511
Residue 0.193152540 0.499595225 0.5241356 1.0000000 0.16475977 -0.4892339
Region -0.032331832 0.278258174 0.4577615 0.1647598 1.00000000 -0.5071783
Quality 0.512236937 -0.251659160 -0.1938511 -0.4892339 -0.50717830 1.0000000

> plot(Foam, Quality, main = "lowess(Foam, Quality)", xlab =


"Foam", ylab = "Quality", pch = 16, col = "green")
> lines(lowess(Foam, Quality), col = 2)

> plot(Scent, Quality, main = "lowess(Scent, Quality)", xlab =


"Scent", ylab = "Quality", pch = 16, col = "green")
> lines(lowess(Scent, Quality), col = 2)

> plot(Color, Quality, main = "lowess(Color, Quality)", xlab =


"Color", ylab = "Quality", pch = 16, col = "green")
> lines(lowess(Color, Quality), col = 2)

> plot(Residue, Quality, main = "lowess(Residue, Quality)", xlab =


"Residue", ylab = "Quality", pch = 16, col = "green")
> lines(lowess(Residue, Quality), col = 2)

> plot(Region, Quality, main = "Scatterplot", xlab = "Region", ylab


= "Quality", pch = 16, col = "green")
> points(1, mean(Quality[1:12]), pch = 17)
> points(2, mean(Quality[13:24]), pch = 17)
> plot(Foam, Quality, main = "lowess", xlab = "Foam", ylab =
"Quality", type = "n")
> points(Foam[1:12], Quality[1:12], pch = 16, col = "green")
> lines(lowess(Foam[1:12], Quality[1:12]), col = "green")
> points(Foam[13:24], Quality[13:24], pch = 3)
> lines(lowess(Foam[13:24], Quality[13:24]))
> legend(3.3, 97, c("Eastern", "Western"), pch = c(16, 3), col =
c("green", "black"))

You might also like