

{"id":12667,"date":"2020-03-02T07:00:10","date_gmt":"2020-03-02T12:00:10","guid":{"rendered":"https:\/\/rud.is\/b\/?p=12667"},"modified":"2020-03-02T07:07:55","modified_gmt":"2020-03-02T12:07:55","slug":"make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/","title":{"rendered":"Make WSJ-esque \u00dcber Tuesday Democrat Delegate Cartograms in R with {catchpole}"},"content":{"rendered":"<p>For folks who are smart enough not to go near Twitter, I&#8217;ve been on a hiatus from the platform insofar as reading the Twitter feed goes. &#8220;Why&#8221; isn&#8217;t the subject of this post so I won&#8217;t go into it, but I&#8217;ve broken this half-NYE resolution on more than one occasion and am very glad I did so late January when I caught a RT of this tweet by WSJ&#8217;s Brian McGill:<\/p>\n<blockquote class=\"twitter-tweet\">\n<p lang=\"en\" dir=\"ltr\">You guys! I spent 2 days making a cartogram by hand with 3,979 freaking squares on it. One for each delegate to the Democratic National Convention. Never doing it again.* Apologies to Georgia, you got the short end of the stick shape-wise.<br \/>.<br \/>.<br \/>.<br \/>.<br \/>*absolutely going to to it again <a href=\"https:\/\/t.co\/1qIgUw1oIc\">pic.twitter.com\/1qIgUw1oIc<\/a><\/p>\n<p>&mdash; Brian McGill (@brian_mcgill) <a href=\"https:\/\/twitter.com\/brian_mcgill\/status\/1222556373864648704?ref_src=twsrc%5Etfw\">January 29, 2020<\/a><\/p><\/blockquote>\n<p><script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n<p>You can find it <a href=\"https:\/\/www.wsj.com\/graphics\/elections\/2020\/track-the-delegate-count\/\">here<\/a>, and a static copy of a recent one is below:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"12668\" data-permalink=\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/wsj-map\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?fit=1990%2C1258&amp;ssl=1\" data-orig-size=\"1990,1258\" 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=\"wsj-map\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?fit=300%2C190&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?fit=510%2C322&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?resize=510%2C322&#038;ssl=1\" alt=\"\" width=\"510\" height=\"322\" class=\"aligncenter size-full wp-image-12668\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?w=1990&amp;ssl=1 1990w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?resize=300%2C190&amp;ssl=1 300w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?resize=530%2C335&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?resize=150%2C95&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?resize=768%2C485&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?resize=1536%2C971&amp;ssl=1 1536w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?resize=500%2C316&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?resize=1200%2C759&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?resize=400%2C253&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?resize=800%2C506&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?resize=200%2C126&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/wsj-map.png?w=1020&amp;ssl=1 1020w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<p>I kinda wanted to try to make a woefully imperfect static version of it in R with {ggplot2} so poked around at that URL&#8217;s XHR objects and javascript to see if I could find the cartogram and the data source.<\/p>\n<p>The data source was easy as it&#8217;s an XHR loaded JSON file: <a href=\"https:\/\/asset.wsj.net\/wsjnewsgraphics\/election\/2020\/delegates.json\">https:\/\/asset.wsj.net\/wsjnewsgraphics\/election\/2020\/delegates.json<\/a>.<\/p>\n<p>The cartogram bits&hellip; were <em>not<\/em>. Brian&#8217;s two-days of manual effort still needed to be put into something that goes onto a web page and news outlets are super-talented at making compact, fast-loading interactive visualizations, which means one tool they use is &#8220;webpack&#8221;-esque tools to combine many small javascript files into one. I did traipse through it seeing if there as a back-end JSON or CSV somewhere but could not locate it. However, their cartogram library builds the SVG you see on the page. If you use Developer Tools to inspect any element of the SVG then copy the whole SVG &#8220;outer HTML&#8221; and save it to a local file:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"12670\" data-permalink=\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/svg-copy\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?fit=2606%2C1002&amp;ssl=1\" data-orig-size=\"2606,1002\" 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=\"svg-copy\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?fit=300%2C115&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?fit=510%2C196&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?resize=510%2C196&#038;ssl=1\" alt=\"\" width=\"510\" height=\"196\" class=\"aligncenter size-full wp-image-12670\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?w=2606&amp;ssl=1 2606w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?resize=300%2C115&amp;ssl=1 300w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?resize=530%2C204&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?resize=150%2C58&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?resize=768%2C295&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?resize=1536%2C591&amp;ssl=1 1536w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?resize=2048%2C787&amp;ssl=1 2048w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?resize=500%2C192&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?resize=1200%2C461&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?resize=400%2C154&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?resize=800%2C308&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?resize=200%2C77&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/svg-copy.png?w=1020&amp;ssl=1 1020w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<p>After using an intercept proxy, it turns out this is a dynamically loaded resource, too: <a href=\"https:\/\/asset.wsj.net\/wsjnewsgraphics\/election\/delegate-tracker\/carto.svg\">https:\/\/asset.wsj.net\/wsjnewsgraphics\/election\/delegate-tracker\/carto.svg<\/a>.<\/p>\n<p>That SVG has three top layer groups and has some wicked transforms in it. There was no way I was going to attempt a {statebins}-esque approach to this copycat project (i.e. convert the squares to a grid and map things manually like Brian did) but I had an idea and used Adobe Illustrator to remove the state names layer and the background polygon layer, then &#8220;flatten&#8221; the image (which &#8212; to over-simplify the explanation &#8212; flattens all the transforms), and save it back out.<\/p>\n<p>Then, I added a some magic metadata prescribed by <a href=\"https:\/\/www.npmjs.com\/package\/svg2geojson\"><code>svg2geojson<\/code><\/a> to turn the SVG into a GeoJSON file (which {sf} can read!). (That sentence just made real cartographers &amp; geocomp&#8217;ers weep, btw).<\/p>\n<p>Now, that I had something R could use in a bit of an easier fashion there was still work to be done. The SVG 1-px <code>&lt;rect&gt;<\/code> elements ended up coming across as <code>POLYGON<\/code>s and many, many more point-squares came along for the ride (in retrospect, I think they may have been the borders around the states, more on that in a bit).<\/p>\n<p>I used {purrr} and {st_coordinates} to figure out where all the 1-px &#8220;polygons&#8221; were in the {sf} object and isolated them, then added an index field (1:<code>n<\/code>, <code>n<\/code> being the number of delegate squares for a given state).<\/p>\n<p>I read in the original SVG with {xml2} and extracted the named state groups. Thankfully the order and number of &#8220;blocks&#8221; matched the filtered {sf} object. I merged them together, turned the 1-px POLYGONs into POINTs, and made the final {sf} object which I put in the nascent {catchpole} package (location below). Here&#8217;s a quick view of it using <code>plot()<\/code>:<\/p>\n<pre><code class=\"language-r\">library(catchpole) # hrbrmstr\/catchpole\n\nplot(delegates_map()[1])\n\ndelegates_map()\n## Simple feature collection with 3979 features and 2 fields\n## geometry type:  POINT\n## dimension:      XY\n## bbox:           xmin: -121.9723 ymin: 37.36802 xmax: -121.9581 ymax: 37.37453\n## epsg (SRID):    4326\n## proj4string:    +proj=longlat +datum=WGS84 +no_defs\n## First 10 features:\n##    state idx                   geometry\n## 1     WY   1 POINT (-121.9693 37.37221)\n## 2     WY   2 POINT (-121.9693 37.37212)\n## 3     WY   3 POINT (-121.9691 37.37221)\n## 4     WY   4 POINT (-121.9691 37.37212)\n## 5     WY   5 POINT (-121.9691 37.37203)\n## 6     WY   6 POINT (-121.9691 37.37194)\n## 7     WY   7 POINT (-121.9691 37.37185)\n## 8     WY   8  POINT (-121.969 37.37221)\n## 9     WY   9  POINT (-121.969 37.37212)\n## 10    WY  10  POINT (-121.969 37.37203)\n<\/code><\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"12671\" data-permalink=\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/catchpole-plot\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?fit=1280%2C790&amp;ssl=1\" data-orig-size=\"1280,790\" 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=\"catchpole-plot\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?fit=300%2C185&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?fit=510%2C315&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?resize=510%2C315&#038;ssl=1\" alt=\"\" width=\"510\" height=\"315\" class=\"aligncenter size-full wp-image-12671\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?w=1280&amp;ssl=1 1280w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?resize=300%2C185&amp;ssl=1 300w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?resize=530%2C327&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?resize=150%2C93&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?resize=768%2C474&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?resize=500%2C309&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?resize=1200%2C741&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?resize=400%2C247&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?resize=800%2C494&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?resize=200%2C123&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/catchpole-plot.png?w=1020&amp;ssl=1 1020w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<p>All that was needed was to try it out with the real data.<\/p>\n<p>I simplified that process quite a bit in {catchpole} but also made it possible to work with the individual bits on your own. {gg_catchpole()} will fetch the WSJ delegate JSON and build the basic map for you using my dark &#8220;ipsum&#8221; theme:<\/p>\n<pre><code class=\"language-r\">library(sf)\nlibrary(catchpole) # hrbrmstr\/catchpole\nlibrary(hrbrthemes)\nlibrary(tidyverse)\n\ngg_catchpole() +\n  theme_ft_rc(grid=\"\") +\n  theme(legend.position = \"bottom\")\n<\/code><\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"12674\" data-permalink=\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/my-map-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=2438%2C1592&amp;ssl=1\" data-orig-size=\"2438,1592\" 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=\"my-map-2\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=300%2C196&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=510%2C333&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?resize=510%2C333&#038;ssl=1\" alt=\"\" width=\"510\" height=\"333\" class=\"aligncenter size-full wp-image-12674\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?w=2438&amp;ssl=1 2438w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?resize=300%2C196&amp;ssl=1 300w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?resize=530%2C346&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?resize=150%2C98&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?resize=768%2C501&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?resize=1536%2C1003&amp;ssl=1 1536w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?resize=2048%2C1337&amp;ssl=1 2048w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?resize=500%2C326&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?resize=1200%2C784&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?resize=400%2C261&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?resize=800%2C522&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?resize=200%2C131&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?w=1020&amp;ssl=1 1020w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<h3>BONUS!<\/h3>\n<p>Now that you have the WSJ JSON file, you can do other, basic visualizations with it:<\/p>\n<pre><code class=\"language-r\">library(hrbrthemes) \nlibrary(waffle)\nlibrary(geofacet)\nlibrary(tidyverse)\n\njsonlite::fromJSON(\n  url(\"https:\/\/asset.wsj.net\/wsjnewsgraphics\/election\/2020\/delegates.json\"),\n  simplifyDataFrame = FALSE\n) -&gt; del\n\nc(\n  \"Biden\" = \"#5ac4c2\",\n  \"Sanders\" = \"#63bc51\",\n  \"Warren\" = \"#9574ae\",\n  \"Buttigieg\" = \"#007bb1\",\n  \"Klobuchar\" = \"#af973a\",\n  \"Bloomberg\" = \"#AA4671\",\n  \"Steyer\" = \"#4E4EAA\",\n  \"Yang\" = \"#C76C48\",\n  \"Gabbard\" = \"#7B8097\"\n) -&gt; dcols\n\nbind_cols(del$data$US$delCount) %&gt;% \n  gather(candidate, delegates) %&gt;% \n  filter(delegates &gt; 0) %&gt;%\n  arrange(desc(delegates)) %&gt;% \n  mutate(candidate = fct_inorder(candidate)) %&gt;%\n  ggplot(aes(candidate, delegates)) +\n  geom_col(fill = ggthemes::tableau_color_pal()(1), width = 0.55) +\n  labs(\n    x = NULL, y = \"# Delegates\",\n    title = \"2020 Democrat POTUS Race Delegate Counts\",\n    subtitle = sprintf(\"Date: %s\", Sys.Date()),\n    caption = \"Data source: WSJ &lt;https:\/\/asset.wsj.net\/wsjnewsgraphics\/election\/2020\/delegates.json&gt;\\n@hrbrmstr #rstats\"\n  ) +\n  theme_ipsum_rc(grid=\"Y\")\n<\/code><\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"12678\" data-permalink=\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/dbars\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?fit=1662%2C774&amp;ssl=1\" data-orig-size=\"1662,774\" 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=\"dbars\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?fit=300%2C140&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?fit=510%2C238&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?resize=510%2C238&#038;ssl=1\" alt=\"\" width=\"510\" height=\"238\" class=\"aligncenter size-full wp-image-12678\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?w=1662&amp;ssl=1 1662w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?resize=300%2C140&amp;ssl=1 300w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?resize=530%2C247&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?resize=150%2C70&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?resize=768%2C358&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?resize=1536%2C715&amp;ssl=1 1536w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?resize=500%2C233&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?resize=1200%2C559&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?resize=400%2C186&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?resize=800%2C373&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?resize=200%2C93&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dbars.png?w=1020&amp;ssl=1 1020w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<pre><code class=\"language-r\">bind_cols(del$data$US$delCount) %&gt;% \n  gather(candidate, delegates) %&gt;% \n  filter(delegates &gt; 0) %&gt;%\n  arrange(desc(delegates)) %&gt;% \n  mutate(candidate = fct_inorder(candidate)) %&gt;%\n  ggplot(aes(fill=candidate, values=delegates)) +\n  geom_waffle(color = \"white\", size = 0.5) +\n  scale_fill_manual(name = NULL, values = dcols) +\n  coord_fixed() +\n  labs(\n    x = NULL, y = \"# Delegates\",\n    title = \"2020 Democrat POTUS Race Delegate Counts\",\n    subtitle = sprintf(\"Date: %s\", Sys.Date()),\n    caption = \"Data source: WSJ &lt;https:\/\/asset.wsj.net\/wsjnewsgraphics\/election\/2020\/delegates.json&gt;\\n@hrbrmstr #rstats\"\n  ) +\n  theme_ipsum_rc(grid=\"\") +\n  theme_enhance_waffle()\n<\/code><\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"12677\" data-permalink=\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/dwaf\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?fit=1686%2C1016&amp;ssl=1\" data-orig-size=\"1686,1016\" 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=\"dwaf\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?fit=300%2C181&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?fit=510%2C307&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?resize=510%2C307&#038;ssl=1\" alt=\"\" width=\"510\" height=\"307\" class=\"aligncenter size-full wp-image-12677\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?w=1686&amp;ssl=1 1686w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?resize=300%2C181&amp;ssl=1 300w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?resize=530%2C319&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?resize=150%2C90&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?resize=768%2C463&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?resize=1536%2C926&amp;ssl=1 1536w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?resize=500%2C301&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?resize=1200%2C723&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?resize=400%2C241&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?resize=800%2C482&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?resize=200%2C121&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/dwaf.png?w=1020&amp;ssl=1 1020w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<pre><code class=\"language-r\">state_del &lt;- del\nstate_del$data[[\"US\"]] &lt;- NULL\n\nmap_df(state_del$data, ~bind_cols(.x$delCount), .id = \"state\") %&gt;% \n  gather(candidate, delegates, -state) %&gt;% \n  filter(delegates &gt; 0) %&gt;% \n  ggplot(aes(candidate, delegates)) +\n  geom_col(aes(fill = candidate), col = NA, width = 0.55) +\n  scale_fill_manual(name = NULL, values = dcols) +\n  facet_geo(~state) +\n  labs(\n    x = NULL, y = \"# Delegates\",\n    title = \"2020 Democrat POTUS Race Delegate Counts by State\",\n    subtitle = sprintf(\"Date: %s\", Sys.Date()),\n    caption = \"Data source: WSJ &lt;https:\/\/asset.wsj.net\/wsjnewsgraphics\/election\/2020\/delegates.json&gt;\\n@hrbrmstr #rstats\"\n  ) +\n  theme_ipsum_rc(grid=\"Y\") +\n  theme(axis.text.x = element_blank()) +\n  theme(panel.spacing.x = unit(0.5, \"lines\")) +\n  theme(panel.spacing.y = unit(0.1, \"lines\")) +\n  theme(legend.position = c(0.95, 0.1)) +\n  theme(legend.justification = c(1, 0))\n<\/code><\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"12679\" data-permalink=\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/geofacet\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?fit=2880%2C1756&amp;ssl=1\" data-orig-size=\"2880,1756\" 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=\"geofacet\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?fit=300%2C183&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?fit=510%2C311&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?resize=510%2C311&#038;ssl=1\" alt=\"\" width=\"510\" height=\"311\" class=\"aligncenter size-full wp-image-12679\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?w=2880&amp;ssl=1 2880w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?resize=300%2C183&amp;ssl=1 300w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?resize=530%2C323&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?resize=150%2C91&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?resize=768%2C468&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?resize=1536%2C937&amp;ssl=1 1536w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?resize=2048%2C1249&amp;ssl=1 2048w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?resize=500%2C305&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?resize=1200%2C732&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?resize=400%2C244&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?resize=800%2C488&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?resize=200%2C122&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/geofacet.png?w=1020&amp;ssl=1 1020w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<h3>FIN<\/h3>\n<p>More work needs to be done on the map and {catchpole} itself but there&#8217;s a sufficient base for others to experiment with (PRs and your own blog posts welcome!).<\/p>\n<p>W\/r\/t &#8220;more on that later&#8221; bits: The extra polygons were very likely borders and I think borders would help the cartogram, but we can make them with {sf}, too. We can also add in a layer for state names and\/or just figure out the centroid for each point grouping (with {sf}) and get places for labels that way). Not sure I&#8217;ll have time for any of that (this whole process went quickly, believe it or not).<\/p>\n<p>Also: <code>ggiraph::geom_sf_interactive()<\/code> can be used as a poor-dude&#8217;s popup to turn this (quickly) into an interactive piece.<\/p>\n<p>If you hit up <a href=\"https:\/\/git.rud.is\/hrbrmstr\/catchpole\">https:\/\/git.rud.is\/hrbrmstr\/catchpole<\/a> you&#8217;ll find the package and URLs to other social coding sites (though GitUgh has been plagued with downtime and degraded performance the past few weeks so you should really think about moving your workloads to real service).<\/p>\n<p>Have fun mapping \u00dcber Tuesday and share your creations, PR&#8217;s, ideas, etc for the package wherever you&#8217;re most comfortable.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For folks who are smart enough not to go near Twitter, I&#8217;ve been on a hiatus from the platform insofar as reading the Twitter feed goes. &#8220;Why&#8221; isn&#8217;t the subject of this post so I won&#8217;t go into it, but I&#8217;ve broken this half-NYE resolution on more than one occasion and am very glad I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":12674,"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":[91],"tags":[],"class_list":["post-12667","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Make WSJ-esque \u00dcber Tuesday Democrat Delegate Cartograms in R with {catchpole} - 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\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Make WSJ-esque \u00dcber Tuesday Democrat Delegate Cartograms in R with {catchpole} - rud.is\" \/>\n<meta property=\"og:description\" content=\"For folks who are smart enough not to go near Twitter, I&#8217;ve been on a hiatus from the platform insofar as reading the Twitter feed goes. &#8220;Why&#8221; isn&#8217;t the subject of this post so I won&#8217;t go into it, but I&#8217;ve broken this half-NYE resolution on more than one occasion and am very glad I [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-02T12:00:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-03-02T12:07:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=2438%2C1592&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"2438\" \/>\n\t<meta property=\"og:image:height\" content=\"1592\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/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=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"Make WSJ-esque \u00dcber Tuesday Democrat Delegate Cartograms in R with {catchpole}\",\"datePublished\":\"2020-03-02T12:00:10+00:00\",\"dateModified\":\"2020-03-02T12:07:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/\"},\"wordCount\":903,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886\"},\"image\":{\"@id\":\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=2438%2C1592&ssl=1\",\"articleSection\":[\"R\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/\",\"url\":\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/\",\"name\":\"Make WSJ-esque \u00dcber Tuesday Democrat Delegate Cartograms in R with {catchpole} - rud.is\",\"isPartOf\":{\"@id\":\"https:\/\/rud.is\/b\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=2438%2C1592&ssl=1\",\"datePublished\":\"2020-03-02T12:00:10+00:00\",\"dateModified\":\"2020-03-02T12:07:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=2438%2C1592&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=2438%2C1592&ssl=1\",\"width\":2438,\"height\":1592},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/rud.is\/b\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Make WSJ-esque \u00dcber Tuesday Democrat Delegate Cartograms in R with {catchpole}\"}]},{\"@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":"Make WSJ-esque \u00dcber Tuesday Democrat Delegate Cartograms in R with {catchpole} - 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\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/","og_locale":"en_US","og_type":"article","og_title":"Make WSJ-esque \u00dcber Tuesday Democrat Delegate Cartograms in R with {catchpole} - rud.is","og_description":"For folks who are smart enough not to go near Twitter, I&#8217;ve been on a hiatus from the platform insofar as reading the Twitter feed goes. &#8220;Why&#8221; isn&#8217;t the subject of this post so I won&#8217;t go into it, but I&#8217;ve broken this half-NYE resolution on more than one occasion and am very glad I [&hellip;]","og_url":"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/","og_site_name":"rud.is","article_published_time":"2020-03-02T12:00:10+00:00","article_modified_time":"2020-03-02T12:07:55+00:00","og_image":[{"width":2438,"height":1592,"url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=2438%2C1592&ssl=1","type":"image\/png"}],"author":"hrbrmstr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hrbrmstr","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"Make WSJ-esque \u00dcber Tuesday Democrat Delegate Cartograms in R with {catchpole}","datePublished":"2020-03-02T12:00:10+00:00","dateModified":"2020-03-02T12:07:55+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/"},"wordCount":903,"commentCount":2,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"image":{"@id":"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=2438%2C1592&ssl=1","articleSection":["R"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/","url":"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/","name":"Make WSJ-esque \u00dcber Tuesday Democrat Delegate Cartograms in R with {catchpole} - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#primaryimage"},"image":{"@id":"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=2438%2C1592&ssl=1","datePublished":"2020-03-02T12:00:10+00:00","dateModified":"2020-03-02T12:07:55+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#primaryimage","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=2438%2C1592&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=2438%2C1592&ssl=1","width":2438,"height":1592},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2020\/03\/02\/make-wsj-esque-uber-tuesday-democrat-delegate-cartograms-in-r-with-catchpole\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"Make WSJ-esque \u00dcber Tuesday Democrat Delegate Cartograms in R with {catchpole}"}]},{"@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":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2020\/03\/my-map-2.png?fit=2438%2C1592&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p23idr-3ij","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":3662,"url":"https:\/\/rud.is\/b\/2015\/09\/06\/three-new-rstats-twitter-bots-to-follow\/","url_meta":{"origin":12667,"position":0},"title":"Three New #rstats Twitter Bots To Follow","author":"hrbrmstr","date":"2015-09-06","format":false,"excerpt":"I engage with the Stack[Overflow|Exchange] community quite a bit and was super-happy @treycausey made the [Stack Overflow #rstats bot](https:\/\/twitter.com\/StackOverflowR) (@StackOverflowR) since I'm also on Twitter alot (mostly hanging out in #rstats these days). However, #rstats questions exist in other Stack watering holes, like the [Geographic Information Systems Stack Exchange](http:\/\/gis.stackexchange.com\/questions\/tagged\/r). [Cross\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":5946,"url":"https:\/\/rud.is\/b\/2017\/05\/14\/r%e2%81%b6-tracking-wannacry-bitcoin-wallet-payments-with-r\/","url_meta":{"origin":12667,"position":1},"title":"R\u2076 \u2014 Tracking WannaCry Bitcoin Wallet Payments with R","author":"hrbrmstr","date":"2017-05-14","format":false,"excerpt":"If you follow me on Twitter or monitor @Rapid7's Community Blog you know I've been involved a bit in the WannaCry ransomworm triage. One thing I've been doing is making charts of the hourly contribution to the Bitcoin addresses that the current\/main attackers are using to accept ransom payments (which\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\/05\/wanna1.png?fit=1200%2C452&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/05\/wanna1.png?fit=1200%2C452&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/05\/wanna1.png?fit=1200%2C452&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/05\/wanna1.png?fit=1200%2C452&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/05\/wanna1.png?fit=1200%2C452&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":6917,"url":"https:\/\/rud.is\/b\/2017\/10\/30\/gg_tweeting-power-outages\/","url_meta":{"origin":12667,"position":2},"title":"gg_tweet&#8217;ing Power Outages","author":"hrbrmstr","date":"2017-10-30","format":false,"excerpt":"As many folks know, I live in semi-rural Maine and we were hit pretty hard with a wind+rain storm Sunday to Monday. The hrbrmstr compound had no power (besides a generator) and no stable\/high-bandwidth internet (Verizon LTE was heavily congested) since 0500 Monday and still does not as I write\u2026","rel":"","context":"In &quot;ggplot&quot;","block_context":{"text":"ggplot","link":"https:\/\/rud.is\/b\/category\/ggplot\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7803,"url":"https:\/\/rud.is\/b\/2018\/01\/15\/cant-stop-at-21-twitter-recipe-22-tying-up-loose-threads\/","url_meta":{"origin":12667,"position":3},"title":"Can&#8217;t Stop at 21: Twitter Recipe #22 \u2014 Tying Up Loose Threads","author":"hrbrmstr","date":"2018-01-15","format":false,"excerpt":"NOTE: The likelihood of this recipe being added to the recent practice bookdown book is slim, but I'll try to keep the same format for the blog post. Problem You want to collect all the tweets in a Twitter tweet thread Solution Use a few key functions in rtweet to\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\/2018\/01\/Screen-Shot-2018-01-15-at-3.01.13-PM.png?fit=962%2C1200&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2018\/01\/Screen-Shot-2018-01-15-at-3.01.13-PM.png?fit=962%2C1200&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2018\/01\/Screen-Shot-2018-01-15-at-3.01.13-PM.png?fit=962%2C1200&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2018\/01\/Screen-Shot-2018-01-15-at-3.01.13-PM.png?fit=962%2C1200&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":2896,"url":"https:\/\/rud.is\/b\/2014\/02\/09\/data-driven-security-roundup-betapert-shiny-honeypots-passwords-reproducible-research\/","url_meta":{"origin":12667,"position":4},"title":"Data Driven Security Roundup: betaPERT, Shiny, Honeypots, Passwords &#038; Reproducible Research","author":"hrbrmstr","date":"2014-02-09","format":false,"excerpt":"Jay Jacobs (@jayjacobs)\u2014my co-author of the soon-to-be-released book [Data-Driven Security](http:\/\/amzn.to\/ddsec)\u2014& I have been hard at work over at the book's [sister-blog](http:\/\/dds.ec\/blog) cranking out code to help security domain experts delve into the dark art of data science. We've covered quite a bit of ground since January 1st, but I'm using\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":4345,"url":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/","url_meta":{"origin":12667,"position":5},"title":"(ggplot2) Exercising with (ggalt) dumbbells","author":"hrbrmstr","date":"2016-04-17","format":false,"excerpt":"I follow the most excellent Pew Research folks on Twitter to stay in tune with what's happening (statistically speaking) with the world. Today, they tweeted this excerpt from their 2015 Global Attitudes survey: The age gap in social media use around the world https:\/\/t.co\/0Dq1PcbExG pic.twitter.com\/9HBM7gLxwR\u2014 PewResearch Internet (@pewinternet) April 17,\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\/04\/RStudio.png?fit=811%2C1200&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=811%2C1200&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=811%2C1200&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=811%2C1200&ssl=1&resize=700%2C400 2x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/12667","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=12667"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/12667\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media\/12674"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=12667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=12667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=12667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}