library(readxl)
library(rcompanion)
library(ggplot2)

StudentData <- read_excel("C:/Users/tawan/OneDrive - Saint Louis University/AA 5221/Assignment 4/A4Q2.xlsx")
table(StudentData$scholarship, StudentData$status)
##    
##     Domestic International
##   0       39           118
##   1      111            32
DataCollected <- table(StudentData$scholarship, StudentData$status)
DataCollected
##    
##     Domestic International
##   0       39           118
##   1      111            32
barplot(DataCollected,
        main = "Student Nationality Scholarships",
        ylab = "Count",
        xlab = "Nationality",
        beside = TRUE,
        col = rainbow(nrow(DataCollected)),
        legend = rownames(DataCollected))

chi_result <- chisq.test(DataCollected)
chi_result
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  DataCollected
## X-squared = 81.297, df = 1, p-value < 2.2e-16
rcompanion::cramerV(DataCollected)
## Cramer V 
##   0.5272
# A Chi-Square Test of Independence was conducted to determine if there was an association between student nationality and scholarship status.
# The results showed that there was an association between the two variables, χ²(1) = 81.30, p = 2.2e-16.
# The association was large (Cramer's V = .52).