<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Brad Lindblad on Medium]]></title>
        <description><![CDATA[Stories by Brad Lindblad on Medium]]></description>
        <link>https://medium.com/@bradley.lindblad?source=rss-27ad429f9b76------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IZboc0xpk4ZZ8VZSdJxCNg.png</url>
            <title>Stories by Brad Lindblad on Medium</title>
            <link>https://medium.com/@bradley.lindblad?source=rss-27ad429f9b76------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 00:53:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bradley.lindblad/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Using Github Actions, Python and Telegram to Get Ribeye Specials]]></title>
            <link>https://medium.com/@bradley.lindblad/using-github-actions-python-and-telegram-to-get-ribeye-specials-f886a6de5a51?source=rss-27ad429f9b76------2</link>
            <guid isPermaLink="false">https://medium.com/p/f886a6de5a51</guid>
            <category><![CDATA[telegram]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[github-ac]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Brad Lindblad]]></dc:creator>
            <pubDate>Thu, 03 Feb 2022 13:57:49 GMT</pubDate>
            <atom:updated>2022-02-03T13:57:49.569Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/705/0*wxeSYuuozrsy8t8g.png" /></figure><p>I buy red meat — mostly steaks — at a local butcher shop. With the <a href="https://www.ers.usda.gov/data-products/food-price-outlook/summary-findings/">insane inflation</a> in the price of meat recently, I’ve been really drawn to their weekly specials. I’ll typically buy a few hundred dollars worth whenever one of my favorite cuts like ribeye or New York strip steak is at a reasonable price.</p><p>My local <a href="http://www.meatsbyjohnandwayne.com/">butcher shop</a> updates their weekly specials on Monday or Tuesday of each week. I was going out to their website manually and checking the specials, but since I’m a data scientist who specializes in web scraping, I couldn’t NOT automate that little task.</p><h3>Solution</h3><p>I began by making a small python app that I would run from the command line whenever I felt like checking. But, I learned that some guys were making simple <a href="https://telegram.org/">Telegram</a> bots to interact with APIs and such, so l checked that out and it seemed simple enough to program.</p><p>I decided on the following simple architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e-IaX_RViAlUUMmp.png" /></figure><p>Now, onto building the first part: the python script to scrape the website.</p><h3>Building it — python</h3><p>First, let’s build a simple scraping script with the <a href="https://www.crummy.com/software/BeautifulSoup/">BeautifulSoup</a> library. Make sure you init a <a href="https://github.com/">Github</a> repo at this point as well because we’ll need that to use <a href="https://github.com/features/actions">Github actions</a>.</p><pre>from bs4 import BeautifulSoup as bs<br>from decouple import config<br>import requests<br>import sys<br>import telepot</pre><p>We’ll use <a href="https://github.com/henriquebastos/python-decouple/">decouple</a> to handle the <a href="https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository">repository secrets</a> in the Github action, and <a href="https://github.com/nickoala/telepot">telepot</a> will work with the Telegram API for us.</p><p>Next, we’ll use the decouple config function to grab the Telegram user ID and API token</p><pre>MY_ID = config(&quot;MY_ID&quot;)<br>API_KEY = config(&quot;API_KEY&quot;)</pre><p>After that, we’ll write two functions: one to scrape the <a href="http://www.meatsbyjohnandwayne.com/">website</a> (it’s kind of messy, hence the garbage code), and the other to send the resulting string to our Telegram bot</p><pre>def getSpecials():<br>  URL = &quot;http://www.meatsbyjohnandwayne.com/weeklyspecials.html&quot;</pre><pre>  response = requests.get(URL)</pre><pre>  html = response.content<br>  soup = bs(html, &quot;lxml&quot;)</pre><pre>  answer = (<br>    soup.find(&quot;td&quot;)<br>    .text.replace(&quot;\n&quot;, &quot;&quot;)<br>    .replace(&quot;\xa0&quot;, &quot;&quot;)<br>    .replace(<br>      &quot;(function(d, s, id) {\r  var js, fjs = d.getElementsByTagName(s)[0];\r  if (d.getElementById(id))        return;\r  js = d.createElement(s); js.id = id;\r  js.src =         \&quot;//connect.facebook.net/en_US/sdk.js#xfbml=1&amp;version=v2.5\&quot;;\r  fjs.parentNode.insertBefore(js, fjs);\r}(document, &#39;script&#39;, &#39;facebook-jssdk&#39;));&quot;,<br>    &quot;&quot;,<br>    )<br>  )</pre><pre>  return answer<br></pre><pre>def send_telegram_message(msg):</pre><pre>  bot = telepot.Bot(API_KEY)<br>  bot.getMe()<br>  bot.sendMessage(MY_ID, msg)</pre><p>Finally, we’ll run the whole thing</p><pre>if __name__ == &quot;__main__&quot;:<br><br>    # Get the specials<br>    meats = getSpecials()<br><br>    send_telegram_message(meats)</pre><p>If we run it, we get something like this:</p><pre>Specials for the WeekMONDAY-SATURDAY1/31/22-2/5/22USDA <br>CHOICENEW YORK STRIPSTEAK$9.99/LB <br>TORTILLA CRUSTEDHOT PEPPER CHEESE STUFFED CHICKEN BREAST$6.99/LB<br>OUR OWNSMOKED HUNTERSRING SAUSAGE$3.99/LB</pre><p>which is really a big run-on sentence. You could easily parse this to make it prettier but I can read it fine so I moved on.</p><p>I use <a href="https://pipenv.pypa.io/en/latest/">pipenv</a> for dependencies and you can see that detail in the repo if you’re interested. Full python code at the end as well as at the <a href="https://github.com/bradlindblad/meatbot">repo</a>.</p><h3>Building it — Github actions</h3><p>Now that we have a working script, we’ll set up the Github action to run our scraping script for us with this yaml file, .github.workflows/send_meat_via_telegram.yaml</p><pre>name: meat_telegram</pre><pre># Controls when the action will run.<br>on:<br>  # Action can be manually started<br>  workflow_dispatch:<br>  # job runs on Mon and Tues mornings<br>  schedule:<br>    - cron: &#39;0 15 * * 1&#39;<br>    - cron: &#39;0 13 * * 2&#39;</pre><pre>jobs:</pre><pre>  build:<br>    name: Build<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Check out this repository<br>        uses: actions/checkout@v2</pre><pre>      - name: Set up Python<br>        uses: actions/setup-python@v2<br>        with:<br>          python-version: &#39;3.8&#39;</pre><pre>      - name: Install pipenv<br>        run: pip install pipenv</pre><pre>      - name: Install deps<br>        run: pipenv install</pre><pre>        # Run the Python script<br>      - name: Run Python script<br>        run: pipenv run python main.py<br>        env:<br>          API_KEY: ${{ secrets.API_KEY }}<br>          MY_ID: ${{ secrets.MY_ID }}</pre><p>Again, check out the repo for more details on where to place this script, but it is very simple: it checks out the current repo (and our python script from above), it sets up pipenv and runs the python scraping script using my two secrets. There is a cron statement up top to run this Monday and Tuesday morning (when I usually buy meat for the week).</p><p>Hold on for now with the secrets on the last two lines, we need to get them from Telegram quick.</p><h3>Building it — Telegram</h3><p>We need to do a few things to get up and running with our Telegram bot. First, search for “@BotFather” user. This is a bot maintained by Telegram to set up other bots. Follow the instructions therein to create a bot, and save the API key that he will give you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/0*J-3C4B6_bqi0xZjB.png" /></figure><p>Next, you need to find your unique chat ID. Search for Telegram bot “@username_to_id_bot”, and it should show you your ID. Save that.</p><p>Now that we have our API key and chat ID, we need to add those to our Github repo as repository secrets. I could explain how to do that but Github does a <a href="https://docs.github.com/en/actions/security-guides/encrypted-secrets">better job than I ever could</a>. Remember to add your Telegram API key as “API_KEY” and your chat ID as “MY_ID” to coincide with our python script and Github action yaml file.</p><h3>Wrap up</h3><p>That’s it. Now this bot will send a notification to my (or your) Telegram account on a regular basis with the best meat specials in town. Use this repo as an example to extend python, github actions and telegram to solve your own problems and hammer your own nails.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/0*WozLH4gxynKXCFUv.png" /></figure><h3>Appendix</h3><p>All of this code can be found at the repo: <a href="https://github.com/bradlindblad/meatbot">https://github.com/bradlindblad/meatbot</a></p><h3>main.py</h3><pre>from bs4 import BeautifulSoup as bs<br>from decouple import config<br>import requests<br>import sys<br>import telepot<br></pre><pre>MY_ID = config(&quot;MY_ID&quot;)<br>API_KEY = config(&quot;API_KEY&quot;)</pre><pre>def getSpecials():<br>    URL = &quot;http://www.meatsbyjohnandwayne.com/weeklyspecials.html&quot;</pre><pre>    response = requests.get(URL)</pre><pre>    html = response.content<br>    soup = bs(html, &quot;lxml&quot;)</pre><pre>    answer = (<br>        soup.find(&quot;td&quot;)<br>        .text.replace(&quot;\n&quot;, &quot;&quot;)<br>        .replace(&quot;\xa0&quot;, &quot;&quot;)<br>        .replace(<br>            &quot;(function(d, s, id) {\r  var js, fjs = d.getElementsByTagName(s)[0];\r  if (d.getElementById(id)) return;\r  js = d.createElement(s); js.id = id;\r  js.src = \&quot;//connect.facebook.net/en_US/sdk.js#xfbml=1&amp;version=v2.5\&quot;;\r  fjs.parentNode.insertBefore(js, fjs);\r}(document, &#39;script&#39;, &#39;facebook-jssdk&#39;));&quot;,<br>            &quot;&quot;,<br>        )<br>    )</pre><pre>    return answer<br></pre><pre>def send_telegram_message(msg):</pre><pre>    bot = telepot.Bot(API_KEY)<br>    bot.getMe()<br>    bot.sendMessage(MY_ID, msg)<br></pre><pre>if __name__ == &quot;__main__&quot;:</pre><pre>    # Get the specials<br>    meats = getSpecials()</pre><pre>    send_telegram_message(meats)</pre><h3>send_meat_via_telegram.yaml</h3><pre>name: meat_telegram</pre><pre># Controls when the action will run.<br>on:<br>  # Action can be manually started<br>  workflow_dispatch:<br>  # job runs on Mon and Tues mornings <br>  schedule:<br>    - cron: &#39;0 15 * * 1&#39;<br>    - cron: &#39;0 13 * * 2&#39;</pre><pre>jobs:</pre><pre>  build:<br>    name: Build<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Check out this repository<br>        uses: actions/checkout@v2</pre><pre>      - name: Set up Python<br>        uses: actions/setup-python@v2<br>        with:<br>          python-version: &#39;3.8&#39;<br>      <br>      - name: Install pipenv<br>        run: pip install pipenv</pre><pre>      - name: Install deps<br>        run: pipenv install</pre><pre>        # Run the Python script<br>      - name: Run Python script<br>        run: pipenv run python main.py<br>        env: <br>          API_KEY: ${{ secrets.API_KEY }}<br>          MY_ID: ${{ secrets.MY_ID }}</pre><h3>Directory structure</h3><pre>.<br>├── .gitattributes<br>├── .github<br>│   └── workflows<br>│       └── send_meat_via_telegram.yml<br>├── main.py<br>├── Pipfile<br>├── Pipfile.lock<br>└── README.md</pre><p><strong><em>Want more content like this?</em></strong> <a href="https://technistema.com/contact/">Subscribe here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f886a6de5a51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Text Analysis With the Schrutepy Package]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/python-text-analysis-with-the-schrutepy-package-234bc70f3916?source=rss-27ad429f9b76------2"><img src="https://cdn-images-1.medium.com/max/820/0*7p-8biq0D2CLXJiJ.png" width="820"></a></p><p class="medium-feed-snippet">This new Python package makes text analysis fun</p><p class="medium-feed-link"><a href="https://medium.com/data-science/python-text-analysis-with-the-schrutepy-package-234bc70f3916?source=rss-27ad429f9b76------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/python-text-analysis-with-the-schrutepy-package-234bc70f3916?source=rss-27ad429f9b76------2</link>
            <guid isPermaLink="false">https://medium.com/p/234bc70f3916</guid>
            <category><![CDATA[the-office]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Brad Lindblad]]></dc:creator>
            <pubDate>Sat, 18 Jan 2020 00:00:00 GMT</pubDate>
            <atom:updated>2020-01-19T03:52:27.344Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How Would Hemingway Write Code?]]></title>
            <link>https://codeburst.io/how-would-hemingway-write-code-cab7054560e0?source=rss-27ad429f9b76------2</link>
            <guid isPermaLink="false">https://medium.com/p/cab7054560e0</guid>
            <category><![CDATA[r]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Brad Lindblad]]></dc:creator>
            <pubDate>Mon, 30 Dec 2019 00:00:00 GMT</pubDate>
            <atom:updated>2019-12-31T01:23:00.156Z</atom:updated>
            <content:encoded><![CDATA[<p>Probably with whiskey</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/0*JBP3SgZXWzudzH6_.jpeg" /></figure><p>How many times have you looked back on code you wrote a few months back and thought, “what the hell was that?” I regularly scratch my head at code I wrote a few days prior, especially if I rationalized my spaghetti code away as a “scratch file.”</p><p>There is objectively good code and bad code, in the same way there is good writing and bad writing. Writing good code isn’t all that different from writing good prose. Both good code and writing need to follow certain rules and best practices, as well as artfully solve many problems that lie outside the scope of rigid covenant.</p><p>Great code is concise, glaring in its intent, and brief — following the <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY principle</a>. There was no other writer who followed these coding practices to their natural conclusion <em>in literature</em> better than Ernest Hemingway. Hemingway wrote seven novels in the first half of the 20th century and won the Nobel Prize for Literature in 1954. He was the master of the simple sentence and the restrained narrative, developing this style as a young reporter.</p><p>My thought experiment: how would Hemingway write code if he were a data scientist or a web developer? What can we learn from the techniques that crafted some of the best American literature? Let’s find out.</p><h3>He would study the greats</h3><blockquote><em>Samuelson: But reading all the good writers must discourage you. Hemingway: Then you ought to be discouraged.</em></blockquote><p>In the open-source world, we have free access to some of the best code ever written. All we have to do is open GitHub and browse the source code of our favorite projects.</p><p>If Hemingway wrote R code like I do, he would have read all the <a href="https://www.tidyverse.org/">Tidyverse</a> “books” written by the phenomenal R scientist Hadley Wickham. These are the classics in the R community; many R developers regularly consult these repos when writing code for inspiration or ideas on how to solve a problem.</p><p>Since ancient times, most forms of art have had some kind of master-apprentice program. Rembrandt didn’t attend an online art school and immediately brush out <em>The Nightwatch</em>. He studied under a master to observe and absorb everything he could.</p><p>Today, the apprenticeship process is not so clearly defined but continues to exist in other forms. In 1934, an aspiring young Minnesotan named Samuelson hitchhiked to Hemingway’s <em>casa</em> in Key West to boldly knock on his door, putting his lot in Fate’s hands. Hem not only invited him over the next day, but he hired him to watch his boat for the next year, with a great deal of mentoring along the way.</p><p>At one point Samuelson asked what he should read to become a great writer. Hem produced a long list of books which he pressed on Samuelson to devour.</p><blockquote><em>Samuelson: Should a writer have read all of those?</em></blockquote><blockquote><em>Hemingway: All of those and plenty more. Otherwise he doesn’t know what he has to beat.</em></blockquote><h3>He would code from experience</h3><p>One of the reason’s Hem’s books are classics is because he wrote from his own experience. His time as an ambulance driver in Italy during the Great War fueled his masterpiece <em>A Farewell To Arms</em>. His love of the outdoors dripped onto the pages of <em>The Old Man and the Sea</em>. He didn’t doodle from imagination but from vivid memories and tactile experiences that the reader finds absolutely authentic.</p><p>But how does a developer code from experience? Two words: business knowledge. If you’re designing an app to optimize freight deliveries for example, ride with a delivery driver for a week to gain a different perspective that your rubber duckie could never provide. Go out and learn the How and Why of what is desired, from the people who will actually use the thing.</p><blockquote><em>Hemingway: Whatever success I have had has been through writing what I know about.</em></blockquote><h3>He would code longhand</h3><p>Hem wrote much of his 50,000+ word novels longhand, with pen and paper. Even though he could have written faster with a typewriter, he still crafted most of his first drafts the ancient way: applying carbon to pressed pulp.</p><p>Modern science now tells us that writing longhand engages our brain more, helps us to be more creative, and increases comprehension — all benefits lacking from computer composition.</p><p>While the idea of writing code longhand may abhor you, especially if you lean a bit too heavily on your IDE’s intellisense, you’ll realize that you will Think before writing when the effort to write is greater, instead of thinking after typing.</p><p>I usually map out the salient chunks of my code on paper before even thinking of firing up my computer. I outline all the functions, map out which modules go where, etc., on whatever paper is handy. At that point, I’ll open my laptop and start carefully revising my ideas until I have something solid — a good first draft of the code. Next, I’ll work through one to three revisions, making changes and asking for feedback from peers. When I follow this practice, I definitely do NOT have the “WFT is this” feeling when reviewing it in the future.</p><h3>He would stop strategically</h3><p>In the age of the full stack and 10x developer, we could take a cue from Hem on resting. In one letter he outlines his thoughts on what we now call the work-home balance:</p><blockquote><em>Hemingway: It is better to produce half as much, get plenty of exercise and not go crazy then to speed up so that your head is hardly normal.</em></blockquote><p>Hem would begin a new adventure after finishing a manuscript or go fishing in the Gulf of Mexico when he had writer’s block. He knew the importance of getting his head out of the game at regular intervals.</p><p>Developers take pride in the odd hours they keep or the late-night work sessions that empty their internal reservoirs. Hem knew that he only had at best a handful of productive hours in any one day, so he didn’t attempt to force work after the golden hours had waned.</p><p>Do you ever stop reading a book on a cliffhanger? Just for the excitement, so when you sit down to read again you’re already jacked to see what happens? Hem did the same thing when he was writing his books. His protégé Samuelson asked him when he should knock off writing for the day, to which he responded:</p><blockquote><em>Hemingway: The best way is always to stop when you are going good and when you know what will happen next. If you do that every day when you are writing a novel you will never be stuck…don’t think about it or worry about it until you start to write the next day, that way your subconscious will work on it all the time.</em></blockquote><p>How often do you carry your work home with you? intentional or not? Junior web developer Hemingway would discourage this behavior because he learned that if he left his work at work, the next morning his subconscious would have the answer he was looking for all ready for him.</p><blockquote><em>Hemingway: The first draft of anything is shit.</em></blockquote><p>How much of your code gets past the first draft? Maybe it’s missing a few comments, or large chunks are carelessly commented out. If you were a craftsman, creating furniture that will be around long enough for your grandchildren to use, would you skip the hand sanding, leaving rough corners and blemishes?</p><p>While it may be entertaining to imagine Hemingway resolving a merge conflict, we can learn much about the development process in general from the man.</p><p>For further reading I suggest Hemingway’s <em>For Whom the Bell Tolls</em> as a good entry point, and <em>Ernest Hemingway on Writing</em> for more on his process.</p><p><em>Originally published at </em><a href="https://technistema.com/posts/how-would-hemingway-write-code/"><em>https://technistema.com</em></a><em> on December 30, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cab7054560e0" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/how-would-hemingway-write-code-cab7054560e0">How Would Hemingway Write Code?</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing the schrute Package: the Entire Transcripts From The Office]]></title>
            <link>https://medium.com/data-science/introducing-the-schrute-package-the-entire-transcripts-from-the-office-cfc13fe1e769?source=rss-27ad429f9b76------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfc13fe1e769</guid>
            <category><![CDATA[r]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[love]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Brad Lindblad]]></dc:creator>
            <pubDate>Sun, 15 Dec 2019 00:00:00 GMT</pubDate>
            <atom:updated>2019-12-15T19:12:41.719Z</atom:updated>
            <content:encoded><![CDATA[<h4>The Jimothy of text datasets</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gf6yzF9Zmy4NW5sIdT_8Gg.png" /></figure><p><a href="https://bradlindblad.github.io/schrute/">Github Repo</a></p><p>This is a package that does/has only one thing: the complete transcriptions of all episodes of <a href="https://www.imdb.com/title/tt0386676/">The Office!</a> (US version).</p><p>Use this data set to master NLP or text analysis. Let’s scratch the surface of the subject with a few examples from the excellent <a href="https://www.tidytextmining.com/">Text Mining with R</a> book, by Julia Silge and David Robinson.</p><p>First, install the package from CRAN:</p><pre># install.packages(&quot;schrute&quot;) <br>library(schrute)</pre><p>There is only one data set with the schrute package; assign it to a variable</p><pre>mydata &lt;- schrute::theoffice</pre><p>Take a peek at the format:</p><pre>dplyr::glimpse(mydata) </pre><pre>#&gt; Observations: 55,130 #&gt; Variables: 7 <br>#&gt; $ index &lt;int&gt; 1, 358, 715, 1072, 1429, 1786, 2143, 2500, 2857... #&gt; $ season &lt;chr&gt; &quot;01&quot;, &quot;01&quot;, &quot;01&quot;, &quot;01&quot;, &quot;01&quot;, &quot;01&quot;, &quot;01&quot;, &quot;01&quot;,... #&gt; $ episode &lt;chr&gt; &quot;01&quot;, &quot;01&quot;, &quot;01&quot;, &quot;01&quot;, &quot;01&quot;, &quot;01&quot;, &quot;01&quot;, &quot;01&quot;,... <br>#&gt; $ episode_name &lt;chr&gt; &quot; Pilot&quot;, &quot; Pilot&quot;, &quot; Pilot&quot;, &quot; Pilot&quot;, &quot; Pilot... <br>#&gt; $ character &lt;chr&gt; &quot;Michael&quot;, &quot;Jim&quot;, &quot;Michael&quot;, &quot;Jim&quot;, &quot;Michael&quot;, ... <br>#&gt; $ text &lt;chr&gt; &quot; All right Jim. Your quarterlies look very goo... #&gt; $ text_w_direction &lt;chr&gt; &quot; All right Jim. Your quarterlies look very goo...</pre><pre>mydata %&gt;% <br>dplyr::filter(season == &#39;01&#39;) %&gt;% <br>dplyr::filter(episode == &#39;01&#39;) %&gt;% <br>dplyr::slice(1:3) %&gt;% <br>knitr::kable()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*vAGlKAbRvJJh8OoOXaJfMQ.png" /></figure><p>So what we have is the season, episode number and name, character, the line spoken and the line spoken with the stage direction (cue).</p><p>We can tokenize all of the lines with a few lines from the tidytext package:</p><pre>token.mydata &lt;- mydata %&gt;% <br>tidytext::unnest_tokens(word, text)</pre><p>This increases our data set to 575146 records, where each record contains a word from the script.</p><pre>token.mydata %&gt;% <br>dplyr::filter(season == &#39;01&#39;) %&gt;% <br>dplyr::filter(episode == &#39;01&#39;) %&gt;% <br>dplyr::slice(1:3) %&gt;% <br>knitr::kable()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*pEb7-s8AEDwTSDmxmW3m-A.png" /></figure><p>If we want to analyze the entire data set, we need to remove some stop words first:</p><pre>stop_words &lt;- tidytext::stop_words tidy.token.mydata &lt;- token.mydata %&gt;% dplyr::anti_join(stop_words, by = &quot;word&quot;)</pre><p>And then see what the most common words are:</p><pre>tidy.token.mydata %&gt;% <br>dplyr::count(word, sort = TRUE) <br>#&gt; # A tibble: 19,225 x 2 <br>#&gt;  word      n <br>#&gt; &lt;chr&gt;    &lt;int&gt; <br>#&gt; 1 yeah    2895 <br>#&gt; 2 hey     2189 <br>#&gt; 3 michael 2054 <br>#&gt; 4 dwight  1540 <br>#&gt; 5 uh      1433 <br>#&gt; 6 gonna   1365 <br>#&gt; 7 jim     1345 <br>#&gt; 8 pam     1168 <br>#&gt; 9 time    1129 <br>#&gt; 10 guys   933 <br>#&gt; # ... with 19,215 more rows</pre><pre>tidy.token.mydata %&gt;% <br>dplyr::count(word, sort = TRUE) %&gt;% <br>dplyr::filter(n &gt; 400) %&gt;% <br>dplyr::mutate(word = stats::reorder(word, n)) %&gt;% ggplot2::ggplot(ggplot2::aes(word, n)) + <br>ggplot2::geom_col() + <br>ggplot2::xlab(NULL) + <br>ggplot2::coord_flip() + <br>ggplot2::theme_minimal()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VBf-4A6EbIMZ7cIc.png" /></figure><p>Feel free to keep going with this. Now that you have the timeline (episode, season) and the character for each line and word in the series, you can perform an unlimited number of analyses. Some ideas: — Sentiment by character — Sentiment by character by season — Narcissism by season (ahem.. Nard Dog season 8–9) — Lines by character — Etc.</p><p><em>Originally published at </em><a href="https://technistema.com/posts/introducing-the-schrute-package-the-entire-transcripts-from-the-office/"><em>https://technistema.com</em></a><em> on December 15, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfc13fe1e769" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/introducing-the-schrute-package-the-entire-transcripts-from-the-office-cfc13fe1e769">Introducing the schrute Package: the Entire Transcripts From The Office</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Announcing tidyUSDA: An R Package for Working with USDA Data]]></title>
            <link>https://medium.com/data-science/announcing-tidyusda-an-r-package-for-working-with-usda-data-6066fa830f0a?source=rss-27ad429f9b76------2</link>
            <guid isPermaLink="false">https://medium.com/p/6066fa830f0a</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Brad Lindblad]]></dc:creator>
            <pubDate>Sun, 29 Sep 2019 00:00:00 GMT</pubDate>
            <atom:updated>2019-10-01T13:16:02.386Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>I’m proud to announce the release of an R package that has cured one of my own personal itches: pulling and working with USDA data, specifically Quick Stats data from NASS. tidyUSDA is a minimal package for doing just that. The following is cut out from the package vignette, which you can find here: </em></strong><a href="https://github.com/bradlindblad/tidyUSDA"><strong><em>https://github.com/bradlindblad/tidyUSDA</em></strong></a></p><h3>Why tidyUSDA?</h3><p><em>Why do we need yet another “tidy” package? Why do I have to install so many geospatial dependencies?</em></p><p>Valid questions. If you work with USDA data, you know that it is difficult at times to find what you need, when you need it. The sheer amount of data (the 2017 Census of Agriculture included some 6.4 million points of information [1]) should be a credit to the USDA, as that is a huge organizational task.</p><p>Currently, the best way to pull data from previous Censuses of Agriculture and Agriculture Surveys is through the <a href="https://quickstats.nass.usda.gov/">Quick Stats web portal</a>, which allows you to apply filters in an interactive gui and then download CSV files. This works great for most applications, but R programmers hate having to pull data non-programmatically, which is where tidyUSDA comes in.</p><p><strong><em>Programmatic data pulls directly from Quick Stats</em></strong> At its core, tidyUSDA is an API for the Quick Stats data, allowing you to pull that same data into a dataframe in your R session.</p><p><strong><em>Geospatial capabilities</em></strong> tidyUSDA also gives you the option to automatically add a simple features column to the Quick Stats data, either at a county or national level. This allows you to quickly visualize Quick Stats data for fast iterations or report generation.</p><h3>Quick start</h3><p>First, install tidyUSDA with the instructions in the <a href="https://github.com/bradlindblad/tidyUSDA#Installation">README section</a>. Note that you may have to upgrade your R version if you are on an older build.</p><p>Next, call tidyUSDA to make sure everything is installed correctly.</p><pre>library(tidyUSDA)</pre><p>The USDA controls access to their data with API keys. You can quickly obtain your free API key by following the brief instructions at <a href="https://quickstats.nass.usda.gov/api">this link</a>.</p><p>Let’s pull some data now.</p><pre># Use keyring to store your api key <br># key &lt;- keyring::key_get(&quot;tidyusda&quot;)</pre><pre># Or hard code that thing <br>key &lt;- &#39;abc-123&#39; </pre><p>At this point, it’s best to use the actual Quick Stats website to pick out the parameters you would like to filter by. This way you know for sure that data will be returned. I want to see a state-level breakdown of counts of operations using the 2017 census data.</p><p>At this point it helps to see which possible values you <strong>can</strong> input into the function parameters. You can view these possible inputs for all of the parameters with the built-in datasets. Let’s check a few out.</p><pre>tidyUSDA::allCategory %&gt;% head() <br>#&gt; statisticcat_desc1 statisticcat_desc2 <br>#&gt; &quot;ACCESSIBILITY&quot; &quot;ACCESSIBILITY, 5 YEAR AVG&quot; <br>#&gt; statisticcat_desc3 statisticcat_desc4 <br>#&gt; &quot;ACCESSIBILITY, PREVIOUS YEAR&quot; &quot;ACTIVE GINS&quot; <br>#&gt; statisticcat_desc5 statisticcat_desc6 <br>#&gt; &quot;ACTIVITY&quot; &quot;ACTIVITY, 5 YEAR AVG&quot;</pre><p>So it looks like there are only six possible input values for the <em>category</em> field. Good to know.</p><pre>tidyUSDA::allGeogLevel %&gt;% head() <br>#&gt; agg_level_desc1 agg_level_desc2 <br>#&gt; &quot;AGRICULTURAL DISTRICT&quot; &quot;AMERICAN INDIAN RESERVATION&quot; <br>#&gt; agg_level_desc3 agg_level_desc4 <br>#&gt; &quot;COUNTY&quot; &quot;INTERNATIONAL&quot; <br>#&gt; agg_level_desc5 agg_level_desc6 <br>#&gt; &quot;NATIONAL&quot; &quot;REGION : MULTI-STATE&quot;</pre><p>There are many different geography levels. Currently there is only support for providing geometries for <em>county</em> and <em>state</em> values.</p><p>Now that we’re a little more clear on what we can input, let’s use our main function for data pulling.</p><pre># Get count of operations with sales in 2017 <br>ops.with.sales &lt;- tidyUSDA::getQuickstat(sector=NULL, group=NULL, commodity=NULL, category=NULL, domain=NULL, county=NULL, key = key, program = &#39;CENSUS&#39;, data_item = &#39;CROP TOTALS - OPERATIONS WITH SALES&#39;, geographic_level = &#39;STATE&#39;, year = &#39;2017&#39;, state = NULL, geometry = TRUE, lower48 = TRUE)</pre><p>Note that I set <em>geometry = TRUE</em> in order to include the geometry feature that we need for plotting, and that I set <em>lower48 = TRUE</em> in order to exclude Hawaii and Alaska.</p><p>At this point, I have a dataframe with a rather verbose number of data fields. If you set <em>geometry = TRUE</em>, you will have even more columns. The main data point from Quick Stats will be in the ‘Value’ field. Feel free to filter the data frame for the fields you actually need at this point.</p><p>Now let’s see what the data looks like with a basic choropleth map.</p><pre># Plot this data for each state <br>tidyUSDA::plotUSDA(df = ops.with.sales)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jT73t9I5Nymxhpfc.png" /></figure><p>OK wow, so it looks like all the farms in the country are in California. But wait a second, California is huge as far as landmass, and the relative size of the farms are smaller on balance, so maybe we should look at this a different way. First, let’s clean up the dataframe so it’s easier to work with.</p><pre>mydata &lt;- ops.with.sales[,c(&quot;NAME&quot;, &quot;Value&quot;, &quot;ALAND&quot;)]</pre><p>We select the name of the state, the value from our Quick Stat query (number of ops) and ‘ALAND’, which is the land area in square meters. Let’s modify our dataframe to calculate the number of operations per square meter, so the size of the state doesn’t affect what we’re trying to derive.</p><pre>mydata$ALAND &lt;- as.numeric(mydata$ALAND) <br>mydata$modified_value &lt;- mydata$Value / mydata$ALAND</pre><p>This gives us a bunch of really small numbers that don’t make sense, but for our purposes of mapping, they’ll do.</p><pre># tidyUSDA::plotUSDA(df = mydata, target_col = &#39;modified_value&#39;) tidyUSDA::plotUSDA(df = mydata, fill_by = &#39;modified_value&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c1fWzO-AnDsacWZy.png" /></figure><p>Ahh, much better. Now we have a true plot showing the number of operations per square meter. Looks like California still has the most farms per dirt clod than any other state.</p><p><em>Originally published at </em><a href="https://technistema.com/post/announcing-tidyusda-a-package-for-working-with-usda-data/"><em>https://technistema.com</em></a><em> on September 29, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6066fa830f0a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/announcing-tidyusda-an-r-package-for-working-with-usda-data-6066fa830f0a">Announcing tidyUSDA: An R Package for Working with USDA Data</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a Corporate R Package for Pleasure and Profit]]></title>
            <link>https://medium.com/data-science/build-a-corporate-r-package-for-pleasure-and-profit-78b73ce4ff4b?source=rss-27ad429f9b76------2</link>
            <guid isPermaLink="false">https://medium.com/p/78b73ce4ff4b</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[r]]></category>
            <dc:creator><![CDATA[Brad Lindblad]]></dc:creator>
            <pubDate>Tue, 05 Mar 2019 13:56:22 GMT</pubDate>
            <atom:updated>2019-03-05T13:56:22.081Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*9AEOr1WsxiIx-T8g5ubBFg.png" /></figure><p>The “Great Restructuring” of our economy is underway. That’s the official name for what we know is happening: the best are rising to the top, and the mediocre are sinking to the bottom. It’s the <a href="https://en.wikipedia.org/wiki/Matthew_effect">Matthew Principle</a> in-motion.</p><p>In Brynjolfsson and McAfee’s 2011 book <em>Race Against the Machine</em>, they detail how this New Economy will favor those that have the skill set or the capital to interface and invest in new technologies such as deep learning and robotics, which are becoming more ubiquitous every day.</p><p>Cal Newport’s <em>Deep Work</em> outlines two core abilities for thriving in this new economy:</p><blockquote>1. Be able to quickly master hard things</blockquote><blockquote>2. Be able to produce at an elite level, in terms of both quality and speed. This need for speed (sorry) will be our focus.</blockquote><p><strong>Don’t repeat yourself (DRY)</strong> is a well-known maxim in software development, and most R programmers follow this rule and build functions to avoid duplicating code. But how often do you:</p><ul><li>Reference the same dataset in different analyses</li><li>Create the same ODBC connection to a database</li><li>Tinker with the same colors and themes in ggplot</li><li>Produce markdown docs from the same template</li></ul><p>and so on? Notice a pattern? The word “same” is sprinkled in each bullet point. I smell an opportunity to apply DRY!</p><p>If you work in a corporate or academic setting like me, you probably do these things pretty often. I’m going to show you how to wrap all of these tasks into a minimalist R package to save you time, which, as we’ve learned, is one of the keys to your success in the New Economy.</p><h3>Tools</h3><p>First some groundwork. I’ll assume if you work in R that you are using RStudio, which will be necessary to follow along. I’m using R version 3.5.1 on a Windows 10 machine (ahh, corporate America…). Note that the package we are about to develop is minimalist, which is a way of saying that we’re gonna cut corners to make a minimum viable product. We won’t get deep into documentation and dependencies much, as the packages we’ll require in our new package are more than likely already on your local machine.</p><h3>Create an empty package project</h3><p>We’ll be creating a package for the consulting firm <a href="https://www.ketchbrookanalytics.com/">Ketchbrook Analytics</a>, a boutique shop from Connecticut who know their way around a %&gt;% better than anyone.</p><p>Open RStudio and create a project in a new directory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*CMssSZ8uLsbLtc6oYHIfzQ.png" /></figure><p>Select <strong>R Package</strong> and give it a name. I’ll call mine ketchR.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*HrXqpeDk5c8Oy_JqFKatGA.png" /></figure><p>RStudio will now start a new session with an example “hello” function. Looks like we’re ready to get down to business.</p><h3>Custom functions</h3><p>Let’s start by adding a function to our package. A common task at Ketchbrook is mapping customer data with an outline for market area or footprint. We can easily wrap that into a simple function.</p><p>Create a new R file and name it ketchR.R. We’ll put all of our functions in here.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb403517e15e9cc2fca5568b0dce5807/href">https://medium.com/media/fb403517e15e9cc2fca5568b0dce5807/href</a></iframe><p>So what we’ve done is create a function that utilizes the tigris package to grab shapefiles for states in our footprint. The function then unions those states into one contiguous polygon so we can easily overlay this using leaflet, ggmap, etc.</p><p>Try your new function out:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f060c0acd75446cb173e9f108bb41a14/href">https://medium.com/media/f060c0acd75446cb173e9f108bb41a14/href</a></iframe><p>You get a nice little western seaboard:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*H0B3xB7XrgYzVt7QCiNsrA.png" /></figure><p>There is no limit to what kinds of custom functions you can add in your package. Machine learning algs, customer segmentation, whatever you want you can throw in a function with easy access in your package.</p><h3>Datasets</h3><p>Let’s stay on our geospatial bent. Branch or store-level analysis is common in companies spread out over a large geographical region. In our example, Ketchbrook’s client has eight branches from Tijuana to Seattle. Instead of manually storing and importing a CSV or R data file each time we need to reference these locations, we can simply save the data set to our package.</p><p>In order to add a dataset to our package, we first need to pull it into our local environment either by reading a csv or grabbing it from somewhere else. I simply read in a csv from my local PC:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97ff703bd2219147da7a539a9a78a0f5/href">https://medium.com/media/97ff703bd2219147da7a539a9a78a0f5/href</a></iframe><p>This is what the data set looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*nbOQPLHzFMoCzzPfZo612Q.png" /></figure><p>Now, we have to put this data in a very specific place, or our package won’t be able to find it. Like when my wife hides the dishwasher so I’m reluctantly forced to place dirty dishes on the counter.</p><p>First, create a folder in your current directory called “data.” Your directory should look like this now, btw:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*zeJchCm9EAXJrxzVjdKmLg.png" /></figure><p>Bonus points: use the terminal feature in RStudio to create the directory easily:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*Vd2NCaWtfpb9XV-PNv2v2w.png" /></figure><p>Now we need to save this branches data set into our new folder as an .RData file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e41fa55914e7c995f53f2d0b6d39473e/href">https://medium.com/media/e41fa55914e7c995f53f2d0b6d39473e/href</a></iframe><h4>Now, we build</h4><p>Let’s test this package out while there’s still a good chance we didn’t mess anything up. When we build the package, we are compiling it into the actual package as we know it. In RStudio, this is super simple. Navigate to the “Build” tab, and click “Install and Restart.”</p><p>If you’ve followed along, you shouldn’t see any errors, but if you do see errors, try updating your local packages.</p><p>Now, we should be able to call our package directly and use our branches dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*C6HFcsUy1CVDu2i_GPVMJA.png" /></figure><p>Cool, that works. Now let’s plot our branches with Leaflet quick to make sure footprint_poly() worked:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eee76caa2bc0c6cc2870c94ee9166e64/href">https://medium.com/media/eee76caa2bc0c6cc2870c94ee9166e64/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*GnYzzWwhrKfNu3Cr3y6MnA.png" /></figure><p>Niiiice.</p><h3>Database connections</h3><p>One of the most common tasks in data science is pulling data from databases. Let’s say that Ketchbrook stores data in a SQL Server. Instead of manually copy and pasting a connection script or relying on the RStudio session to cache the connection string, let’s just make a damn function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5016e657cde22dfe1e1d19fa9d0f3821/href">https://medium.com/media/5016e657cde22dfe1e1d19fa9d0f3821/href</a></iframe><p>Here, we’re building a function that lets us enter any query we want to bang against this SQL Server. The function creates the connection, prompts us to enter the password each time (we don’t store passwords in code…) and closes the connection when it’s through.</p><p>Let’s take it a step further. Many times you may pull a generic SELECT * query in order to leverage dplyr to do your real data munging. In this case, it’s easier to just make a function that does just that.</p><p>Let’s make another function that pulls a SELECT * FROM Customers.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d61918ede91b33e48f4b4c96a3b22d8/href">https://medium.com/media/5d61918ede91b33e48f4b4c96a3b22d8/href</a></iframe><p>Ahh, this alone saved me quarters-of-hours each week once I started using it in my own practice. Think hard about any piece of code that you may copy and paste on a regular basis — that’s a candidate for your packages stable of functions.</p><h3>Branded ggplot visualizations</h3><p>Ok now we’re getting to the <em>primo</em> honey, the real time-savers, the analyst-impresser parts of our package. We’re going to make it easy to produce consistent data visualizations which reflect a company’s image with custom colors and themes.</p><p>Although I personally believe the viridis palette is the best color scheme of all time, it doesn’t necessarily line up with Ketchbrook’s corporate color palette. So let’s make our own set of functions to use Ketchbrook’s palette is a ‘lazy’ way. (Big thanks to this <a href="https://www.r-bloggers.com/creating-corporate-colour-palettes-for-ggplot2/">Simon Jackson’s great article</a>).</p><h4>Get the colors</h4><p>Let’s pull the colors directly from <a href="https://www.ketchbrookanalytics.com/">their website.</a> We can use the Chrome plugin <a href="https://chrome.google.com/webstore/detail/colorzilla/bhlhnicpbhignbdhedgjhgdocnmhomnp">Colorzilla</a> to pull the colors we need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eOvQ_QEkBlQSSwhkcB5FaA.png" /></figure><p>Take those hex color codes and paste them into this chunk like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf5fb53403e0251b9fe1208f649ee3f8/href">https://medium.com/media/cf5fb53403e0251b9fe1208f649ee3f8/href</a></iframe><p>This will give us a nice palette that has colors different enough for categorical data, and similar enough for continuous data. We can even split this up into two separate sub-palettes for this very purpose:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84116968067c657de7d12204ae9f972f/href">https://medium.com/media/84116968067c657de7d12204ae9f972f/href</a></iframe><h4>Create the functions</h4><p>I’m not going to go through these functions line by line; if you have questions reach out to me at bradley.lindblad[at]gmail[dot]com, create an issue on the <a href="https://github.com/bradlindblad/ketchR">Github repo</a>. Here is the full code snippet:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c20127027010b62d5ececeeb5782de5/href">https://medium.com/media/9c20127027010b62d5ececeeb5782de5/href</a></iframe><p>Let’s test it out:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4a8650f5bcc496b5b8c5d38c5b90ef8/href">https://medium.com/media/b4a8650f5bcc496b5b8c5d38c5b90ef8/href</a></iframe><p>produces:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*7tDSG06TztFr1BS35_ai6g.png" /></figure><p>Nice. Having consistent colors in Ketchbrook’s visualizations will help build awareness for their brand, and faster recognition in the marketplace.</p><h3>Markdown templates</h3><p>Now that we’ve fetched the data and plotted the data much more quickly, the final step is to communicate the results of our analysis. Again, we want to be able to do this quickly and consistently. A custom markdown template is in order.</p><p>I found this part to be the hardest to get right, as everything needs to be in the right place within the file structure, so follow closely. (Most of the credit here goes to <a href="https://ismayc.github.io/ecots2k16/template_pkg/">this article by Chester Ismay</a>.)</p><h4>1. Create skeleton directory</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4fa4637ed882c6109bb56f68f536725b/href">https://medium.com/media/4fa4637ed882c6109bb56f68f536725b/href</a></iframe><p>This creates a nested directory that will hold our template .Rmd and .yaml files. You should have a new folder in your directory called “ketchbrookTemplate”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*jz2QbQemibgvt-TZr8CMpQ.png" /></figure><h4>2. Create skeleton.Rmd</h4><p>Next we create a new RMarkdown file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*DGL_LJGXB0-lVMZO2ptFVg.png" /></figure><p>This will give us a basic RMarkdown file like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mr3qqrTNRpgwkAZFspzK_A.png" /></figure><p>At this point let’s modify the template to fit our needs. First I’ll replace the top matter with a theme that I’ve found to work well for me, feel free to rip it off:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34e997d431bb8bb1faae0df7d5939ad7/href">https://medium.com/media/34e997d431bb8bb1faae0df7d5939ad7/href</a></iframe><p>I like to follow an analysis template, so this is the top matter combined with my basic EDA template:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86089bc45b121c66530368f82d6cd19f/href">https://medium.com/media/86089bc45b121c66530368f82d6cd19f/href</a></iframe><p>Save this file in the skeleton folder and we’re done here.</p><h4>3. Create the yaml file</h4><p>Next we need to create a yaml file. Simply create a new text document called “template.yaml” in RStudio and save it like you see in this picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GWh1HlrMVbxDGM3l0cpnHA.png" /></figure><p>Rebuild the package and open a new RMarkdown document, select “From Template” and you should see your new template available:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*LTlEePlGKOdVrNMPhgyvDw.png" /></figure><p>Sweet. You can now knit to html pretty and have sweet output like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*kN2eplvt-kE20IHKToXfUg.png" /></figure><p>If you run into problems, make sure your file structure matches this:</p><pre><br>├───inst<br>│   └───rmarkdown<br>│       └───templates<br>│           └───ketchbrookTemplate<br>│               │   template.yaml<br>│               │<br>│               └───skeleton<br>│                       skeleton.nb.html<br>│                       skeleton.Rmd</pre><h3>What’s next?</h3><p>So we’ve essentially made a bomb package that will let you do everything just a little more quickly and a little better: pull data, reference common data, create data viz and communicate results.</p><p>From here, you can use the package locally, or push it to a remote Github repository to spread the code among your team.</p><p>The full code for this package is available at the <a href="https://github.com/bradlindblad/ketchR">Github repo</a> set up for it. Feel free to fork it and make it your own. I’m not good at goodbye’s so I’m just gonna go.</p><p><em>I’m available for data science consulting on a limited basis. Reach me at bradley.lindblad[at]gmail[dot]com</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/0*ZVgvoIg73KbNOuNz" /></figure><h4>Thanks for reading!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78b73ce4ff4b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/build-a-corporate-r-package-for-pleasure-and-profit-78b73ce4ff4b">Build a Corporate R Package for Pleasure and Profit</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Customize your RStudio Theme (Finally)]]></title>
            <link>https://medium.com/data-science/customize-your-rstudio-theme-914cca8b04b1?source=rss-27ad429f9b76------2</link>
            <guid isPermaLink="false">https://medium.com/p/914cca8b04b1</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[r-language]]></category>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Brad Lindblad]]></dc:creator>
            <pubDate>Tue, 18 Dec 2018 14:07:33 GMT</pubDate>
            <atom:updated>2018-12-18T14:07:33.865Z</atom:updated>
            <content:encoded><![CDATA[<h4>Follow these simple steps to install custom themes in RStudio -themes included!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*eLjON45R_kHIfg_IgL8FIg.jpeg" /></figure><p>When my brain is tapped out after a grueling morning of data sciencing, my browser will invariably point to a smorgasbord of websites that <a href="https://www.rescuetime.com/">RescueTime</a> will classify as “entertainment.” From the <a href="https://stackexchange.com/questions">Hot Network Questions</a> page on Stack Overflow (“Question: why do demons heal faster than angels?”) to looking into <a href="https://github.com/hadley">Hadley’s</a> commits for the last six months.</p><p>After I feel like I’ve seen the entire internet, I’ll sometimes start fiddling with my IDE theme, as if changing the hex color of my function calls will actually improve my work. It’s not that my current font or color scheme aren’t perfectly fine, it’s the juicy rationalization that I’ll actually work faster if I have some dope ligatures.</p><p>I reinforce my obsession with these minutia by reminding myself what Oliver Wendell Holmes said way back in the 19th century; supposedly regarding his Win95 settings:</p><blockquote>“A moment’s insight is sometimes worth a life’s experience”</blockquote><p>So maybe, all of this sharpening of the axe, so to speak, is actually beneficial. Maybe, it makes us more suseptible to positive black swans. There, that’s a healthy rationalization!</p><h3>What a sweet update!</h3><p>I work in RStudio a lot, and while there’s been excellent themes and styles available for most IDEs and text editors like Sublime, Atom, Visual Studio Code for years, we RStudio peeps have been limited in this area. We’ve had a few basic themes and that’s about it.</p><p>Welp, that all changed a few months ago. RStudio v1.2xxx Preview was released in October and has a host of new features, including:</p><ul><li>D3 capabilities</li><li>Ability to run R jobs in the background</li><li>More SQL functionality</li><li>Cool plumbr API tools</li></ul><p>But for us, the sweetest feature is the ability to import our own themes! This article will quickly run through how we can duplicate the <a href="https://panda.siamak.work/">Panda syntax theme</a> in RStudio.</p><p>Let’s get to it.</p><h3>Git the theme with get</h3><p>RStudio now lets you upload .<em>tmThemes</em> and .<em>rsThemes</em> files. I hacked together a Panda-like theme and put it in a repo for you to download. I’ve also included an awesome font called “Fira Code iScript” in the repo, which we’ll get to later. Download the files with this git command:</p><pre>git clone <a href="https://github.com/bradlindblad/rstudio-panda.git">https://github.com/bradlindblad/rstudio-panda.git</a></pre><h4>Install fonts</h4><p>Fira Code iScript is an <a href="https://github.com/kencrocken/FiraCodeiScript">excellent font put together by Ken Crocken</a> which is a mash up of Fira Code and Script12. This font applies the Script12 typeface wherever there are italics, and Fira code everywhere else. To install it, double click on the <em>.tff</em> files you downloaded and then install the fonts in your system, which will be different for each OS.</p><p>It will end up looking like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*obde9zkqD5HWDC8uYbHybQ.png" /></figure><p>Pretty cool, eh? To use this font in RStudio, follow these steps:</p><ul><li>Open up RStudio, if you haven’t already</li><li>Navigate to Tools &gt; Global Options &gt; Appearance</li><li>Use the Editor Font box to select Fira Code iScript</li></ul><p>Note that you can install pretty much any font you want by following this process.</p><h4>Install panda theme</h4><p>Next we’ll install the panda theme. Follow along:</p><ul><li>Navigate to Tools &gt; Global Options &gt; Appearance</li><li>Under the Editor Theme box, click Add</li><li>Navigate to the <em>panda.thTheme</em> file that you cloned</li><li>Hit Open</li></ul><p>Now all you need is a quick restart and you’re rocking a new sweet theme! This is what it looks like in my system (Linux Mint 19, Dark):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7d-_S9O3Ssxpxf2OrJNLYQ.png" /></figure><p>Nice!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uXLoxXVjlNPm6LR4wOE91g.jpeg" /><figcaption>Obi Wan is pleased</figcaption></figure><h3>Make your own theme</h3><p>If the panda theme doesn’t do it for you, you can make your own with this <a href="https://tmtheme-editor.herokuapp.com/#!/editor/theme/Monokai">online editor</a>. This allows you to make any kind of custom theme you want. You just need to download the theme from the website and upload it to RStudio like we did above.</p><p>Good luck in your procrastinations!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=914cca8b04b1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/customize-your-rstudio-theme-914cca8b04b1">How to Customize your RStudio Theme (Finally)</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Woodworking Will Make You a Better Coder]]></title>
            <link>https://codeburst.io/why-woodworking-will-make-you-a-better-coder-b842e3733896?source=rss-27ad429f9b76------2</link>
            <guid isPermaLink="false">https://medium.com/p/b842e3733896</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Brad Lindblad]]></dc:creator>
            <pubDate>Wed, 11 Jul 2018 23:25:58 GMT</pubDate>
            <atom:updated>2018-08-30T12:18:24.316Z</atom:updated>
            <content:encoded><![CDATA[<p>Working with Wood is Fun.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*yg_9sRk4W7x2WV88akdojA.gif" /><figcaption>Security cam footage of my office</figcaption></figure><p>The era of the specialist is over.</p><p>Many adept technologists agree that being good at one thing is the same as being good at none; “two is one and one is none”. Those who can work across many disciplines — the polymaths — will dominate the future of business. As technology increases at an exponential rate, new industries are emerging that are the result of the cross-pollination of existing disciplines. Blockchain is a good example. Those that have a background in coding, cryptography, and web development have found themselves in the perfect position for building one of the most eminent emerging technologies of the present.</p><p>I’ve found that dissimilar hobbies can lead to unexpected transfer learning. In the following essay, I share an example of this lateral thinking; how skills in one area can inform learning and decision making in another.</p><p>I was tinkering in my woodshop after a long day of <em>data science-ing</em>. I often come to this dusty sanctuary to clear my head. It’s refreshing to produce something tactile after a long day of producing files that live on a server somewhere, out of reach. Working with wood tends to put me in <em>flow</em> the same a long jog will.</p><p>It was during one of these spaced-out sessions, mid chisel-blow, that I realized how similar woodworking and coding are. Building with a computer isn’t much different from building with a set of hand tools. The more I pondered, the more I realized how the lessons I learned in the woodshop as a kid have helped me write better code as a grown up. Follow along as I share five reasons why coders should think about trying their hand at woodworking.</p><h3><strong>It will teach you utility</strong></h3><p>I started writing code out of necessity. I had outgrown the analytical capabilities of excel and found myself fording the shallows of the R language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*YCsgUhuaNUBXHf7frI-YpA.jpeg" /></figure><p>Most people start woodworking in the same way; they need a box to store something in, or a coffee table to put coffee on. They slap some pine boards together with drywall screws and call it good. Code is no different- it’s a functional means to an end. No one writes code for the aesthetics of the words on the screen, they write it to do something — although I’ll admit Panda syntax is a joy to stare at. We strive to write code that’s as simple as possible, so our colleagues can decode it in the future. The more complex a system is, the more entropy will tear it apart.</p><h4><strong>Design</strong></h4><p>Let’s look at utility in the context of design. There are many interesting styles of furniture, but none match the beautiful simplicity of Shaker Furniture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*LkLj4lu0KEPgUYg7Gu6Obw.png" /><figcaption>Traditional Shaker Coffee Table</figcaption></figure><p>The Shakers were an Anabaptist sect scattered about New England in the 18th and 19th centuries. They were known for their utilitarian furniture, simple living, and celibacy (also why there are no Shakers today). As you can see, the piece above has simple lines with little to no ornamentation. It’s built out of hardwood selected for its durability and strength.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*DqE3MHhFC0kfX5ftVSHXAQ.png" /><figcaption>Chippendale Table</figcaption></figure><p>The second table is a reproduction of a Chippendale table, which is a more high-end style favored by the upper classes. This piece is stylized with carvings, frills, and otherwise unnecessary features that don’t add to its usefulness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*_ho13gx-quRMk0Zquy10Zw.jpeg" /><figcaption>Aged Shaker End Table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QV9Qf6Vd-_gMjKkr7kXVuQ.jpeg" /><figcaption>Aged Chippendale Table</figcaption></figure><p>The next two images are original Shaker and Chippendale pieces that have aged a few hundred years. As you can see, the Shaker is in much better shape than the Chippendale. Time didn’t treat the Chippendale as kindly due to the use of laminated wood veneer, which is a paper-thin sheet of wood that glued to the wood beneath. Over time, the glue loses its bond and the veneer curls off. The Shakers wouldn’t touch veneer with a ten-foot-long chastity belt, which is a reason why their furniture has aged gracefully like a sitcom in syndication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*Z2JnkN9UtMwWWS__M80jWQ.gif" /></figure><h4><strong>Templates</strong></h4><p>Efficient coders use templates whenever possible.</p><p>Woodworkers also use templates to produce consistent work quickly. For example, if I need to cut four table legs down to length, I will have more consistent and accurate results if I build a template on my crosscut saw, so I don’t have to measure and mark each leg. Another trick that woodworkers use is the ‘story stick’. Instead of repeatedly marking measurements with a tape measure throughout the project, you simply mark each measurement on one long stick of wood. Then you mark off cuts by placing the stick on the wood and transferring the measurements, eliminating the need for rulers and tape measures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*gzdB3tTVdWp5qCtvnccdAg.jpeg" /><figcaption>Story Stick</figcaption></figure><p>In a field of work where the term “lazy” is a positive connotation, building programs that run with minimal human input is a best practice. I’ve built several templates for EDA (exploratory data analysis) that I use to quickly and systematically analyze new data.</p><p>I realized at a young age that templating saved time and allowed me to build furniture more efficiently. No doubt, this skill transferred to my day job years later.</p><h3><strong>It will teach you to troubleshoot</strong></h3><p>Throughout the process of writing a program, you solve lots of little problems in order to solve one big problem. In this case, I define “problem” as an aspect of the build that stands on its own. For example, to build a web application that tracks stock prices, a developer would have to solve many micro problems such as setting up a database, API feeds, UI, etc. Along the way, issues will invariably crop up that need to be solved — either with novel ideas or a desultory review of Stack Overflow.</p><p>Woodworking prepares you for this work beautifully. Since many woodworking projects are bespoke, novel ideas, there often isn’t tested blueprints to work from, so the builder is forced to figure many things out for his or herself along the way, such as the best way to cut pieces from a rectangle of plywood, balancing the aesthetics of a piece or taking out “wobble”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*xN9Qo-XumEZpsutWp8Hg3g.gif" /><figcaption>Satisfying</figcaption></figure><h3><strong>It will teach you bootstrapping</strong></h3><p>In the startup or business sense, bootstrapping refers to starting a project with little or no funding or support, ‘to pull oneself up by his bootstraps’. A startup bootstrapping a new app will often spend just enough money to create an MVP (minimum viable product) before testing and rolling out a more complex product in the future. In the process of the aforementioned strategy, certain aspects of development may be placed together in a less than perfect manner, with cheaper parts.</p><p>In the context of woodworking, many larger projects are first bootstrapped together with cheaper materials and methods before the actual build begins for a few reasons. Number one, it is important to see what a finished project may look like in the flesh before expensive hardwoods are used. A client will also change their mind quite often after seeing the shop sketch of their buffet table in three dimensions in front of them.</p><p>Number two, having the opportunity to build the project in this test environment allows the inevitable unseen errors to crop up. Maybe the dovetail joint you planned to use in the case distracts from the ornamental wood you wished to draw attention to in the face frame. At any rate, you invite Murphy in and let his Law take effect, so you can clean up that mess before you get to the real thing.</p><p>In addition to this prototype bootstrapping, woodworkers often lack the exact materials they need to complete a project, so they’re forced to improvise. Black cherry is a premier hardwood used in fine furniture. Due to its relative scarcity in nature, small trunk diameter, and market demand, the price of a board-foot is higher than the price of many other wood types. Woodworkers don’t always have the funds to build a chair or kitchen cabinet set with the coppery wood, so they’ll bootstrap the project by improvising with dyes and paint glazes on cheaper woods like birch. Natural cherry and stained and glazed birch are virtually indistinguishable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*WkOn0_RxjmNHLq0XQvsRSQ.gif" /><figcaption>Hipster Woodworker</figcaption></figure><h3><strong>It will teach you to progress</strong></h3><p>William S Burroughs is credited with the quote, “if you’re not growing, you’re dying.” In this global economy where workers aren’t just competing with talent in their locality, but with talent around the world, this quote should be your jam. You need to constantly improve your existing skill set as well as learn new things.</p><p>Sort your code repository or Git repo by date and look at the first program you wrote. It’s horrendous, right? Doesn’t pay any attention to folding best practices, probably repeats itself and may even lack a single comment.</p><p>If you compare that program to your most recent one, the progress you’ve made is evident. You learned how to compile a project properly. How to comment out the code that isn’t immediately self-evident. You have made a conscious effort to get better at coding, and your work has paid off</p><p>I owe much of my progression as a coder to a thirst for expertness I developed in the woodshop. The first rule of happiness is to only compare yourself to you in the past — not to other people. When I look at one of my first woodworking projects that sits in my office- a crude purpleheart jewelry box held together with penny nails- I can instantly see the progress that I’ve made as a woodworker. I started making things out of wood in the simplest way possible: screwing and nailing cheap boards together without much thought. I learned about proportion, the Golden Ratio, and the Steelyard Principle, and my pieces began to look more balanced. Eventually I moved on to routered dovetail joints, which were stronger and more attractive than the nailed butt joints of my youth.</p><p>At approximately the same time, I matured as both an R programmer and a woodworker. I make all my joints with hand tools now, and experiment with avant-garde inlays and concepts, having mastered conventional design. My R programs have also reached a polished state that allows me the freedom to experiment with more ‘fun’ concepts.</p><p>This focus on skill progression pays dividends to those that put in the time and effort to achieve mastery in an area.</p><h3><strong>It will teach you to work backwards</strong></h3><p>Do you tackle the hardest items on your #TODO list first, or do you save them for last? Mark Twain has said that if you eat a live frog first thing in the morning, nothing worse will happen to you the rest of the day. There is always an aspect of a project- wood or code- that you know will be tricky. The project may fail if you mess up at the hard part.</p><p>I once was working on a project that necessitated the use of a hand router to shape a profile on a clock base. A router is a high-powered tool that spins a cutting bit at over 15,000 rpms; it’s easy to make mistakes in the wood that are difficult to fix, as well as mistakes in your appendages that are equally troublesome. I knew this cut would be difficult, so I procrastinated and put the whole clock together first, saving the hard cut for last. I ended up chipping a corner of the base off with the router and had to take the whole clock apart to repair it, wasting time and money. Eventually, I learned to make those tough cuts early, which made the builds go much smoother thereafter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*x4CwjlNDSBYzpCsbG4Sf2A.gif" /></figure><p>In yet another snafu, I built out an entire recommendation engine system for a client, only to find out later that their system couldn’t accept the data in the way that I had prepared it, wasting both their time and mine. This error changed the way I worked on data projects. Instead of working front to back- gathering data, building algs, sending the data to the client- I work in the opposite direction. If I can’t get the data to client, why work on the algs? So on and so on. By working back to front, and hard to easy, you’ll be able to fail forward faster and get more work done in less time.</p><p>The difference between good code and great code is often pronounced. We’ve all seen code like this. It jumps out to you from the Github page; it makes you say, ‘I wish I’d thought of that.’ The method the dev used to solve the problem is brilliant in its simplicity. She found the path of least resistance and executed in a way that made the script efficient as well as durable. A top-notch piece of furniture has the same features. The design focuses on the beauty of the wood, so you don’t even see how the boards attach to each other; it appears as if someone took a slice out of a tree and set it in a house. Building furniture and building scripts couldn’t be more different in their execution and purpose.</p><p>But the underlying principles used by the coder and the woodworker couldn’t be more similar. It’s my hope that devs reading this pick up a nail gun, get a few blood blisters from errant mallet blows, and cross train in woodworking. It will take your game to a whole ‘nother level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*H2vHnDjL4yXqhfFtHuzjzg.gif" /></figure><p><em>I’m available for data consulting on a contract-basis. Email </em><a href="http://bradley.lindblad@gmail.com/"><em>bradley.lindblad@gmail.com</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*BvvechEjRLmjpivxviyPuQ.png" /></figure><figure><a href="http://bit.ly/codeburst"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i3hPOj27LTt0ZPn5TQuhZg.png" /></a></figure><blockquote>✉️ <em>Subscribe to </em>CodeBurst’s<em> once-weekly </em><a href="http://bit.ly/codeburst-email"><strong><em>Email Blast</em></strong></a><strong><em>, </em></strong>🐦 <em>Follow </em>CodeBurst<em> on </em><a href="http://bit.ly/codeburst-twitter"><strong><em>Twitter</em></strong></a><em>, view </em>🗺️ <a href="http://bit.ly/2018-web-dev-roadmap"><strong><em>The 2018 Web Developer Roadmap</em></strong></a><em>, and </em>🕸️ <a href="http://bit.ly/learn-web-dev-codeburst"><strong><em>Learn Full Stack Web Development</em></strong></a><em>.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b842e3733896" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/why-woodworking-will-make-you-a-better-coder-b842e3733896">Why Woodworking Will Make You a Better Coder</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Woodworking Will Make You a Better Coder]]></title>
            <link>https://medium.com/data-science/why-woodworking-will-make-you-a-better-coder-adb91cbcaafd?source=rss-27ad429f9b76------2</link>
            <guid isPermaLink="false">https://medium.com/p/adb91cbcaafd</guid>
            <category><![CDATA[life]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Brad Lindblad]]></dc:creator>
            <pubDate>Wed, 11 Jul 2018 23:25:58 GMT</pubDate>
            <atom:updated>2018-08-30T12:19:35.042Z</atom:updated>
            <content:encoded><![CDATA[<p>Working with Wood is Fun.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*lePz8LA4f1degcE3zDbXww.jpeg" /></figure><p>The era of the specialist is over.</p><p>Many adept technologists agree that being good at one thing is the same as being good at none; “two is one and one is none”. Those who can work across many disciplines — the polymaths — will dominate the future of business. As technology increases at an exponential rate, new industries are emerging that are the result of the cross-pollination of existing disciplines. Blockchain is a good example. Those that have a background in coding, cryptography, and web development have found themselves in the perfect position for building one of the most eminent emerging technologies of the present.</p><p>I’ve found that dissimilar hobbies can lead to unexpected transfer learning. In the following essay, I share an example of this lateral thinking; how skills in one area can inform learning and decision making in another.</p><p>I was tinkering in my woodshop after a long day of <em>data science-ing</em>. I often come to this dusty sanctuary to clear my head. It’s refreshing to produce something tactile after a long day of producing files that live on a server somewhere, out of reach. Working with wood tends to put me in <em>flow</em> the same a long jog will.</p><p>It was during one of these spaced-out sessions, mid chisel-blow, that I realized how similar woodworking and coding are. Building with a computer isn’t much different from building with a set of hand tools. The more I pondered, the more I realized how the lessons I learned in the woodshop as a kid have helped me write better code as a grown up. Follow along as I share five reasons why coders should think about trying their hand at woodworking.</p><h3>It will teach you utility</h3><p>I started writing code out of necessity. I had outgrown the analytical capabilities of excel and found myself fording the shallows of the R language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*YCsgUhuaNUBXHf7frI-YpA.jpeg" /></figure><p>Most people start woodworking in the same way; they need a box to store something in, or a coffee table to put coffee on. They slap some pine boards together with drywall screws and call it good. Code is no different- it’s a functional means to an end. No one writes code for the aesthetics of the words on the screen, they write it to do something — although I’ll admit Panda syntax is a joy to stare at. We strive to write code that’s as simple as possible, so our colleagues can decode it in the future. The more complex a system is, the more entropy will tear it apart.</p><h4>Design</h4><p>Let’s look at utility in the context of design. There are many interesting styles of furniture, but none match the beautiful simplicity of Shaker Furniture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*LkLj4lu0KEPgUYg7Gu6Obw.png" /><figcaption>Traditional Shaker Coffee Table</figcaption></figure><p>The Shakers were an Anabaptist sect scattered about New England in the 18th and 19th centuries. They were known for their utilitarian furniture, simple living, and celibacy (also why there are no Shakers today). As you can see, the piece above has simple lines with little to no ornamentation. It’s built out of hardwood selected for its durability and strength.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*DqE3MHhFC0kfX5ftVSHXAQ.png" /><figcaption>Chippendale Table</figcaption></figure><p>The second table is a reproduction of a Chippendale table, which is a more high-end style favored by the upper classes. This piece is stylized with carvings, frills, and otherwise unnecessary features that don’t add to its usefulness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*_ho13gx-quRMk0Zquy10Zw.jpeg" /><figcaption>Aged Shaker End Table</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*QV9Qf6Vd-_gMjKkr7kXVuQ.jpeg" /><figcaption>Aged Chippendale Table</figcaption></figure><p>The next two images are original Shaker and Chippendale pieces that have aged a few hundred years. As you can see, the Shaker is in much better shape than the Chippendale. Time didn’t treat the Chippendale as kindly due to the use of laminated wood veneer, which is a paper-thin sheet of wood that glued to the wood beneath. Over time, the glue loses its bond and the veneer curls off. The Shakers wouldn’t touch veneer with a ten-foot-long chastity belt, which is a reason why their furniture has aged gracefully like a sitcom in syndication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Z2JnkN9UtMwWWS__M80jWQ.gif" /></figure><h4>Templates</h4><p>Efficient coders use templates whenever possible.</p><p>Woodworkers also use templates to produce consistent work quickly. For example, if I need to cut four table legs down to length, I will have more consistent and accurate results if I build a template on my crosscut saw, so I don’t have to measure and mark each leg. Another trick that woodworkers use is the ‘story stick’. Instead of repeatedly marking measurements with a tape measure throughout the project, you simply mark each measurement on one long stick of wood. Then you mark off cuts by placing the stick on the wood and transferring the measurements, eliminating the need for rulers and tape measures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*gzdB3tTVdWp5qCtvnccdAg.jpeg" /><figcaption>Story Stick</figcaption></figure><p>In a field of work where the term “lazy” is a positive connotation, building programs that run with minimal human input is a best practice. I’ve built several templates for EDA (exploratory data analysis) that I use to quickly and systematically analyze new data.</p><p>I realized at a young age that templating saved time and allowed me to build furniture more efficiently. No doubt, this skill transferred to my day job years later.</p><h3>It will teach you to troubleshoot</h3><p>Throughout the process of writing a program, you solve lots of little problems in order to solve one big problem. In this case, I define “problem” as an aspect of the build that stands on its own. For example, to build a web application that tracks stock prices, a developer would have to solve many micro problems such as setting up a database, API feeds, UI, etc. Along the way, issues will invariably crop up that need to be solved — either with novel ideas or a desultory review of Stack Overflow.</p><p>Woodworking prepares you for this work beautifully. Since many woodworking projects are bespoke, novel ideas, there often isn’t tested blueprints to work from, so the builder is forced to figure many things out for his or herself along the way, such as the best way to cut pieces from a rectangle of plywood, balancing the aesthetics of a piece or taking out “wobble”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*xN9Qo-XumEZpsutWp8Hg3g.gif" /><figcaption>Satisfying</figcaption></figure><h3>It will teach you bootstrapping</h3><p>In the startup or business sense, bootstrapping refers to starting a project with little or no funding or support, ‘to pull oneself up by his bootstraps’. A startup bootstrapping a new app will often spend just enough money to create an MVP (minimum viable product) before testing and rolling out a more complex product in the future. In the process of the aforementioned strategy, certain aspects of development may be placed together in a less than perfect manner, with cheaper parts.</p><p>In the context of woodworking, many larger projects are first bootstrapped together with cheaper materials and methods before the actual build begins for a few reasons. Number one, it is important to see what a finished project may look like in the flesh before expensive hardwoods are used. A client will also change their mind quite often after seeing the shop sketch of their buffet table in three dimensions in front of them.</p><p>Number two, having the opportunity to build the project in this test environment allows the inevitable unseen errors to crop up. Maybe the dovetail joint you planned to use in the case distracts from the ornamental wood you wished to draw attention to in the face frame. At any rate, you invite Murphy in and let his Law take effect, so you can clean up that mess before you get to the real thing.</p><p>In addition to this prototype bootstrapping, woodworkers often lack the exact materials they need to complete a project, so they’re forced to improvise. Black cherry is a premier hardwood used in fine furniture. Due to its relative scarcity in nature, small trunk diameter, and market demand, the price of a board-foot is higher than the price of many other wood types. Woodworkers don’t always have the funds to build a chair or kitchen cabinet set with the coppery wood, so they’ll bootstrap the project by improvising with dyes and paint glazes on cheaper woods like birch. Natural cherry and stained and glazed birch are virtually indistinguishable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*WkOn0_RxjmNHLq0XQvsRSQ.gif" /><figcaption>Hipster Woodworker</figcaption></figure><h3>It will teach you to progress</h3><p>William S Burroughs is credited with the quote, “if you’re not growing, you’re dying.” In this global economy where workers aren’t just competing with talent in their locality, but with talent around the world, this quote should be your jam. You need to constantly improve your existing skill set as well as learn new things.</p><p>Sort your code repository or Git repo by date and look at the first program you wrote. It’s horrendous, right? Doesn’t pay any attention to folding best practices, probably repeats itself and may even lack a single comment.</p><p>If you compare that program to your most recent one, the progress you’ve made is evident. You learned how to compile a project properly. How to comment out the code that isn’t immediately self-evident. You have made a conscious effort to get better at coding, and your work has paid off</p><p>I owe much of my progression as a coder to a thirst for expertness I developed in the woodshop. The first rule of happiness is to only compare yourself to you in the past — not to other people. When I look at one of my first woodworking projects that sits in my office- a crude purpleheart jewelry box held together with penny nails- I can instantly see the progress that I’ve made as a woodworker. I started making things out of wood in the simplest way possible: screwing and nailing cheap boards together without much thought. I learned about proportion, the Golden Ratio, and the Steelyard Principle, and my pieces began to look more balanced. Eventually I moved on to routered dovetail joints, which were stronger and more attractive than the nailed butt joints of my youth.</p><p>At approximately the same time, I matured as both an R programmer and a woodworker. I make all my joints with hand tools now, and experiment with avant-garde inlays and concepts, having mastered conventional design. My R programs have also reached a polished state that allows me the freedom to experiment with more ‘fun’ concepts.</p><p>This focus on skill progression pays dividends to those that put in the time and effort to achieve mastery in an area.</p><h3>It will teach you to work backwards</h3><p>Do you tackle the hardest items on your #TODO list first, or do you save them for last? Mark Twain has said that if you eat a live frog first thing in the morning, nothing worse will happen to you the rest of the day. There is always an aspect of a project- wood or code- that you know will be tricky. The project may fail if you mess up at the hard part.</p><p>I once was working on a project that necessitated the use of a hand router to shape a profile on a clock base. A router is a high-powered tool that spins a cutting bit at over 15,000 rpms; it’s easy to make mistakes in the wood that are difficult to fix, as well as mistakes in your appendages that are equally troublesome. I knew this cut would be difficult, so I procrastinated and put the whole clock together first, saving the hard cut for last. I ended up chipping a corner of the base off with the router and had to take the whole clock apart to repair it, wasting time and money. Eventually, I learned to make those tough cuts early, which made the builds go much smoother thereafter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*x4CwjlNDSBYzpCsbG4Sf2A.gif" /></figure><p>In yet another snafu, I built out an entire recommendation engine system for a client, only to find out later that their system couldn’t accept the data in the way that I had prepared it, wasting both their time and mine. This error changed the way I worked on data projects. Instead of working front to back- gathering data, building algs, sending the data to the client- I work in the opposite direction. If I can’t get the data to client, why work on the algs? So on and so on. By working back to front, and hard to easy, you’ll be able to fail forward faster and get more work done in less time.</p><p>The difference between good code and great code is often pronounced. We’ve all seen code like this. It jumps out to you from the Github page; it makes you say, ‘I wish I’d thought of that.’ The method the dev used to solve the problem is brilliant in its simplicity. She found the path of least resistance and executed in a way that made the script efficient as well as durable. A top-notch piece of furniture has the same features. The design focuses on the beauty of the wood, so you don’t even see how the boards attach to each other; it appears as if someone took a slice out of a tree and set it in a house. Building furniture and building scripts couldn’t be more different in their execution and purpose.</p><p>But the underlying principles used by the coder and the woodworker couldn’t be more similar. It’s my hope that devs reading this pick up a nail gun, get a few blood blisters from errant mallet blows, and cross train in woodworking. It will take your game to a whole ‘nother level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*H2vHnDjL4yXqhfFtHuzjzg.gif" /></figure><p><em>I’m available for data consulting on a contract-basis. Email </em><a href="http://bradley.lindblad@gmail.com/"><em>bradley.lindblad@gmail.com</em></a></p><p><em>Originally published at </em><a href="https://medium.com/@bradley.lindblad/why-woodworking-will-make-you-a-better-coder-b842e3733896"><em>medium.com</em></a><em> on July 11, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adb91cbcaafd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/why-woodworking-will-make-you-a-better-coder-adb91cbcaafd">Why Woodworking Will Make You a Better Coder</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Analyzed Fargo Crime Data and This is What I Found]]></title>
            <link>https://medium.com/data-science/i-analyzed-fargo-crime-data-and-this-is-what-i-found-25138e2d6bb1?source=rss-27ad429f9b76------2</link>
            <guid isPermaLink="false">https://medium.com/p/25138e2d6bb1</guid>
            <category><![CDATA[police]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[crime]]></category>
            <dc:creator><![CDATA[Brad Lindblad]]></dc:creator>
            <pubDate>Mon, 18 Jun 2018 16:50:33 GMT</pubDate>
            <atom:updated>2018-08-30T12:20:11.163Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hAa3l04Df_OWGcbydwoRTQ.png" /></figure><p><strong><em>tl;dr:</em></strong> <em>If you are impatient and want to go straight to the fun stuff, here is a link to the</em> <a href="https://bradleylindblad.shinyapps.io/Fargo_Crime/">interactive web dashboard</a> <em>that I built to supplement this analysis. Best viewed on desktop PC.</em></p><p>On a recent Monday afternoon that I would normally have spent slumped over my desk gingerly pecking out bits of code, I stumbled across an article about my home town that made me do a double-take. “<a href="http://www.inforum.com/news/3775550-fargo-violent-crime-tops-us-average-first-time">Fargo violent crime tops U.S. national average for the first time</a>.” The article details how the once sleepy farming community nestled in a fertile and flat ancient lake bed had surpassed the national violent crime rate.</p><p>I’m a new father so I wasn’t a little bit alarmed at these claims, so I did what any data scientist would do in that situation, I hunted down some data to learn more. Fortunately, the Fargo Police Department publishes their <a href="http://fargond.gov/city-government/departments/police/police-records-data/dispatch-logs">dispatch logs</a> which detail all of the calls that are made to police. There is also a handy <a href="https://www.crimereports.com/city/Fargo%2C%20ND#!/dashboard?incident_types=Assault%252CAssault%2520with%2520Deadly%2520Weapon%252CBreaking%2520%2526%2520Entering%252CDisorder%252CDrugs%252CHomicide%252CKidnapping%252CLiquor%252COther%2520Sexual%2520Offense%252CProperty%2520Crime%252CProperty%2520Crime%2520Commercial%252CProperty%2520Crime%2520Residential%252CQuality%2520of%2520Life%252CRobbery%252CSexual%2520Assault%252CSexual%2520Offense%252CTheft%252CTheft%2520from%2520Vehicle%252CTheft%2520of%2520Vehicle&amp;start_date=2017-04-26&amp;end_date=2017-05-10&amp;days=sunday%252Cmonday%252Ctuesday%252Cwednesday%252Cthursday%252Cfriday%252Csaturday&amp;start_time=0&amp;end_time=23&amp;include_sex_offenders=false&amp;lat=46.865389&amp;lng=-96.829027&amp;zoom=13&amp;current_tab=map&amp;shapeIds=">map application</a> that helps visualize where the “danger zones” are in two dimensions. But, I wanted to know more. So I formulated a set of questions that I’ll answer below using the dispatch data from 2017.</p><h3>Problem Statements</h3><ul><li>Question 1: Which month has the most crime?</li><li>Question 2: Which weekday has the most crime?</li><li>Question 3: What time of day has the most crime?</li><li>Question 4: Where are crimes committed?</li></ul><p>But first, let’s get the assumptions and methods out of the way.</p><h3>Assumptions</h3><p>(1) Of the categories of crime in the dispatch logs, we will be looking at the calls that are actually crimes, for example, we will ignore parking complaints, chest pain and the like.</p><p>(2) Each call incident is reported at the block level, meaning our maps will be accurate to the block, not to the house or address.</p><p>(3) For brevity, I will be using the word “crime” as a substitute for “dispatch calls,” with the assumption that dispatch calls are generally indicative of crime.</p><h3>Methods</h3><p>The <a href="https://en.wikipedia.org/wiki/R_(programming_language)">R computing language</a> was used to perform these analyses. The complete source code can be found at this <a href="https://github.com/bradlindblad/Fargo_Crime">Github repository</a>.</p><h3>Which month has the most crime?</h3><p>Fargo gets both hot and cold weather, but the hamlet is better known for the latter in popular culture, (thanks, Coen Brothers/FX!). Cripes, when you do an image search for Fargo, all you get are posters for the 1996 film and a bloodied Steve Buscemi:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sWThBMRMSY78ELwD" /></figure><p>People in Northern climates know that “cabin fever” is a real thing, although not as extreme as Jack Nicholson’s interpretation in <em>The Shining</em>. My point is that crime is simply more difficult when you have to scrape the windshield and warm up the engine of a vehicle before boosting it.</p><p>Before I looked at the data, I assumed that crime would be sparse in the cold months, which can start as early as October and lead into May.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*MpeLbZrSSYEQy8Zs" /></figure><p>The chart above is known as a calendar heat map. It shows the crime frequency by month as well as day of week. The cooler (purple) colors indicate low crime levels, and the warmer (yellow) colors indicate high crime levels. As I suspected, November through February were relatively tame months compared to the <em>bacchanals</em> of June and September.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*Gdg7bzEbfzKGEPOK" /></figure><p>Ahh, now this bar chart makes it more clear. It seems that the frosty months starting in January leading up to May are a metaphorical ramp to the depraved summer months, with June being the pinnacle of this debauchery.</p><h3>Which weekday has the most crime?</h3><p>I think a bar chart will do the trick for this question as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*-xB0uNTS5hnTqkQk" /></figure><p>Well this makes sense. As folks get busy in their work week, they have less time for being #savage than on the weekend. I’m curious, are certain crimes more common on different days of the week? For that, I’ll pull some screenshots from the <a href="http://bradleylindblad.shinyapps.io/Fargo_Crime">interactive dashboard</a>:</p><h3>Impaired Driver</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/0*jdGxcdGCjJyvmqu3" /></figure><p>People party more on the weekend; pretty obvious.</p><h3>Harassment</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/0*VdSeuHBi4tmcA9SE" /></figure><p>Looking at the dispatch logs, it seems like many of the calls are in response to phone harassment, like scammers. Apparently Monday is their big day at the scammer offices.</p><h3>What time of day has the most crime?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*0mDv3lyXL4nDc7za" /></figure><p>I didn’t expect to see these results. Apparently, crime drops off around midnight, before picking back up again around bar close at two AM. For simplicity, I grouped the different offence types by three subcategories.</p><h3>Where are crimes committed?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*DUhfDqfUkWxFboGd" /></figure><p>In general, there is crime all over the city. The downtown area, however, had the most crime in 2017.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/0*N8PMS_NGlCAV1ErT" /></figure><p>The heat map on the <a href="https://bradleylindblad.shinyapps.io/Fargo_Crime/">interactive dashboard</a> is fun to play with to see where the hot spots were for certain crimes.</p><h3>Interesting Finds</h3><p>When I play with the dashboard I find a few interesting things. First of all, I notice that the peeper data was fairly concentrated in one area:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-_pWIWcXwbUwRNTb" /></figure><p>Is that area of Fargo immediately west of West Acres just prime peeping grounds? I don’t know. But it may indicate that there was just one or two peepers that were staying in their own neighborhoods. There were almost twice as many calls on Sunday vs. the rest of the week, which is a definite pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/0*WN8EJDSlz3xj1WWe" /></figure><p>An examination of the “Overdose- Poisoning” crime chart shows a different pattern:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AMI3oWzss9et9R8r" /></figure><p>Here we see two distinct clusters; one east of Yunker Farm and another situated downtown. If I zoom in closer on the downtown cluster, we can pinpoint the epicenter (keep in mind this is data on the block-level):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3qNx3xs17VEaUET_" /></figure><p>Seems like an area to be careful around.</p><h3>Conclusions</h3><p>So what did we learn? You will invariably come to different conclusions than myself when you examine the interactive dashboard, but my take was that (1) downtown = danger zone, (2) the cold definitely has a “cooling effect” (sorry) on local crime and (3), bar close isn’t a good time to be walking the dog.</p><h3>Further Research</h3><p>I toyed with the idea of building a real — time web page that showed Fargo crimes as they were happening. There is a <a href="https://www.crimereports.com/city/Fargo%2C%20ND#!/dashboard?incident_types=Assault%252CAssault%2520with%2520Deadly%2520Weapon%252CBreaking%2520%2526%2520Entering%252CDisorder%252CDrugs%252CHomicide%252CKidnapping%252CLiquor%252COther%2520Sexual%2520Offense%252CProperty%2520Crime%252CProperty%2520Crime%2520Commercial%252CProperty%2520Crime%2520Residential%252CQuality%2520of%2520Life%252CRobbery%252CSexual%2520Assault%252CSexual%2520Offense%252CTheft%252CTheft%2520from%2520Vehicle%252CTheft%2520of%2520Vehicle&amp;start_date=2017-04-26&amp;end_date=2017-05-10&amp;days=sunday%252Cmonday%252Ctuesday%252Cwednesday%252Cthursday%252Cfriday%252Csaturday&amp;start_time=0&amp;end_time=23&amp;include_sex_offenders=false&amp;lat=46.865389&amp;lng=-96.829027&amp;zoom=13&amp;current_tab=map&amp;shapeIds=">webpage</a> that already does something like that, but it is clumsy and slow. If there is enough interest in this analysis I’ll definitely throw the app together (shoot me an email or comment if you would like this).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*H2vHnDjL4yXqhfFtHuzjzg.gif" /></figure><p><em>I’m available for data consulting on a contract-basis. Email bradley.lindblad@gmail.com</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/0*MkAF5OJKq0zqsEeV" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25138e2d6bb1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/i-analyzed-fargo-crime-data-and-this-is-what-i-found-25138e2d6bb1">I Analyzed Fargo Crime Data and This is What I Found</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>