Update your PASWR2 package from http://github.com/alanarnholt/PASWR2 by following the directions. First we will change the levels of month from alphabetical to their proper order.
library(PASWR2)
summary(PAMTEMP)
tmax tmin precip day
Min. :-1.50 Min. :-10.000 Min. : 0.000 Min. : 1.00
1st Qu.:11.50 1st Qu.: 4.000 1st Qu.: 0.000 1st Qu.: 8.00
Median :17.20 Median : 8.000 Median : 0.000 Median :16.00
Mean :17.96 Mean : 8.152 Mean : 2.139 Mean :15.73
3rd Qu.:24.00 3rd Qu.: 12.600 3rd Qu.: 1.200 3rd Qu.:23.00
Max. :40.00 Max. : 23.500 Max. :69.200 Max. :31.00
month year tmean
Aug : 651 Min. :1990 Min. :-4.00
Dec : 651 1st Qu.:1995 1st Qu.: 7.90
Mar : 651 Median :2000 Median :12.50
Oct : 651 Mean :2000 Mean :13.06
Jun : 630 3rd Qu.:2005 3rd Qu.:18.20
Nov : 630 Max. :2010 Max. :31.00
(Other):3683
levels(PAMTEMP$month)
[1] "Apr" "Aug" "Dec" "Feb" "Jan" "Jul" "Jun" "Mar" "May" "Nov" "Oct"
[12] "Sep"
PAMTEMP$month <- factor(PAMTEMP$month, levels = month.abb[1:12])
levels(PAMTEMP$month)
[1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov"
[12] "Dec"
library(ggplot2)
ggplot(data = PAMTEMP, aes(x = 1:dim(PAMTEMP)[1], y = tmean)) +
geom_line() +
theme_bw() +
labs(x = "", y = "Average Temperature (Celcius)")
Now some side-by-side violin plots.
ggplot(data = PAMTEMP) +
geom_violin(aes(x = month, y = tmean, fill = month)) +
theme_bw() +
guides(fill = FALSE) +
labs(x = "", y = "Temperature (Celcius)")
ggplot(data = PAMTEMP) +
geom_violin(aes(x = as.factor(year), y = tmean, fill = as.factor(year))) +
theme_bw() +
guides(fill = FALSE) +
labs(x = "", y = "Temperature (Celcius)")