C One-Sample T-test code

Vide link: https://youtu.be/eOCl0jUOC1U

################################################################################
#                          One-Sample T-Test
################################################################################
#Load up our data
trees <- trees

#Summary statistics
summary(trees$Height)

#And the standard deviation
sd(trees$Height)

#Call ggplot
library(ggplot2)

#Make the plot
ggplot(data = trees, aes(x = Height)) + 
  geom_histogram()

#Shapiro-Wilk test
shapiro.test(trees$Height)

#Run the one sample t test
t.test(trees$Height, mu = 72)

#One sample t test, greater
t.test(trees$Height, mu = 72, alternative = "greater")

#Calculate cohen's d
d <- (76-72)/(6.3718)

#Print the value
d

library(effectsize)

#Get Cohen's d; comparing to a value of 72
cohens_d(trees$Height, mu = 72)