{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Rforch18 - R Material for Chapter 18 > data.sales16

This preview shows pages 1–2. Sign up to view the full content.

R Material for Chapter 18 > data.sales16 <- read.table(file=" http://www.stat.ufl.edu/~rrandles/sta4211/Rclassnotes/data/data16- 1.txt ",col.names=c("sales","package","repl")) ## reading in the data > data.sales16 sales package repl 1 11 1 1 2 17 1 2 3 16 1 3 4 14 1 4 5 15 1 5 6 12 2 1 7 10 2 2 8 15 2 3 9 19 2 4 10 11 2 5 11 23 3 1 12 20 3 2 13 18 3 3 14 17 3 4 15 27 4 1 16 33 4 2 17 22 4 3 18 26 4 4 19 28 4 5 > attach(data.sales16) > boxplot(sales~package,data.sales16) ## draw a boxplot of the four data sets > fpack <- factor(package) ## make package a factor > model <- aov(sales~fpack,data=data.sales16) ## run the anova model on this data > summary(model) Df Sum Sq Mean Sq F value Pr(>F) fpack 3 588.22 196.074 18.591 2.585e-05 *** Residuals 15 158.20 10.547 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > res <- residuals(model) > res 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 -3.6 2.4 1.4 -0.6 0.4 -1.4 -3.4 1.6 5.6 -2.4 3.5 0.5 -1.5 -2.5 -0.2 5.8 17 18 19 -5.2 -1.2 0.8 > with(data.sales16, tapply(sales,fpack,mean)) ## sample means for each factor level 1 2 3 4 14.6 13.4 19.5 27.2 > with(data.sales16, tapply(sales,fpack,sd)) ## sample std deviations for each factor level 1 2 3 4 2.302173 3.646917 2.645751 3.962323

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}