######################################################################################################## "Conventional surrogates of natural organic matter and their relationship with disinfection by-products" ######################################################################################################## #Packages# require(MASS) require(ggplot2) require(stats) require(reshape2) require(car) require(caret) #Set Work Directory# setwd('C:/Data/Seasonal Stats') getwd() #colour for graphs my.colour = c("#0571b0","#92c5de","#f4a582", "#ca0020") #4 colours my.colour1 = c("#0571b0","#92c5de","#f7f7f7", "#f4a582", "#ca0020") #5 colours my.colour2 = c("#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00")#5 colours diverging my.colour.div = c("#252525", "#525252", "#737373", "#969696", "#bdbdbd") #5 shades my.colour.div1 = c("#252525", "#525252", "#737373", "#969696", "#bdbdbd", "#d9d9d9") #6 shades #Obtaining Data Set# Seasonal = read.table( file = "Seasonal.txt", header = TRUE) March16 = read.table( file = "March 2016.txt", header = TRUE) June16 = read.table( file = "June 2016.txt", header = TRUE) August16 = read.table( file = "August 2016.txt", header = TRUE) December16 = read.table( file = "December 2016.txt", header = TRUE) March17 = read.table( file = "March 2017.txt", header = TRUE) #Editing Data Set Seasonal$Time = factor(Seasonal$Time, levels = c("3/03/2016","10/06/2016","29/08/2016","7/12/2016","8/03/2017"), ordered = TRUE) Seasonal$Location = factor(Seasonal$Location, levels = c("Intake","Surface","Inflow","Creek"), ordered = TRUE) March16$Location = factor(March16$Location, levels = c("Intake","Surface","Inflow","Creek"), ordered = TRUE) June16$Location = factor(June16$Location, levels = c("Intake","Surface","Inflow","Creek"), ordered = TRUE) August16$Location = factor(August16$Location, levels = c("Intake","Surface","Inflow","Creek"), ordered = TRUE) December16$Location = factor(December16$Location, levels = c("Intake","Surface","Inflow","Creek"), ordered = TRUE) March17$Location = factor(March17$Location, levels = c("Intake","Surface","Inflow","Creek"), ordered = TRUE) Intake = Seasonal$Location == "Intake" Intake.data = Seasonal[Intake,] Intake.data Surface = Seasonal$Location == "Surface" Surface.data = Seasonal[Surface,] Surface.data Inflow = Seasonal$Location == "Inflow" Inflow.data = Seasonal[Inflow,] Inflow.data Creek = Seasonal$Location == "Creek" Creek.data = Seasonal[Creek,] Creek.data ####################################### "DATA TRANSFORMATIONS, IMPORTANT!!!!!!" ####################################### "preProcess Seasonal" pp <- preProcess(Seasonal, method = "YeoJohnson") pp$yj Seasonal.pp = predict(pp, Seasonal) Seasonal.pp "preProcess March16" pp <- preProcess(March16, method = "YeoJohnson") pp$yj March16.pp = predict(pp, March16) March16.pp "preProcess June16" pp <- preProcess(June16, method = "YeoJohnson") pp$yj June16.pp = predict(pp, June16) June16.pp "preProcess August16" pp <- preProcess(August16, method = "YeoJohnson") pp$yj August16.pp = predict(pp, August16) August16.pp "preProcess December16" pp <- preProcess(December16, method = "YeoJohnson") pp$yj December16.pp = predict(pp, December16) December16.pp "preProcess March17" pp <- preProcess(March17, method = "YeoJohnson") pp$yj March17.pp = predict(pp, March17) March17.pp