#load required packages
library(readxl)
library(ggpubr)
## Loading required package: ggplot2
library(rcompanion)
library(rmarkdown)
#Correction: I removed the package installation line and duplicate package commands, and added required packages from answer key.
#Import dataset
A5Q2 <- read_excel("~/Downloads/A5Q2.xlsx")
#create table of data
MyTable <- table(A5Q2$nationality, A5Q2$scholarship_awarded)
MyTable
##
## 0 1
## Domestic 39 111
## International 118 32
#create barchart
barplot(MyTable, beside = TRUE,
col = rainbow(nrow(MyTable)),
legend = rownames(MyTable),
main = "Nationality and Scholarship Awarded",
xlab = "No or Yes",
ylab = "Count")

#Correction: I added the bar chart title and axis labels.
#Conduct chi-square test
chisq.test(MyTable)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: MyTable
## X-squared = 81.297, df = 1, p-value < 2.2e-16
#Calculate effect size
rcompanion::cramerV(MyTable)
## Cramer V
## 0.5272
#Interpretation
#A Chi-Square Test of Independence was conducted to determine if there was an association between student nationality (domestic versus international) and whether or not the student got a scholarship.
#The results showed that there was an association between the two variables, χ²(1) = 81.30, p < .001.
#The association was strong, (Cramer's V = .53).
#Correction: I added section comments, corrected the interpretation wording, and changed the Cramer's V symbol from a plus sign to an equals sign.