Read file

temperature <- read.csv("Temperature.csv")
library(ggplot2)

Create histogram of salinity values for each year

myplot = ggplot(temperature, aes(x = Salinity))
myplot + geom_histogram() + facet_wrap(~ Year)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 798 rows containing non-finite values (stat_bin).

Create historgram of salinity values for each month

myplot = ggplot(temperature, aes(x = Salinity))
myplot + geom_histogram() + facet_wrap(~ Month)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 798 rows containing non-finite values (stat_bin).

Create a boxplot of temperature values for each station

myplot = ggplot(temperature, aes(x = Station, y = Temperature))
myplot + geom_boxplot()
## Warning: Removed 927 rows containing non-finite values (stat_boxplot).

myplot + geom_boxplot(aes(x=reorder(Station, Temperature, median)))
## Warning: Removed 927 rows containing non-finite values (stat_boxplot).

Save as png file

myplot = myplot + ggtitle("Temperatures at Stations") + xlab("Station") + ylab("Temperature")
ggsave("temperatures_at_stations.png", myplot)
## Saving 7 x 5 in image

Part 2

Variable for continuous time

temperature$decdate <- temperature$Year + temperature$dDay3/365

Create scatterplot of salinity and temperature over time

myplot = ggplot(temperature, aes(x = Salinity, y = temperature$decdate))
myplot + geom_point()
## Warning: Use of `temperature$decdate` is discouraged. Use `decdate` instead.
## Warning: Removed 798 rows containing missing values (geom_point).

Create scatterplot of salinity, grouped using facet_wrap() into different ‘Areas’

myplot = ggplot(temperature, aes(x = Salinity, y = decdate))
myplot + geom_point() + facet_wrap(~ Area)
## Warning: Removed 798 rows containing missing values (geom_point).

Create lineplot of salinity for each station, grouped into different ‘Areas’

myplot = ggplot(temperature, aes(x = Salinity, y = Station))
myplot + geom_line() + facet_wrap(~ Area)
## Warning: Removed 798 row(s) containing missing values (geom_path).

ggplot(subset(temperature, Area == "OS"), aes(x = Salinity, y = Station)) + geom_line() + geom_point()
## Warning: Removed 23 row(s) containing missing values (geom_path).
## Warning: Removed 23 rows containing missing values (geom_point).