install.packages("rstatix")
library(readxl)
library(ggpubr)
library(effsize)
  library(rstatix)
library(effectsize)
install.packages("effectsize")
library(effectsize)

library(readxl)
> A6Q1 <- read_excel("Documents/a6/A6Q1/A6Q1.xlsx")
> View(A6Q1) 

BEFORE <-
  A6Q1$Before
AFTER <-
  A6Q1$After

DIFFERENCES <- AFTER - BEFORE

mean(BEFORE, na.rm = TRUE)
#[1] 76.13299
sd(BEFORE, na.rm = TRUE)
#[1] 7.781323
median(BEFORE, na.rm = TRUE)
#[1] 75.95988

mean(AFTER, na.rm = TRUE)
#[1] 57.17874
sd(AFTER, na.rm = TRUE)
#[1] 14.39364
median(AFTER, na.rm = TRUE)
#[1] 58.36459

hist(DIFFERENCES, main = "Histogram of Different Scores", xlab = "Value", ylab = "Frequency", col = "light green", border = "dark green", breaks = 20)

#Histogram of Different Scores
#The scores look normally distributed.
#The data is symmetrical.
# The data does have proper bell curve.

boxplot(DIFFERENCES, main = "Distribution of Score Differences (after - before)", ylab = "Difference in Scores", col = "light green", border = "dark green"
boxplot(DIFFERENCES, main = "Distribution of Score Differences (after - before)", ylab = "Difference in Scores", col = "light green", border = "dark green") 

#Boxplot
# There are dots outside the boxplot.
#The dot is close to the whiskers.
#The dot is not very far away from the whiskers.
#Based on these findings, the boxplot is normal.

#Shapiro-Wilk normality test

shapiro.test(DIFFERENCES)

#data:  DIFFERENCES
#W = 0.94757, p-value = 0.3318

#Shapiro-Wilk
#Difference Scores
#The data is normally distributed, (p= .332).

#A dependent T test was conducted to determine if there was a difference in body weight before a low calorie diet versus after the low calorie diet.
#Before scores ( M=76.13 , SD =7.78 ,) were not significantly different from after scores (m= 71.58 , SD = 6.63), p = 0.33

# A Wilcox Signed Rank Test was conducted to determine if there was a difference in Weight before a low calorie diet versus after a low calorie diet
# Before scores (Mdn = 75.95988) were different from after scores ( Mdn = 70.88) , V= 148, p = [< .001 / = .114 / > .05] = .175