library(PASWR2)
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(plyr)
SEL <- ddply(PAMTEMP, .(year), summarize, Tmax = max(tmax), Tmin = min(tmin))
head(SEL)
year Tmax Tmin
1 1990 37.0 -5.6
2 1991 38.2 -5.2
3 1992 36.4 -4.4
4 1993 37.6 -4.5
5 1994 37.2 -6.8
6 1995 40.0 -5.0
#
ggplot(data = SEL, aes(x = year, y = Tmax)) +
geom_line(color = "red") +
geom_line(aes(x = year, y = Tmin), color = "blue") +
theme_bw() +
labs(y = "Temperature (Celcius)") +
geom_smooth(method = "lm") +
geom_smooth(aes(x = year, y = Tmin), method = "lm")
summary(lm(Tmax ~ year, data = SEL))
Call:
lm(formula = Tmax ~ year, data = SEL)
Residuals:
Min 1Q Median 3Q Max
-2.5376 -0.8475 -0.3030 0.6229 2.6723
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 27.482251 92.351247 0.298 0.769
year 0.004935 0.046175 0.107 0.916
Residual standard error: 1.281 on 19 degrees of freedom
Multiple R-squared: 0.0006008, Adjusted R-squared: -0.052
F-statistic: 0.01142 on 1 and 19 DF, p-value: 0.916
summary(lm(Tmin ~ year, data = SEL))
Call:
lm(formula = Tmin ~ year, data = SEL)
Residuals:
Min 1Q Median 3Q Max
-4.6261 -0.5147 0.2952 0.7377 3.9001
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 47.11991 136.65578 0.345 0.734
year -0.02623 0.06833 -0.384 0.705
Residual standard error: 1.896 on 19 degrees of freedom
Multiple R-squared: 0.007699, Adjusted R-squared: -0.04453
F-statistic: 0.1474 on 1 and 19 DF, p-value: 0.7053
PAMTEMP[which.max(PAMTEMP$precip), ]
tmax tmin precip day month year tmean
1455 8.6 4 69.2 25 Dec 1993 6.3
The largest precipitation on a single day was 69.2 mm on December 25, 1993.