library(readxl)
library(rcompanion)
library(ggplot2)
A4Q2 <- read_excel("C:/Users/USER/OneDrive - Saint Louis University/AA 5221/Assignment 4/A4Q2.xlsx")
View(A4Q2)

#Frequency table
table(A4Q2$status, A4Q2$scholarship)
##                
##                   0   1
##   Domestic       39 111
##   International 118  32
univ_table<- table(A4Q2$status, A4Q2$scholarship)
univ_table
##                
##                   0   1
##   Domestic       39 111
##   International 118  32
#plot
barplot(univ_table,
beside = TRUE,
col = rainbow(nrow(univ_table)),
legend = rownames(univ_table))

#Chi-square test
chi_result<-chisq.test(univ_table)
chi_result
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  univ_table
## X-squared = 81.297, df = 1, p-value < 2.2e-16
#since our P-value=2.2e-16 less than .05 so we will calcualte cramer's V
rcompanion::cramerV(univ_table)
## Cramer V 
##   0.5272
#A Chi-Square test of independence was conducted to determine if there was an association between Status and scholarship
#the results showed that there was an association between the two variables, X-squared = 81.30, df = 1, P-value<.001
#The association was large. (Cramer's V = 0.53)