require(ggplot2) require(plyr) #Loads required plyr package and a ggplot2 package for plotting reproaov<-aov(repro4$Brooders~repro4$Site+repro4$Pop+repro4$Site:repro4$Pop,repro4) summary(reproaov) SitevPopTukey<-TukeyHSD(reproaov) print(SitevPopTukey) #Standard ANOVA and TukeyHSD on non transformed data. Finds huge difference between pops and sites but heavily skewed and non normaly distributed. repro4$arcsinbrooders<-asin(sign(repro4$Brooders)*sqrt(abs(repro4$Brooders))) repro4$arcsinbrooders<-replace(repro4$arcsinbrooders,is.na(repro4$arcsinbrooders),0) #For fun, arc sine transformed brooder data. This is essentially meaningless in the long run. reproaov2<-aov(repro4$arcsinbrooders~repro4$Site+repro4$Pop+repro4$Site:repro4$Pop,repro4) summary(reproaov2) arcsinbroodertukey<-TukeyHSD(reproaov2) print(arcsinbroodertukey) #Makes ANOVA based on arcsine transform of brooders. Finds no differences which is also skewed. repro4$prop<-repro4$Brooders/repro4$Gaping #creates individual proportion for each sample date repro4$arcsinprop<-asin(sign(repro4$prop)*sqrt(abs(repro4$prop))) repro4$arcsinprop<-replace(repro4$arcsinprop,is.na(repro4$arcsinprop),0) #arcsine transforms individual proportion data to normalize for use in ANOVA and TukeyHSD. reproaov3<-aov(repro4$arcsinprop~repro4$Site+repro4$Pop+repro4$Site:repro4$Pop,repro4) summary(reproaov3) summary.aov(reproaov3) arcsinproptukey<-TukeyHSD(reproaov3) print(arcsinproptukey) #ANOVA and TukeyHSD on Arcsine transformed proportions conservatively finds significant differences between pops and sites. More trust worthy due to normality. Gapingsum<-ddply(repro4,.(Site,Pop),summarise,sum=sum(Gaping,na.rm=T)) #Summarises Gaping data for each pop at each site Broodsum<-ddply(repro4,.(Site,Pop),summarise,sum=sum(Brooders,na.rm=T)) #Summarises Brooder data for each pop at each site BroodGapingSum<-merge(Gapingsum,Broodsum,by=c("Site","Pop")) BroodGapingSum<-rename(BroodGapingSum, c("Site"="Site","Pop"="Pop","sum.x"="Gaping","sum.y"="Brooder")) BroodGapingSum$prop<-BroodGapingSum$Brooder/BroodGapingSum$Gaping print(BroodGapingSum) #Creates clean Data frame for Summarized data as well as creating raw proportion data from summaries BroodGapingSum$ArcSine<-asin(sign(BroodGapingSum$prop)*sqrt(abs(BroodGapingSum$prop))) #Arcsine transforms raw proportions but is not useful. arcaov<-aov(BroodGapingSum$ArcSine~BroodGapingSum$Site+BroodGapingSum$Pop+BroodGapingSum$Site:BroodGapingSum$Pop,BroodGapingSum) summary(arcaov) arcTukey<-TukeyHSD(arcaov) print(arcTukey) #Arcsine transform on raw proportions fails due to lack of replicates Proptest<-prop.test(BroodGapingSum$Brooder,BroodGapingSum$Gaping, conf.level=0.95) print(Proptest) #Proportion test with confidence levels. Doesn't have meaning. ggplot(data=BroodGapingSum,aes(x=Site, y=prop, group=Pop, col=Pop))+ geom_line(size=2)+geom_point(size=6)+ scale_color_manual(name="Population", labels=c("Dabob","Fidalgo","Oyster Bay"), values=c("blue","purple","orange"))+ labs(title="Raw Proportion of Brooders\nSite by Population", x="Site",y="Raw Proportion of Brooders")+ theme_bw()+ theme(axis.text.x=element_text(color=c("purple","red","orange"), size=20), axis.text.y=element_text(color="black",size=15), axis.title.x=element_text(color="black",size=25), axis.title.y=element_text(color="black",size=25), plot.title=element_text(color="forestgreen",size=35), legend.justification=c(0,1), legend.position=c(0,1)) #Graph uses raw proportions of brooders to gaping animals produced at each site. #ANOVA and Tukey test on proportions uses arcsin transformed data for normality #ANOVA/Tukey Find that the Oyster Bay site is significantly Different from the other two sites #ANOVA/Tukey Find that the Oyster Bay Pop is significantly Different from the other two pops. #Individual interactions find that the Oyster Bay pop at Oyster Bay site is significantly #different than all almost all other populations at all other sites including itself at Manchester #but not significantly different than the other two populations at Oyster Bay site