require(MASS) # Do every time you restart R require(car) require(dplyr) setlib('C:/Data/Seasonal Stats') getlib() getwd() setwd('C:/Data/Seasonal Stats') Seasonal = read.table( file = "Seasonal.txt", header = TRUE) June16 = read.table( file = "June 2016.txt", header = TRUE) str(Seasonal) str(June16) ####################################### #Seasonal ####################################### unique(Seasonal$Location) IntakeSeasonal = Seasonal$Location == 'Intake' SurfaceSeasonal = Seasonal$Location == 'Surface' InflowSeasonal = Seasonal$Location == 'Inflow' CreekSeasonal = Seasonal$Location == 'Creek' IntakeSeasonal SurfaceSeasonal InflowSeasonal CreekSeasonal SeasonalIntake = Seasonal[IntakeSeasonal,] SeasonalSurface = Seasonal[SurfaceSeasonal,] SeasonalInflow = Seasonal[InflowSeasonal,] SeasonalCreek = Seasonal[CreekSeasonal,] SeasonalIntake SeasonalSurface SeasonalInflow SeasonalCreek plot(x = Seasonal$DOC, y = Seasonal$VHA) points(x = SeasonalIntake$DOC, y = SeasonalIntake$VHA, col = 'ReD', pch = 16) points(x = SeasonalSurface$DOC, y = SeasonalSurface$VHA, col = 'blue', pch = 16) points(x = SeasonalInflow$DOC, y = SeasonalInflow$VHA, col = 'Green', pch = 16) points(x = SeasonalCreek$DOC, y = SeasonalCreek$VHA, col = 'Orange', pch = 16) #Alternative method plot(x = Seasonal$DOC, y = Seasonal$VHA) points(x = Seasonal$DOC[Seasonal$Location=="Intake"], y = Seasonal$VHA[Seasonal$Location=="Intake"], col = 'ReD', pch = 16) points(x = Seasonal$DOC[Seasonal$Location=="Surface"], y = Seasonal$VHA[Seasonal$Location=="Surface"], col = 'blue', pch = 16) points(x = Seasonal$DOC[Seasonal$Location=="Inflow"], y = Seasonal$VHA[Seasonal$Location=="Inflow"], col = 'Green', pch = 16) points(x = Seasonal$DOC[Seasonal$Location=="Creek"], y = Seasonal$VHA[Seasonal$Location=="Creek"], col = 'Orange', pch = 16) #Date plot(x = Seasonal$DOC, y = Seasonal$VHA) points(x = Seasonal$DOC[Seasonal$Time=="3/03/2016"], y = Seasonal$VHA[Seasonal$Time=="3/03/2016"], col = 'ReD', pch = 16) points(x = Seasonal$DOC[Seasonal$Time=="10/06/2016"], y = Seasonal$VHA[Seasonal$Time=="10/06/2016"], col = 'blue', pch = 16) points(x = Seasonal$DOC[Seasonal$Time=="29/08/2016"], y = Seasonal$VHA[Seasonal$Time=="29/08/2016"], col = 'Green', pch = 16) points(x = Seasonal$DOC[Seasonal$Time=="7/12/2016"], y = Seasonal$VHA[Seasonal$Time=="7/12/2016"], col = 'Orange', pch = 16) points(x = Seasonal$DOC[Seasonal$Time=="8/03/2017"], y = Seasonal$VHA[Seasonal$Time=="8/03/2017"], col = 'Purple', pch = 16) #AOX plot(x = Seasonal$DOC, y = Seasonal$AOX) points(x = Seasonal$DOC[Seasonal$Time=="3/03/2016"], y = Seasonal$AOX[Seasonal$Time=="3/03/2016"], col = 'ReD', pch = 16) points(x = Seasonal$DOC[Seasonal$Time=="10/06/2016"], y = Seasonal$AOX[Seasonal$Time=="10/06/2016"], col = 'blue', pch = 16) points(x = Seasonal$DOC[Seasonal$Time=="29/08/2016"], y = Seasonal$AOX[Seasonal$Time=="29/08/2016"], col = 'Green', pch = 16) points(x = Seasonal$DOC[Seasonal$Time=="7/12/2016"], y = Seasonal$AOX[Seasonal$Time=="7/12/2016"], col = 'Orange', pch = 16) points(x = Seasonal$DOC[Seasonal$Time=="8/03/2017"], y = Seasonal$AOX[Seasonal$Time=="8/03/2017"], col = 'Purple', pch = 16) plot(x = Seasonal$DOC, y = Seasonal$AOX) points(x = Seasonal$DOC[Seasonal$Location=="Intake"], y = Seasonal$AOX[Seasonal$Location=="Intake"], col = 'ReD', pch = 16) points(x = Seasonal$DOC[Seasonal$Location=="Surface"], y = Seasonal$AOX[Seasonal$Location=="Surface"], col = 'blue', pch = 16) points(x = Seasonal$DOC[Seasonal$Location=="Inflow"], y = Seasonal$AOX[Seasonal$Location=="Inflow"], col = 'Green', pch = 16) points(x = Seasonal$DOC[Seasonal$Location=="Creek"], y = Seasonal$AOX[Seasonal$Location=="Creek"], col = 'Orange', pch = 16) unique(Seasonal$Time) points(x = SeasonalIntake$DOC, y = SeasonalIntake$VHA, col = 'ReD', pch = 16) points(x = SeasonalSurface$DOC, y = SeasonalSurface$VHA, col = 'blue', pch = 16) points(x = SeasonalInflow$DOC, y = SeasonalInflow$VHA, col = 'Green', pch = 16) points(x = SeasonalCreek$DOC, y = SeasonalCreek$VHA, col = 'Orange', pch = 16) ########## ##JUNE16## ########## #making unique# unique(June16$Location) IntakeJ16 = June16$Location == 'Intake' SurfaceJ16 = June16$Location == 'Surface' InflowJ16 = June16$Location == 'Inflow' CreekJ16 = June16$Location == 'Creek' IntakeJ16 SurfaceJ16 InflowJ16 CreekJ16 #Assigning# June16Intake = June16[IntakeJ16,] June16Surface = June16[SurfaceJ16,] June16Inflow = June16[InflowJ16,] June16Creek = June16[CreekJ16,] June16Intake June16Surface June16Inflow June16Creek ######### ##Plots## ######### plot(x = June16$Location, y = June16$Turbidity) plot(x = June16$Location, y = June16$pH) plot(x = June16$Location, y = June16$Colour) plot(x = June16$Location, y = June16$UV) plot(x = June16$Location, y = June16$Temperature) plot(x = June16$Location, y = June16$DOC) plot(x = June16$Location, y = June16$VHA) plot(x = June16$Location, y = June16$SHA) plot(x = June16$Location, y = June16$CHU) plot(x = June16$Location, y = June16$NEU) plot(x = June16$Location, y = June16$AOX) plot(x = June16$Location, y = June16$tHAA) plot(x = June16$Location, y = June16$tTHM) plot(x = June16$Location, y = June16$DBP551) #AOX# plot(x = June16$DOC, y = June16$AOX) points(x = June16Intake$DOC, y = June16Intake$AOX, col = 'ReD', pch = 16) points(x = June16Surface$DOC, y = June16Surface$AOX, col = 'blue', pch = 16) points(x = June16Inflow$DOC, y = June16Inflow$AOX, col = 'Green', pch = 16) points(x = June16Creek$DOC, y = June16Creek$AOX, col = 'Orange', pch = 16) plot(x = June16$VHA, y = June16$AOX) points(x = June16Intake$VHA, y = June16Intake$AOX, col = 'ReD', pch = 16) points(x = June16Surface$VHA, y = June16Surface$AOX, col = 'blue', pch = 16) points(x = June16Inflow$VHA, y = June16Inflow$AOX, col = 'Green', pch = 16) points(x = June16Creek$VHA, y = June16Creek$AOX, col = 'Orange', pch = 16) plot(x = June16$SHA, y = June16$AOX) points(x = June16Intake$SHA, y = June16Intake$AOX, col = 'ReD', pch = 16) points(x = June16Surface$SHA, y = June16Surface$AOX, col = 'blue', pch = 16) points(x = June16Inflow$SHA, y = June16Inflow$AOX, col = 'Green', pch = 16) points(x = June16Creek$SHA, y = June16Creek$AOX, col = 'Orange', pch = 16) plot(x = June16$CHU, y = June16$AOX) points(x = June16Intake$CHU, y = June16Intake$AOX, col = 'ReD', pch = 16) points(x = June16Surface$CHU, y = June16Surface$AOX, col = 'blue', pch = 16) points(x = June16Inflow$CHU, y = June16Inflow$AOX, col = 'Green', pch = 16) points(x = June16Creek$CHU, y = June16Creek$AOX, col = 'Orange', pch = 16) plot(x = June16$NEU, y = June16$AOX) points(x = June16Intake$NEU, y = June16Intake$AOX, col = 'ReD', pch = 16) points(x = June16Surface$NEU, y = June16Surface$AOX, col = 'blue', pch = 16) points(x = June16Inflow$NEU, y = June16Inflow$AOX, col = 'Green', pch = 16) points(x = June16Creek$NEU, y = June16Creek$AOX, col = 'Orange', pch = 16) #HAA# plot(x = June16$DOC, y = June16$tHAA) points(x = June16Intake$DOC, y = June16Intake$tHAA, col = 'ReD', pch = 16) points(x = June16Surface$DOC, y = June16Surface$tHAA, col = 'blue', pch = 16) points(x = June16Inflow$DOC, y = June16Inflow$tHAA, col = 'Green', pch = 16) plot(x = June16$VHA, y = June16$tHAA) points(x = June16Intake$VHA, y = June16Intake$tHAA, col = 'ReD', pch = 16) points(x = June16Surface$VHA, y = June16Surface$tHAA, col = 'blue', pch = 16) points(x = June16Inflow$VHA, y = June16Inflow$tHAA, col = 'Green', pch = 16) plot(x = June16$SHA, y = June16$tHAA) points(x = June16Intake$SHA, y = June16Intake$tHAA, col = 'ReD', pch = 16) points(x = June16Surface$SHA, y = June16Surface$tHAA, col = 'blue', pch = 16) points(x = June16Inflow$SHA, y = June16Inflow$tHAA, col = 'Green', pch = 16) plot(x = June16$CHU, y = June16$tHAA) points(x = June16Intake$CHU, y = June16Intake$tHAA, col = 'ReD', pch = 16) points(x = June16Surface$CHU, y = June16Surface$tHAA, col = 'blue', pch = 16) points(x = June16Inflow$CHU, y = June16Inflow$tHAA, col = 'Green', pch = 16) plot(x = June16$NEU, y = June16$tHAA) points(x = June16Intake$NEU, y = June16Intake$tHAA, col = 'ReD', pch = 16) points(x = June16Surface$NEU, y = June16Surface$tHAA, col = 'blue', pch = 16) points(x = June16Inflow$NEU, y = June16Inflow$tHAA, col = 'Green', pch = 16) #THM# plot(x = June16$DOC, y = June16$tTHM) points(x = June16Intake$DOC, y = June16Intake$tTHM, col = 'ReD', pch = 16) points(x = June16Surface$DOC, y = June16Surface$tTHM, col = 'blue', pch = 16) points(x = June16Inflow$DOC, y = June16Inflow$tTHM, col = 'Green', pch = 16) plot(x = June16$VHA, y = June16$tTHM) points(x = June16Intake$VHA, y = June16Intake$tTHM, col = 'ReD', pch = 16) points(x = June16Surface$VHA, y = June16Surface$tTHM, col = 'blue', pch = 16) points(x = June16Inflow$VHA, y = June16Inflow$tTHM, col = 'Green', pch = 16) plot(x = June16$SHA, y = June16$tTHM) points(x = June16Intake$SHA, y = June16Intake$tTHM, col = 'ReD', pch = 16) points(x = June16Surface$SHA, y = June16Surface$tTHM, col = 'blue', pch = 16) points(x = June16Inflow$SHA, y = June16Inflow$tTHM, col = 'Green', pch = 16) plot(x = June16$CHU, y = June16$tTHM) points(x = June16Intake$CHU, y = June16Intake$tTHM, col = 'ReD', pch = 16) points(x = June16Surface$CHU, y = June16Surface$tTHM, col = 'blue', pch = 16) points(x = June16Inflow$CHU, y = June16Inflow$tTHM, col = 'Green', pch = 16) plot(x = June16$NEU, y = June16$tTHM) points(x = June16Intake$NEU, y = June16Intake$tTHM, col = 'ReD', pch = 16) points(x = June16Surface$NEU, y = June16Surface$tTHM, col = 'blue', pch = 16) points(x = June16Inflow$NEU, y = June16Inflow$tTHM, col = 'Green', pch = 16) #DBP551# plot(x = June16$DOC, y = June16$DBP551) points(x = June16Intake$DOC, y = June16Intake$DBP551, col = 'ReD', pch = 16) points(x = June16Surface$DOC, y = June16Surface$DBP551, col = 'blue', pch = 16) points(x = June16Inflow$DOC, y = June16Inflow$DBP551, col = 'Green', pch = 16) plot(x = June16$VHA, y = June16$DBP551) points(x = June16Intake$VHA, y = June16Intake$DBP551, col = 'ReD', pch = 16) points(x = June16Surface$VHA, y = June16Surface$DBP551, col = 'blue', pch = 16) points(x = June16Inflow$VHA, y = June16Inflow$DBP551, col = 'Green', pch = 16) plot(x = June16$SHA, y = June16$DBP551) points(x = June16Intake$SHA, y = June16Intake$DBP551, col = 'ReD', pch = 16) points(x = June16Surface$SHA, y = June16Surface$DBP551, col = 'blue', pch = 16) points(x = June16Inflow$SHA, y = June16Inflow$DBP551, col = 'Green', pch = 16) plot(x = June16$CHU, y = June16$DBP551) points(x = June16Intake$CHU, y = June16Intake$DBP551, col = 'ReD', pch = 16) points(x = June16Surface$CHU, y = June16Surface$DBP551, col = 'blue', pch = 16) points(x = June16Inflow$CHU, y = June16Inflow$DBP551, col = 'Green', pch = 16) plot(x = June16$NEU, y = June16$DBP551) points(x = June16Intake$NEU, y = June16Intake$DBP551, col = 'ReD', pch = 16) points(x = June16Surface$NEU, y = June16Surface$DBP551, col = 'blue', pch = 16) points(x = June16Inflow$NEU, y = June16Inflow$DBP551, col = 'Green', pch = 16) ###### plot(June16$AOX) hist(June16$AOX, col="darkgreen", main='AOX', xlab='ug') shapiro.test(June16$AOX) qq = qqnorm(June16$AOX) qqline(June16$AOX) hist(June16Intake$AOX) boxplot() qq = qqnorm (June16Intake$VHA) qqline(June16Intake$VHA) qq = qqnorm (June16$AOX) qqline(June16$AOX) reg = lm (qq$y~qq$x) boxcox(reg,lambda=seq (-3,3,0.5)) boxplot(June16$AOX) June16Intake June16Surface June16Inflow June16Creek ?hist hist(June16Inflow$DOC,freq = F) shapiro.test(June16Inflow$DOC) plot(June16Inflow$DOC) par(mfcol = c(1,4)) hist(June16$AOX[June16$Location=='Creek']) hist(June16$AOX[June16$Location=='Inflow']) hist(June16$AOX[June16$Location=='Intake']) hist(June16$AOX[June16$Location=='Surface']) par(mfcol=c(1,1)) t.test(June16$AOX,conf.level = 0.95) by(June16$AOX, June16$Location, t.test) June16Intake$AOX June16$AOX #ANOVA ANOVA <- aov(AOX ~ Location, data=June16) summary(ANOVA) #LeveneTest# leveneTest(AOX~Location, data = June16) #Pairwise Test# pairwise.t.test(June16$AOX, June16$Location,p.adj= 'bonf') #Mann Whitney U Test# JuneLoc = select order(June16$AOX) June16$rank = NA order.AOX=ordera June16$rank[order.AOX] = 1:nrow(June16) install.packages("dplyr") plot(June16AOX) June16$AOX library("reshape2",lib.loc="/path/2/R-packages/") help(Startup) #UV plot(Seasonal$UV ~ Seasonal$AOX)