Part 1
Use ggplot() to produce a histogram of salinity values
library(ggplot2)
temp = read.csv("Temperature.csv")
myplot = ggplot(temp, aes(x = Salinity))
myplot + geom_histogram(na.rm = TRUE, binwidth = 1)
Make a histogram of salinity values for each year of study, and then for each month
myplot + geom_histogram(na.rm = TRUE, binwidth = 1) + facet_wrap(~ Year) + ggtitle ("Salinity by Year")
myplot + geom_histogram(na.rm = TRUE, binwidth = 1) + facet_wrap(~ Month) + ggtitle ("Salinity by Month")
Make a boxplot of temperature values for each station
myplot2 = ggplot(temp, aes(x = Station, y = Temperature))
myplot2 + geom_boxplot(na.rm = TRUE) + ggtitle("Temperatures by Station")
bonus: Reorganize the box-plot by low to high median temperatures
myplot2 + geom_boxplot(aes(x=reorder(Station, Temperature, median, na.rm = TRUE)), na.rm = TRUE) + ggtitle("Sorted Temp. by Station")
Part 2
temp$decdate <- temp$Year + temp$dDay3 / 365
Using this variable make a scatterplot of temperature and salinity over time
myplot3 = ggplot(temp, aes(x = decdate))
myplot3 + geom_point(aes(y = Temperature, color = "Temperature"), na.rm = TRUE) +
geom_point(aes(y = Salinity, color = "Salinity"), na.rm = TRUE) +
labs(y = "Temp / Salinity", x= "Date", title = "Temp & Salinity Over Time")
Make a scatterplot of salinity, grouped using facet_wrap() into different ‘Areas’
myplot3 + geom_point(aes(y = Salinity, color = Area), na.rm = TRUE,) + facet_wrap(~ Area) +
labs(x = "Date", title = "Salinity by Area Over Time")
Make a lineplot of salinity for each station, grouped into different ‘Areas’
myplot3 + geom_line(aes(y = Salinity, color = Station), na.rm = TRUE) + facet_wrap( ~ Area) +
labs(title = "Salinity by Station, Grouped by 'Area'", x = "Date")