--- title: "Environmental Data Line Graph" author: "Yaamini Venkataraman" date: "11/20/2018" output: html_document --- In this script, I'll visualize environmental data for each site and habitat combination over the course of the entire outplant. ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` # Install packages ```{r} sessionInfo() ``` # Import environmental data ```{r} pHData <- read.csv("2018-11-18-pH-Tide-Data-Corrected.csv", header = TRUE, na.strings = "NA") pHData <- pHData[, -1] #Remove first column of redundant values head(pHData) ``` ```{r} DOData <- read.csv("2018-11-18-DO-Tide-Data-Corrected.csv", header = TRUE, na.strings = "NA") DOData <- DOData[, -1] #Remove first column of redundant values head(DOData) ``` ```{r} salinityData <- read.csv("2018-11-18-Salinity-Tide-Data-Corrected.csv", header = TRUE, na.strings = "NA") salinityData <- salinityData[, -1] #Remove first column of redundant values head(salinityData) ``` ```{r} temperatureData <- read.csv("2018-11-18-Temperature-Corrected.csv", header = TRUE, na.strings = "NA") temperatureData <- temperatureData[, -1] #Remove first column of redundant values head(temperatureData) ``` #Calculate axis information ## Environmental data (y-axis) ```{r} pHMin <- as.integer((min(pHData[, -c(1:3, 13:17)], na.rm = TRUE))) #Calculate minimum pHMax <- as.integer((max(pHData[, -c(1:3, 13:17)], na.rm = TRUE))+1) #Calculate maximum pHRange <- c(pHMin, pHMax) #Create range values ``` ```{r} DOMin <- as.integer((min(DOData[, -c(1:3, 14:18)], na.rm = TRUE))) DOMax <- as.integer((max(DOData[, -c(1:3, 14:18)], na.rm = TRUE))) DORange <- c(DOMin, DOMax) ``` ```{r} salinityMin <- as.integer((min(salinityData[, -c(1:3, 12:16)], na.rm = TRUE))) salinityMax <- as.integer((max(salinityData[, -c(1:3, 12:16)], na.rm = TRUE))) salinityRange <- c(salinityMin, salinityMax) ``` ```{r} temperatureMin <- as.integer((min(temperatureData[, -c(1:2, 13)], na.rm = TRUE))) temperatureMax <- as.integer((max(temperatureData[, -c(1:2, 13)], na.rm = TRUE))) temperatureRange <- c(temperatureMin, temperatureMax) ``` ## Dates (x-axis) ```{r} temperatureAxisDates <- c("6/19", "6/24", "6/29", "7/04", "7/09", "7/14", "7/19") #Isolate dates for x-axis ``` # Plot data ```{r} #pdf("2018-11-20-Environmental-Data-Line-Graph.pdf", width = 11, height = 8.5) #Save as a new file par(mfrow = c(4, 5), oma = c(6, 4, 3, 1), mar = c(0, 1.5, 0, 0)) #Create a 4x5 multipanel plot, filling in the rows first. Add space along certain outer and inner margins. #Temperature plot(temperatureData$CIB, xaxs = "i", yaxs = "i", axes = F, ann = F, xlim = c(1, 4896), ylim = temperatureRange, pch = 16, cex = 0.2, col = "#00A9BD") #Case Inlet bare lines(temperatureData$CIE, lty = 3, col = "grey50") #Case Inlet eelgrass mtext(side = 3, line = -1.5, adj = 0, text = "Unvegetated", cex = 1, col = "#00A9BD") #Add habitat specificiation name. Use adj = 1 to left-justify the text mtext(side = 3, line = -2.75, adj = 0, text = "Eelgrass", cex = 1, col = "grey50") #Add habitat specificiation name. Use adj = 1 to left-justify the text box(col = "grey80") axis(side = 2, las = 1, at = c(15, 35), col = "grey80") #Put the axis labels at the values specified mtext(side = 2, line = 3, "Temperature (ÂșC)") #Add environmental variable indication mtext(side = 3, line = 1, "Case Inlet") #Add site indication plot(temperatureData$FBB, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = temperatureRange, pch = 16, cex = 0.2, col = "#38001C") #Fidalgo Bay bare lines(temperatureData$FBE, lty = 3, col = "grey50") #Eelgrass mtext(side = 3, line = -1.5, adj = 0, text = "Unvegetated", cex = 1, col = "#38001C") #Add habitat specificiation name. Use adj = 1 to left-justify the text mtext(side = 3, line = -2.75, adj = 0, text = "Eelgrass", cex = 1, col = "grey50") #Add habitat specificiation name. Use adj = 1 to left-justify the text box(col = "grey80") mtext(side = 3, line = 1, "Fidalgo Bay") #Add site indication plot(temperatureData$PGB, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = temperatureRange, pch = 16, cex = 0.2, col = "#440D82") #Port Gamble bare lines(temperatureData$PGE, lty = 3, col = "grey50") #Eelgrass mtext(side = 3, line = -1.5, adj = 0, text = "Unvegetated", cex = 1, col = "#440D82") #Add habitat specificiation name. Use adj = 1 to left-justify the text mtext(side = 3, line = -2.75, adj = 0, text = "Eelgrass", cex = 1, col = "grey50") #Add habitat specificiation name. Use adj = 1 to left-justify the text box(col = "grey80") mtext(side = 3, line = 1, "Port Gamble Bay") #Add site indication plot(temperatureData$SKB, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = temperatureRange, pch = 16, cex = 0.2, col = "#017A74") #Skokomish River bare lines(temperatureData$SKE, lty = 3, col = "grey50") #Eelgrass mtext(side = 3, line = -1.5, adj = 0, text = "Unvegetated", cex = 1, col = "#017A74") #Add habitat specificiation name. Use adj = 1 to left-justify the text mtext(side = 3, line = -2.75, adj = 0, text = "Eelgrass", cex = 1, col = "grey50") #Add habitat specificiation name. Use adj = 1 to left-justify the text box(col = "grey80") mtext(side = 3, line = 1, "Skokomish River Delta") #Add site indication plot(temperatureData$WBB, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = temperatureRange, pch = 16, cex = 0.2, col = "#EB8B0C") #Willapa Bay bare lines(temperatureData$WBE, lty = 3, col = "grey50") #Eelgrass mtext(side = 3, line = -1.5, adj = 0, text = "Unvegetated", cex = 1, col = "#EB8B0C") #Add habitat specificiation name. Use adj = 1 to left-justify the text mtext(side = 3, line = -2.75, adj = 0, text = "Eelgrass", cex = 1, col = "grey50") #Add habitat specificiation name. Use adj = 1 to left-justify the text box(col = "grey80") mtext(side = 3, line = 1, "Willapa Bay") #Add site indication #pH data plot(pHData$CIB.pH, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = pHRange, pch = 16, cex = 0.2, col = "#00A9BD") #Case Inlet bare lines(pHData$CIE.pH, lty = 3, col = "grey50") #Eelgrass box(col = "grey80") axis(side = 2, las = 1, at = c(7.5, 8.5), col = "grey80") #Put the axis labels at the values specified mtext(side = 2, line = 3, "pH") #Add environmental variable indication plot(pHData$FBB.pH, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = pHRange, pch = 16, cex = 0.2, col = "#38001C") #Fidalgo Bay bare lines(pHData$FBE.pH, lty = 3, col = "grey50") #Eelgrass box(col = "grey80") plot(pHData$PGB.pH, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = pHRange, pch = 16, cex = 0.2, col = "#440D82") #Port Gamble bare box(col = "grey80") plot(pHData$SKB.pH, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = pHRange, pch = 16, cex = 0.2, col = "#017A74") #Skokomish River bare lines(pHData$SKE.pH, lty = 3, col = "grey50") #Eelgrass box(col = "grey80") plot(pHData$WBB.pH, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = pHRange, pch = 16, cex = 0.2, col = "#EB8B0C") #Willapa Bay bare lines(pHData$WBE.pH, lty = 3, col = "grey50") #Eelgrass box(col = "grey80") #Salinity plot(salinityData$CIB.Salinity, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = salinityRange, pch = 16, cex = 0.2, col = "#00A9BD") #Case Inlet bare lines(salinityData$CIE.Salinity, lty = 3, col = "grey50") #Eelgrass box(col = "grey80") axis(side = 2, las = 1, at = c(15, 25), col = "grey50") #Put the axis labels at the values specified mtext(side = 2, line = 3, "Salinity (PSU)") #Add environmental variable indication plot(salinityData$FBB.Salinity, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = salinityRange, pch = 16, cex = 0.2, col = "#38001C") #Fidalgo Bay bare lines(salinityData$FBE.Salinity, lty = 3, col = "grey50") #Eelgrass box(col = "grey80") plot(salinityData$PGE.Salinity, type = "l", lty = 3, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = salinityRange, col = "grey80") #Port Gamble Bay bare lines(salinityData$PGE.Salinity, lty = 3, col = "grey50") #Eelgrass box(col = "grey80") plot(salinityData$SKB.Salinity, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = salinityRange, pch = 16, cex = 0.2, col = "#017A74") #Skokomish River bare lines(salinityData$SKE.Salinity, lty = 3, col = "grey50") #Eelgrass box(col = "grey80") plot(salinityData$WBB.Salinity, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = salinityRange, pch = 16, cex = 0.2, col = "#EB8B0C") #Willapa Bay bare box(col = "grey80") #Dissolved oxygen plot(DOData$CIB.DO, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = DORange, pch = 16, cex = 0.2, col = "#00A9BD") #Case Inlet bare lines(DOData$CIE.DO, lty = 3, col = "grey50") #Eelgrass box(col = "grey80") axis(side = 2, las = 1, at = c(25, 45), col = "grey80") #Put the axis labels at the values specified mtext(side = 2, line = 3, "DO (mg/L)") #Add environmental variable indication axis(side = 1, at = seq(from = 1, to = length(temperatureData$Date), by = 144*5), lab = temperatureAxisDates, las = 3, col = "grey80") #Make x-axis plot(DOData$FBB.DO, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = DORange, pch = 16, cex = 0.2, col = "#38001C") #Fidalgo Bay bare lines(DOData$FBE.DO, lty = 3, col = "grey50") #Eelgrass box(col = "grey80") axis(side = 1, at = seq(from = 1, to = length(temperatureData$Date), by = 144*5), lab = temperatureAxisDates, las = 3, col = "grey80") #Make x-axis plot(DOData$PGB.DO, xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = DORange, pch = 16, cex = 0.2, col = "#440D82") #Port Gamble bare lines(DOData$PGE.DO, lty = 3, col = "grey50") #Eelgrass box(col = "grey80") axis(side = 1, at = seq(from = 1, to = length(temperatureData$Date), by = 144*5), lab = temperatureAxisDates, las = 3, col = "grey80") #Make x-axis plot(DOData$SKB.DO, type = "l", xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = DORange, pch = 16, cex = 0.2, col = "#017A74") #Skokomish River bare lines(DOData$SKE.DO, lty = 3, col = "grey50") #Eelgrass box(col = "grey80") axis(side = 1, at = seq(from = 1, to = length(temperatureData$Date), by = 144*5), lab = temperatureAxisDates, las = 3, col = "grey80") #Make x-axis plot(DOData$WBB.DO, type = "l", xaxs = "i", yaxs = "i", axes = F, ann = F, ylim = DORange, pch = 16, cex = 0.2, col = "#EB8B0C") #Willapa Bay bare lines(DOData$WBE.DO, lty = 3, col = "grey50") #Eelgrass box(col = "grey80") axis(side = 1, at = seq(from = 1, to = length(temperatureData$Date), by = 144*5), lab = temperatureAxisDates, las = 2, col = "grey80") #Make x-axis mtext(side = 1, outer = TRUE, line = 4, "Date") #Add x-axis label #dev.off() ```