setwd("C:/Users/clintbrunson/Desktop/Grad_school/MNR_project/Temple Fork_MNR/TF_and_SCdata") dat <- read.csv("tfdata_plus_k.csv") usu <- read.csv("usu10yrs.csv") install.packages("FSA") library("FSA")ws bnt <- subset(dat, dat$species == "BNT") bkt <- subset(dat, dat$species == "BKT") bct <- subset(dat, dat$species == "BCT") dat$condition_k <- round((dat$weight/dat$length^3)*100000, 2) write.csv(dat, file = "tfdata_plus_k.csv") par(mfrow = c(2, 2)) plot(dat$length, dat$weight, # scatterplot of length on x and weight on y axis main = "Length vs. Weight", xlab = "Length (mm)", ylab = "Weight (g)") plot(bct$length, bct$weight, # scatterplot of length on x and weight on y axis main = "Length vs. Weight", xlab = "Length (mm)", ylab = "Weight (g)") plot(bkt$length, bkt$weight, # scatterplot of length on x and weight on y axis main = "Length vs. Weight", xlab = "Length (mm)", ylab = "Weight (g)") plot(bnt$length, bnt$weight, # scatterplot of length on x and weight on y axis main = "Length vs. Weight", xlab = "Length (mm)", ylab = "Weight (g)") par(mfrow = c(1, 1)) hist(bnt$length, breaks = 40, col = "blue") hist(bct$length, breaks = 40, col = "red") hist(bkt$length, breaks = 40, col = "blue") ############################################################################ ############################################################################ #set up only bnt and bct variables bnt <- subset(dat, dat$species == "BNT") bct <- subset(dat, dat$species == "BCT") usubnt <- subset(usu, usu$Species == "brown trout") usubct <- subset(usu, usu$Species == "cutthroat trout") #################################### #start breaking out year, age class, stream for Brown Trout (BNT) # Year 2010 #Brown Trout age110_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2010") age210_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2010") age110_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2010") age210_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2010") #Cutthroat Trout age110_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2010") age210_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2010") age110_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2010") age210_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2010") # Year 2011 #Brown Trout age111_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2011") age211_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2011") age111_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2011") age211_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2011") #Cutthroat Trout age111_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2011") age211_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2011") age111_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2011") age211_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2011") # Year 2012 #Brown Trout age112_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2012") age212_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2012") age112_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2012") age212_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2012") #Cutthroat Trout age112_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2012") age212_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2012") age112_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2012") age212_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2012") # Year 2013 #Brown Trout age113_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2013") age213_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2013") age113_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2013") age213_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2013") #Cutthroat Trout age113_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2013") age213_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2013") age113_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2013") age213_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2013") # Year 2014 #Brown Trout age114_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2014") age214_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2014") age114_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2014") age214_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2014") #Cutthroat Trout age114_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2014") age214_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2014") age114_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2014") age214_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2014") # Year 2015 #Brown Trout age115_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2015") age215_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2015") age115_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2015") age215_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2015") #Cutthroat Trout age115_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2015") age215_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2015") age115_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2015") age215_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2015") # Year 2016 #Brown Trout age116_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2016") age216_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2016") age116_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2016") age216_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2016") #Cutthroat Trout age116_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2016") age216_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2016") age116_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2016") age216_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2016") # Year 2018 #Brown Trout age118_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2018") age218_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2018") age118_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2018") age218_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2018") #Cutthroat Trout age118_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2018") age218_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2018") age118_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2018") age218_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2018") # Year 2019 #Brown Trout age119_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2019") age219_BNT_tf <- subset(usubnt, usubnt$Location == "Temple Fork" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2019") age119_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 100 & usubnt$length < 199 & usubnt$Year == "2019") age219_BNT_sc <- subset(usubnt, usubnt$Location == "Spawn Creek" & usubnt$length > 200 & usubnt$length < 279 & usubnt$Year == "2019") #Cutthroat Trout age119_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2019") age219_BCT_tf <- subset(usubct, usubct$Location == "Temple Fork" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2019") age119_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 90 & usubct$length < 149 & usubct$Year == "2019") age219_BCT_sc <- subset(usubct, usubct$Location == "Spawn Creek" & usubct$length > 150 & usubct$length < 199 & usubct$Year == "2019") ############################################################ # Year 2020 My removal data #Cutthroat Trout age120_BCT_tf <- subset(bct, bct$location == "temple_fork" & bct$length > 90 & bct$length < 149 & bct$pass == "1") age220_BCT_tf <- subset(bct, bct$location == "temple_fork" & bct$length >150 & bct$length < 199 & bct$pass == "1") age120_BCT_sc <- subset(bct, bct$location == "spawn_creek" & bct$length > 90 & bct$length < 149 & bct$pass == "1") age220_BCT_sc <- subset(bct, bct$location == "spawn_creek" & bct$length >150 & bct$length < 199 & bct$pass == "1") # Mean of K in BCT in my data mean(age120_BCT_tf$condition_k) mean(age220_BCT_tf$condition_k) mean(age120_BCT_sc$condition_k) mean(age220_BCT_sc$condition_k) #Brown Trout age120_BNT_tf <- subset(bnt, bnt$location == "temple_fork" & bnt$length > 100 & bnt$length < 199 & bnt$pass == "1") age220_BNT_tf <- subset(bnt, bnt$location == "temple_fork" & bnt$length > 200 & bnt$length < 279 & bnt$pass == "1") age120_BNT_sc <- subset(bnt, bnt$location == "spawn_creek" & bnt$length > 100 & bnt$length < 199 & bnt$pass == "1") age220_BNT_sc <- subset(bnt, bnt$location == "spawn_creek" & bnt$length > 200 & bnt$length < 279 & bnt$pass == "1") # Mean of K in BNT of my data mean(age120_BNT_tf$condition_k) mean(age220_BNT_tf$condition_k) mean(age120_BNT_sc$condition_k) mean(age220_BNT_sc$condition_k) ########################################################################################################################## ########################################################################################################################## # Combine 3 years of data into one dataset using rbind() #BCT early_age1_bct <- rbind(age110_BCT_sc, age111_BCT_sc, age112_BCT_sc) early_age2_bct <- rbind(age210_BCT_sc, age211_BCT_sc, age212_BCT_sc) early_age1_bcttf <- rbind(age110_BCT_tf, age111_BCT_tf, age112_BCT_tf) early_age2_bcttf <- rbind(age210_BCT_tf, age211_BCT_tf, age212_BCT_tf) mid_age1_bct <- rbind(age113_BCT_sc, age114_BCT_sc, age115_BCT_sc) mid_age2_bct <- rbind(age213_BCT_sc, age214_BCT_sc, age215_BCT_sc) mid_age1_bcttf <- rbind(age113_BCT_tf, age114_BCT_tf, age115_BCT_tf) mid_age2_bcttf <- rbind(age213_BCT_tf, age214_BCT_tf, age215_BCT_tf) late_age1_bct <- rbind(age116_BCT_sc, age118_BCT_sc, age119_BCT_sc) late_age2_bct <- rbind(age216_BCT_sc, age218_BCT_sc, age219_BCT_sc) late_age1_bcttf <- rbind(age116_BCT_tf, age118_BCT_tf, age119_BCT_tf) late_age2_bcttf <- rbind(age216_BCT_tf, age218_BCT_tf, age219_BCT_tf) # Means of K for BCT mean(early_age1_bct$condition_k) mean(early_age2_bct$condition_k) mean(early_age1_bcttf$condition_k) mean(early_age2_bcttf$condition_k) mean(mid_age1_bct$condition_k) mean(mid_age2_bct$condition_k) mean(mid_age1_bcttf$condition_k) mean(mid_age2_bcttf$condition_k) mean(late_age1_bct$condition_k) mean(late_age2_bct$condition_k) mean(late_age1_bcttf$condition_k) mean(late_age2_bcttf$condition_k) #BNT early_age1_bnt <- rbind(age110_BNT_sc, age111_BNT_sc, age112_BNT_sc) early_age2_bnt <- rbind(age210_BNT_sc, age211_BNT_sc, age212_BNT_sc) early_age1_bnttf <- rbind(age110_BNT_tf, age111_BNT_tf, age112_BNT_tf) early_age1_bnttf <- na.omit(early_age1_bnttf) early_age1_bnttf early_age2_bnttf <- rbind(age210_BNT_tf, age211_BNT_tf, age212_BNT_tf) mid_age1_bnt <- rbind(age113_BNT_sc, age114_BNT_sc, age115_BNT_sc) mid_age2_bnt <- rbind(age213_BNT_sc, age214_BNT_sc, age215_BNT_sc) mid_age1_bnttf <- rbind(age113_BNT_tf, age114_BNT_tf, age115_BNT_tf) mid_age1_bnttf <- na.omit(mid_age1_bnttf) mid_age1_bnttf mid_age2_bnttf <- rbind(age213_BNT_tf, age214_BNT_tf, age215_BNT_tf) late_age1_bnt <- rbind(age116_BNT_sc, age118_BNT_sc, age119_BNT_sc) late_age2_bnt <- rbind(age216_BNT_sc, age218_BNT_sc, age219_BNT_sc) late_age1_bnttf <- rbind(age116_BNT_tf, age118_BNT_tf, age119_BNT_tf) late_age1_bnttf <- na.omit(late_age1_bnttf) late_age1_bnttf late_age2_bnttf <- rbind(age216_BNT_tf, age218_BNT_tf, age219_BNT_tf) # Mean of K in BNT mean(early_age1_bnt$condition_k) mean(early_age2_bnt$condition_k) mean(early_age1_bnttf$condition_k) mean(early_age2_bnttf$condition_k) mean(mid_age1_bnt$condition_k) mean(mid_age2_bnt$condition_k) mean(mid_age1_bnttf$condition_k) mean(mid_age2_bnttf$condition_k) mean(late_age1_bnt$condition_k) mean(late_age2_bnt$condition_k) mean(late_age1_bnttf$condition_k) mean(late_age2_bnttf$condition_k) ################################################################################ # Three years combined and TF and SC are both combined #BCT com_age1_bct_early <- rbind(age110_BCT_sc, age111_BCT_sc, age112_BCT_sc, age110_BCT_tf, age111_BCT_tf, age112_BCT_tf) com_age2_bct_early <- rbind(age210_BCT_sc, age211_BCT_sc, age212_BCT_sc, age210_BCT_tf, age211_BCT_tf, age212_BCT_tf) com_age1_bct_mid <- rbind(age113_BCT_sc, age114_BCT_sc, age115_BCT_sc, age113_BCT_tf, age114_BCT_tf, age115_BCT_tf) com_age2_bct_mid <- rbind(age213_BCT_sc, age214_BCT_sc, age215_BCT_sc, age213_BCT_tf, age214_BCT_tf, age215_BCT_tf) com_age1_bct_late <- rbind(age116_BCT_sc, age118_BCT_sc, age119_BCT_sc, age116_BCT_tf, age118_BCT_tf, age119_BCT_tf) com_age2_bct_late <- rbind(age216_BCT_sc, age218_BCT_sc, age219_BCT_sc, age216_BCT_tf, age218_BCT_tf, age219_BCT_tf) # Mean of K in combined TF an SC for BCT mean(com_age1_bct_early$condition_k) mean(com_age2_bct_early$condition_k) mean(com_age1_bct_mid$condition_k) mean(com_age2_bct_mid$condition_k) mean(com_age1_bct_late$condition_k) mean(com_age2_bct_late$condition_k) #BNT com_age1_bnt_early <- rbind(age110_BNT_sc, age111_BNT_sc, age112_BNT_sc, age110_BNT_tf, age111_BNT_tf, age112_BNT_tf) com_age1_bnt_early <- na.omit(com_age1_bnt_early) com_age1_bnt_early com_age2_bnt_early <- rbind(age210_BNT_sc, age211_BNT_sc, age212_BNT_sc, age210_BNT_tf, age211_BNT_tf, age212_BNT_tf) com_age1_bnt_mid <- rbind(age113_BNT_sc, age114_BNT_sc, age115_BNT_sc, age113_BNT_tf, age114_BNT_tf, age115_BNT_tf) com_age1_bnt_mid <- na.omit(com_age1_bnt_mid) com_age1_bnt_mid com_age2_bnt_mid <- rbind(age213_BNT_sc, age214_BNT_sc, age215_BNT_sc, age213_BNT_tf, age214_BNT_tf, age215_BNT_tf) com_age1_bnt_late <- rbind(age116_BNT_sc, age118_BNT_sc, age119_BNT_sc, age116_BNT_tf, age118_BNT_tf, age119_BNT_tf) com_age1_bnt_late <- na.omit(com_age1_bnt_late) com_age1_bnt_late com_age2_bnt_late <- rbind(age216_BNT_sc, age218_BNT_sc, age219_BNT_sc, age216_BNT_tf, age218_BNT_tf, age219_BNT_tf) # Mean of K in combine TF and SC for BNT mean(com_age1_bnt_early$condition_k) mean(com_age2_bnt_early$condition_k) mean(com_age1_bnt_mid$condition_k) mean(com_age2_bnt_mid$condition_k) mean(com_age1_bnt_late$condition_k) mean(com_age2_bnt_late$condition_k) # My data combined myage1bct <- rbind(age120_BCT_sc, age120_BCT_tf) myage2bct <- rbind(age220_BCT_sc, age220_BCT_tf) myage1bnt <- rbind(age120_BNT_tf, age120_BNT_sc) myage2bnt <- rbind(age220_BNT_sc, age220_BNT_tf) mean(myage1bct$condition_k) mean(myage2bct$condition_k) mean(myage1bnt$condition_k) mean(myage2bnt$condition_k)