Opening Libraries

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

Imorting Dataset

D2 <- read_excel("A5Q2.xlsx")

Creating data Table and dataframe

T2 <- table(D2$nationality, D2$scholarship_awarded)
T2
##                
##                   0   1
##   Domestic       39 111
##   International 118  32
cat("\n")
df <- as.data.frame(T2)
names(df) <- c("nationality","scholarship","count")
print(df)
##     nationality scholarship count
## 1      Domestic           0    39
## 2 International           0   118
## 3      Domestic           1   111
## 4 International           1    32

Barlots

## Barplot

ggbarplot(df, 
          x = "scholarship", 
          y= "count", 
          fill = "nationality",
          position = position_dodge())

## Creating bar plot with method from notes

barplot(T2, 
        beside = TRUE,
        col = c("pink", "black"),
        legend.text = rownames(T2),
        args.legend = list(x="bottom"),
        main = "Scholarship Awarded by Nationality"
        )

chi squared

chisq.test(T2)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  T2
## X-squared = 81.297, df = 1, p-value < 2.2e-16

cramer effect size

rcompanion::cramerV(T2)
## Cramer V 
##   0.5272

Observation

A Chi-Square Test of Independence test was conducted to determine if there was an association between Student nationality and Awarded scholarship.

The results showed that there [was] an association between the two variabless, x²(1) = 81.297, p < 0.001. The association was [strong], (Cramer’s V = 0.527).