knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(dplyr) library(ggplot2) library(emphatic)
The raw challenger o-ring data shows the o-ring erosion and blow-by events on shuttle launches leading up to the Challenger disaster.
This dataset was sourced from tufte
Presented in order of launch date, there are obvious signs of damage on some flights, but it's difficult to see trends in this presentation.
library(dplyr) library(ggplot2) library(emphatic) challenger
When ordered by decreasing temperature, a trend is somewhat apparent in the data i.e. lower temperatures have more incidents.
Finding this trend still requires close inspection of the data.
challenger %>% arrange(desc(temp))
{emphatic}
The cluster of damage at lower temperatures is now much more visually apparent.
challenger %>% arrange(desc(temp)) %>% hl(palette = scale_color_viridis_c(option = 'B'), cols = 'temp') %>% hl( scale_color_gradient(low = 'pink', high = 'red'), rows = damage > 0, cols = damage )
{emphatic}
damage
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Expand temperature range to include challenger launch temperature #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ challenger_expanded <- challenger %>% mutate(temp = factor(temp, levels = 30:81)) %>% tidyr::complete(temp) %>% arrange(desc(temp)) %>% as.data.frame() %>% mutate(temp = as.numeric(levels(temp))[temp]) %>% select(flight, everything()) %>% mutate( flight = if_else(temp == 31, "Challenger", flight) ) challenger_expanded %>% hl(scale_color_viridis_c(option = 'B'), cols = temp, show_legend = TRUE) %>% hl( scale_color_gradient(low = 'lightblue', high = 'orange'), rows = !is.na(damage), cols = damage, show_legend = TRUE ) %>% hl('firebrick1', rows = temp == 31, cols = flight) %>% hl_adjust(na = '')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.