Looking at weather trends through years can help pick out weather anomalies. The figures below show rain as it accumulated through the years 2000-2016 in Madison, WI.

The data was generated through calling historical weather data from https://www.wunderground.com/history/ with the following code.

rain_data <- function(location, year) {
        #download data from wunderground, create one data frame containing all months with year to date
        mo <- list()
        for(i in 1:12) {
                url <- paste0("http://www.wunderground.com/history/airport/",location, "/", year, "/", i, "/1/MonthlyHistory.html?format=1")
                download.file(url = url, destfile = paste0("./mo", i, ".csv"))
                mon <- read.csv(paste0("./mo", i, ".csv"), header = FALSE)[-1 ,c(1, 20)]
                mo[[i]] <- mon
        }
        deg_data <- do.call(rbind, mo) #data frame with date and precipitation for each month
        names(deg_data) <- c("Date", "Precip")
        # create text file
        filename <- paste(location, "_", year, ".txt", sep="")
        write.table(deg_data, filename, sep = "\t", row.names = FALSE)
}

The data from each year could be called with the function by inserting the airport code “KMSN” and the desired year. For example,

rain_data("KMSN", 2016)

Each year’s data was further processed by adding a column for that year, an interger column that represented calendar date and adding a column that kept track of the accumulation of precipitation. When all years were read into R as dataframes, they were combined into one dataframe with a call to rbind.

This first figure shows the pattern of accumulation throughout the year. When dragging your mouse across the figure, cal = calendar date, and cum = accumulation of precipitation to date.

The second figure shows the total precipitation for a given year in Madison.

We can see that there is a great amount of variation from year to year. The next step will be to go back further in the history of recorded weather on https://www.wunderground.com/history/ to see if there are any interesting trends.