8.1.1 Data summary
data <- read.table("c:\\temp\\classic.txt",header=T)
names(data)
attach(data)
par(mfrow=c(2,2))
plot(y)
boxplot(y)
hist(y,main="")
y2 <- y
y2[52] <- 21.75
plot(y2)
summary(y)
fivenum(y)
x <- sort(y)
n <- length(y)
d <- c(1, 0.5 * floor(0.5 * (n + 3)), 0.5 * (n + 1), n + 1 - 0.5 *
floor(0.5 * (n + 3)), n)
0.5 * (x[floor(d)] + x[ceiling(d)])
8.1.2 Plots for testing normality
par(mfrow=c(1,1))
qqnorm(y)
qqline(y,lty=2)
8.1.3 Testing for normality
x <- exp(rnorm(30))
shapiro.test(x)
8.1.4 An example of single-sample data
light <- read.table("t:\\data\\light.txt",header=T)
attach(light)
hist(speed,main="",col="green")
summary(speed)
We want to test the hypothesis that Michelson’s estimate of the speed of light is significantly different
from the value of 299 990 thought to prevail at the time. Since the data have all had 299 000 subtracted from
them, the test value is 990.
wilcox.test(speed,mu=990)