如何添加主标题,x和y轴标签

时间:2018-11-09 05:24:17

标签: r plot visualization

这是我生成的代码,但是,我似乎无法弄清楚如何通过对照和药物实验在我的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"]))

1 个答案:

答案 0 :(得分:0)

执行以下操作:

df<- data.frame(x=1:10, g=c("a","b"))

qqnormX<- function(x,tt) {
  qqnorm(x, main = tt)
  qqline(x)
}

s <- tapply(df$x,df$g, list)   

purrr::map2(s,names(s),qqnormX)

enter image description here enter image description here