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

RQ2 <- read_excel("A4Q2.xlsx")

table(RQ2$status, RQ2$scholarship)
##                
##                   0   1
##   Domestic       39 111
##   International 118  32
stud_table <- table(RQ2$status, RQ2$scholarship)

stud_table
##                
##                   0   1
##   Domestic       39 111
##   International 118  32
barplot(stud_table, 
        beside = TRUE,
        col = rainbow(nrow(stud_table)),
        legend = rownames(stud_table))

chi_result <- chisq.test(stud_table) 
chi_result
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  stud_table
## X-squared = 81.297, df = 1, p-value < 2.2e-16
rcompanion::cramerV(stud_table)
## Cramer V 
##   0.5272
# A Chi-Square Test of Independence was conducted to determine if there was an association between
# the status of a student (domestic or international) and whether they have a scholarship or not.
# The results showed that there was an association between the two variables, χ²(1) = 81.3, p < 2.2e-16.
# The association was strong, (Cramer's V = .53).