这是我生成的代码,但是,我似乎无法弄清楚如何通过对照和药物实验在我的QQ图上放置x或y轴标签或主要标题。
#Sherri Tabinski
rm(list=ls(all=T))
#detach the data
detach(sleep)
#import the data and read the data frame
sleep <- read.delim("C:/Users/sherb/OneDrive/Desktop/Biol 315/sleep.txt",
header=T)
attach(sleep)
qqnormandline<-function(x){
qqnorm(x)
qqline(x)
}
tapply(sleep.diff,group,qqnormandline)
boxplot(sleep.diff~group,boxwex=0.25)
res.ftest<-var.test(sleep.diff~group,data=sleep)
res.ftest
bartlett.test(sleep.diff~group)
facvec<-factor(group)
t.test(sleep.diff~facvec,alternative="two.sided",var.equal=TRUE)
tapply(sleep.diff,group,mean)
tapply(sleep.diff,group,sd)
# Shapiro-Wilk normality test for drug sleep difference
with(sleep, shapiro.test(sleep.diff[group == "drug"]))
# Shapiro-Wilk normality test for control sleep difference
with(sleep, shapiro.test(sleep.diff[group == "control"]))