# install neccessary packages and load libraries install.packages (c("tidyverse")) library ("tidyverse") # load dataframe and split by date variable WissDat <- read.csv("Data.csv") WissDat$Date <- ifelse (WissDat$Date == "23-Sep" & WissDat$Measurement == 0, "23-Sep (A)", ifelse(WissDat$Date == "23-Sep" & WissDat$Measurement == 1, "23-Sep (B)", WissDat$Date)) WissDat.split <- split(WissDat, WissDat$Date) July29 <- WissDat.split$`29-Jul` July30 <- WissDat.split$`30-Jul` Aug5 <- WissDat.split$`5-Aug` Aug6 <- WissDat.split$`6-Aug` Aug8 <- WissDat.split$`8-Aug` Sept23a <- WissDat.split$`23-Sep (A)` Sept23b <- WissDat.split$`23-Sep (B)` Oct7 <- WissDat.split$`7-Oct` May19 <- WissDat.split$`19-May` May20 <- WissDat.split$`20-May` # create colorblind friendly palette for plotting cbp1 <- c("#D55E00", "#E69F00", "#56B4E9", "#0072B2","#F0E442","#009E73","#999999", "#CC79A7", "#999933") # moisture by location plot for data collection on two days in July 2019 WissDat.Transect<- rbind(July29, July30) options (repr.plot.width=14, repr.plot.height=10) WissDat.Transect$DistJitter <- jitter(WissDat.Transect$Distance, amount = 5) print (ggplot(WissDat.Transect, aes(x=DistJitter, y=Moisture, color=Date, shape=Date)) + geom_point(size=6, alpha=.8) + scale_x_reverse (name = "Distance (in meters) from bottom of hill", breaks = seq(0,200,25)) + scale_y_continuous (breaks = seq(1, 2.2, .2), limits = c(1, 2.2)) + scale_color_manual (values = cbp1) + theme_minimal() + ggtitle ("Soil Moisture by Location") + theme (text = element_text(size=20), axis.title.x = element_text(margin = margin(15,0,0,0)), axis.title.y = element_text(margin = margin(0,15,0,0)), panel.background = element_rect(fill = NA, color = "black"), aspect.ratio = .6) ) # strength by location plot for data collection on two days in July 2019 options (repr.plot.width=14, repr.plot.height=10) print (ggplot(WissDat.Transect, aes(x=DistJitter, y=Strength, color=Date, shape=Date)) + geom_point(size=6, alpha=.8) + scale_x_reverse (name = "Distance (in meters) from bottom of hill", breaks = seq(0,200,25)) + scale_y_continuous (breaks = seq(1, 8.5, .5), limits = c(1, 8.5)) + scale_color_manual (values = cbp1) + theme_minimal() + ggtitle ("Soil Strength by Location") + theme (text = element_text(size=20), axis.title.x = element_text(margin = margin(15,0,0,0)), axis.title.y = element_text(margin = margin(0,15,0,0)), panel.background = element_rect(fill = NA, color = "black"), aspect.ratio = .6) ) # moisture by location plot that now includes data collection in September 2020 WissDat.Transect <- rbind(July29, July30, Sept23a, Sept23b) WissDat.Transect$DistJitter <- ifelse(WissDat.Transect$Date == "29-Jul" | WissDat.Transect$Date == "30-Jul", jitter(WissDat.Transect$Distance, amount = 5), WissDat.Transect$Distance) WissDat.Transect$Date <- factor(WissDat.Transect$Date, levels = c("29-Jul", "30-Jul", "23-Sep (A)", "23-Sep (B)")) alpha <- ifelse(WissDat.Transect$Date == "29-Jul" | WissDat.Transect$Date == "30-Jul", .25, .8) options (repr.plot.width=14, repr.plot.height=10) print (ggplot(WissDat.Transect, aes(x=DistJitter, y=Moisture, color=Date, shape=Date)) + geom_point(size=6, alpha=alpha) + scale_x_reverse (name = "Distance (in meters) from bottom of hill", breaks = seq(0,200,25)) + scale_y_continuous (breaks = seq(1, 2.2, .2), limits = c(1, 2.2)) + scale_color_manual (values = cbp1) + scale_shape_manual (values = c(19,17,15,18)) + theme_minimal() + ggtitle ("Soil Moisture by Location") + theme (text = element_text(size=20), axis.title.x = element_text(margin = margin(15,0,0,0)), axis.title.y = element_text(margin = margin(0,15,0,0)), panel.background = element_rect(fill = NA, color = "black"), aspect.ratio = .6) ) # strength by location plot that now includes data collection in September 2020 options (repr.plot.width=14, repr.plot.height=10) print (ggplot(WissDat.Transect, aes(x=DistJitter, y=Strength, color=Date, shape=Date)) + geom_point(size=6, alpha=alpha) + scale_x_reverse (name = "Distance (in meters) from bottom of hill", breaks = seq(0,200,25)) + scale_y_continuous (breaks = seq(1, 8.5, .5), limits = c(1, 8.5)) + scale_color_manual (values = cbp1) + scale_shape_manual (values = c(19,17,15,18)) + theme_minimal() + ggtitle ("Soil Strength by Location") + theme (text = element_text(size=20), axis.title.x = element_text(margin = margin(15,0,0,0)), axis.title.y = element_text(margin = margin(0,15,0,0)), panel.background = element_rect(fill = NA, color = "black"), aspect.ratio = .6) ) # moisture by location plot that now includes data collection in October 2020 WissDat.Transect <- rbind(July29, July30, Sept23a, Sept23b, Oct7) WissDat.Transect$DistJitter <- ifelse(WissDat.Transect$Date == "29-Jul" | WissDat.Transect$Date == "30-Jul" | WissDat.Transect$Date == "7-Oct", jitter(WissDat.Transect$Distance, amount = 5), WissDat.Transect$Distance) WissDat.Transect$Date <- factor(WissDat.Transect$Date, levels = c("29-Jul", "30-Jul", "23-Sep (A)", "23-Sep (B)", "7-Oct")) alpha <- ifelse(WissDat.Transect$Date == "7-Oct", .8, .3) options (repr.plot.width=14, repr.plot.height=10) print (ggplot(WissDat.Transect, aes(x=DistJitter, y=Moisture, color=Date, shape=Date)) + geom_point(size=6, alpha=alpha) + scale_x_reverse (name = "Distance (in meters) from bottom of hill", breaks = seq(0,200,25)) + scale_y_continuous (breaks = seq(1, 2.2, .2), limits = c(1, 2.2)) + scale_color_manual (values = cbp1) + scale_shape_manual (values = c(19,17,15,18,19)) + theme_minimal() + ggtitle ("Soil Moisture by Location") + theme (text = element_text(size=20), axis.title.x = element_text(margin = margin(15,0,0,0)), axis.title.y = element_text(margin = margin(0,15,0,0)), panel.background = element_rect(fill = NA, color = "black"), aspect.ratio = .6) ) # strength by location plot that now includes data collection in October 2020 options (repr.plot.width=14, repr.plot.height=10) print (ggplot(WissDat.Transect, aes(x=DistJitter, y=Strength, color=Date, shape=Date)) + geom_point(size=6, alpha=alpha) + scale_x_reverse (name = "Distance (in meters) from bottom of hill", breaks = seq(0,200,25)) + scale_y_continuous (breaks = seq(0.5, 8.5, .5), limits = c(0.5, 8.5)) + scale_color_manual (values = cbp1) + scale_shape_manual (values = c(19,17,15,18,19)) + theme_minimal() + ggtitle ("Soil Strength by Location") + theme (text = element_text(size=20), axis.title.x = element_text(margin = margin(15,0,0,0)), axis.title.y = element_text(margin = margin(0,15,0,0)), panel.background = element_rect(fill = NA, color = "black"), aspect.ratio = .6) ) # moisture by location plot that now includes data collection in May 2022 WissDat.Transect <- rbind(July29, July30, Sept23a, Sept23b, Oct7, May19) WissDat.Transect$DistJitter <- ifelse(WissDat.Transect$Date == "29-Jul" | WissDat.Transect$Date == "30-Jul" | WissDat.Transect$Date == "7-Oct" | WissDat.Transect$Date == "19-May" , jitter(WissDat.Transect$Distance, amount = 5), WissDat.Transect$Distance) WissDat.Transect$Date <- factor(WissDat.Transect$Date, levels = c("29-Jul", "30-Jul", "23-Sep (A)", "23-Sep (B)", "7-Oct", "19-May")) alpha <- ifelse(WissDat.Transect$Date == "19-May", .8, .3) options (repr.plot.width=14, repr.plot.height=10) print (ggplot(WissDat.Transect, aes(x=DistJitter, y=Moisture, color=Date, shape=Date)) + geom_point(size=6, alpha=alpha) + scale_x_reverse (name = "Distance (in meters) from bottom of hill", breaks = seq(0,200,25)) + scale_y_continuous (breaks = seq(1, 2.2, .2), limits = c(1, 2.2)) + scale_color_manual (values = cbp1) + scale_shape_manual (values = c(19,17,15,18,19,17)) + theme_minimal() + ggtitle ("Soil Moisture by Location") + theme (text = element_text(size=20), axis.title.x = element_text(margin = margin(15,0,0,0)), axis.title.y = element_text(margin = margin(0,15,0,0)), panel.background = element_rect(fill = NA, color = "black"), aspect.ratio = .6) ) # strength by location plot that now includes data collection in May 2022 options (repr.plot.width=14, repr.plot.height=10) print (ggplot(WissDat.Transect, aes(x=DistJitter, y=Strength, color=Date, shape=Date)) + geom_point(size=6, alpha=alpha) + scale_x_reverse (name = "Distance (in meters) from bottom of hill", breaks = seq(0,200,25)) + scale_y_continuous (breaks = seq(0.5, 8.5, .5), limits = c(0.5, 8.5)) + scale_color_manual (values = cbp1) + scale_shape_manual (values = c(19,17,15,18,19,17)) + theme_minimal() + ggtitle ("Soil Strength by Location") + theme (text = element_text(size=20), axis.title.x = element_text(margin = margin(15,0,0,0)), axis.title.y = element_text(margin = margin(0,15,0,0)), panel.background = element_rect(fill = NA, color = "black"), aspect.ratio = .6) ) # moisture by location plot that now includes data collection in August 2020 WissDat.Rain <- rbind(July29, July30, Sept23a, Sept23b, Oct7, May19, Aug5, Aug6, Aug8) WissDat.Rain$DistJitter <- ifelse(WissDat.Rain$Date == "23-Sept (A)" | WissDat.Rain$Date == "23-Sep (B)", WissDat.Rain$Distance, jitter(WissDat.Rain$Distance, amount = 5)) WissDat.Rain$Date <- factor(WissDat.Rain$Date, levels = c("29-Jul", "30-Jul", "23-Sep (A)", "23-Sep (B)", "7-Oct","19-May","5-Aug", "6-Aug", "8-Aug")) alpha <- ifelse(WissDat.Rain$Date == "5-Aug" | WissDat.Rain$Date == "6-Aug" | WissDat.Rain$Date == "8-Aug", .8, .25) options (repr.plot.width=14, repr.plot.height=10) WissDat.Rain$DistJitter <- jitter(WissDat.Rain$Distance, amount = 3) print (ggplot(WissDat.Rain, aes(x=DistJitter, y=Moisture, color=Date, shape=Date)) + geom_point(size=6, alpha=alpha) + scale_x_reverse (name = "Distance (in meters) from bottom of hill", breaks = seq(0,200,25)) + scale_y_continuous (breaks = seq(1, 2.2, .2), limits = c(1, 2.2)) + scale_color_manual (values = cbp1) + scale_shape_manual (values = c(19,17,15,18,19,17,15,18,19)) + theme_minimal() + ggtitle ("Soil Moisture by Location") + theme (text = element_text(size=20), axis.title.x = element_text(margin = margin(15,0,0,0)), axis.title.y = element_text(margin = margin(0,15,0,0)), panel.background = element_rect(fill = NA, color = "black"), aspect.ratio = .6) ) # strength by location plot that now includes data collection in August 2020 options (repr.plot.width=14, repr.plot.height=10) print (ggplot(WissDat.Rain, aes(x=DistJitter, y=Strength, color=Date, shape=Date)) + geom_point(size=6, alpha=alpha) + scale_x_reverse (name = "Distance (in meters) from bottom of hill", breaks = seq(0,200,25)) + scale_y_continuous (breaks = seq(0.5, 8.5, .5), limits = c(0.5, 8.5)) + scale_color_manual (values = cbp1) + scale_shape_manual (values = c(19,17,15,18,19,17,15,18,19)) + theme_minimal() + ggtitle ("Soil Strength by Location") + theme (text = element_text(size=20), axis.title.x = element_text(margin = margin(15,0,0,0)), axis.title.y = element_text(margin = margin(0,15,0,0)), panel.background = element_rect(fill = NA, color = "black"), aspect.ratio = .6) ) # moisture by location plot for data collection in May 2022 WissDat.TransectNew<- rbind(May20) options (repr.plot.width=14, repr.plot.height=10) WissDat.TransectNew$DistJitter <- jitter(WissDat.TransectNew$Distance, amount = 0.01) print (ggplot(WissDat.TransectNew, aes(x=DistJitter, y=Moisture, color=Date, shape=Date)) + geom_point(size=6, alpha=.8) + scale_x_continuous (name = "Distance from top of hill (as proportion, 1=bottom)", breaks = seq(0,1,0.1)) + scale_y_continuous (breaks = seq(0.8, 2.2, .2), limits = c(0.8, 2.2)) + scale_color_manual (values = cbp1) + theme_minimal() + ggtitle ("Soil Moisture by Location") + theme (text = element_text(size=20), axis.title.x = element_text(margin = margin(15,0,0,0)), axis.title.y = element_text(margin = margin(0,15,0,0)), panel.background = element_rect(fill = NA, color = "black"), aspect.ratio = .6) ) # strength by location plot for data collection in May 2022 options (repr.plot.width=14, repr.plot.height=10) print (ggplot(WissDat.TransectNew, aes(x=DistJitter, y=Strength, color=Date, shape=Date)) + geom_point(size=6, alpha=.8) + scale_x_continuous (name = "Distance from top of hill (as proportion, 1=bottom)", breaks = seq(0,1,0.1)) + scale_y_continuous (breaks = seq(1, 8.5, .5), limits = c(1, 8.5)) + scale_color_manual (values = cbp1) + theme_minimal() + ggtitle ("Soil Strength by Location") + theme (text = element_text(size=20), axis.title.x = element_text(margin = margin(15,0,0,0)), axis.title.y = element_text(margin = margin(0,15,0,0)), panel.background = element_rect(fill = NA, color = "black"), aspect.ratio = .6) )