

{"id":4560,"date":"2016-07-26T12:33:24","date_gmt":"2016-07-26T17:33:24","guid":{"rendered":"https:\/\/rud.is\/b\/?p=4560"},"modified":"2018-03-10T07:54:36","modified_gmt":"2018-03-10T12:54:36","slug":"use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/","title":{"rendered":"Use quick formula functions in purrr::map (+ base vs tidtyverse idiom comparisons\/examples)"},"content":{"rendered":"<p>I&#8217;ve converted the vast majority of my <code>*apply<\/code> usage over to <a href=\"https:\/\/github.com\/tidyverse\/purrr\"><code>purrr<\/code><\/a> functions. In an attempt to make this a quick post, I&#8217;ll refrain from going into all the benefits of the <code>purrr<\/code> package. Instead, I&#8217;ll show just <em>one<\/em> thing that&#8217;s super helpful: formula functions.<\/p>\n<p>After seeing <a href=\"https:\/\/qz.com\/741391\/its-not-your-imagination-gun-violence-is-over-the-top-this-summer\/\">this Quartz article<\/a> using a visualization to compare the frequency and volume of mass shootings, I wanted to grab the data to look at it with a stats-eye (humans are ++gd at visually identifying patterns, but we&#8217;re also ++gd as misinterpreting them, plus stats validates visual assumptions). I&#8217;m not going into that here, but will use the grabbing of the data to illustrate the formula functions. Note that there&#8217;s quite a bit of &#8220;setup&#8221; here for just one example, so I guess I kinda am attempting to shill the <code>purrr<\/code> package and the &#8220;piping tidyverse&#8221; <em>just a tad<\/em>.<\/p>\n<p>If you head on over to the <a href=\"https:\/\/www.massshootingtracker.org\/data\">site with the data<\/a> you&#8217;ll see you can download files for all four years. In <em>theory<\/em>, these are all individual years, but the names of the files gave me pause:<\/p>\n<ul>\n<li><code>MST Data 2013 - 2015.csv<\/code><\/li>\n<li><code>MST Data 2014 - 2015.csv<\/code><\/li>\n<li><code>MST Data 2015 - 2015.csv<\/code><\/li>\n<li><code>Mass Shooting Data 2016 - 2016.csv<\/code><\/li>\n<\/ul>\n<p>So, they <em>may<\/em> all be individual years, but the naming consistency isn&#8217;t there and it&#8217;s better to double check than to assume.<\/p>\n<p>First, we can check to see if the column names are the same (we can eyeball this since there are only four files and a small # of columns):<\/p>\n<pre id=\"mst-cols\"><code class=\"language-r\">library(purrr)\r\nlibrary(readr)\r\n\r\ndir() %&gt;% \r\n  map(read_csv) %&gt;% \r\n  map(colnames)\r\n\r\n## [[1]]\r\n## [1] &quot;date&quot;                        &quot;name_semicolon_delimited&quot;   \r\n## [3] &quot;killed&quot;                      &quot;wounded&quot;                    \r\n## [5] &quot;city&quot;                        &quot;state&quot;                      \r\n## [7] &quot;sources_semicolon_delimited&quot;\r\n## \r\n## [[2]]\r\n## [1] &quot;date&quot;                        &quot;name_semicolon_delimited&quot;   \r\n## [3] &quot;killed&quot;                      &quot;wounded&quot;                    \r\n## [5] &quot;city&quot;                        &quot;state&quot;                      \r\n## [7] &quot;sources_semicolon_delimited&quot;\r\n## \r\n## [[3]]\r\n## [1] &quot;date&quot;                        &quot;name_semicolon_delimited&quot;   \r\n## [3] &quot;killed&quot;                      &quot;wounded&quot;                    \r\n## [5] &quot;city&quot;                        &quot;state&quot;                      \r\n## [7] &quot;sources_semicolon_delimited&quot;\r\n## \r\n## [[4]]\r\n## [1] &quot;date&quot;                        &quot;name_semicolon_delimited&quot;   \r\n## [3] &quot;killed&quot;                      &quot;wounded&quot;                    \r\n## [5] &quot;city&quot;                        &quot;state&quot;                      \r\n## [7] &quot;sources_semicolon_delimited&quot;<\/code><\/pre>\n<p>A quick inspection of the <code>date<\/code> column shows it&#8217;s in <code>month\/day\/year<\/code> format and we want to know if each file only spans one year. This is where the elegance of the formula function comes in:<\/p>\n<pre id=\"mst-date\"><code class=\"language-r\">library(lubridate)\r\n\r\ndir() %&gt;% \r\n  map(read_csv) %&gt;% \r\n  map(~range(mdy(.$date))) # &lt;--- the *entire* post was to show this one line ;-)\r\n\r\n## [[1]]\r\n## [1] &quot;2016-01-06&quot; &quot;2016-07-25&quot;\r\n## \r\n## [[2]]\r\n## [1] &quot;2013-01-01&quot; &quot;2013-12-31&quot;\r\n## \r\n## [[3]]\r\n## [1] &quot;2014-01-01&quot; &quot;2014-12-29&quot;\r\n## \r\n## [[4]]\r\n## [1] &quot;2015-01-01&quot; &quot;2015-12-31&quot;<\/code><\/pre>\n<p>To break that down a bit:<\/p>\n<ul>\n<li><code>dir()<\/code> returns a vector of filenames in the current directory<\/li>\n<li>the first <code>map()<\/code> reads each of those files in and creates a list with four elements, each being a <code>tibble<\/code> (<code>data_frame<\/code> \/ <code>data.frame<\/code>)<\/li>\n<li>the second <code>map()<\/code> iterates over those data frames and calls a newly created anonymous function which converts the <code>date<\/code> column to a proper <code>Date<\/code> data type then gets the range of those dates, ultimately resulting in a four element list, with each element being a two element vector of <code>Date<\/code>s<\/li>\n<\/ul>\n<p>For you &#8220;basers&#8221; out there, this is what that looks like old school style:<\/p>\n<pre id=\"mst-base\"><code class=\"language-r\">fils &lt;- dir()\r\ndfs &lt;- lapply(fils, read.csv, stringsAsFactors=FALSE)\r\nlapply(dfs, function(x) range(as.Date(x$date, format=&quot;%m\/%e\/%Y&quot;)))<\/code><\/pre>\n<p>or<\/p>\n<pre id=\"mst-base-alt\"><code class=\"language-r\">lapply(dir(), function(x) {\r\n  df &lt;- read.csv(x, stringsAsFactors=FALSE)\r\n  range(as.Date(df$date, format=&quot;%m\/%e\/%Y&quot;))\r\n})<\/code><\/pre>\n<p>You eliminate the <code>function(x) { }<\/code> and get pre-defined vars (either <code>.x<\/code> or <code>.<\/code> and, if needed, <code>.y<\/code>) to compose your <code>map<\/code>s and pipes very cleanly and succinctly, but still being super-readable.<\/p>\n<p>After performing this inspection (i.e. that each file does contain only a incidents for a single year), we can now automate the data ingestion:<\/p>\n<pre id=\"mst-fin\"><code class=\"language-r\">library(rvest)\r\nlibrary(purrr)\r\nlibrary(readr)\r\nlibrary(dplyr)\r\nlibrary(lubridate)\r\n\r\nread_html(&quot;https:\/\/www.massshootingtracker.org\/data&quot;) %&gt;% \r\n  html_nodes(&quot;a[href^=&#039;https:\/\/docs.goo&#039;]&quot;) %&gt;% \r\n  html_attr(&quot;href&quot;) %&gt;% \r\n  map_df(read_csv) %&gt;% \r\n  mutate(date=mdy(date)) -&gt; shootings<\/code><\/pre>\n<p>Here&#8217;s what that looks like w\/o the tidyverse\/piping:<\/p>\n<pre id=\"mst-last\"><code class=\"language-r\">library(XML)\r\n\r\ndoc &lt;- htmlParse(&quot;http:\/\/www.massshootingtracker.org\/data&quot;) # note the necessary downgrade to &quot;http&quot;\r\n\r\ndfs &lt;- xpathApply(doc, &quot;\/\/a[contains(@href, &#039;https:\/\/docs.goo&#039;)]&quot;, function(x) {\r\n  csv &lt;- xmlGetAttr(x, &quot;href&quot;)\r\n  df &lt;- read.csv(csv, stringsAsFactors=FALSE)\r\n  df$date &lt;- as.Date(df$date, format=&quot;%m\/%e\/%Y&quot;)\r\n  df\r\n})\r\n\r\nshootings &lt;- do.call(rbind, dfs)\r\n<\/code><\/pre>\n<p>Even hardcore &#8220;basers&#8221; may have to admit that the piping\/tidyverse version is ultimately better.<\/p>\n<p>Give the <code>purrr<\/code> package a first (or second) look if you haven&#8217;t switched over to it. Type safety, readable anonymous functions and C-backed fast functional idioms will mean that your code may ultimately be purrrfect.<\/p>\n<h3>UPDATE #1<\/h3>\n<p>I received a question in the comments regarding how I came to that CSS selector for the gdocs CSV URLs, so I made a quick video of the exact steps I took. Exposition below the film.<\/p>\n<p><center><\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/OSmfOIg8jM4\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p><\/center><\/p>\n<p>Right-click &#8220;Inspect&#8221; in Chrome is my go-to method for finding what I&#8217;m after. This isn&#8217;t the place to dive deep into the dark art of web page spelunking, but in this case, when I saw there were four similar anchor (<code>&lt;a&gt;<\/code>) tags that pointed to the CSV &#8220;files&#8221;, I took the easy way out and just built a selector based on the <code>href<\/code> attribute value (or, more specifically, the characters at the start of the <code>href<\/code> attribute). However, all four ways below end up targeting the same four elements:<\/p>\n<pre id=\"mst-sel\"><code class=\"language-r\">pg &lt;- read_html(&quot;https:\/\/www.massshootingtracker.org\/data&quot;)\r\n\r\nhtml_nodes(pg, &quot;a.btn.btn-default&quot;)\r\nhtml_nodes(pg, &quot;a[href^=&#039;https:\/\/docs.goo&#039;]&quot;)\r\nhtml_nodes(pg, xpath=&quot;.\/\/a[@class=&#039;btn btn-default&#039;]&quot;)\r\nhtml_nodes(pg, xpath=&quot;.\/\/a[contains(@href, &#039;https:\/\/docs.goo&#039;)]&quot;)<\/code><\/pre>\n<h3>UPDATE #2<\/h3>\n<p>Due to:<\/p>\n<blockquote class=\"twitter-tweet\" data-lang=\"en\">\n<p lang=\"en\" dir=\"ltr\"><a href=\"https:\/\/mobile.twitter.com\/hrbrmstr\">@hrbrmstr<\/a> haha yes. Only basers use list.files() ?<\/p>\n<p>&mdash; Hadley Wickham (@hadleywickham) <a href=\"https:\/\/mobile.twitter.com\/hadleywickham\/status\/758670831199191041\">July 28, 2016<\/a><\/p><\/blockquote>\n<p><script async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n<p>I swapped out <code>list.files()<\/code> in favour of <code>dir()<\/code> (though, as someone who <em>detests<\/em> DOS\/Windows, typing that function name is super-painful).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve converted the vast majority of my *apply usage over to purrr functions. In an attempt to make this a quick post, I&#8217;ll refrain from going into all the benefits of the purrr package. Instead, I&#8217;ll show just one thing that&#8217;s super helpful: formula functions. After seeing this Quartz article using a visualization to compare [&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":true,"_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":[810],"class_list":["post-4560","post","type-post","status-publish","format-standard","hentry","category-r","tag-post"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Use quick formula functions in purrr::map (+ base vs tidtyverse idiom comparisons\/examples) - 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\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Use quick formula functions in purrr::map (+ base vs tidtyverse idiom comparisons\/examples) - rud.is\" \/>\n<meta property=\"og:description\" content=\"I&#8217;ve converted the vast majority of my *apply usage over to purrr functions. In an attempt to make this a quick post, I&#8217;ll refrain from going into all the benefits of the purrr package. Instead, I&#8217;ll show just one thing that&#8217;s super helpful: formula functions. After seeing this Quartz article using a visualization to compare [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-26T17:33:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-03-10T12:54:36+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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/07\\\/26\\\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/07\\\/26\\\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\\\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"Use quick formula functions in purrr::map (+ base vs tidtyverse idiom comparisons\\\/examples)\",\"datePublished\":\"2016-07-26T17:33:24+00:00\",\"dateModified\":\"2018-03-10T12:54:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/07\\\/26\\\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\\\/\"},\"wordCount\":687,\"commentCount\":9,\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"keywords\":[\"post\"],\"articleSection\":[\"R\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/07\\\/26\\\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/07\\\/26\\\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\\\/\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/07\\\/26\\\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\\\/\",\"name\":\"Use quick formula functions in purrr::map (+ base vs tidtyverse idiom comparisons\\\/examples) - rud.is\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\"},\"datePublished\":\"2016-07-26T17:33:24+00:00\",\"dateModified\":\"2018-03-10T12:54:36+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/07\\\/26\\\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/07\\\/26\\\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/07\\\/26\\\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/rud.is\\\/b\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Use quick formula functions in purrr::map (+ base vs tidtyverse idiom comparisons\\\/examples)\"}]},{\"@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":"Use quick formula functions in purrr::map (+ base vs tidtyverse idiom comparisons\/examples) - 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\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/","og_locale":"en_US","og_type":"article","og_title":"Use quick formula functions in purrr::map (+ base vs tidtyverse idiom comparisons\/examples) - rud.is","og_description":"I&#8217;ve converted the vast majority of my *apply usage over to purrr functions. In an attempt to make this a quick post, I&#8217;ll refrain from going into all the benefits of the purrr package. Instead, I&#8217;ll show just one thing that&#8217;s super helpful: formula functions. After seeing this Quartz article using a visualization to compare [&hellip;]","og_url":"https:\/\/rud.is\/b\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/","og_site_name":"rud.is","article_published_time":"2016-07-26T17:33:24+00:00","article_modified_time":"2018-03-10T12:54:36+00:00","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\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"Use quick formula functions in purrr::map (+ base vs tidtyverse idiom comparisons\/examples)","datePublished":"2016-07-26T17:33:24+00:00","dateModified":"2018-03-10T12:54:36+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/"},"wordCount":687,"commentCount":9,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"keywords":["post"],"articleSection":["R"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/","url":"https:\/\/rud.is\/b\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/","name":"Use quick formula functions in purrr::map (+ base vs tidtyverse idiom comparisons\/examples) - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"datePublished":"2016-07-26T17:33:24+00:00","dateModified":"2018-03-10T12:54:36+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2016\/07\/26\/use-quick-formula-functions-in-purrrmap-base-vs-tidtyverse-idiom-comparisonsexamples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"Use quick formula functions in purrr::map (+ base vs tidtyverse idiom comparisons\/examples)"}]},{"@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-1by","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":4574,"url":"https:\/\/rud.is\/b\/2016\/07\/27\/u-s-drought-animations-with-the-witchs-brew-purrr-broom-magick\/","url_meta":{"origin":4560,"position":0},"title":"U.S. Drought Animations with the &#8220;Witch&#8217;s Brew&#8221; (purrr + broom + magick)","author":"hrbrmstr","date":"2016-07-27","format":false,"excerpt":"This is another purrr-focused post but it's also an homage to the nascent magick package (R interface to ImageMagick) by @opencpu. We're starting to see\/feel the impact of the increasing drought up here in southern Maine. I've used the data from the U.S. Drought Monitor before on the blog, but\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":5206,"url":"https:\/\/rud.is\/b\/2017\/03\/27\/all-in-on-r%e2%81%b4-progress-bars-on-first-post\/","url_meta":{"origin":4560,"position":1},"title":"All-in on R\u2076 : Progress [bars] on first post","author":"hrbrmstr","date":"2017-03-27","format":false,"excerpt":"@eddelbuettel's idea is a good one. (it's a quick read\u2026jump there and come back). We'll avoid confusion and call it R\u2076 over here. Feel free to don the superclass. I often wait for a complete example or new package announcement to blog something when a briefly explained snippet might have\u2026","rel":"","context":"In &quot;dplyr&quot;","block_context":{"text":"dplyr","link":"https:\/\/rud.is\/b\/category\/dplyr\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5841,"url":"https:\/\/rud.is\/b\/2017\/04\/23\/decomposing-composers-with-r\/","url_meta":{"origin":4560,"position":2},"title":"Decomposing Composers with R","author":"hrbrmstr","date":"2017-04-23","format":false,"excerpt":"The intrepid @ma_salmon cranked out another blog post, remixing classical music schedule data from Radio Swiss Classic. It's a fun post and you should read it before continuing here. Seriously, click the link and go read it before continuing. No, I mean it. Click the link or the rest of\u2026","rel":"","context":"In &quot;xml&quot;","block_context":{"text":"xml","link":"https:\/\/rud.is\/b\/category\/xml\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4942,"url":"https:\/\/rud.is\/b\/2017\/01\/26\/one-view-of-the-impact-of-the-new-immigration-ban-freeing-pdf-data-with-tabulizer\/","url_meta":{"origin":4560,"position":3},"title":"One View of the Impact of the New Immigration Ban (+ freeing PDF data with tabulizer)","author":"hrbrmstr","date":"2017-01-26","format":false,"excerpt":"Dear Leader has made good on his campaign promise to \"crack down\" on immigration from \"dangerous\" countries. I wanted to both see one side of the impact of that decree \u2014 how many potential immigrants per year might this be impacting \u2014 and show toss up some code that shows\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\/01\/RStudio.png?fit=1200%2C530&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/RStudio.png?fit=1200%2C530&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/RStudio.png?fit=1200%2C530&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/RStudio.png?fit=1200%2C530&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/RStudio.png?fit=1200%2C530&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":11837,"url":"https:\/\/rud.is\/b\/2019\/01\/30\/quick-hit-using-seymour-to-subscribe-to-your-gitlahub-repo-issues-in-feedly\/","url_meta":{"origin":4560,"position":4},"title":"Quick Hit: Using seymour to Subscribe to your Git[la|hu]b Repo Issues in Feedly","author":"hrbrmstr","date":"2019-01-30","format":false,"excerpt":"The seymour? Feedly API package has been updated to support subscribing to RSS\/Atom feeds. Previously the package was intended to just treat your Feedly as a data source, but there was a compelling use case for enabling subscription support: subscribing to code repository issues. Sure, there's already email notice integration\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":6788,"url":"https:\/\/rud.is\/b\/2017\/10\/22\/a-call-to-tweets-blog-posts\/","url_meta":{"origin":4560,"position":5},"title":"A Call to Tweets (&#038; Blog Posts)!","author":"hrbrmstr","date":"2017-10-22","format":false,"excerpt":"Way back in July of 2009, the first version of the twitteR package was published by Geoff Jentry in CRAN. Since then it has seen 28 updates, finally breaking the 0.x.y barrier into 1.x.y territory in March of 2013 and receiving it's last update in July of 2015. For a\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":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/4560","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=4560"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/4560\/revisions"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=4560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=4560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=4560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}