1.绘制茎叶图
attach(faithful)
summary(eruptions) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.600 2.163 4.000 3.488 4.454 5.100
fivenum(eruptions) [1] 1.6000 2.1585 4.0000 4.4585 5.1000
stem(eruptions) 16 | 070355555588 18 | 000022233333335577777777888822335777888 20 | 00002223378800035778 22 | 0002335578023578 24 | 00228 26 | 23 28 | 080 30 | 7 32 | 2337 34 | 250077 36 | 0000823577 38 | 2333335582225577 40 | 0000003357788888002233555577778 42 | 03335555778800233333555577778 44 | 02222335557780000000023333357778888 46 | 0000233357700000023578 48 | 00000022335800333 50 | 0370
hist(eruptions, seq(1.6, 5.2, 0.2), prob=TRUE)
lines(density(eruptions, bw=0.1))
rug(eruptions)
plot(ecdf(eruptions), do.points=FALSE, verticals=TRUE)
long <- eruptions[eruptions > 3] plot(ecdf(long), do.points=FALSE, verticals=TRUE)
x <- seq(3, 5.4, 0.01) lines(long, pnorm(long, mean=mean(long), sd=sqrt(var(long))), lty=3)
par(pty="s") qqnorm(long); qqline(long)
shapiro.test(x) ks.test(long, "pnorm", mean = mean(long), sd = sqrt(var(long)))