problem-11.12

problem-11.12  The data can be entered as follows:
> type1 = c(303, 293, 296, 299, 298)
> type2 = c(322, 326, 315, 318, 320, 320)
> type3 = c(309, 327, 317, 315)
> wear = list(type1=type1,type2=type2,type3=type3)
> wear.st = stack(wear)
    
The use of stack() stores the data in two variables: the numeric information in values and a factor indicating the type in ind. The p-value from oneway.test() can be returned succinctly with
> oneway.test(values ~ ind, data = wear.st)$p.value
[1] 0.0001522

Using lm(), this p-value is returned by the extractor function summary() in the section labeled F-statistic.
> summary(lm(values ~ ind, data = wear.st))
...
F-statistic:   31 on 2 and 12 DF,  p-value: 1.81e-05

Why the difference? The F-test assumes equal variances, whereas the default for oneway.test() assumes unequal variances. Changing the default produces equivalent answers.
> oneway.test(values ~ ind, data = wear.st, var.equal=TRUE)$p.value
[1] 1.810e-05