<- read.csv("Temperature.csv")
temp library(ggplot2)
Module07 Part1
Read the data
Use ggplot() to produce a histogram of salinity values
ggplot(temp, aes(x = Salinity)) + geom_histogram(binwidth = 0.2, fill = 'steelblue', color = 'white', na.rm = TRUE) + ggtitle("Histogram of Salinity")
A histogram of salinity values for each year
ggplot(temp, aes(x = Salinity)) + geom_histogram(binwidth = 0.5, fill = 'salmon', na.rm = TRUE) + facet_wrap(~ Year) + ggtitle("Salinity by Year")
A histogram of salinity values for each month
ggplot(temp, aes(x = Salinity)) + geom_histogram(binwidth = 0.5, fill = 'olivedrab', na.rm = TRUE) + facet_wrap(~ Month) + ggtitle("Salinity by Month")
Make a boxplot of temperature values for each station
ggplot(temp, aes(x = Station, y = Temperature)) + geom_boxplot(fill = 'steelblue', na.rm = TRUE) + ggtitle("Temperature by Station")
Save the boxplot to a png file
= ggplot(temp, aes(x = Station, y = Temperature, na.rm = TRUE)) + ggtitle("Temperature by Station")
myplot ggsave("Temperature by Station.png", myplot)
Saving 7 x 5 in image
Bonus: Reorganize the boxplot from low to high median temperatures
ggplot(temp, aes(x = reorder(Station, Temperature, median, na.rm = TRUE), y = Temperature)) + geom_boxplot(fill = 'skyblue', na.rm = TRUE) + ggtitle("Temperature by Station")