globaltemp <- read_csv("data/globaltemp.csv",
col_types = cols(Dec = col_double()))
temp <- globaltemp[, 1:13]
temp <- na.omit(temp)
temp <-
gather(
data = temp,
key = Month,
value = Value,
na.rm = FALSE,
Jan,Feb,Mar,Apr,May,Jun,
Jul,Aug,Sep,Oct,Nov,Dec
)
temp$Month <- factor(temp$Month, levels = month.abb)
temp <- temp %>% arrange(Year,Month)saveGIF({
for (i in 1:136) {
print(
ggplot(temp[1:(12 * i), ], aes(
x = Year, y = Value, color = Month
)) + xlim(1880, 2015) + ylim(-1.11, 1.11) +
geom_line(alpha = 0.3) + theme_fivethirtyeight() +
ggtitle("Global temperature change 1880 ~ 2015") + theme(legend.position = "none")
)
}
}, interval = 0.1, ani.width = 800, ani.height = 450)