Winter 2025 ……………………………….. Score ____ / 20

Homework #6

Heidi Van Ness

___________________________________________

highlight and click “Run” the line below before knitting

install.packages(“rmarkdown”)

# set seed replace 12345678 with your student ID
seed = 78944924
set.seed(seed + 25)
# creates data table for homework
i<-c("A","A","A","A","A","B","B","B","B","B","C","C","C","C","C")
table<-as.data.frame(i)

table$X <-as.numeric(ifelse(table$i=="A",round(rnorm(5,mean=5,sd=2),0),
             ifelse(table$i=="B",round(rnorm(5,mean=15,sd=2),0),
              ifelse(table$i=="C",round(rnorm(5,mean=10,sd=2),0),""))))
table
##    i  X
## 1  A  3
## 2  A  5
## 3  A  2
## 4  A  3
## 5  A  5
## 6  B 16
## 7  B 15
## 8  B 15
## 9  B 18
## 10 B 15
## 11 C  5
## 12 C 10
## 13 C 11
## 14 C  4
## 15 C 12
# results for ANOVA test
results<-aov(X~i,data=table)  
summary(results)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## i            2  377.7   188.9   33.73 1.19e-05 ***
## Residuals   12   67.2     5.6                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# boxplot
boxplot(table$X ~ table$i, main = "Boxplot", xlab = "Group", ylab = "X")