

{"id":3455,"date":"2015-06-07T16:59:42","date_gmt":"2015-06-07T21:59:42","guid":{"rendered":"http:\/\/rud.is\/b\/?p=3455"},"modified":"2018-03-07T16:43:48","modified_gmt":"2018-03-07T21:43:48","slug":"animated-us-hexbin-map-of-the-avian-flu-outbreak","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/","title":{"rendered":"Animated US Hexbin Map of the Avian Flu Outbreak"},"content":{"rendered":"<p>The recent announcement of the [start of egg rationing in the U.S.](http:\/\/www.washingtonpost.com\/blogs\/wonkblog\/wp\/2015\/06\/05\/the-largest-grocer-in-the-texas-is-now-rationing-eggs\/) made me curious enough about the avian flu outbreak to try to dig into the numbers a bit. I finally stumbled upon a [USDA site](http:\/\/www.aphis.usda.gov\/wps\/portal\/aphis\/ourfocus\/animalhealth\/sa_animal_disease_information\/sa_avian_health\/sa_detections_by_states\/ct_ai_pacific_flyway\/!ut\/p\/a1\/lVPBkqIwEP2WOexpCxMBAY-oo6Kybo01q3JJNSGB1GCgSNTi7zcwe3CnZnQ3h1Sl-3X369cdlKADSiRcRA5aVBLK7p14ZLVd2sMJtqPFbvyMox-_5nGw8Z3t0jWAowHgL06I_47friOvi3_Bk-VsiHcO2qMEJVTqWhfoCHUhFKGV1ExqUoq0gab9hhWQ6twQXtGz6l8gxQlKUjAodXFryYRioBgRklfNqW_i3X0RIG_xGdOMdm5F0pYoDZqZ1FQTEKQGKrighJftFdqOX01Fho7c9iiAzS3HG6WWm2HbSnmAzYXxyA3AG1L-R487Df-TntNFuHT9jVHQDWwczUywP44xjrxH8b2eDzL0gHsj-1Bk8TwxReabn_56ZeP1CB0NSf9LFmMX7f5TtdXDtmYoib9z5YadQnYTT-PcVABdWN2s0eHuDry7b3agN3y2A-jw6Q4YfnlZpeZD7Ke3REKZOoEh0jDOGtYMikppdLher4OzymCQVxdUn15PgdMK6-0lwM7obR9ayTx_evoNPxBrVg!!\/?1dmy&#038;urile=wcm:path:\/APHIS_Content_Library\/SA_Our_Focus\/SA_Animal_Health\/SA_Animal_Disease_Information\/SA_Avian_Health\/SA_Detections_by_States\/) that had an embedded HTML table of flock outbreak statistics by state, county and date (also flock type and whether it was a commercial enterprise or &#8220;backyard&#8221; farm). Just looking at the sum of flock sizes on that page shows that nearly 50 million birds have been impacted since December, 2014. <\/p>\n<p>We can scrape the data with R &#038; `rvest` and then use the shapefile hexbins from [previous posts](http:\/\/rud.is\/b\/2015\/05\/15\/u-s-drought-monitoring-with-hexbin-state-maps-in-r\/) to watch the spread week-over-week.<\/p>\n<p>The number of packages I ended up relying on was a bit surprising. Let&#8217;s get them out of the way before focusing on the scraping and hexbin-making:<\/p>\n<pre lang=\"rsplus\">library(rvest)     # scraping\r\nlibrary(stringr)   # string manipulation\r\nlibrary(lubridate) # date conversion\r\nlibrary(dplyr)     # data mjnging\r\nlibrary(zoo)       # for locf\r\nlibrary(ggplot2)   # plotting\r\nlibrary(rgdal)     # map stuff\r\nlibrary(rgeos)     # map stuff<\/pre>\n<p>We also end up using `magrittr` and `tidyr` but only for one function, so you&#8217;ll see those with `::` in the code.<\/p>\n<p>Grabbing the USDA page is pretty straightforward:<\/p>\n<pre lang=\"rsplus\">url <- \"http:\/\/www.aphis.usda.gov\/wps\/portal\/aphis\/ourfocus\/animalhealth\/sa_animal_disease_information\/sa_avian_health\/ct_avian_influenza_disease\/!ut\/p\/a1\/lVJbb4IwFP41e1qwFZDLI-oUnGgyswm8kAMUaAaFQNG4X7-ibnEPYtakDz3nO_kupyhAHgoYHGgGnFYMiv4daOFqa8vjKZad5c58wc7mY-Eaa13Z2qoA-AKA7xwL_53fvjpaP_-Gp_Z8jHcK2qMABTHjNc-RD3VO2zCuGCeMhwWNGmhOT7iFsOqaMK3irj2_gNESijAnUPD8tpLQlkBLQsrSqinPJi7tAwX2i4_5tSBgRUfYF_wM9mLqmCbIj2QzxZpMJMUYg6TGkSLBBCaSPEnSJIljXVH0q_kBdw_CO5sXkNnSslV9LQJTDRk7czGumy7GjnYFDOTrCw36XRJTRbt_mlo9VD1FgfuctqrVByA37szNBAPwXOpzR97gPi7tm30gb2AfQkxWVJH4ifvZLavFIsUQrA1JSUOaUV61HHnH43HUtQmMsuqA6vK9NJST9JluNlKwyPr7DT6YvRs!\/?1dmy&#038;urile=wcm%3apath%3a%2Faphis_content_library%2Fsa_our_focus%2Fsa_animal_health%2Fsa_animal_disease_information%2Fsa_avian_health%2Fsa_detections_by_states%2Fct_ai_pacific_flyway\"\r\n\r\n#' read in the data, extract the table and clean up the fields\r\n#' also clean up the column names to since they are fairly nasty\r\n\r\npg <- html(url)<\/pre>\n<p>If you poke at the source for the page you'll see there are two tables in the code and we only need the first one. Also, if you scan the rendered table on the USDA page by eye you'll see that the column names are horrible for data analysis work and they are also inconsistent in the values used for various columns. Furthermore, there are commas in the flock counts and it would be handy to have the date as an actual date type. We can extract the table we need and clean all that up in a reasonably-sized `dplyr` pipe:<\/p>\n<pre lang=\"rsplus\">pg %>%\r\n  html_nodes(\"table\") %>%\r\n  magrittr::extract2(1) %>%\r\n  html_table(header=TRUE) %>%\r\n  filter(`Flock size`!=\"pending\") %>%\r\n  mutate(Species=str_replace(tolower(Species), \"s$\", \"\"),\r\n         `Avian influenza subtype*`=str_replace_all(`Avian influenza subtype*`, \" \", \"\"),\r\n         `Flock size`=as.numeric(str_replace_all(`Flock size`, \",\", \"\")),\r\n         `Confirmation date`=as.Date(mdy(`Confirmation date`))) %>%\r\n  rename(state=State, county=County, flyway=Flyway, flock_type=`Flock type`,\r\n         species=Species, subtype=`Avian influenza subtype*`, date=`Confirmation date`,\r\n         flock_size=`Flock size`) -> birds<\/pre>\n<p>Let's take a look at what we have:<\/p>\n<pre lang=\"rsplus\">glimpse(birds)\r\n\r\n## Observations: 202\r\n## Variables:\r\n## $ state      (chr) \"Iowa\", \"Minnesota\", \"Minnesota\", \"Iowa\", \"Minnesota\", \"Iowa\",...\r\n## $ county     (chr) \"Sac\", \"Renville\", \"Renville\", \"Hamilton\", \"Kandiyohi\", \"Hamil...\r\n## $ flyway     (chr) \"Mississippi\", \"Mississippi\", \"Mississippi\", \"Mississippi\", \"M...\r\n## $ flock_type (chr) \"Commercial\", \"Commercial\", \"Commercial\", \"Commercial\", \"Comme...\r\n## $ species    (chr) \"turkey\", \"chicken\", \"turkey\", \"turkey\", \"turkey\", \"turkey\", \"...\r\n## $ subtype    (chr) \"EA\/AM-H5N2\", \"EA\/AM-H5N2\", \"EA\/AM-H5N2\", \"EA\/AM-H5N2\", \"EA\/AM...\r\n## $ date       (date) 2015-06-04, 2015-06-04, 2015-06-04, 2015-06-04, 2015-06-03, 2...\r\n## $ flock_size (dbl) 42200, 415000, 24800, 19600, 37000, 26200, 17200, 1115700, 159...<\/pre>\n<p>To make an animated map of cumulative flock totals by week, we'll need to<\/p>\n<p>- group the `birds` data frame by week and state<br \/>\n- calculate the cumulative sums<br \/>\n- fill in the gaps where there are missing state\/week combinations<br \/>\n- carry the last observations by state\/week forward in this expanded data frame<br \/>\n- make breaks for data ranges so we can more intelligently map them to colors<\/p>\n<p>This ends up being a longer `dplyr` pipe than I usuall like to code (I think very long ones are hard to follow) but it gets the job done and is still pretty readable:<\/p>\n<pre lang=\"rsplus\">\r\nbirds %>%\r\n  mutate(week=as.numeric(format(birds$date, \"%Y%U\"))) %>%\r\n  arrange(week) %>%\r\n  group_by(week, state) %>%\r\n  tally(flock_size) %>%\r\n  group_by(state) %>%\r\n  mutate(cum=cumsum(n)) %>%\r\n  ungroup %>%\r\n  select(week, state, cum) %>%\r\n  mutate(week=as.Date(paste(week, 1), \"%Y%U %u\")) %>%\r\n  left_join(tidyr::expand(., week, state), .) %>%\r\n  group_by(state) %>%\r\n  do(na.locf(.)) %>%\r\n  mutate(state_abb=state.abb[match(state, state.name)],\r\n         cum=as.numeric(ifelse(is.na(cum), 0, cum)),\r\n         brks=cut(cum,\r\n                  breaks=c(0, 200, 50000, 1000000, 10000000, 50000000),\r\n                  labels=c(\"1-200\", \"201-50K\", \"50k-1m\",\r\n                           \"1m-10m\", \"10m-50m\"))) -> by_state_and_week<\/pre>\n<p>Now, we perform the standard animation steps:<\/p>\n<p>- determine where we're going to break the data up<br \/>\n- feed that into a loop<br \/>\n- partition the data in the loop<br \/>\n- render the plot to a file<br \/>\n- combine all the individual images into an animation<\/p>\n<p>For this graphic, I'm doing something a bit extra. The color ranges for the hexbin choropleth go from very light to very dark, so it would be helpful if the titles for the states went from very dark to very light, matching the state colors. The lines that do this check for state breaks that fall in the last two values and appropriately assign `\"black\"` or `\"white\"` as the color.<\/p>\n<pre lang=\"rsplus\">\r\ni <- 0\r\n\r\nfor (wk in unique(by_state_and_week$week)) {\r\n\r\n  # filter by week\r\n\r\n  by_state_and_week %>% filter(week==wk) -> this_wk\r\n\r\n  # hack to let us color the state labels in white or black depending on\r\n  # the value of the fill\r\n\r\n  this_wk %>%\r\n    filter(brks %in% c(\"1m-10m\", \"10m-50m\")) %>%\r\n    .$state_abb %>%\r\n    unique -> white_states\r\n\r\n  centers %>%\r\n    mutate(txt_col=\"black\") %>%\r\n    mutate(txt_col=ifelse(id %in% white_states, \"white\", \"black\")) -> centers\r\n\r\n  # setup the plot\r\n\r\n  gg <- ggplot()\r\n  gg <- gg + geom_map(data=us_map, map=us_map,\r\n                      aes(x=long, y=lat, map_id=id),\r\n                      color=\"white\", fill=\"#dddddd\", size=2)\r\n  gg <- gg + geom_map(data=this_wk, map=us_map,\r\n                      aes(fill=brks, map_id=state_abb),\r\n                      color=\"white\", size=2)\r\n  gg <- gg + geom_text(data=centers,\r\n                       aes(label=id, x=x, y=y, color=txt_col), size=4)\r\n  gg <- gg + scale_color_identity()\r\n  gg <- gg + scale_fill_brewer(name=\"Combined flock size\\n(all types)\",\r\n                               palette=\"RdPu\", na.value=\"#dddddd\", drop=FALSE)\r\n  gg <- gg + guides(fill=guide_legend(override.aes=list(colour=NA)))\r\n  gg <- gg + coord_map()\r\n  gg <- gg + labs(x=NULL, y=NULL,\r\n                  title=sprintf(\"U.S. Avian Flu Total Impact as of %s\\n\", wk))\r\n  gg <- gg + theme_bw()\r\n  gg <- gg + theme(plot.title=element_text(face=\"bold\", hjust=0, size=24))\r\n  gg <- gg + theme(panel.border=element_blank())\r\n  gg <- gg + theme(panel.grid=element_blank())\r\n  gg <- gg + theme(axis.ticks=element_blank())\r\n  gg <- gg + theme(axis.text=element_blank())\r\n  gg <- gg + theme(legend.position=\"bottom\")\r\n  gg <- gg + theme(legend.direction=\"horizontal\")\r\n  gg <- gg + theme(legend.title.align=1)\r\n\r\n  # save the image\r\n\r\n  # i'm using \"quartz\" here since I'm on a Mac. Use what works for you system to ensure you\r\n  # get the best looking output png\r\n\r\n  png(sprintf(\"output\/%03d.png\", i), width=800, height=500, type=\"quartz\")\r\n  print(gg)\r\n  dev.off()\r\n\r\n  i <- i + 1\r\n\r\n}<\/pre>\n<p>We could use one of the R animation packages to actually make the animation, but I know ImageMagick pretty well so I just call it as a `system` command:<\/p>\n<pre lang=\"rsplus\">system(\"convert -delay 60 -loop 1 output\/*png output\/avian.gif\")<\/pre>\n<p>All that results in:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3456\" data-permalink=\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/avian\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif?fit=800%2C500&amp;ssl=1\" data-orig-size=\"800,500\" 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=\"avian\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif?fit=300%2C188&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif?fit=510%2C319&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif?resize=510%2C319&#038;ssl=1\" alt=\"avian\" width=\"510\" height=\"319\" class=\"aligncenter size-full wp-image-3456\" \/><\/a><\/p>\n<p>If that's a static image, open it in a new tab\/window (or just click on it). I really didn't want to do a looping gif but if you do just make the `-loop 1` into `-loop 0`. <\/p>\n<p>Now, we can just re-run the code when the USDA refreshes the data.<\/p>\n<p>The code, data and sample bitmaps are on [github](https:\/\/github.com\/hrbrmstr\/avianflu).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The recent announcement of the [start of egg rationing in the U.S.](http:\/\/www.washingtonpost.com\/blogs\/wonkblog\/wp\/2015\/06\/05\/the-largest-grocer-in-the-texas-is-now-rationing-eggs\/) made me curious enough about the avian flu outbreak to try to dig into the numbers a bit. I finally stumbled upon a [USDA site](http:\/\/www.aphis.usda.gov\/wps\/portal\/aphis\/ourfocus\/animalhealth\/sa_animal_disease_information\/sa_avian_health\/sa_detections_by_states\/ct_ai_pacific_flyway\/!ut\/p\/a1\/lVPBkqIwEP2WOexpCxMBAY-oo6Kybo01q3JJNSGB1GCgSNTi7zcwe3CnZnQ3h1Sl-3X369cdlKADSiRcRA5aVBLK7p14ZLVd2sMJtqPFbvyMox-_5nGw8Z3t0jWAowHgL06I_47friOvi3_Bk-VsiHcO2qMEJVTqWhfoCHUhFKGV1ExqUoq0gab9hhWQ6twQXtGz6l8gxQlKUjAodXFryYRioBgRklfNqW_i3X0RIG_xGdOMdm5F0pYoDZqZ1FQTEKQGKrighJftFdqOX01Fho7c9iiAzS3HG6WWm2HbSnmAzYXxyA3AG1L-R487Df-TntNFuHT9jVHQDWwczUywP44xjrxH8b2eDzL0gHsj-1Bk8TwxReabn_56ZeP1CB0NSf9LFmMX7f5TtdXDtmYoib9z5YadQnYTT-PcVABdWN2s0eHuDry7b3agN3y2A-jw6Q4YfnlZpeZD7Ke3REKZOoEh0jDOGtYMikppdLher4OzymCQVxdUn15PgdMK6-0lwM7obR9ayTx_evoNPxBrVg!!\/?1dmy&#038;urile=wcm:path:\/APHIS_Content_Library\/SA_Our_Focus\/SA_Animal_Health\/SA_Animal_Disease_Information\/SA_Avian_Health\/SA_Detections_by_States\/) that had an embedded HTML table of flock outbreak statistics by state, county and date (also flock type [&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":[721,24,678,673,674,706,91],"tags":[810],"class_list":["post-3455","post","type-post","status-publish","format-standard","hentry","category-cartography","category-charts-graphs","category-data-visualization","category-datavis-2","category-dataviz","category-maps","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>Animated US Hexbin Map of the Avian Flu Outbreak - 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\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Animated US Hexbin Map of the Avian Flu Outbreak - rud.is\" \/>\n<meta property=\"og:description\" content=\"The recent announcement of the [start of egg rationing in the U.S.](http:\/\/www.washingtonpost.com\/blogs\/wonkblog\/wp\/2015\/06\/05\/the-largest-grocer-in-the-texas-is-now-rationing-eggs\/) made me curious enough about the avian flu outbreak to try to dig into the numbers a bit. I finally stumbled upon a [USDA site](http:\/\/www.aphis.usda.gov\/wps\/portal\/aphis\/ourfocus\/animalhealth\/sa_animal_disease_information\/sa_avian_health\/sa_detections_by_states\/ct_ai_pacific_flyway\/!ut\/p\/a1\/lVPBkqIwEP2WOexpCxMBAY-oo6Kybo01q3JJNSGB1GCgSNTi7zcwe3CnZnQ3h1Sl-3X369cdlKADSiRcRA5aVBLK7p14ZLVd2sMJtqPFbvyMox-_5nGw8Z3t0jWAowHgL06I_47friOvi3_Bk-VsiHcO2qMEJVTqWhfoCHUhFKGV1ExqUoq0gab9hhWQ6twQXtGz6l8gxQlKUjAodXFryYRioBgRklfNqW_i3X0RIG_xGdOMdm5F0pYoDZqZ1FQTEKQGKrighJftFdqOX01Fho7c9iiAzS3HG6WWm2HbSnmAzYXxyA3AG1L-R487Df-TntNFuHT9jVHQDWwczUywP44xjrxH8b2eDzL0gHsj-1Bk8TwxReabn_56ZeP1CB0NSf9LFmMX7f5TtdXDtmYoib9z5YadQnYTT-PcVABdWN2s0eHuDry7b3agN3y2A-jw6Q4YfnlZpeZD7Ke3REKZOoEh0jDOGtYMikppdLher4OzymCQVxdUn15PgdMK6-0lwM7obR9ayTx_evoNPxBrVg!!\/?1dmy&#038;urile=wcm:path:\/APHIS_Content_Library\/SA_Our_Focus\/SA_Animal_Health\/SA_Animal_Disease_Information\/SA_Avian_Health\/SA_Detections_by_States\/) that had an embedded HTML table of flock outbreak statistics by state, county and date (also flock type [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2015-06-07T21:59:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-03-07T21:43:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif\" \/>\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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"Animated US Hexbin Map of the Avian Flu Outbreak\",\"datePublished\":\"2015-06-07T21:59:42+00:00\",\"dateModified\":\"2018-03-07T21:43:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/\"},\"wordCount\":752,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886\"},\"image\":{\"@id\":\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif\",\"keywords\":[\"post\"],\"articleSection\":[\"cartography\",\"Charts &amp; Graphs\",\"Data Visualization\",\"DataVis\",\"DataViz\",\"maps\",\"R\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/\",\"url\":\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/\",\"name\":\"Animated US Hexbin Map of the Avian Flu Outbreak - rud.is\",\"isPartOf\":{\"@id\":\"https:\/\/rud.is\/b\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif\",\"datePublished\":\"2015-06-07T21:59:42+00:00\",\"dateModified\":\"2018-03-07T21:43:48+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif?fit=800%2C500&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif?fit=800%2C500&ssl=1\",\"width\":800,\"height\":500},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/rud.is\/b\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Animated US Hexbin Map of the Avian Flu Outbreak\"}]},{\"@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":"Animated US Hexbin Map of the Avian Flu Outbreak - 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\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/","og_locale":"en_US","og_type":"article","og_title":"Animated US Hexbin Map of the Avian Flu Outbreak - rud.is","og_description":"The recent announcement of the [start of egg rationing in the U.S.](http:\/\/www.washingtonpost.com\/blogs\/wonkblog\/wp\/2015\/06\/05\/the-largest-grocer-in-the-texas-is-now-rationing-eggs\/) made me curious enough about the avian flu outbreak to try to dig into the numbers a bit. I finally stumbled upon a [USDA site](http:\/\/www.aphis.usda.gov\/wps\/portal\/aphis\/ourfocus\/animalhealth\/sa_animal_disease_information\/sa_avian_health\/sa_detections_by_states\/ct_ai_pacific_flyway\/!ut\/p\/a1\/lVPBkqIwEP2WOexpCxMBAY-oo6Kybo01q3JJNSGB1GCgSNTi7zcwe3CnZnQ3h1Sl-3X369cdlKADSiRcRA5aVBLK7p14ZLVd2sMJtqPFbvyMox-_5nGw8Z3t0jWAowHgL06I_47friOvi3_Bk-VsiHcO2qMEJVTqWhfoCHUhFKGV1ExqUoq0gab9hhWQ6twQXtGz6l8gxQlKUjAodXFryYRioBgRklfNqW_i3X0RIG_xGdOMdm5F0pYoDZqZ1FQTEKQGKrighJftFdqOX01Fho7c9iiAzS3HG6WWm2HbSnmAzYXxyA3AG1L-R487Df-TntNFuHT9jVHQDWwczUywP44xjrxH8b2eDzL0gHsj-1Bk8TwxReabn_56ZeP1CB0NSf9LFmMX7f5TtdXDtmYoib9z5YadQnYTT-PcVABdWN2s0eHuDry7b3agN3y2A-jw6Q4YfnlZpeZD7Ke3REKZOoEh0jDOGtYMikppdLher4OzymCQVxdUn15PgdMK6-0lwM7obR9ayTx_evoNPxBrVg!!\/?1dmy&#038;urile=wcm:path:\/APHIS_Content_Library\/SA_Our_Focus\/SA_Animal_Health\/SA_Animal_Disease_Information\/SA_Avian_Health\/SA_Detections_by_States\/) that had an embedded HTML table of flock outbreak statistics by state, county and date (also flock type [&hellip;]","og_url":"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/","og_site_name":"rud.is","article_published_time":"2015-06-07T21:59:42+00:00","article_modified_time":"2018-03-07T21:43:48+00:00","og_image":[{"url":"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif","type":"","width":"","height":""}],"author":"hrbrmstr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hrbrmstr","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"Animated US Hexbin Map of the Avian Flu Outbreak","datePublished":"2015-06-07T21:59:42+00:00","dateModified":"2018-03-07T21:43:48+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/"},"wordCount":752,"commentCount":3,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"image":{"@id":"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#primaryimage"},"thumbnailUrl":"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif","keywords":["post"],"articleSection":["cartography","Charts &amp; Graphs","Data Visualization","DataVis","DataViz","maps","R"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/","url":"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/","name":"Animated US Hexbin Map of the Avian Flu Outbreak - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#primaryimage"},"image":{"@id":"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#primaryimage"},"thumbnailUrl":"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif","datePublished":"2015-06-07T21:59:42+00:00","dateModified":"2018-03-07T21:43:48+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#primaryimage","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif?fit=800%2C500&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/06\/avian.gif?fit=800%2C500&ssl=1","width":800,"height":500},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2015\/06\/07\/animated-us-hexbin-map-of-the-avian-flu-outbreak\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"Animated US Hexbin Map of the Avian Flu Outbreak"}]},{"@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\/p23idr-TJ","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":4805,"url":"https:\/\/rud.is\/b\/2017\/01\/02\/removing-personal-bias-from-flu-severity-estimation-a-k-a-misery-loves-data\/","url_meta":{"origin":3455,"position":0},"title":"Removing Personal Bias From Flu Severity Estimation (a.k.a. Misery Loves Data)","author":"hrbrmstr","date":"2017-01-02","format":false,"excerpt":"The family got hit pretty hard with the flu right as the Christmas festivities started and we were all pretty much bed-ridden zombies up until today (2017-01-02). When in the throes of a very bad ILI it's easy to imagine that you're a victim of a severe outbreak, especially with\u2026","rel":"","context":"In &quot;ggplot&quot;","block_context":{"text":"ggplot","link":"https:\/\/rud.is\/b\/category\/ggplot\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/Cursor_and___Development_cdcfluview_-_master_-_RStudio-1.png?fit=1200%2C610&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/Cursor_and___Development_cdcfluview_-_master_-_RStudio-1.png?fit=1200%2C610&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/Cursor_and___Development_cdcfluview_-_master_-_RStudio-1.png?fit=1200%2C610&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/Cursor_and___Development_cdcfluview_-_master_-_RStudio-1.png?fit=1200%2C610&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/Cursor_and___Development_cdcfluview_-_master_-_RStudio-1.png?fit=1200%2C610&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3215,"url":"https:\/\/rud.is\/b\/2015\/01\/10\/new-r-package-cdcfluview-retrieve-flu-data-from-cdcs-fluview-portal\/","url_meta":{"origin":3455,"position":1},"title":"New R Package: cdcfluview \u2014 Retrieve Flu Data from CDC&#8217;s FluView Portal","author":"hrbrmstr","date":"2015-01-10","format":false,"excerpt":"**NOTE** If there's a particular data set from http:\/\/www.cdc.gov\/flu\/weekly\/fluviewinteractive.htm that you want and that isn't in the pacakge, please file it as an issue and be as specific as you can (screen shot if possible). ----- Towards the end of 2014 I had been tinkering with flu data from the\u2026","rel":"","context":"In &quot;DataVis&quot;","block_context":{"text":"DataVis","link":"https:\/\/rud.is\/b\/category\/datavis-2\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3610,"url":"https:\/\/rud.is\/b\/2015\/08\/09\/cdcfluview-on-the-way-to-cran-7k\/","url_meta":{"origin":3455,"position":2},"title":"cdcfluview &#8211; On The Way to &#8220;CRAN 7K&#8221;","author":"hrbrmstr","date":"2015-08-09","format":false,"excerpt":"I like to turn coincidence into convergence whenever possible. This weekend, a user of [cdcfluview](http:\/\/github.com\/hrbrmstr\/cdcfluview) had a question that caused me to notice a difference in behaviour between the package was interacting with CDC FluView API, so I updated the package to accommodate the change and the user. Around the\u2026","rel":"","context":"In &quot;Data Analysis&quot;","block_context":{"text":"Data Analysis","link":"https:\/\/rud.is\/b\/category\/data-analysis-2\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1640,"url":"https:\/\/rud.is\/b\/2012\/10\/08\/diy-zeroaccess-geoip-analysis-so-what\/","url_meta":{"origin":3455,"position":3},"title":"DIY ZeroAccess GeoIP Analysis : So What?","author":"hrbrmstr","date":"2012-10-08","format":false,"excerpt":"NOTE: A great deal of this post comes from @jayjacobs as he took a conversation we were having about thoughts on ways to look at the data and just ran like the Flash with it. Did you know that \u2013\u00a0if you're a US citizen \u2013\u00a0you have approximately a 1 in\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":3262,"url":"https:\/\/rud.is\/b\/2015\/02\/04\/a-step-to-the-right-in-r-assignments\/","url_meta":{"origin":3455,"position":4},"title":"A Step to the Right in R Assignments","author":"hrbrmstr","date":"2015-02-04","format":false,"excerpt":"I received an out-of-band question on the use of `%%` in my [CDC FluView](rud.is\/b\/2015\/01\/10\/new-r-package-cdcfluview-retrieve-flu-data-from-cdcs-fluview-portal\/) post, and took the opportunity to address it in a broader, public fashion. Anyone using R knows that the two most common methods of assignment are the venerable (and sensible) left arrow `` RHS assignment operator.\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/rud.is\/b\/category\/programming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7020,"url":"https:\/\/rud.is\/b\/2017\/11\/06\/taking-a-shot-at-cdcfluview-v0-7-0-a-k-a-the-dangers-of-relying-on-hidden-apis\/","url_meta":{"origin":3455,"position":5},"title":"Taking a Shot at cdcfluview v0.7.0 (a.k.a. The Dangers of Relying on &#8216;Hidden&#8217; APIs)","author":"hrbrmstr","date":"2017-11-06","format":false,"excerpt":"Unlike @noamross, I am not an epidemiologist (NOTE: Noam battles pandemics before breakfast, so be super nice to him) but I do like to find kindred methodologies in other disciplines to help foster the growth of cybersecurity into something beyond it's current Barnum & Bailey state. I also love finding\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/11\/unnamed-chunk-5-4.png?fit=672%2C480&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/11\/unnamed-chunk-5-4.png?fit=672%2C480&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/11\/unnamed-chunk-5-4.png?fit=672%2C480&ssl=1&resize=525%2C300 1.5x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/3455","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=3455"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/3455\/revisions"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=3455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=3455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=3455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}