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)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ lubridate 1.9.5     ✔ tibble    3.3.1
## ✔ purrr     1.2.1     ✔ tidyr     1.3.2
## ✔ readr     2.2.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
A6Q3<- read_excel("C:/Users/raadrish/Downloads/A6Q3.xlsx")
A6Q3_long <- A6Q3 %>%
  pivot_longer(cols = c(nocardio, cardio),
               names_to = "Cardio",
               values_to = "BodyWeight_kg")

A6Q3_long %>%
  group_by(Cardio) %>%
  summarise(
    Mean = mean(BodyWeight_kg, na.rm = TRUE),
    Median = median(BodyWeight_kg, na.rm = TRUE),
    SD = sd(BodyWeight_kg, na.rm = TRUE),
    N = n()
  )
## # A tibble: 2 × 5
##   Cardio    Mean Median    SD     N
##   <chr>    <dbl>  <dbl> <dbl> <int>
## 1 cardio    70.8   69.5  7.35    25
## 2 nocardio  74.7   73.3  7.57    25
hist(A6Q3_long$BodyWeight_kg[A6Q3_long$Cardio == "nocardio"],
     main = "Histogram of noCardio Body Weight kg",
     xlab = "Value",
     ylab = "Frequency",
     col = "lightblue",
     border = "black",
     breaks = 10)

hist(A6Q3_long$BodyWeight_kg[A6Q3_long$Cardio == "cardio"],
     main = "Histogram of Cardio of Body Weight kg",
     xlab = "Value",
     ylab = "Frequency",
     col = "lightgreen",
     border = "black",
     breaks = 10)

Group 1: noCardio

The first variable looks normally distributed.

The data is negatively skewed.

The data does not have a proper bell curve.

Group 2: Cardio

The second variable looks normally distributed.

The data is positively skewed.

The data does not have a proper bell curve.

ggboxplot(A6Q3_long, x = "Cardio", y = "BodyWeight_kg",
          color = "Cardio",
          palette = "jco",
          add = "jitter")

Boxplot 1: nocardio

There are dots outside the boxplot.

The dots are close to the whiskers.

The dots are not very far away from the whiskers.

Based on these findings, the boxplot is normal.

Boxplot 2: cardio

There are dots outside the boxplot.

The dots are close to the whiskers.

The dots are not very far away from the whiskers.

Based on these findings, the boxplot is normal.

shapiro.test(A6Q3_long$BodyWeight_kg[A6Q3_long$Cardio == "nocardio"])
## 
##  Shapiro-Wilk normality test
## 
## data:  A6Q3_long$BodyWeight_kg[A6Q3_long$Cardio == "nocardio"]
## W = 0.96745, p-value = 0.5812
shapiro.test(A6Q3_long$BodyWeight_kg[A6Q3_long$Cardio == "cardio"])
## 
##  Shapiro-Wilk normality test
## 
## data:  A6Q3_long$BodyWeight_kg[A6Q3_long$Cardio == "cardio"]
## W = 0.97686, p-value = 0.8166

Group 1: No Cardio

The first group is normally distributed, (p = 0.5812).

Group 2: Cardio

The second group is normally distributed, (p = 0.8166).

t.test(BodyWeight_kg ~ Cardio, data = A6Q3_long, var.equal = TRUE)
## 
##  Two Sample t-test
## 
## data:  BodyWeight_kg by Cardio
## 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:
##  -8.1605622  0.3280454
## sample estimates:
##   mean in group cardio mean in group nocardio 
##               70.81710               74.73336
cohens_d_result <- cohens_d(BodyWeight_kg ~ Cardio, data = A6Q3_long, pooled_sd = TRUE)
print(cohens_d_result)
## Cohen's d |        95% CI
## -------------------------
## -0.52     | [-1.09, 0.04]
## 
## - Estimated using pooled SD.

An Independent T-Test was conducted to determine if there was a difference in body weight (kg) between cardio and nocardio participants.

The nocardio group scores (M = 74.73, SD = 7.57) were not significantly different from the cardio group scores (M = 70.82, SD = 7.35), t(48) = -1.86, p > .05.

The effect size is not reported because the results were not statistically significant (p > .05).