

{"id":13251,"date":"2021-12-02T02:34:45","date_gmt":"2021-12-02T07:34:45","guid":{"rendered":"https:\/\/rud.is\/b\/?p=13251"},"modified":"2021-12-02T02:34:45","modified_gmt":"2021-12-02T07:34:45","slug":"2021-advent-of-code-day-02-dont-try-this-at-home-edition","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/","title":{"rendered":"2021 Advent of Code Day 02 &#8220;Don&#8217;t Try This At Home&#8221; Edition"},"content":{"rendered":"<p>The Moderna booster level drained me all day on Dec 1 and did what jab two did during the overnight period (achy enough to wake me up and not get back to slumber easily). To try to wear myself down, I decided to practice a bit of R with the <a href=\"https:\/\/adventofcode.com\/2021\">2021 Advent of Code<\/a>. There are plenty of superb R bloggers chronicling their daily katas that I do not feel compelled to post every one (truth be told, work and fam tasks\/priorities will make devoting any time to this year&#8217;s daily puzzles a rare event).<\/p>\n<p><a href=\"https:\/\/adventofcode.com\/2021\/day\/1\">Day 01<\/a> was very straightforward (even part 2 which I used {RcppRoll} despite hoping to stick to only base R 4.x) so it&#8217;s kinda not worth a post (for me), but <a href=\"https:\/\/adventofcode.com\/2021\/day\/2\">Day 02<\/a> was kinda fun as I don&#8217;t have regular opportunities to use <code>scan()<\/code> and <code>get()<\/code>.<\/p>\n<p>The input is a series of submarine commands:<\/p>\n<pre><code class=\"language-plain\">forward 5\ndown 5\nforward 8\nup 3\ndown 8\nforward 2\n<\/code><\/pre>\n<p>with a set of rules that change between parts 1 and 2.<\/p>\n<p>We can read in those commands with <code>scan()<\/code> which lets us specify a pattern for each line (<code>scan()<\/code> takes care of dealing with whitespace for you):<\/p>\n<pre><code class=\"language-r\">scan(\n  text = \"forward 5\ndown 5\nforward 8\nup 3\ndown 8\nforward 2\",\nwhat = list(character(0), integer(0))\n) |&gt;\n  setNames(c(\"command\", \"value\")) -&gt; input\n\nstr(input)\n## List of 2\n##  $ command: chr [1:6] \"forward\" \"down\" \"forward\" \"up\" ...\n##  $ value  : int [1:6] 5 5 8 3 8 2\n<\/code><\/pre>\n<p>The rules (link above) were pretty basic, increment\/decrement some variables based on the command input, but I wanted to avoid a bunch of <code>if<\/code> statements.  Since R has the <code>get()<\/code> function that enables searching by name for an object, we can make a series of functions that have the command as the identifier and then use <code>get()<\/code> to call the function:<\/p>\n<pre><code class=\"language-r\">up &lt;- \\(x) depth &lt;&lt;- depth - x\ndown &lt;- \\(x) depth &lt;&lt;- depth + x\nforward &lt;- \\(x) position &lt;&lt;- position + x\n\nposition &lt;- depth &lt;- 0\n\nfor (idx in seq_along(input$command)) {\n  get(input$command[idx], mode = \"function\")(input$value[idx])\n}\n<\/code><\/pre>\n<p>(the final answer is computed by <code>position<\/code> X <code>depth<\/code>).<\/p>\n<p>While I find this to be a &#8220;fun&#8221; solution, I&#8217;d strongly suggest:<\/p>\n<ul>\n<li>avoiding using the new shortcut function declaration in mixed R version shops as it&#8217;s very new and likely to be confusing to new R users<\/li>\n<li>being wary of the <code>&lt;&lt;-<\/code> assignment operator as it&#8217;s introducing a side-effect (parent\/global environment modification) which will come back to bite you in other projects some day<\/li>\n<li>ditching the <code>$<\/code> referencing in favour of <code>[[]]<\/code> \/ <code>[]<\/code> to avoid partial name matching &#8220;gotchas&#8221;, and<\/li>\n<li>adding explicit documentation to what you&#8217;re doing with <code>get()<\/code> calls (provided you really have a good case for using <code>get()<\/code> to begin with)<\/li>\n<\/ul>\n<p>The code only changes slightly for part 2, so I&#8217;ll refrain from adding even more unreadable code from this post.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Moderna booster level drained me all day on Dec 1 and did what jab two did during the overnight period (achy enough to wake me up and not get back to slumber easily). To try to wear myself down, I decided to practice a bit of R with the 2021 Advent of Code. There [&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":[849,91],"tags":[],"class_list":["post-13251","post","type-post","status-publish","format-standard","hentry","category-advent-of-code","category-r"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>2021 Advent of Code Day 02 &quot;Don&#039;t Try This At Home&quot; Edition - 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\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"2021 Advent of Code Day 02 &quot;Don&#039;t Try This At Home&quot; Edition - rud.is\" \/>\n<meta property=\"og:description\" content=\"The Moderna booster level drained me all day on Dec 1 and did what jab two did during the overnight period (achy enough to wake me up and not get back to slumber easily). To try to wear myself down, I decided to practice a bit of R with the 2021 Advent of Code. There [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-02T07:34:45+00:00\" \/>\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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/12\\\/02\\\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/12\\\/02\\\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\\\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"2021 Advent of Code Day 02 &#8220;Don&#8217;t Try This At Home&#8221; Edition\",\"datePublished\":\"2021-12-02T07:34:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/12\\\/02\\\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\\\/\"},\"wordCount\":380,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"articleSection\":[\"advent of code\",\"R\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/12\\\/02\\\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/12\\\/02\\\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\\\/\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/12\\\/02\\\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\\\/\",\"name\":\"2021 Advent of Code Day 02 \\\"Don't Try This At Home\\\" Edition - rud.is\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\"},\"datePublished\":\"2021-12-02T07:34:45+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/12\\\/02\\\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/12\\\/02\\\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2021\\\/12\\\/02\\\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/rud.is\\\/b\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"2021 Advent of Code Day 02 &#8220;Don&#8217;t Try This At Home&#8221; Edition\"}]},{\"@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":"2021 Advent of Code Day 02 \"Don't Try This At Home\" Edition - 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\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/","og_locale":"en_US","og_type":"article","og_title":"2021 Advent of Code Day 02 \"Don't Try This At Home\" Edition - rud.is","og_description":"The Moderna booster level drained me all day on Dec 1 and did what jab two did during the overnight period (achy enough to wake me up and not get back to slumber easily). To try to wear myself down, I decided to practice a bit of R with the 2021 Advent of Code. There [&hellip;]","og_url":"https:\/\/rud.is\/b\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/","og_site_name":"rud.is","article_published_time":"2021-12-02T07:34:45+00:00","author":"hrbrmstr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hrbrmstr","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rud.is\/b\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"2021 Advent of Code Day 02 &#8220;Don&#8217;t Try This At Home&#8221; Edition","datePublished":"2021-12-02T07:34:45+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/"},"wordCount":380,"commentCount":6,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"articleSection":["advent of code","R"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/","url":"https:\/\/rud.is\/b\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/","name":"2021 Advent of Code Day 02 \"Don't Try This At Home\" Edition - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"datePublished":"2021-12-02T07:34:45+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2021\/12\/02\/2021-advent-of-code-day-02-dont-try-this-at-home-edition\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"2021 Advent of Code Day 02 &#8220;Don&#8217;t Try This At Home&#8221; Edition"}]},{"@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-3rJ","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":13685,"url":"https:\/\/rud.is\/b\/2022\/12\/19\/2022-hanukkah-of-data-puzzle-1\/","url_meta":{"origin":13251,"position":0},"title":"2022 Hanukkah of Data \u2022\u00a0Puzzle 1","author":"hrbrmstr","date":"2022-12-19","format":false,"excerpt":"Visiting #2 and doing some $WORK-work, but intrigued with Hanukkah of Data since Puzzle 0 was solvable with a ZIP password cracker (the calendar date math seemed too trivial to bother with). Decided to fall back to R for this (vs Observable for the Advent of Code which I'll dedicate\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5565,"url":"https:\/\/rud.is\/b\/2017\/04\/01\/r%e2%81%b4-snow-day-facets\/","url_meta":{"origin":13251,"position":1},"title":"R\u2076 \u2014 Snow Day Facets","author":"hrbrmstr","date":"2017-04-01","format":false,"excerpt":"Back in 2014 I blogged about first snowfall dates for a given U.S. state. It's April 1, 2017 and we're slated to get 12-18\" of snow up here in Maine and @mrshrbrmstr asked how often this \u2014\u00a0snow in May \u2014 has occurred near us. As with all of these \"R\u2076\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\/04\/Cursor_and___projects_snowfirst_-_master_-_RStudio.png?fit=1200%2C1098&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/04\/Cursor_and___projects_snowfirst_-_master_-_RStudio.png?fit=1200%2C1098&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/04\/Cursor_and___projects_snowfirst_-_master_-_RStudio.png?fit=1200%2C1098&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/04\/Cursor_and___projects_snowfirst_-_master_-_RStudio.png?fit=1200%2C1098&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/04\/Cursor_and___projects_snowfirst_-_master_-_RStudio.png?fit=1200%2C1098&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":12866,"url":"https:\/\/rud.is\/b\/2021\/01\/04\/bringing-r-to-swift-on-macos\/","url_meta":{"origin":13251,"position":2},"title":"Bringing R to Swift on macOS","author":"hrbrmstr","date":"2021-01-04","format":false,"excerpt":"Over Christmas break I teased some screencaps: A more refined #rstats #swift \"SwiftR\" example. Simple Image view + some text views, a color picker and a button that runs R-in-Swift code (like {reticulate} does for Python in R)Note no ssd\/hd storage round-trip for the plot.Code snippet: https:\/\/t.co\/fWaHnztUgd pic.twitter.com\/y5m1I16tCB\u2014 Caliban's War\u2026","rel":"","context":"In &quot;Apple&quot;","block_context":{"text":"Apple","link":"https:\/\/rud.is\/b\/category\/apple\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4501,"url":"https:\/\/rud.is\/b\/2016\/07\/07\/bridging-the-political-polygons-gap-with-ggplot2\/","url_meta":{"origin":13251,"position":3},"title":"Bridging The Political [Polygons] Gap with ggplot2","author":"hrbrmstr","date":"2016-07-07","format":false,"excerpt":"The @pewresearch folks have been collecting political survey data for quite a while, and I noticed the [visualization below](http:\/\/www.people-press.org\/2014\/06\/12\/section-1-growing-ideological-consistency\/#interactive) referenced in a [Tableau vis contest entry](https:\/\/www.interworks.com\/blog\/rrouse\/2016\/06\/24\/politics-viz-contest-plotting-political-polarization): Those are filled [frequency polygons](http:\/\/onlinestatbook.com\/2\/graphing_distributions\/freq_poly.html), which are super-easy to replicate in ggplot2, especially since Pew even _kind of_ made the data available via their\u2026","rel":"","context":"In &quot;Data Visualization&quot;","block_context":{"text":"Data Visualization","link":"https:\/\/rud.is\/b\/category\/data-visualization\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/07\/engfull.png?fit=1200%2C1098&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/07\/engfull.png?fit=1200%2C1098&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/07\/engfull.png?fit=1200%2C1098&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/07\/engfull.png?fit=1200%2C1098&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/07\/engfull.png?fit=1200%2C1098&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":6496,"url":"https:\/\/rud.is\/b\/2017\/09\/30\/identify-analyze-web-site-tech-stacks-with-rappalyzer\/","url_meta":{"origin":13251,"position":4},"title":"Identify &#038; Analyze Web Site Tech Stacks With rappalyzer","author":"hrbrmstr","date":"2017-09-30","format":false,"excerpt":"Modern websites are complex beasts. They house photo galleries, interactive visualizations, web fonts, analytics code and other diverse types of content. Despite the potential for diversity, many web sites share similar \"tech stacks\" --- the components that come together to make them what they are. These stacks consist of web\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\/09\/Viewer_Zoom.png?fit=1198%2C1200&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/09\/Viewer_Zoom.png?fit=1198%2C1200&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/09\/Viewer_Zoom.png?fit=1198%2C1200&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/09\/Viewer_Zoom.png?fit=1198%2C1200&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/09\/Viewer_Zoom.png?fit=1198%2C1200&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":12917,"url":"https:\/\/rud.is\/b\/2021\/01\/26\/making-it-easier-to-experiment-with-compiled-swift-code-in-r\/","url_meta":{"origin":13251,"position":5},"title":"Making It Easier To Experiment With Compiled Swift Code In R","author":"hrbrmstr","date":"2021-01-26","format":false,"excerpt":"The past two posts have (lightly) introduced how to use compiled Swift code in R, but they've involved a bunch of \"scary\" command line machinations and incantations. One feature of {Rcpp} I've always ? is the cppFunction() (\"r-lib\" zealots have a similar cpp11::cpp_function()) which lets one experiment with C[++] code\u2026","rel":"","context":"In &quot;macOS&quot;","block_context":{"text":"macOS","link":"https:\/\/rud.is\/b\/category\/macos\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/13251","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=13251"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/13251\/revisions"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=13251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=13251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=13251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}