The data used for the plots in these exercises is from the dataset Temperature.csv

temp = read.csv("Temperature.csv")

The ggplot() package is added into the markdown

library(ggplot2)

For the rest of the plots, we need a variable to represent continuous time from the start of the observations

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

Using this variable make a scatterplot of temperature and salinity over time

tempsal = ggplot(temp, aes(x=decdate, y=Salinity))
tempsal = tempsal + geom_point()
tempsal
## Warning: Removed 798 rows containing missing values or values outside the scale range
## (`geom_point()`).

Make a scatterplot of salinity, grouped using facet_wrap() into ‘Areas’

salarea = ggplot(temp, aes(x=decdate, y=Salinity))
salarea = salarea + geom_point() + facet_wrap(~ Area)
salarea
## Warning: Removed 798 rows containing missing values or values outside the scale range
## (`geom_point()`).

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

salstat = ggplot(temp, aes(x=decdate, y=Salinity))
salstat = salstat + facet_wrap(~ Area) + geom_line(aes(group=Station, color=Station))
salstat
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_line()`).

Bonus: Do the same as above but only for Area ‘OS’

os = ggplot(subset(temp, Area=="OS"), aes(x=decdate, y=Salinity)) + 
  geom_line(aes(color=Station)) + facet_wrap(~ Area)
os