R Markdown

library(readxl)
library(ggpubr)
## Loading required package: ggplot2
#library(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)
A6Q1<-read_excel("A6Q1.xlsx")
A6Q1
## # A tibble: 20 × 3
##       ID Before After
##    <dbl>  <dbl> <dbl>
##  1     1   70.5  63.5
##  2     2   73.2  70.3
##  3     3   87.5  63.8
##  4     4   75.6  66.2
##  5     5   76.0  67.0
##  6     6   88.7  58.5
##  7     7   78.7  78.7
##  8     8   64.9  73.2
##  9     9   69.5  62.9
## 10    10   71.4  82.0
## 11    11   84.8  75.4
## 12    12   77.9  69.6
## 13    13   78.2  79.2
## 14    14   75.9  79.0
## 15    15   70.6  78.6
## 16    16   89.3  77.5
## 17    17   79.0  76.4
## 18    18   59.3  71.5
## 19    19   80.6  69.6
## 20    20   71.2  69.0
Before <- A6Q1$Before
After <- A6Q1$After

Differences <- After - Before
Differences
##  [1]  -7.05878448  -2.90237940 -23.67770210  -9.39519697  -9.03461602
##  [6] -30.21406638   0.01496671   8.34747482  -6.61027268  10.59581513
## [11]  -9.38094061  -8.23908248   0.95483368   3.13960617   8.01937773
## [16] -11.78618306  -2.55146260  12.23764357 -11.05854852  -2.26143675
mean(Before, na.rm = TRUE)
## [1] 76.13299
median(Before, na.rm = TRUE)
## [1] 75.95988
sd(Before, na.rm = TRUE)
## [1] 7.781323
mean(After, na.rm = TRUE)
## [1] 71.58994
median(After, na.rm = TRUE)
## [1] 70.88045
sd(After, na.rm = TRUE)
## [1] 6.639509
hist(Differences,
     main = "Histogram of Difference Scores",
     xlab = "Value",
     ylab = "Frequency",
     col = "blue",
     border = "black",
     breaks = 20)

The difference scores look normally distributed. The data is positively skewed. The data does not have a proper bell curve.

boxplot(Differences,
        main = "Distribution of Score Differences (After - Before)",
        ylab = "Difference in Scores",
        col = "blue",
        border = "darkblue")

#There is one dot 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.test(Differences)
## 
##  Shapiro-Wilk normality test
## 
## data:  Differences
## W = 0.94757, p-value = 0.3318

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

t.test(Before, After, paired = TRUE, na.action = na.omit)
## 
##  Paired t-test
## 
## data:  Before and After
## t = 1.902, df = 19, p-value = 0.07245
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
##  -0.4563808  9.5424763
## sample estimates:
## mean difference 
##        4.543048

A Dependent T-Test was conducted to determine if there was a difference in weight before the diet versus after the diet. Before scores (M = 76.13, SD = 7.78) were significantly different from after scores (M = 71.58, SD = 6.64), t(19) = 1.9, p = .07.

#https://rpubs.com/jishimwe1/1426229