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

Homework #5

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("HW5.csv")
set.seed(seed + 25)
# assigns a "random" sample of 100 from the population to data
sample<-pop[sample(1:nrow(pop), 100, replace=FALSE),]
# creates data table for homework
crosstab <-table(sample$X,sample$G)
crosstab
##    
##      F  M
##   A 15 16
##   B 16 22
##   C 19 12
# chi-square test
chisq.test(crosstab)
## 
##  Pearson's Chi-squared test
## 
## data:  crosstab
## X-squared = 2.5603, df = 2, p-value = 0.278