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)
library(readxl)
library(ggpubr)
## Loading required package: ggplot2
A6Q3 <- read_excel("//apporto.com/dfs/SLU/Users/hannahsmith3_slu/Downloads/A6Q3.xlsx")

A6Q3 %>% 
  group_by(Exercise) %>% 
  summarize(
mean(Weight, na.rm = TRUE),
median(Weight, na.rm = TRUE),
sd(Weight, na.rm = TRUE),
N = n()
)
## # A tibble: 2 × 5
##   Exercise mean(Weight, na.rm = …¹ median(Weight, na.rm…² sd(Weight, na.rm = T…³
##   <chr>                      <dbl>                  <dbl>                  <dbl>
## 1 cardio                      74.7                   73.3                   7.57
## 2 nocardio                    70.8                   69.5                   7.35
## # ℹ abbreviated names: ¹​`mean(Weight, na.rm = TRUE)`,
## #   ²​`median(Weight, na.rm = TRUE)`, ³​`sd(Weight, na.rm = TRUE)`
## # ℹ 1 more variable: N <int>
hist(A6Q3$Weight[A6Q3$Exercise == "cardio"], 
     breaks = 15, 
     col = "skyblue", 
     border = "white")

hist(A6Q3$Weight[A6Q3$Exercise == "nocardio"], 
     breaks = 15, 
     col = "firebrick", 
     border = "white")

#Data for the cardio group appears normally distrubuted. 
#Data for the nocardio group appears normally distrubuted.

ggboxplot(A6Q3, x = "Exercise", y = "Weight", 
          color = "Exercise", 
          pallette = "jco", 
          add = "jitter")

#The cardio boxplot does not have outliers. 
#The nocardio boxplot does not have outliers. 

shapiro.test(A6Q3$Weight[A6Q3$Exercise == "cardio"])
## 
##  Shapiro-Wilk normality test
## 
## data:  A6Q3$Weight[A6Q3$Exercise == "cardio"]
## W = 0.96745, p-value = 0.5812
shapiro.test(A6Q3$Weight[A6Q3$Exercise == "nocardio"])
## 
##  Shapiro-Wilk normality test
## 
## data:  A6Q3$Weight[A6Q3$Exercise == "nocardio"]
## W = 0.97686, p-value = 0.8166
#The cardio group is normally distrubuted, (p = >.05). 
#The nocardio group is normally distrubuted, (p = >.05).

t.test(Weight ~ Exercise, data = A6Q3, var.equal= TRUE)
## 
##  Two Sample t-test
## 
## data:  Weight by Exercise
## t = 1.8552, df = 48, p-value = 0.06971
## alternative hypothesis: true difference in means between group cardio and group nocardio is not equal to 0
## 95 percent confidence interval:
##  -0.3280454  8.1605622
## sample estimates:
##   mean in group cardio mean in group nocardio 
##               74.73336               70.81710
cohens_d_result <- cohens_d(Weight ~ Exercise, data = A6Q3, pooled_sd = TRUE)
print(cohens_d_result)
## Cohen's d |        95% CI
## -------------------------
## 0.52      | [-0.04, 1.09]
## 
## - Estimated using pooled SD.
#An independent t-test was conducted to determine if there was a difference in weight between groups who did cardio and did not do cardio exercise.
#Cardio group scores(M = 74.7, SD = 7.57) were significantly different from the no cardio group scores(M = 70.8 , SD = 7.35), t(48) = 1.86, p-value > .05. 
#The effect size was medium, Cohen's d = .52.