# Exercise Mod 7

Part 1

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.0.5
temp = read.csv("Temperature.csv")

General Salinity Plot

salplot = ggplot(temp, aes(x=Salinity))
salplot + geom_histogram(binwidth = 1)
## Warning: Removed 798 rows containing non-finite values (stat_bin).

Salinity of Years

salplot + geom_histogram(fill='lightblue') + facet_wrap(~ Year) + ggtitle("Salinity by Year")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 798 rows containing non-finite values (stat_bin).

Salinity of Months

salplot + geom_histogram(fill='lightblue') + facet_wrap(~ Month) + ggtitle("Salinity by Month")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 798 rows containing non-finite values (stat_bin).

Boxplot by Station + Save file

staplot = ggplot(temp, aes(x=Station, y=Salinity))
staplot + geom_boxplot(aes(x=reorder(Station, Salinity, median, na.rm=TRUE))) + ggtitle ("Station Salinity")
## Warning: Removed 798 rows containing non-finite values (stat_boxplot).

sta2plot =  staplot + geom_boxplot(aes(x=reorder(Station, Salinity, median, na.rm=TRUE))) + ggtitle ("Station Salinity")
ggsave("Sation_Salinity.png", sta2plot)
## Saving 7 x 5 in image
## Warning: Removed 798 rows containing non-finite values (stat_boxplot).

Part 2

making the variable

temp$decdate = temp$Year + temp$dDay3 / 365

Scatter of Temp and Salinity

templot = ggplot(temp, aes(x=decdate, y=Temperature))
templot + geom_point() + geom_smooth(method = 'lm')
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 927 rows containing non-finite values (stat_smooth).
## Warning: Removed 927 rows containing missing values (geom_point).

sal3plot = ggplot(temp, aes(x=decdate, y=Salinity))
sal3plot + geom_point() + geom_smooth(method = 'lm')
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 798 rows containing non-finite values (stat_smooth).
## Warning: Removed 798 rows containing missing values (geom_point).

Scatter of Salinity (grouped)

sal3plot + geom_point() + facet_wrap(~ Area) + geom_smooth(method='lm')
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 798 rows containing non-finite values (stat_smooth).
## Warning: Removed 798 rows containing missing values (geom_point).

Line plot of Salinity (grouped)

sal3plot + geom_line(aes(color=Area)) + facet_wrap(~ Area)