#Load table into a new object "Awake" and attach it to the workspace Death<- read.table("C:/Users/Challenger/Documents/Stats/TEA_flies_deaths1.txt", header = TRUE, stringsAsFactors = TRUE) attach(Death) #Define variables dead<- Deaths anesthesia<-Treatment sex <- Sex #Checking the variables summary(dead) summary(sex) summary(anesthesia) #Test of normality, significant result = non-normal shapiro.test(dead) #plotting the residuals qqnorm(dead) #general linear model with poisson regression for count data dead.glm <- glm(dead ~anesthesia+sex, family = poisson) summary(dead.glm) dead.glm2 <- glm(dead~anesthesia, family = poisson) summary(dead.glm2) dead.glm3 <- glm(dead ~anesthesia*sex, family = poisson) summary(dead.glm) dead.glm4 <- glm(dead~anesthesia, family = quasipoisson) summary(dead.glm4) anova(dead.glm, dead.glm3, test="Chi") anova(dead.glm, dead.glm2, test="Chi") #creates table with response variable and significant variable tapply(dead,list(anesthesia),mean) #package for multiple comparisons install.packages("multcomp") library("multcomp") #run multiple comparisons summary(glht(dead.glm2, mcp(anesthesia="Tukey"))) #creates bargraph of response variable (deaths) barplot(tapply(dead,list(anesthesia),mean))