Last active
August 21, 2018 20:25
-
-
Save kevinsoo/c5c172b38f94b52bd17210757dc6e6ab to your computer and use it in GitHub Desktop.
Visualization of California wildfire data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #### R4DS TidyTuesday 2018-08-21 | |
| #### Exploring California widfires | |
| #### https://github.com/rfordatascience/tidytuesday/tree/master/data/2018-08-21 | |
| #### By Kevin Soo | |
| # Load libraries | |
| library(tidyverse) | |
| library(gganimate) | |
| library(scales) | |
| # Load and clean data | |
| df <- read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2018-08-21/week21_calfire_frap.csv") %>% | |
| select(objectid:plot_date) %>% | |
| mutate(duration = as.numeric(cont_date - alarm_date)) | |
| # Plot | |
| df %>% | |
| select(fire_cause, year_, gis_acres, duration) %>% | |
| na.omit() %>% | |
| # Taking out outliers for ease of visualization | |
| filter(duration < 150, | |
| duration >= 0) %>% | |
| ggplot(aes(x = fire_cause, y = duration)) + | |
| geom_jitter(alpha = .5, aes(size = gis_acres, color = gis_acres)) + | |
| theme_dark() + | |
| scale_color_gradient(low = "red", high = "orange", breaks = seq(0, 500000, by = 100000), labels = comma, name = "Fire size (acres)") + | |
| guides(color = guide_legend(), size = guide_legend()) + | |
| scale_size_continuous(breaks = seq(0, 500000, by = 100000), labels = comma, name = "Fire size (acres)") + | |
| labs(x = "Cause of fire", y = "Days to containment", | |
| title = "California wildfires over time", | |
| subtitle = "Year: {frame_time}", | |
| caption = "Data from frap.fire.ca.gov") + | |
| transition_time(year_) + | |
| ease_aes('linear') + | |
| shadow_wake(wake_length = .1, wrap = FALSE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment