── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(zoo)
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
library(plotly)
Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
#set the working directorysetwd("C:/Users/andy/Desktop/rDataSets")saltWatch <-read_csv("Salt Watch Muddy Branch 2022R.csv")
Rows: 31 Columns: 6
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): Data Source, Date, Description
dbl (3): Chloride Reading, Latitude, Longitude
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Clean up data
#lower case and get rid of spacenames(saltWatch) <-tolower(names(saltWatch))names(saltWatch) <-gsub(" ","_",names(saltWatch))head(saltWatch)
# A tibble: 6 × 6
data_source date chloride_reading description latitude longitude
<chr> <chr> <dbl> <chr> <dbl> <dbl>
1 Clean Water Hub 1/28/2022 91 Pulled from the… 39.1 -77.2
2 Clean Water Hub 1/28/2022 167 Pulled from the… 39.1 -77.2
3 Clean Water Hub 1/29/2022 332 Pulled from the… 39.1 -77.2
4 Clean Water Hub 1/30/2022 280 Pulled from the… 39.1 -77.2
5 Clean Water Hub 1/30/2022 497 Pulled from the… 39.1 -77.2
6 Clean Water Hub 2/4/2022 215 Pulled from the… 39.1 -77.2
#get rid of the year in the date formatsaltWatch$date <-as.Date(saltWatch$date, format="%m/%d/%Y")saltWatch$date
We want to see the levels of chloride in bodies of water throughout the year.
scatterplot1 <-ggplot(data = saltWatch, aes(x = month_day2022,y = chloride_reading)) +geom_point(color="brown", size=3)+labs(title ="Montgomery County Chloride Levels in Waterbodies 2022",x ="Date in 2022",y ="Chloride Levels (Milligrams per liter)")+theme_bw()+theme(axis.text.x =element_text(angle=75))ggplotly(scatterplot1)
Analysis:
The data shows the different levels of chloride in Montgomery County, Maryland’s water bodies in 2022. The data set includes the source and descriptions of where the samples were taken from. On the graph, the x-axis tracks which time of the year the samples were taken. The y-axis displays the chloride levels in milligrams per liter throughout 2022. Trends that I see are higher levels of chloride in the water bodies in the months of January through March than April through December. Chloride from road salt in water is toxic and harmful to the environment.
The hypothesis is that if the levels of chloride in the water are higher in the winter months of January through March then the water quality will be worse compared to bodies of water that have less chloride.
First, the control group would be a body of water that was not affected by chloride. The experimental group would be multiple bodies of water that were affected by chloride. Both bodies of water will have samples taken from them and receive chloride readings. The experiment can be repeated by taking multiple samples of different bodies of water around Montgomery County and measuring the levels of chloride.
The chloride readings would serve as data to determine whether a body of water is toxic. Additional data collected could be observations of plant and animal life in the bodies of water to determine the water quality.