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

Homework #2

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
# loads in data for the full population
pop<-read.csv("HW2.csv")
set.seed(seed + 25)
# assigns a random sample of 20 from the population to data
sample<-pop[sample(1:nrow(pop), 20, replace=FALSE),]
data <- data.frame(table(sample$G, sample$X))
colnames(data) <- c("G", "X", "f")
table <- subset(data, f != 0)
# creates data table for homework
table <- data[order(data$G),]
table <- subset(table, f != 0)
table
##    G  X f
## 1  A 10 3
## 3  A 11 1
## 5  A 13 3
## 7  A 14 1
## 9  A 15 1
## 8  B 14 1
## 12 B 16 2
## 14 B 17 1
## 16 B 18 3
## 18 B 19 2
## 20 B 20 2
# two sample t-test
t.test(sample$X~sample$G,var.equal=TRUE )
## 
##  Two Sample t-test
## 
## data:  sample$X by sample$G
## t = -6.6752, df = 18, p-value = 2.914e-06
## alternative hypothesis: true difference in means between group A and group B is not equal to 0
## 95 percent confidence interval:
##  -7.383765 -3.848558
## sample estimates:
## mean in group A mean in group B 
##        12.11111        17.72727