Temp <- read.csv("Temperature.csv")
ls(Temp)
## [1] "Area" "CHLFa" "Date" "DateNr" "dDay1"
## [6] "dDay2" "dDay3" "Month" "Salinity" "Sample"
## [11] "Season" "Station" "Temperature" "X31UE_ED50" "X31UN_ED50"
## [16] "Year"
library(ggplot2)
library(reshape2)
-Next we will utilize ggplot() to produce a histogram of salinity values
qplot(Salinity, data = Temp, geom = 'histogram', binwidth = 0.25)
## Warning: Removed 798 rows containing non-finite values (stat_bin).
-Then we will create a histogram of salinity values for each, and then
each month of the study.
tempplot = ggplot(Temp, aes(x = Salinity))
tempplot + geom_histogram(binwidth = 1)
## Warning: Removed 798 rows containing non-finite values (stat_bin).
tempplot + geom_histogram(aes(fill = Year), position = "identity")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 798 rows containing non-finite values (stat_bin).
tempplot + geom_histogram(fill = 'darkorange', binwidth = 1) +
facet_wrap(Temp$Year)
## Warning: Removed 798 rows containing non-finite values (stat_bin).
tempplot + geom_histogram(fill = 'olivedrab', binwidth = 1) +
facet_wrap(Temp$Month)
## Warning: Removed 798 rows containing non-finite values (stat_bin).
As you can see by the two graphs, I was able to utilize the face_wrap()
feature to create different graphs for each of the months and years. -
Next we created a boxplot based on the temperature values of each
station.
tempbox = ggplot(Temp, aes(x = Temperature, y = Station))
tempbox + geom_boxplot()
## Warning: Removed 927 rows containing non-finite values (stat_boxplot).
ggsave("temp_vs_station_.png", tempbox)
## Saving 7 x 5 in image
-Finally as a bonus we attempted to reorganize the boxplot from low to high median temperatures.
tempbox + geom_boxplot(aes(x = reorder(Station, Temperature, median)))
- Dont really know if I did this right. Looks like a man-made horror far
beyond my comprehension.
Temp$decdate <- Temp$Year + Temp$dDay3 / 365
timeplot = ggplot(Temp, aes(x = Salinity, y = Temperature))
timeplot + geom_point()
## Warning: Removed 963 rows containing missing values (geom_point).
timeplot = ggplot(Temp, aes(x = Salinity, y = Temperature, color = decdate))
timeplot + geom_point() + scale_x_log10()
## Warning: Removed 963 rows containing missing values (geom_point).
timeplot + geom_point() + geom_smooth(method = 'lm')
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 963 rows containing non-finite values (stat_smooth).
## Warning: Removed 963 rows containing missing values (geom_point).
- Now utilizing the facet_wraap() command, we made a scatterplot of
salinity grouped into different ‘Areas’:
scatsal = ggplot(Temp, aes(x = Salinity, y = Temperature))
scatsal + geom_point()
## Warning: Removed 963 rows containing missing values (geom_point).
scatsal + geom_point(color = 'lightblue', fill = 'white') + facet_wrap(~Area)
## Warning: Removed 963 rows containing missing values (geom_point).
- Finally we created a lineplot of salinity for each station grouped by
area.
scatsal = ggplot(Temp, aes(x = Salinity, y = Station))
scatsal + geom_line() + scale_x_log10()
## Warning: Removed 798 row(s) containing missing values (geom_path).
scatsal + geom_line(color = 'olivedrab', fill = 'white') + facet_wrap(~Area)
## Warning: Ignoring unknown parameters: fill
## Warning: Removed 798 row(s) containing missing values (geom_path).