buffalo_snow: Historic Snowfall by Month for Buffalo

Description Usage Format Details References Examples

Description

A dataset containing historical monthly snowfall records. Columns are in character because of T cell values. The user will want to determine what T means, replace it with an appropriate value, and convert the columns to numeric.

Usage

1

Format

A data frame with 78 rows and 13 variables

Details

References

https://www.weather.gov/buf/BuffaloSnow

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## Not run: 
library(tidyverse)
library(exampledata)
library(viridis)

bufsnow <- buffalo_snow %>%
    gather(Month, Snow, - SEASON)  %>%
    extract(SEASON, c('Start'), '(\\d{4})-\\d{2}', remove = FALSE) %>%
    filter(!is.na(Snow)) %>%
    mutate(
        Month = gsub('(^.)(.+$)', '\\U\\1\\L\\2', Month, perl = TRUE)  %>%
            factor(levels = month.abb),
        Snow = replace_na(as.numeric(Snow), .01),
        Start = as.integer(Start),
        Year = case_when(as.integer(Month) %in% 1:6 ~ as.integer(Start + 1), TRUE ~ Start)
    ) %>%  
    rename(Season = SEASON) %>%
    arrange(Season, Year, Month) %>% 
    select(Season, Year, Month, Snow)


bufsnow %>%
    ggplot(aes(x = Month, y = Snow, color = as.factor(Year), group = Year)) +
        geom_line() +
        coord_polar()


bufsnow %>%
    mutate(Month = factor(Month, levels = c(month.abb[c(7:12, 1:6)]))) %>%
    ggplot(aes(x = Month, y = Season, fill= Snow)) +
    geom_tile() +
    scale_fill_viridis()


bufsnow %>%
    group_by(Season) %>%
    summarize(total = sum(Snow)) %>%
    ggplot(aes(y=total, x=Season, group = 1)) +
        geom_line(size = 1) +
        geom_point() +
        theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust =1))


## End(Not run)

trinker/exampledata documentation built on May 25, 2019, 8:32 p.m.