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
A6Q4 <- read_excel("//apporto.com/dfs/SLU/Users/hannahsmith3_slu/Downloads/A6Q4.xlsx")

A6Q4 %>% 
  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 lift                       120.                   116.                    53.3
## 2 nolift                      33.0                   40.8                   56.7
## # ℹ abbreviated names: ¹​`mean(Weight, na.rm = TRUE)`,
## #   ²​`median(Weight, na.rm = TRUE)`, ³​`sd(Weight, na.rm = TRUE)`
## # ℹ 1 more variable: N <int>
hist(A6Q4$Weight[A6Q4$Exercise == "lift"], 
     breaks = 15, 
     col = "skyblue", 
     border = "white")

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

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

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

#The nolift boxplot does have one outlier. 
#The lift boxplot does have outliers. 

shapiro.test(A6Q4$Weight[A6Q4$Exercise == "lift"])
## 
##  Shapiro-Wilk normality test
## 
## data:  A6Q4$Weight[A6Q4$Exercise == "lift"]
## W = 0.78786, p-value = 0.0001436
shapiro.test(A6Q4$Weight[A6Q4$Exercise == "nolift"])
## 
##  Shapiro-Wilk normality test
## 
## data:  A6Q4$Weight[A6Q4$Exercise == "nolift"]
## W = 0.70002, p-value = 7.294e-06
#The lift group is abnormally distrubuted, (p = <.05). 
#The nolift group is abnormally distrubuted, (p = <.05).

wilcox.test(Weight ~ Exercise, 
            data = A6Q4)
## 
##  Wilcoxon rank sum exact test
## 
## data:  Weight by Exercise
## W = 603, p-value = 7.132e-11
## alternative hypothesis: true location shift is not equal to 0
mw_effect <- cliff.delta(Weight ~ Exercise, data = A6Q4)
print(mw_effect)
## 
## Cliff's Delta
## 
## delta estimate: 0.9296 (large)
## 95 percent confidence interval:
##     lower     upper 
## 0.7993841 0.9764036
#A Mann-Whitney U test was conducted to determine if there was a difference in weight between groups who lifted and did not lift.
#Lift group scores(Mdn = 116) were significantly different from the no lift group scores (Mdn = 40.8), W = .79, p-value < .001. 
#The effect size was large, Cliff's Delta = .92.