install.packages(“rmarkdown”)

# sets wd to the path on my computer; 
setwd("C:\\Users\\hmon1\\Desktop\\10B+Homework\\") #this is where you downloaded the HW1.csv file
# loads in data for the full population
pop<-read.csv("HW11.csv")
# sets the seed for the random number generator
set.seed(48183130)  #use your student ID instead of 12345678
# assigns a "random" sample of 100 from the population to 'data'
data<-data.frame(X=as.character(pop[sample(1:nrow(pop), 100, replace=FALSE),]))
# creates a frequency table
tmpX = c(); tmpf = c() # initialize vectors to save values
for (xi in unique(sort(data$X))){ # for each unique value of X
  tmpX = c(tmpX,xi) # save that value to the vector tmpX
  tmpf = c(tmpf,sum(data$X == xi)) # save the number of times that value appears in data
  # in the vectof tmpf
}
# fill in the table on your homework
table = data.frame(X=tmpX, f = tmpf)
table
##   X  f
## 1 A 46
## 2 B 30
## 3 C 18
## 4 D  6
chisq.test(table$f, p = c(1/4,1/4,1/4,1/4))
## 
##  Chi-squared test for given probabilities
## 
## data:  table$f
## X-squared = 35.04, df = 3, p-value = 1.195e-07