library(readxl)
library(ggpubr)
## Loading required package: ggplot2
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(effectsize)
library(effsize)


Dataset6.1 <- read_excel("C:/Users/Admin/Downloads/Dataset6.1.xlsx")

Dataset6.1 %>%
  group_by(Group) %>%
  summarise(
    Mean = mean(Exam_Score, na.rm = TRUE),
    Median = median(Exam_Score, na.rm = TRUE),
    SD = sd(Exam_Score, na.rm = TRUE),
    N = n()
  )
## # A tibble: 2 × 5
##   Group        Mean Median    SD     N
##   <chr>       <dbl>  <dbl> <dbl> <int>
## 1 No Tutoring  71.9   71.5  7.68    40
## 2 Tutoring     78.4   78.7  7.18    40
hist(Dataset6.1$Exam_Score[Dataset6.1$Group == "Tutoring"],
     main = "Histogram of Tutoring Scores",
     xlab = "Value",
     ylab = "Frequency",
     col = "lightblue",
     border = "black",
     breaks = 10)

hist(Dataset6.1$Exam_Score[Dataset6.1$Group == "No Tutoring"],
     main = "Histogram of No Tutoring Scores",
     xlab = "Value",
     ylab = "Frequency",
     col = "lightgreen",
     border = "black",
     breaks = 10)

#For the Tutoring histogram, the data appears slightly negatively skewed. The kurtosis looks roughly bell-shaped, but it may be a bit flatter than a perfect normal curve.
#For the No Tutoring histogram, the data appears roughly symmetrical (close to normal), though there may be a slight negative skew due to a small left tail. The kurtosis looks like a normal bell-shape overall.
#Since the Tutoring group looked a bit skewed, we may need to use a Mann–Whitney U test.

ggboxplot(Dataset6.1, x = "Group", y = "Exam_Score",
          color = "Group",
          palette = "jco",
          add = "jitter")

#The Tutoring boxplot appears normal. There are no dots past the whiskers.
#The No Tutoring boxplot appears abnormal. There are several dots past the whiskers. Although some are very close to the whiskers, some are arguably far away.
#We may need to use a Mann-Whitney U test.

shapiro.test(Dataset6.1$Exam_Score[Dataset6.1$Group == "Tutoring"])
## 
##  Shapiro-Wilk normality test
## 
## data:  Dataset6.1$Exam_Score[Dataset6.1$Group == "Tutoring"]
## W = 0.98859, p-value = 0.953
shapiro.test(Dataset6.1$Exam_Score[Dataset6.1$Group == "No Tutoring"])
## 
##  Shapiro-Wilk normality test
## 
## data:  Dataset6.1$Exam_Score[Dataset6.1$Group == "No Tutoring"]
## W = 0.98791, p-value = 0.9398
#The data for Tutoring was normal (p > .05).
#The data for No Tutoring was normal (p > .05).
#After conducting all three normality tests, it is suggested that we should use a Mann-Whitney U test.

wilcox.test(Exam_Score ~ Group, data = Dataset6.1)
## 
##  Wilcoxon rank sum exact test
## 
## data:  Exam_Score by Group
## W = 419, p-value = 0.0001833
## alternative hypothesis: true location shift is not equal to 0
cliff.delta(Exam_Score ~ Group, data = Dataset6.1)
## 
## Cliff's Delta
## 
## delta estimate: -0.47625 (large)
## 95 percent confidence interval:
##      lower      upper 
## -0.6640312 -0.2319561
# The Tutoring Group ((Mdn = 78.70) was significantly different from The No Tutoring Group  (Mdn = 71.50), U = 419, p < .001.The effect size was large (r₍rb₎ = -0.47625).