weather_data: Montgomery County Weather Data

Description Usage Format Details References Examples

Description

A dataset containing weather data for 2015-2017 for Montgomery County. Data scraped from https://www.wunderground.com/history/airport/KGAI. This data can be joined with the traffic_violations data. Note that 61 daya were missing from the scraped data for the 3 year period.

Usage

1

Format

A data frame with 1,035 rows and 3 variables

Details

References

https://www.wunderground.com/history/airport/KGAI

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
## Not run: 
library(exampledata)
library(tidyverse)
library(lubridate)


traffic_violations %>%
    count(`Date Of Stop`) %>%
    mutate(`Date Of Stop` = lubridate::mdy(`Date Of Stop`)) %>%
    left_join(weather_data, by = c(`Date Of Stop` = 'date')) %>%
    arrange(`Date Of Stop`) %>%
    dplyr::filter(temperature > 35) %>%
    ggplot(aes(precipitation, n)) +
        geom_jitter(alpha = .25) +
        coord_cartesian(xlim = c(0, 2.5), ylim = c(0, 1300)) +
        geom_smooth(fill = NA, method = 'loess')



traffic_violations %>%
    count(`Date Of Stop`) %>%
    mutate(`Date Of Stop` = lubridate::mdy(`Date Of Stop`)) %>%
    left_join(weather_data, by = c(`Date Of Stop` = 'date')) %>%
    arrange(`Date Of Stop`) %>%
    mutate(precipitation2 = cut(precipitation, 3, breaks = c(-Inf, 0, .15, Inf), labels = c('no', 'low', 'high'))) %>%  
    ggplot(aes(temperature, n, color = precipitation2)) +
        geom_jitter() +
        geom_smooth(fill = NA) +
        facet_wrap(~precipitation2)

## End(Not run)

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