

{"id":3364,"date":"2015-03-30T14:32:08","date_gmt":"2015-03-30T19:32:08","guid":{"rendered":"http:\/\/rud.is\/b\/?p=3364"},"modified":"2018-03-07T16:44:04","modified_gmt":"2018-03-07T21:44:04","slug":"3364","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/","title":{"rendered":"A look at airline crashes in R with googlesheets, dplyr &#038; ggplot2"},"content":{"rendered":"<p>Over on The DO Loop, @RickWicklin does a nice job [visualizing the causes of airline crashes](http:\/\/blogs.sas.com\/content\/iml\/2015\/03\/30\/visualizing-airline-crashes\/) in SAS using a mosaic plot. More often than not, I find mosaic plots can be a bit difficult to grok, but Rick&#8217;s use was spot on and I believe it shows the data pretty well, but I also thought I&#8217;d take the opportunity to:<\/p>\n<p>&#8211; Give @jennybc&#8217;s new [googlesheets](http:\/\/github.com\/jennybc\/googlesheets) a spin<br \/>\n&#8211; Show some `dplyr` &#038; `tidyr` data wrangling (never can have too many examples)<br \/>\n&#8211; Crank out some `ggplot` zero-based streamgraph-y area charts for the data with some extra `ggplot` wrangling for good measure<\/p>\n<p>I also decided to use the colors in the [original David McCandless\/Kashan visualization](http:\/\/www.informationisbeautiful.net\/visualizations\/plane-truth-every-single-commercial-plane-crash-visualized\/).<\/p>\n<p>#### Getting The Data<\/p>\n<p>As I mentioned, @jennybc made a really nice package to interface with Google Sheets, and the IIB site [makes the data available](https:\/\/docs.google.com\/spreadsheet\/ccc?key=0AjOUPqcIwvnjdEx2akx5ZjJXSk9oM1E3dWpqZFJ6Nmc&#038;usp=drive_web#gid=1), so I copied it to my Google Drive and gave her package a go:<\/p>\n<pre lang=\"rsplus\">library(googlesheets)\r\nlibrary(ggplot2) # we'll need the rest of the libraries later\r\nlibrary(dplyr)   # but just getting them out of the way\r\nlibrary(tidyr)\r\n\r\n# this will prompt for authentication the first time\r\nmy_sheets <- list_sheets()\r\n\r\n# which one is the flight data one\r\ngrep(\"Flight\", my_sheets$sheet_title, value=TRUE)\r\n\r\n## [1] \"Copy of Flight Risk JSON\" \"Flight Risk JSON\" \r\n\r\n# get the sheet reference then the data from the second tab\r\nflights <- register_ss(\"Flight Risk JSON\")\r\nflights_csv <- flights %>% get_via_csv(ws = \"93-2014 FINAL\")\r\n\r\n# take a quick look\r\nglimpse(flights_csv)\r\n\r\n## Observations: 440\r\n## Variables:\r\n## $ date       (chr) \"d\", \"1993-01-06\", \"1993-01-09\", \"1993-01-31\", \"1993-02-08\", \"1993-02-28\", \"...\r\n## $ plane_type (chr) \"t\", \"Dash 8-311\", \"Hawker Siddeley HS-748-234 Srs\", \"Shorts SC.7 Skyvan 3-1...\r\n## $ loc        (chr) \"l\", \"near Paris Charles de Gualle\", \"near Surabaya Airport\", \"Mt. Kapur\", \"...\r\n## $ country    (chr) \"c\", \"France\", \"Indonesia\", \"Indonesia\", \"Iran\", \"Taiwan\", \"Macedonia\", \"Nor...\r\n## $ ref        (chr) \"r\", \"D-BEAT\", \"PK-IHE\", \"9M-PID\", \"EP-ITD\", \"B-12238\", \"PH-KXL\", \"LN-TSA\", ...\r\n## $ airline    (chr) \"o\", \"Lufthansa Cityline\", \"Bouraq Indonesia\", \"Pan Malaysian Air Transport\"...\r\n## $ fat        (chr) \"f\", \"4\", \"15\", \"14\", \"131\", \"6\", \"83\", \"3\", \"6\", \"2\", \"32\", \"55\", \"132\", \"4...\r\n## $ px         (chr) \"px\", \"20\", \"29\", \"29\", \"67\", \"22\", \"56\", \"19\", \"22\", \"17\", \"38\", \"47\", \"67\"...\r\n## $ cat        (chr) \"cat\", \"A1\", \"A1\", \"A1\", \"A1\", \"A1\", \"A1\", \"A1\", \"A1\", \"A2\", \"A1\", \"A1\", \"A1...\r\n## $ phase      (chr) \"p\", \"approach\", \"initial_climb\", \"en_route\", \"en_route\", \"approach\", \"initi...\r\n## $ cert       (chr) \"cert\", \"confirmed\", \"probable\", \"probable\", \"confirmed\", \"probable\", \"confi...\r\n## $ meta       (chr) \"meta\", \"human_error\", \"mechanical\", \"weather\", \"human_error\", \"weather\", \"h...\r\n## $ cause      (chr) \"cause\", \"pilot & ATC error\", \"engine failure\", \"low visibility\", \"pilot err...\r\n## $ notes      (chr) \"n\", NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,...\r\n\r\n# the spreadsheet has a \"helper\" row for javascript, so we nix it\r\nflights_csv <- flights_csv[-1,] # js vars removal\r\n\r\n# and we convert some columns while we're at it\r\nflights_csv %>%\r\n  mutate(date=as.Date(date),\r\n         fat=as.numeric(fat),\r\n         px=as.numeric(px)) -> flights_csv<\/pre>\n<p>#### A Bit of Cleanup<\/p>\n<p>Despite being a spreadsheet, the data needs some cleanup and there&#8217;s no real need to include &#8220;grounded&#8221; or &#8220;unknown&#8221; in the flight phase given the limited number of incidents in those categories. I&#8217;d actually mention that descriptively near the visual if this were anything but a blog post. <\/p>\n<p>The area chart also needs full values for each category combo per year, so we use `expand` from `tidyr` with `left_join` and `mutate` to fill in the gaps.<\/p>\n<p>Finally, we make proper, ordered labels:<\/p>\n<pre lang=\"rsplus\">flights_csv %>%\r\n  mutate(year=as.numeric(format(date, \"%Y\"))) %>%\r\n  mutate(phase=tolower(phase),\r\n         phase=ifelse(grepl(\"take\", phase), \"takeoff\", phase),\r\n         phase=ifelse(grepl(\"climb\", phase), \"takeoff\", phase),\r\n         phase=ifelse(grepl(\"ap\", phase), \"approach\", phase)) %>%\r\n  count(year, meta, phase) %>%\r\n  left_join(expand(., year, meta, phase), ., c(\"year\", \"meta\", \"phase\")) %>% \r\n  mutate(n=ifelse(is.na(n), 0, n)) %>% \r\n  filter(!phase %in% c(\"grounded\", \"unknown\")) %>%\r\n  mutate(phase=factor(phase, \r\n                      levels=c(\"takeoff\", \"en_route\", \"approach\", \"landing\"),\r\n                      labels=c(\"Takeoff\", \"En Route\", \"Approach\", \"Landing\"),\r\n                      ordered=TRUE)) -> flights_dat<\/pre>\n<p>I probably took some liberties lumping &#8220;climb&#8221; in with &#8220;takeoff&#8221;, but I&#8217;d&#8217;ve asked an expert for a production piece just as I would hope folks doing work for infosec reports or visualizations would consult someone knowledgable in cybersecurity.<\/p>\n<p>#### The Final Plot<\/p>\n<p>I&#8217;m a big fan of an incremental, additive build idiom for `ggplot` graphics. By using the `gg <- gg + \u2026` style one can move lines around, comment them out, etc without dealing with errant `+` signs. It also forces a logical separation of ggplot elements. Personally, I tend to keep my build orders as follows:\n\n- main `ggplot` call with mappings if the graph is short, otherwise add the mappings to the `geom`s\n- all `geom_` or `stat_` layers in the order I want them, and using line breaks to logically separate elements (like `aes`) or to wrap long lines for easier readability.\n- all `scale_` elements in order from axes to line to shape to color to fill to alpha; I'm not as consistent as I'd like here, but keeping to this makes it really easy to quickly hone in on areas that need tweaking\n- `facet` call (if any)\n- label setting, always with `labs` unless I really have a need for using `ggtitle`\n- base `theme_` call\n- all other `theme` elements, one per `gg <- gg +` line\n\nI know that's not everyone's cup of tea, but it's just how I roll `ggplot`-style.\n\nFor this plot, I use a smoothed stacked plot with a custom smoother and also use Futura Medium for the text font. Substitute your own fav font if you don't have Futura Medium.\n\n\n\n<pre lang=\"rsplus\">flights_palette <- c(\"#702023\", \"#A34296\", \"#B06F31\", \"#939598\", \"#3297B0\")\r\n\r\ngg <- ggplot(flights_dat, aes(x=year, y=n, group=meta)) \r\ngg <- gg + stat_smooth(mapping=aes(fill=meta), geom=\"area\",\r\n                       position=\"stack\", method=\"gam\", formula=y~s(x)) \r\ngg <- gg + scale_fill_manual(name=\"Reason:\", values=flights_palette, \r\n                             labels=c(\"Criminal\", \"Human Error\",\r\n                                      \"Mechanical\", \"Unknown\", \"Weather\"))\r\ngg <- gg + scale_y_continuous(breaks=c(0, 5, 10, 13))\r\ngg <- gg + facet_grid(~phase)\r\ngg <- gg + labs(x=NULL, y=NULL, title=\"Crashes by year, by reason &#038; flight phase\")\r\ngg <- gg + theme_bw()\r\ngg <- gg + theme(legend.position=\"bottom\")\r\ngg <- gg + theme(text=element_text(family=\"Futura Medium\"))\r\ngg <- gg + theme(plot.title=element_text(face=\"bold\", hjust=0))\r\ngg <- gg + theme(panel.grid=element_blank())\r\ngg <- gg + theme(panel.border=element_blank())\r\ngg <- gg + theme(strip.background=element_rect(fill=\"#525252\"))\r\ngg <- gg + theme(strip.text=element_text(color=\"white\"))\r\ngg<\/pre>\n<p>That ultimately produces:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3365\" data-permalink=\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/flights\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png?fit=928%2C362&amp;ssl=1\" data-orig-size=\"928,362\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"flights\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png?fit=300%2C117&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png?fit=510%2C199&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png?resize=510%2C199&#038;ssl=1\" alt=\"flights\" width=\"510\" height=\"199\" class=\"aligncenter size-full wp-image-3365\" \/><\/p>\n<p>with the facets ordered by takeoff, flying, approaching landing and actual landing phases. Overall, things have gotten way better, though I haven&#8217;t had time to look in to the _bump_ between 2005 and 2010 for landing crashes.<\/p>\n<p>As an aside, Boeing has a [really nice PDF](http:\/\/www.boeing.com\/news\/techissues\/pdf\/statsum.pdf) on some of this data with quite a bit more detail.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over on The DO Loop, @RickWicklin does a nice job [visualizing the causes of airline crashes](http:\/\/blogs.sas.com\/content\/iml\/2015\/03\/30\/visualizing-airline-crashes\/) in SAS using a mosaic plot. More often than not, I find mosaic plots can be a bit difficult to grok, but Rick&#8217;s use was spot on and I believe it shows the data pretty well, but I also [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[24,678,673,674,91],"tags":[810],"class_list":["post-3364","post","type-post","status-publish","format-standard","hentry","category-charts-graphs","category-data-visualization","category-datavis-2","category-dataviz","category-r","tag-post"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>A look at airline crashes in R with googlesheets, dplyr &amp; ggplot2 - rud.is<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A look at airline crashes in R with googlesheets, dplyr &amp; ggplot2 - rud.is\" \/>\n<meta property=\"og:description\" content=\"Over on The DO Loop, @RickWicklin does a nice job [visualizing the causes of airline crashes](http:\/\/blogs.sas.com\/content\/iml\/2015\/03\/30\/visualizing-airline-crashes\/) in SAS using a mosaic plot. More often than not, I find mosaic plots can be a bit difficult to grok, but Rick&#8217;s use was spot on and I believe it shows the data pretty well, but I also [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2015-03-30T19:32:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-03-07T21:44:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png\" \/>\n<meta name=\"author\" content=\"hrbrmstr\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"hrbrmstr\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"A look at airline crashes in R with googlesheets, dplyr &#038; ggplot2\",\"datePublished\":\"2015-03-30T19:32:08+00:00\",\"dateModified\":\"2018-03-07T21:44:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/\"},\"wordCount\":354,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886\"},\"image\":{\"@id\":\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png\",\"keywords\":[\"post\"],\"articleSection\":[\"Charts &amp; Graphs\",\"Data Visualization\",\"DataVis\",\"DataViz\",\"R\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/\",\"url\":\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/\",\"name\":\"A look at airline crashes in R with googlesheets, dplyr & ggplot2 - rud.is\",\"isPartOf\":{\"@id\":\"https:\/\/rud.is\/b\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png\",\"datePublished\":\"2015-03-30T19:32:08+00:00\",\"dateModified\":\"2018-03-07T21:44:04+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png?fit=928%2C362&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png?fit=928%2C362&ssl=1\",\"width\":928,\"height\":362},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/rud.is\/b\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A look at airline crashes in R with googlesheets, dplyr &#038; ggplot2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/rud.is\/b\/#website\",\"url\":\"https:\/\/rud.is\/b\/\",\"name\":\"rud.is\",\"description\":\"&quot;In God we trust. All others must bring data&quot;\",\"publisher\":{\"@id\":\"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/rud.is\/b\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886\",\"name\":\"hrbrmstr\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1\",\"url\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1\",\"width\":460,\"height\":460,\"caption\":\"hrbrmstr\"},\"logo\":{\"@id\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1\"},\"description\":\"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7\",\"sameAs\":[\"http:\/\/rud.is\"],\"url\":\"https:\/\/rud.is\/b\/author\/hrbrmstr\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"A look at airline crashes in R with googlesheets, dplyr & ggplot2 - rud.is","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/","og_locale":"en_US","og_type":"article","og_title":"A look at airline crashes in R with googlesheets, dplyr & ggplot2 - rud.is","og_description":"Over on The DO Loop, @RickWicklin does a nice job [visualizing the causes of airline crashes](http:\/\/blogs.sas.com\/content\/iml\/2015\/03\/30\/visualizing-airline-crashes\/) in SAS using a mosaic plot. More often than not, I find mosaic plots can be a bit difficult to grok, but Rick&#8217;s use was spot on and I believe it shows the data pretty well, but I also [&hellip;]","og_url":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/","og_site_name":"rud.is","article_published_time":"2015-03-30T19:32:08+00:00","article_modified_time":"2018-03-07T21:44:04+00:00","og_image":[{"url":"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png","type":"","width":"","height":""}],"author":"hrbrmstr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hrbrmstr","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"A look at airline crashes in R with googlesheets, dplyr &#038; ggplot2","datePublished":"2015-03-30T19:32:08+00:00","dateModified":"2018-03-07T21:44:04+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/"},"wordCount":354,"commentCount":5,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"image":{"@id":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#primaryimage"},"thumbnailUrl":"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png","keywords":["post"],"articleSection":["Charts &amp; Graphs","Data Visualization","DataVis","DataViz","R"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/","url":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/","name":"A look at airline crashes in R with googlesheets, dplyr & ggplot2 - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#primaryimage"},"image":{"@id":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#primaryimage"},"thumbnailUrl":"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png","datePublished":"2015-03-30T19:32:08+00:00","dateModified":"2018-03-07T21:44:04+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2015\/03\/30\/3364\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#primaryimage","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png?fit=928%2C362&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/flights.png?fit=928%2C362&ssl=1","width":928,"height":362},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2015\/03\/30\/3364\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"A look at airline crashes in R with googlesheets, dplyr &#038; ggplot2"}]},{"@type":"WebSite","@id":"https:\/\/rud.is\/b\/#website","url":"https:\/\/rud.is\/b\/","name":"rud.is","description":"&quot;In God we trust. All others must bring data&quot;","publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rud.is\/b\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886","name":"hrbrmstr","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","width":460,"height":460,"caption":"hrbrmstr"},"logo":{"@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1"},"description":"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7","sameAs":["http:\/\/rud.is"],"url":"https:\/\/rud.is\/b\/author\/hrbrmstr\/"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/s23idr-3364","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":3127,"url":"https:\/\/rud.is\/b\/2014\/11\/26\/visualizing-historical-most-likely-first-snowfall-dates-for-u-s-regions\/","url_meta":{"origin":3364,"position":0},"title":"Visualizing Historical &#038; Most-likely First Snowfall Dates for U.S. Regions","author":"hrbrmstr","date":"2014-11-26","format":false,"excerpt":"UPDATE: You can now run this as a local Shiny app by entering shiny::runGist(\"95ec24c1b0cb433a76a5\", launch.browser=TRUE) at an R prompt (provided all the dependent libraries (below) are installed) or use it interactively over at Shiny Apps. The impending arrival of the first real snowfall of the year in my part of\u2026","rel":"","context":"In &quot;Charts &amp; Graphs&quot;","block_context":{"text":"Charts &amp; Graphs","link":"https:\/\/rud.is\/b\/category\/charts-graphs\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4285,"url":"https:\/\/rud.is\/b\/2016\/04\/12\/beating-lollipops-into-dumbbells\/","url_meta":{"origin":3364,"position":1},"title":"Beating lollipops into dumbbells","author":"hrbrmstr","date":"2016-04-12","format":false,"excerpt":"Shortly after I added lollipop charts to ggalt I had a few requests for a dumbbell geom. It wasn't difficult to do modify the underlying lollipop Geoms to make a geom_dumbbell(). Here it is in action: library(ggplot2) library(ggalt) # devtools::install_github(\"hrbrmstr\/ggalt\") library(dplyr) # from: https:\/\/plot.ly\/r\/dumbbell-plots\/ URL","rel":"","context":"In &quot;Charts &amp; Graphs&quot;","block_context":{"text":"Charts &amp; Graphs","link":"https:\/\/rud.is\/b\/category\/charts-graphs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3775,"url":"https:\/\/rud.is\/b\/2015\/11\/08\/visualizing_survey_data\/","url_meta":{"origin":3364,"position":2},"title":"Visualizing Survey Data : Comparison Between Observations","author":"hrbrmstr","date":"2015-11-08","format":false,"excerpt":"Cybersecurity is a domain that really likes surveys, or at the very least it has many folks within it that like to conduct and report on surveys. One recent survey on threat intelligence is in it's second year, so it sets about comparing answers across years. Rather than go into\u2026","rel":"","context":"In &quot;Cybersecurity&quot;","block_context":{"text":"Cybersecurity","link":"https:\/\/rud.is\/b\/category\/cybersecurity\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/11\/Visualizing_Survey_Data___Comparison_Between_Observations.png?fit=1200%2C721&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/11\/Visualizing_Survey_Data___Comparison_Between_Observations.png?fit=1200%2C721&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/11\/Visualizing_Survey_Data___Comparison_Between_Observations.png?fit=1200%2C721&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/11\/Visualizing_Survey_Data___Comparison_Between_Observations.png?fit=1200%2C721&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/11\/Visualizing_Survey_Data___Comparison_Between_Observations.png?fit=1200%2C721&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3756,"url":"https:\/\/rud.is\/b\/2015\/10\/24\/less-drama-more-encoding\/","url_meta":{"origin":3364,"position":3},"title":"Less Drama, More Encoding","author":"hrbrmstr","date":"2015-10-24","format":false,"excerpt":"Junk Charts [adeptly noted and fixed](http:\/\/junkcharts.typepad.com\/junk_charts\/2015\/10\/is-it-worth-the-drama.html) this excessively stylized chart from the WSJ this week: Their take on it does reduce the ZOMGOSH WE ARE DOOMED! look and feel of the WSJ chart: But, we can further reduce the drama by using a more neutral color encoding _and_ encode both\u2026","rel":"","context":"In &quot;Charts &amp; Graphs&quot;","block_context":{"text":"Charts &amp; Graphs","link":"https:\/\/rud.is\/b\/category\/charts-graphs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/10\/RStudio.png?fit=1200%2C724&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/10\/RStudio.png?fit=1200%2C724&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/10\/RStudio.png?fit=1200%2C724&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/10\/RStudio.png?fit=1200%2C724&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/10\/RStudio.png?fit=1200%2C724&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3498,"url":"https:\/\/rud.is\/b\/2015\/07\/09\/faceted-world-population-by-income-choropleths-in-ggplot\/","url_meta":{"origin":3364,"position":4},"title":"Faceted &#8220;World Population by Income&#8221; Choropleths in ggplot","author":"hrbrmstr","date":"2015-07-09","format":false,"excerpt":"Poynter did a nice interactive piece on world population by income (i.e. \"How Many Live on How Much, and Where\"). I'm always on the lookout for optimized shapefiles and clean data (I'm teaching a data science certificate program starting this Fall) and the speed of the site load and the\u2026","rel":"","context":"In &quot;cartography&quot;","block_context":{"text":"cartography","link":"https:\/\/rud.is\/b\/category\/cartography\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4225,"url":"https:\/\/rud.is\/b\/2016\/03\/30\/introducing-a-weekly-r-python-js-etc-vis-challenge\/","url_meta":{"origin":3364,"position":5},"title":"Introducing a Weekly R \/ Python \/ JS \/ etc Vis Challenge!","author":"hrbrmstr","date":"2016-03-30","format":false,"excerpt":">UPDATE: Deadline is now 2016-04-05 23:59 EDT; next vis challenge is 2016-04-06! Per a suggestion, I'm going to try to find a neat data set (prbly one from @jsvine) to feature each week and toss up some sample code (99% of the time prbly in R) and offer up a\u2026","rel":"","context":"In &quot;Charts &amp; Graphs&quot;","block_context":{"text":"Charts &amp; Graphs","link":"https:\/\/rud.is\/b\/category\/charts-graphs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/RStudioScreenSnapz024.png?fit=1200%2C605&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/RStudioScreenSnapz024.png?fit=1200%2C605&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/RStudioScreenSnapz024.png?fit=1200%2C605&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/RStudioScreenSnapz024.png?fit=1200%2C605&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/RStudioScreenSnapz024.png?fit=1200%2C605&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/3364","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/comments?post=3364"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/3364\/revisions"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=3364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=3364"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=3364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}