temp <- read.csv("Temperature.csv")
library(ggplot2)Module07 Part2
Read the data
Make time series plots of temperature and salinity
temp$decdate <- temp$Year + temp$dDay3 / 365Make a scatterplot of temperature and salinity
a) Temperature
ggplot(temp, aes(x = decdate, y = Temperature)) + geom_point(color = 'darkorange', na.rm = TRUE) + ggtitle("Temperature over Time")b) Salinity
ggplot(temp, aes(x = decdate, y = Salinity)) + geom_point(color = 'darkcyan', na.rm = TRUE) + ggtitle("Salinity over Time")Make a scatterplot of salinity grouped by different areas
ggplot(temp, aes(x = decdate, y = Salinity)) + geom_point(color = 'tomato1', na.rm = TRUE, alpha = 0.5) + facet_wrap(~ Area) + ggtitle("Salinity over Time by Area")Make a lineplot of salinity for each station, grouped by different areas
ggplot(temp, aes(x = decdate, y = Salinity, group = Station, color = Station)) + geom_line(na.rm = TRUE) + facet_wrap(~ Area) + ggtitle("Salinity per Station by Area")Bonus: do the same but only for area ‘OS’
osdata <- subset(temp, Area == "OS")
ggplot(osdata, aes(x = decdate, y = Salinity, group = Station, color = Station)) + geom_line(na.rm = TRUE) + ggtitle("Salinity per Station in OS")