library(tidyverse)

met <- read_csv("https://denvirlab.marshall.edu/BMR617-2022/data/TH-B6-metabolic.csv") %>%
  separate(MouseID, sep="-", into=c("Strain","Diet","ID"))
met %>% group_by(Strain) %>% summarize(Mean_Chol=mean(Cholesterol), SD_Chol=sd(Cholesterol))
met %>% group_by(Strain) %>% summarize(Mean_Chol=mean(Cholesterol), SD_Chol=sd(Cholesterol)) %>% as.data.frame()

b6_chol <- pull((filter(met, Strain=="B6")), Cholesterol)
mean(b6_chol)
sd(b6_chol)

th_chol <- pull((filter(met, Strain=="TH")), Cholesterol)
mean(th_chol)
sd(th_chol)

install.packages("TeachingDemos")
library(TeachingDemos)

z.test(b6_chol, mu=90, stdev=35, alternative="two.sided")
z.test(th_chol, mu=90, stdev=35, alternative="two.sided")

# Modified dataset
metmod <- read_csv("https://denvirlab.marshall.edu/BMR617-2022/data/TH-B6-metabolic-modified.csv") %>%
  separate(MouseID, sep="-", into=c("Strain","Diet","ID"))

mice_chol <- pull(metmod, Cholesterol)
mean(mice_chol)
sd(mice_chol)

z.test(mice_chol, mu=90, alternative ="two.sided")    # will spit out error
z.test(mice_chol, mu=90, stdev=48.94094, alternative ="two.sided")

# Small sample size, normal distribution, unknown population standard deviation
t.test(th_chol, mu=90, alternative="two.sided")

