library(readxl)
library(rcompanion)
library(ggplot2)
#Load Data
data2026 <- read_excel("A4Q2.xlsx")
data2026
## # A tibble: 300 × 3
## ID status scholarship
## <dbl> <chr> <dbl>
## 1 1 Domestic 1
## 2 2 Domestic 0
## 3 3 Domestic 1
## 4 4 Domestic 0
## 5 5 Domestic 0
## 6 6 Domestic 1
## 7 7 Domestic 1
## 8 8 Domestic 0
## 9 9 Domestic 1
## 10 10 Domestic 1
## # ℹ 290 more rows
#Create the Frequency Table
scolar_table <- table(data2026$status, data2026$scholarship)
scolar_table
##
## 0 1
## Domestic 39 111
## International 118 32
#Create a Bar Graph
barplot(scolar_table,
xlab = data2026$status,
ylab = data2026$scholarship,
beside = TRUE,
col = rainbow(nrow(scolar_table)),
legend = rownames(scolar_table),
main = "Bar Chart")

# A Chi-Square Test of Independence was conducted to determine if there was an association between gender (male or female) and voting behavior (yes or no).
# Conduct the Chi-Square Test of Independence
chi_result <- chisq.test(scolar_table)
chi_result
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: scolar_table
## X-squared = 81.297, df = 1, p-value < 2.2e-16
# The results showed that there was an association between the two variables, data: scolar_table X-squared = 81.297, df = 1, p-value < 2.2e-16
# Calculate the Cohen's W (Effect Size)
cramer_v <- rcompanion::cramerV(scolar_table)
cramer_v
## Cramer V
## 0.5272
# The association was moderate (Cramer's V = 0.5272 ).