<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Shamindra Shrotriya</title>
<link>https://www.shamindras.com/posts.html</link>
<atom:link href="https://www.shamindras.com/posts.xml" rel="self" type="application/rss+xml"/>
<description></description>
<generator>quarto-1.8.27</generator>
<lastBuildDate>Fri, 27 Feb 2026 14:00:00 GMT</lastBuildDate>
<item>
  <title>Shamindra’s February 2026 Roundup</title>
  <dc:creator>Shamindra Shrotriya</dc:creator>
  <link>https://www.shamindras.com/posts/2026-02-28-shrotriya2026february26roundup/</link>
  <description><![CDATA[ 





<style>
.quarto-layout-cell img {
  border: 1px solid #000;
}
.quarto-video {
  max-width: 75%;
  margin: 0 auto;
}
.quarto-video iframe {
  border: 1px solid #000;
}
.quarto-float-vid {
  text-align: center;
}
.quarto-layout-panel .quarto-video {
  max-width: 100%;
  margin: 0;
}
.quarto-layout-panel .quarto-float-vid {
  text-align: center;
}
.quarto-layout-panel .quarto-float-vid figcaption {
  font-size: 0.85em;
}
.quarto-layout-panel .quarto-layout-row {
  gap: 0;
}
blockquote {
  border-left: 4px solid #2e7d32;
  background-color: #f0f7f0;
  padding: 0.75em 1em;
  margin-left: 0;
  border-radius: 0 4px 4px 0;
}
blockquote table {
  width: auto !important;
  max-width: fit-content;
  font-size: 0.95em;
}
blockquote table td {
  border: none !important;
  padding: 2px 6px !important;
  white-space: nowrap;
}
.column-margin .quarto-float-vid {
  width: 350px;
  max-width: none;
}
.column-margin .quarto-video {
  max-width: 100%;
}
.star-rating {
  display: inline-block;
  position: relative;
  font-size: 1.1em;
  letter-spacing: 1px;
  vertical-align: middle;
  cursor: default;
}
.star-rating:hover::after {
  content: attr(data-rating);
  position: absolute;
  top: -2em;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.7em;
  white-space: nowrap;
  letter-spacing: 0;
}
.star-rating .star-full {
  color: #f5c518;
}
.star-rating .star-half {
  position: relative;
  display: inline-block;
  color: #d0d0d0;
}
.star-rating .star-half::before {
  content: "★";
  position: absolute;
  left: 0;
  overflow: hidden;
  width: 50%;
  color: #f5c518;
}
.star-rating .star-empty {
  color: #d0d0d0;
}
</style>
<style type="text/css">/**
  * Author: Mikhail Popov
  * License: MIT
  */
a.wiki {
    /* color: #0645ad; */
    text-decoration: none;
    border-bottom: 1px dotted #0645ad;
}
.wiki::after {
    font-family: serif;
    content: " W";
    vertical-align: super;
    font-size: 6pt;
}</style>
<script src="https://unpkg.com/wikipedia-preview@1.8.0/dist/wikipedia-preview.production.js" type="text/javascript"></script>
<script type="text/javascript">
    window.onload = function() {
      wikipediaPreview.init({
        lang: 'en',
        selector: '.wiki',
        detectLinks: true
      });
    };</script>
<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>Welcome to the February 2026 roundup! Similar to <a href="../../posts/2020-01-27-shrotriya2020january20roundup/" target="_blank">last time</a>, here I document anything interesting I come across each month, from articles and books to skills and beyond. This is more for my personal reference and benefit but may also help others.</p>
</section>
<section id="summary" class="level2">
<h2 class="anchored" data-anchor-id="summary">Summary</h2>
<!-- 2-3 line overview of highlights: key skills learned, books read,
     articles discovered, and anything else notable this month. -->
</section>
<section id="articles" class="level2">
<h2 class="anchored" data-anchor-id="articles">Articles</h2>
<section id="how-markdown-took-over-the-world" class="level3">
<h3 class="anchored" data-anchor-id="how-markdown-took-over-the-world">How Markdown Took Over the World</h3>
<p><em>by Anil Dash</em> <a href="https://www.anildash.com/2026/01/09/how-markdown-took-over-the-world/" target="_blank">🔗</a>.</p>
<p>This was a really important historical overview over the rise of one of the most ubiquitous<sup>1</sup> text document formats used on the web, i.e. <a href="https://daringfireball.net/projects/markdown/">markdown</a>. Dash worked at Movable Type, an influential blogging platform in the early 21st century. Key takeaways:</p>
<blockquote class="blockquote">
<ol type="1">
<li><strong>Motivation.</strong> <a href="https://daringfireball.net/">John Gruber</a> originally developed markdown <em>to simplify</em> his blogging experience with Movable Type.</li>
<li><strong>Success.</strong> Is owed to a collection of favorable events and good design, i.e.&nbsp;rise of blogging, brilliant branding (mark<em>down</em> as the simplification of mark<em>up</em>), easy syntax which could be picked up <a href="https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax">in just a few minutes</a>, open-sourced (<strong>not monetized</strong>) with a helpful community.</li>
</ol>
</blockquote>
<p>On a personal note, <a href="https://rmarkdown.rstudio.com/index.html">Rmarkdown</a> was revolutionary in developing reproducible and version-controlled data science workflows. It showcased the power of <a href="https://en.wikipedia.org/wiki/Literate_programming" class="wiki">literate programming</a> in the “Big Data” era. With the rise of amazing packages like <a href="https://quarto.org/docs/blog/">Quarto</a>, markdown continues to evolve and still shapes blogging<sup>2</sup> more than two decades later 🎆.</p>
</section>
</section>
<section id="tutorials" class="level2">
<h2 class="anchored" data-anchor-id="tutorials">Tutorials</h2>
<section id="llms-in-five-formulas" class="level3">
<h3 class="anchored" data-anchor-id="llms-in-five-formulas">LLMs in Five Formulas</h3>
<p><em>by Sasha Rush</em> <a href="https://www.youtube.com/watch?v=KCXDr-UOb9A&amp;t=2989s" target="_blank">▶️</a>.</p>
<div class="quarto-layout-panel" data-layout="[40, 60]">
<div class="quarto-layout-row quarto-layout-valign-top">
<div class="quarto-layout-cell" style="flex-basis: 40.0%;justify-content: flex-start;">
<div id="vid-feb26-llm-five-formulas" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-vid figure">
<div aria-describedby="vid-feb26-llm-five-formulas-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="quarto-video ratio ratio-4x3"><iframe data-external="1" src="https://www.youtube.com/embed/KCXDr-UOb9A?start=2989" title="Large Language Models in Five Formulas by Sasha Rush" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-vid" id="vid-feb26-llm-five-formulas-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Video&nbsp;1: <a href="https://www.youtube.com/watch?v=KCXDr-UOb9A&amp;t=2989s" target="_blank">LLMs in Five Formulas</a>.
</figcaption>
</figure>
</div>
</div>
<div class="quarto-layout-cell" style="flex-basis: 60.0%;justify-content: center;">
<p>A truly remarkable lecture by Prof.&nbsp;Rush’s distilling the five features of LLMs that make them ‘tick’.</p>
<blockquote class="blockquote">
<table class="caption-top table">
<tbody>
<tr class="odd">
<td style="text-align: left;">1. <strong>Perplexity</strong></td>
<td style="text-align: center;">⟷</td>
<td style="text-align: left;"><em>Generation</em>.</td>
</tr>
<tr class="even">
<td style="text-align: left;">2. <strong>Attention</strong></td>
<td style="text-align: center;">⟷</td>
<td style="text-align: left;"><em>Memory</em>.</td>
</tr>
<tr class="odd">
<td style="text-align: left;">3. <strong>GEMM</strong></td>
<td style="text-align: center;">⟷</td>
<td style="text-align: left;"><em>Scaling</em>.</td>
</tr>
<tr class="even">
<td style="text-align: left;">4. <strong>Chinchilla</strong></td>
<td style="text-align: center;">⟷</td>
<td style="text-align: left;"><em>Efficiency</em>.</td>
</tr>
<tr class="odd">
<td style="text-align: left;">5. <strong>RASP</strong></td>
<td style="text-align: center;">⟷</td>
<td style="text-align: left;"><em>Reasoning</em>.</td>
</tr>
</tbody>
</table>
</blockquote>
</div>
</div>
</div>
<p>This tutorial really helped me to build a good mental model when studying llms deeply, or applying them in practice. Prof.&nbsp;Rush intentionally leaves out certain topics<sup>3</sup> which are also useful for explaining LLM performance, e.g.&nbsp;human feedback, post-attention, new architectures, low-resource llms, and mechanistic interpretability.</p>
<p>I plan to reflect on and return to this lecture multiple times<sup>4</sup>. Highly recommend!</p>
</section>
</section>
<section id="books" class="level2">
<h2 class="anchored" data-anchor-id="books">Books</h2>
<section id="audiobooks" class="level3">
<h3 class="anchored" data-anchor-id="audiobooks">Audiobooks</h3>
<div class="callout callout-style-default callout-caution no-icon callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-1-contents" aria-controls="callout-1" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon no-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Caution</span>🎯 Try Audiobooks - You Might Be Surprised
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-1" class="callout-1-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>I came to a epiphany in early 2026, namely, that <strong><em>for me</em> self-help books should be listened to as audiobooks</strong> rather than read as paperbacks. This simple change has made a world of difference. I previously found the act of reading such books quite tedious and dry, given their often prescriptive tone. Now I can use my idle walking time to listen to them. Many audiobook platforms (e.g.&nbsp;Spotify, Audible) include these titles in their premium memberships. In case you have felt similarly about this genre, this tip might help you sample more of it. There is often <em>some</em> nugget to take away from each one.</p>
</div>
</div>
</div>
<section id="the-life-changing-magic-of-tidying-up" class="level4">
<h4 class="anchored" data-anchor-id="the-life-changing-magic-of-tidying-up">The Life Changing Magic of Tidying Up</h4>
<div class="quarto-layout-panel" data-layout="[15, 85]">
<div class="quarto-layout-row quarto-layout-valign-top">
<div class="quarto-layout-cell" style="flex-basis: 15.0%;justify-content: center;">
<p><img src="https://www.shamindras.com/posts/2026-02-28-shrotriya2026february26roundup/images/feb26-life-changing-magic.jpg" class="img-fluid" alt="Book cover of The Life-Changing Magic of Tidying Up by Marie Kondo"></p>
</div>
<div class="quarto-layout-cell" style="flex-basis: 85.0%;justify-content: flex-start;">
<p><em>by Marie Kondo</em> (narrator: <em>Lucy Scott</em>) <a href="https://open.spotify.com/show/4evjgM54KB8lxxT87caPCd" target="_blank">🎧</a><sup>5</sup>. <span class="star-rating" data-rating="4.5 / 5"><span class="star-full">★★★★</span><span class="star-half">★</span></span></p>
<div class="callout callout-style-default callout-note no-icon callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-2-contents" aria-controls="callout-2" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon no-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Key Takeaways
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-2" class="callout-2-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>This is a genuinely remarkable book and one that I’m more than a decade late to<sup>6</sup>. I had heard all of the “spark joy” memes when the Netflix show landed, and simply assumed this was another decluttering gimmick and ignored it. How wrong I was. This is a very deep book about life prioritization disguised as a home tidying manifesto. I learned many practical skills, but the main four biggest takeaways were as follows.</p>
<blockquote class="blockquote">
<ol type="1">
<li><strong>One and Done.</strong> Marie Kondo (or ‘KonMari’) notes that tidying your home should be <strong>one-off</strong> activity, <em>not</em> a recurring one as often recommended by other books in this genre. This is the key motivation to “get your house in order” as KonMari says.</li>
<li><strong>Categories not rooms.</strong> An amazing approach of this book is to focus on categories of items rather than rooms, when tidying ones home. So tidying books doesn’t mean to do a separate bookshelf each day, but <em>all</em> bookshelves in the house at once. Moreover KonMari mentions a prioritization order for categories to aid decision fatigue: clothes, books, papers, komono (miscellaneous), and sentimental items. It is <strong>this</strong> tip which makes the “one and done” approach to tidying feasible.</li>
<li><strong>Qualitative &gt; Quantitative.</strong> The book emphasizes the use of qualitative over quantitative decision making for tidying. So no more “one in, one out” type rules to remember. Instead you get advice like “when you are choosing what to keep, ask your heart, when you are choosing where to store something, ask your house”. Strangely, I found this to be very practical.</li>
<li><strong>Principled.</strong> <em>Maintaining</em> tidyness can be done via principled methods, e.g.&nbsp;the KonMari folding technique.</li>
</ol>
</blockquote>
<p>An overarching theme of the book is that tidying is only the <em>first</em> step towards prioritizing your life, not the final one. Highly Recommend.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="how-to-win-friends-and-influence-people" class="level4">
<h4 class="anchored" data-anchor-id="how-to-win-friends-and-influence-people">How to Win Friends and Influence People</h4>
<div class="quarto-layout-panel" data-layout="[15, 85]">
<div class="quarto-layout-row quarto-layout-valign-top">
<div class="quarto-layout-cell" style="flex-basis: 15.0%;justify-content: center;">
<p><img src="https://www.shamindras.com/posts/2026-02-28-shrotriya2026february26roundup/images/feb26-win-friends.jpg" class="img-fluid" alt="Book cover of How to Win Friends and Influence People by Dale Carnegie"></p>
</div>
<div class="quarto-layout-cell" style="flex-basis: 85.0%;justify-content: flex-start;">
<p><em>by Dale Carnegie</em> (narrator: <em>Andrew MacMillan</em>) <a href="https://open.spotify.com/show/3UfAQ6yAJQqHjifKaQ2Nm5" target="_blank">🎧</a><sup>7</sup>. <span class="star-rating" data-rating="3.5 / 5"><span class="star-full">★★★</span><span class="star-half">★</span><span class="star-empty">★</span></span></p>
<div class="callout callout-style-default callout-note no-icon callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-3-contents" aria-controls="callout-3" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon no-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Key Takeaways
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-3" class="callout-3-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>If I was asked to name “a classic in the motivational self-help literature”, this would be the first title that would come to mind. Although I’m late to the party, this book ended up providing many useful guidelines for improving my interactions with other people. The book is split into fairly universal themes including: dealing with people, becoming more likable, moving people towards your way of thinking, and how to lead without causing offense. My main takeaways were as follows.</p>
<blockquote class="blockquote">
<ol type="1">
<li><strong>Positivity focus.</strong> When dealing with other people always engage with positivity, empathy, and kindness.</li>
<li><strong>Small sincere gestures.</strong> Correctly pronouncing and acknowledging the another’s name (“the sweetest sound and most important sound to that person”), asking thoughtful questions, listening intently, and making the other person feel important are all good habits to cultivate daily in a sincere manner.</li>
<li><strong>Discussion not argument.</strong> Carnegie notes that there are never any “winners” in an argument. He advocates for healthy debate where necessary, but to avoid approaching it as a point scoring contest to fuel one’s ego. For me, the biggest win here is saving time and energy by simply refusing to engage in trivial arguments.</li>
</ol>
</blockquote>
<p>Some critiques were that many of the references were a bit dated, but these can be corrected for mentally, e.g.&nbsp;just replace “writing a letter” with “sending an email/text”. A more serious issue is that Carnegie often plays out the ‘best case’ scenario for using his strategies, and that many of his recommendations are not field tested with formal experiments. But again, erring on the side of positivity is not a bad approach to most interactions, so these should not be dealbreakers and could be supplemented with more modern literature. Would recommend.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="diary-of-a-ceo" class="level4">
<h4 class="anchored" data-anchor-id="diary-of-a-ceo">Diary of a CEO</h4>
<div class="quarto-layout-panel" data-layout="[15, 85]">
<div class="quarto-layout-row quarto-layout-valign-top">
<div class="quarto-layout-cell" style="flex-basis: 15.0%;justify-content: center;">
<p><img src="https://www.shamindras.com/posts/2026-02-28-shrotriya2026february26roundup/images/feb26-diary-of-a-ceo.jpg" class="img-fluid" alt="Book cover of The Diary of a CEO by Steven Bartlett"></p>
</div>
<div class="quarto-layout-cell" style="flex-basis: 85.0%;justify-content: flex-start;">
<p><em>by Steven Bartlett</em> (narrated by <em>the author</em>) <a href="https://open.spotify.com/show/7iQXmUT7XGuZSzAMjoNWlX" target="_blank">🎧</a><sup>8</sup>. <span class="star-rating" data-rating="2.5 / 5"><span class="star-full">★★</span><span class="star-half">★</span><span class="star-empty">★★</span></span></p>
<div class="callout callout-style-default callout-note no-icon callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-4-contents" aria-controls="callout-4" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon no-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Note</span>Key Takeaways
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-4" class="callout-4-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>This was recommended to me by Spotify audiobooks. The book title is eponymous with a wildly popular podcast run by the author, where he interviews various celebrities and entrepreneurs on lessons to improve ones daily life. I had never listened to the podcast previously, so went into this fresh. I enjoyed the fact that it was read by the author. Interestingly, I learned more about eloquent storytelling and techniques for effective message delivery through the audiobook reading than from the contents of the book.</p>
<p>The book itself is framed as “The 33 laws for business and life” and strikes quite a serious tone. Much of the business advice is framed in the context of improving branding, e.g.&nbsp;“avoid wallpaper at all costs”. This is unsurprising given the author’s background in building a successful marketing firm in the UK. So ones mileage may vary depending on your personal and professional goals. My main practical takeaway was:</p>
<blockquote class="blockquote">
<ol type="1">
<li><strong>Small details matter.</strong> Bartlett notes that “you must sweat the small stuff”, i.e.&nbsp;details matter. Here he emphasises the notion of Kaizen as a business philosophy to measure and focus on incremental gains in ones regular activities. He notes, for example, that his podcast team go all out in interview preparation for new guests. This involves thoroughly researching their guests and understanding their preferences on intricacies like beverage, music, lighting, and calibrating the interview room accordingly. I found this type of focused attention to detail quite cool and practical. This inspired me to apply the same principle to my own relationships, by listening more attentively to friends and family and acting on those details.</li>
</ol>
</blockquote>
<p>Overall, a fun modern take on motivational self-help, but would only recommend if you are a fan of the podcast.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</section>
</section>
<section id="skills" class="level2">
<h2 class="anchored" data-anchor-id="skills">Skills</h2>
<p>I really enjoy learning new practical skills in a <strong>principled manner</strong>. This way, even the most routine tasks become easy and, most importantly, <em>fun</em> 🤹.</p>
<p>Here are some of the cool skills I picked up this month. Try them out!</p>
<section id="the-konmari-fold" class="level3">
<h3 class="anchored" data-anchor-id="the-konmari-fold">The KonMari Fold</h3>
<p><em>by Marie Kondo</em> <a href="https://www.youtube.com/watch?v=IjkmqbJTLBM&amp;t=7s" target="_blank">▶️</a>.</p>
<div class="quarto-layout-panel" data-layout="[40, 60]">
<div class="quarto-layout-row quarto-layout-valign-top">
<div class="quarto-layout-cell" style="flex-basis: 40.0%;justify-content: flex-start;">
<div id="vid-feb26-konmari-fold" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-vid figure">
<div aria-describedby="vid-feb26-konmari-fold-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="quarto-video ratio ratio-4x3"><iframe data-external="1" src="https://www.youtube.com/embed/IjkmqbJTLBM?start=7" title="The KonMari Fold by Marie Kondo" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-vid" id="vid-feb26-konmari-fold-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Video&nbsp;2: <a href="https://www.youtube.com/watch?v=IjkmqbJTLBM&amp;t=7s" target="_blank">The KonMari Fold</a>.
</figcaption>
</figure>
</div>
</div>
<div class="quarto-layout-cell" style="flex-basis: 60.0%;justify-content: flex-start;">
<p>After recently becoming a student of KonMari, I decided to raise my folding game with her method. Game changer! The main idea can be summarized in three-steps:</p>
<blockquote class="blockquote">
<ol type="1">
<li><strong>Shapes matter.</strong> Rectangular shapes are easiest to repeatedly fold down.</li>
<li><strong>Rectangulate.</strong> First fold any item into the largest rectangle<sup>9</sup> (see video).</li>
<li><strong>Divide and stand.</strong> Repeatedly fold down the rectangle so that the item stands vertically.</li>
</ol>
</blockquote>
</div>
</div>
</div>
</section>
<section id="overunder-roadie-wrap" class="level3">
<h3 class="anchored" data-anchor-id="overunder-roadie-wrap">Over/Under Roadie Wrap</h3>
<p><em>by Rattlesnake Cable Company</em> <a href="https://www.youtube.com/watch?v=zjpBXx8oNOc&amp;t=2s" target="_blank">▶️</a>.</p>
<div class="quarto-layout-panel" data-layout="[40, 60]">
<div class="quarto-layout-row quarto-layout-valign-top">
<div class="quarto-layout-cell" style="flex-basis: 40.0%;justify-content: flex-start;">
<div id="vid-feb26-roadie-wrap" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-vid figure">
<div aria-describedby="vid-feb26-roadie-wrap-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="quarto-video ratio ratio-4x3"><iframe data-external="1" src="https://www.youtube.com/embed/zjpBXx8oNOc?start=2" title="Over/Under Roadie Wrap by Rattlesnake Cable Company" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-vid" id="vid-feb26-roadie-wrap-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Video&nbsp;3: <a href="https://www.youtube.com/watch?v=zjpBXx8oNOc&amp;t=2s" target="_blank">Over/Under Roadie Wrap</a>.
</figcaption>
</figure>
</div>
</div>
<div class="quarto-layout-cell" style="flex-basis: 60.0%;justify-content: flex-start;">
<p>After collecting hundreds of cables and wires over the years, I’d never learned a proper way to coil them. The “roadie-wrap” is a well-tested technique used by grips who have to coil (and uncoil!) hundreds of cables daily. It works a treat with these gains:</p>
<blockquote class="blockquote">
<ol type="1">
<li><strong>Tangle-free.</strong> Uncoiling doesn’t lead to tangles.</li>
<li><strong>Easy recoiling.</strong> Recoiling is a matter of nailing the over/under technique (see video).</li>
<li><strong>Durability.</strong> Use this on all cables, and they will last a lot longer.</li>
</ol>
</blockquote>
</div>
</div>
</div>
</section>
</section>
<section id="concluding-thoughts" class="level2">
<h2 class="anchored" data-anchor-id="concluding-thoughts">Concluding Thoughts</h2>
<p>Overall, this was quite an eventful month of activities for me. Also it took all my energy to fire up the blog after a four year hiatus 😬. Hopefully I’ll keep adding to it more regularly this year!</p>
<div class="callout callout-style-default callout-warning no-icon callout-titled">
<div class="callout-header d-flex align-content-center collapsed" data-bs-toggle="collapse" data-bs-target=".callout-5-contents" aria-controls="callout-5" aria-expanded="false" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon no-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Warning</span>LLMs Usage Declaration
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-5" class="callout-5-contents callout-collapse collapse">
<div class="callout-body-container callout-body">
<p>All reviews, opinions, and written content in this post, unless explicitly stated, are authored by me, a human. LLMs were used solely for formatting purposes, such as layout assistance, writing git commits, sourcing thumbnails, adding alt-text, and generating the thumbnail image for this post.</p>
</div>
</div>
</div>


</section>


<div id="quarto-appendix" class="default"><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>

<ol>
<li id="fn1"><p>And increasingly so, with modern LLM specification docs like <a href="https://modelcontextprotocol.io/" target="_blank">MCP</a> and <a href="https://docs.anthropic.com/en/docs/claude-code/slash-commands" target="_blank">skills</a>.↩︎</p></li>
<li id="fn2"><p>Including <a href="https://www.shamindras.com/posts" target="_blank">this very blog</a> 🎉↩︎</p></li>
<li id="fn3"><p>However <a href="https://www.youtube.com/@srush_nlp" target="_blank">his channel</a> covers a few of these.↩︎</p></li>
<li id="fn4"><p>There is also a recorded <a href="https://www.youtube.com/watch?v=k9DnQPrfJQs&amp;t=3571s" target="_blank">tutorial format</a> of this lecture if you prefer a slightly relaxed pace with interaction from the audience.↩︎</p></li>
<li id="fn5"><p>Image source for <em>The Life-Changing Magic of Tidying Up</em>: <a href="https://openlibrary.org/isbn/9781607747307" target="_blank">Open Library</a>.↩︎</p></li>
<li id="fn6"><p>Credit to <a href="https://www.julian.ac/read/" target="_blank">Julian Schrittwieser’s reading list</a> for the recent nudge to finally pick this up.↩︎</p></li>
<li id="fn7"><p>Image source for <em>How to Win Friends and Influence People</em>: <a href="https://open.spotify.com/show/3UfAQ6yAJQqHjifKaQ2Nm5" target="_blank">Spotify</a>.↩︎</p></li>
<li id="fn8"><p>Image source for <em>The Diary of a CEO</em>: <a href="https://openlibrary.org/works/OL37187091W" target="_blank">Open Library</a>.↩︎</p></li>
<li id="fn9"><p>Technically we are in 3D land, but we mean rectangles looking down 👀.↩︎</p></li>
</ol>
</section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a></div></div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{shrotriya2026february26roundup,
  author = {Shrotriya, Shamindra},
  title = {Shamindra’s {February} 2026 {Roundup}},
  date = {2026-02-28},
  url = {https://www.shamindras.com/posts/2026-02-28-shrotriya2026february26roundup/},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-shrotriya2026february26roundup" class="csl-entry quarto-appendix-citeas">
Shrotriya, Shamindra. 2026. <span>“Shamindra’s February 2026
Roundup.”</span> February 28, 2026. <a href="https://www.shamindras.com/posts/2026-02-28-shrotriya2026february26roundup/">https://www.shamindras.com/posts/2026-02-28-shrotriya2026february26roundup/</a>.
</div></div></section></div> ]]></description>
  <category>personal</category>
  <category>roundup</category>
  <guid>https://www.shamindras.com/posts/2026-02-28-shrotriya2026february26roundup/</guid>
  <pubDate>Fri, 27 Feb 2026 14:00:00 GMT</pubDate>
  <media:content url="https://www.shamindras.com/posts/2026-02-28-shrotriya2026february26roundup/images/preview-february-2026-01.png" medium="image" type="image/png" height="80" width="144"/>
</item>
<item>
  <title>Characterizing norm triangle inequalites via convexity</title>
  <dc:creator>Shamindra Shrotriya</dc:creator>
  <link>https://www.shamindras.com/posts/2021-12-31-shrotriya2021normtriconvexity/</link>
  <description><![CDATA[ <style type="text/css">/**
  * Author: Mikhail Popov
  * License: MIT
  */
a.wiki {
    /* color: #0645ad; */
    text-decoration: none;
    border-bottom: 1px dotted #0645ad;
}
.wiki::after {
    font-family: serif;
    content: " W";
    vertical-align: super;
    font-size: 6pt;
}</style>
<script src="https://unpkg.com/wikipedia-preview@1.8.0/dist/wikipedia-preview.production.js" type="text/javascript"></script><script type="text/javascript">
    window.onload = function() {
      wikipediaPreview.init({
        lang: 'en',
        selector: '.wiki',
        detectLinks: true
      });
    };</script><section id="tldr" class="level1 page-columns page-full"><h1>TL;DR</h1>
<p>I walk through a cool and possibly less known result connecting convexity and the triangle inequalities for norms. Using this result, typical proofs of the triangle inequality for a proposed norm function are significantly simplified. This exposition is based on <span class="citation" data-cites="robinson2020introfuncanalysis_book">(Chapter 3, Robinson 2020)</span> <sup>1</sup>.</p>
<aside><p><span class="citation" data-cites="robinson2020introfuncanalysis_book">(Robinson 2020)</span> is a wonderful functional analysis book, highly recommend it 💯!</p>
</aside></section><section id="background---norms" class="level1 page-columns page-full"><h1>Background - Norms</h1>
<aside><p><br><br> Experienced readers can freely skip this Background section.</p>
</aside><p>Normed linear spaces are a natural setting for much applied mathematics and statistics. These are vector spaces, <img src="https://latex.codecogs.com/png.latex?V">, endowed with a norm function, <img src="https://latex.codecogs.com/png.latex?%5ClVert%20%5Ccdot%20%5CrVert_%7BV%7D">. Intuitively, norms give us a “yardstick” to measure the “lengths” of individual vectors in the given vector space space. A standard definition of a norm is as follows:</p>
<div id="def-norm" class="theorem definition">
<p><span class="theorem-title"><strong>Definition 1 (Norms in vector spaces)</strong></span> For a given vector space <img src="https://latex.codecogs.com/png.latex?V">, a norm <img src="https://latex.codecogs.com/png.latex?%5ClVert%20%5Ccdot%20%5CrVert_%7BV%7D:%20V%20%5Cto%20%5Cmathbb%7BR%7D">, is a function satisfying the following three properties.</p>
<ol type="1">
<li>
<strong>Positive definiteness:</strong> For a <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D%20%5Cin%20V">, if <img src="https://latex.codecogs.com/png.latex?%5ClVert%20%5Cmathbf%7Bx%7D%20%5CrVert%20=%200"> then <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D%20=%20%5Cmathbf%7B0%7D_%7BV%7D">.</li>
<li>
<strong>Absolute homogeneity:</strong> <img src="https://latex.codecogs.com/png.latex?%5ClVert%20%5Clambda%20%5Cmathbf%7Bx%7D%20%5CrVert%20=%20%7C%20%5Clambda%20%7C%20%5ClVert%20%20%5Cmathbf%7Bx%7D%20%5CrVert">, for a <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D%20%5Cin%20V,%20%5Clambda%20%5Cin%20%5Cmathbb%7BR%7D">.</li>
<li>
<strong>Triangle inequality:</strong> <img src="https://latex.codecogs.com/png.latex?%5ClVert%20%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D%20%5CrVert%20%5Cleq%20%5ClVert%20%5Cmathbf%7Bx%7D%20%5CrVert%20+%20%20%5ClVert%20%5Cmathbf%7By%7D%20%5CrVert">, for a <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D,%20%5Cmathbf%7By%7D%20%5Cin%20V">.</li>
</ol>
</div>
<aside><p>We often use many norms on a given vector space, depending on which seems “meaningful” for the given purpose. See <a href="https://en.wikipedia.org/wiki/Norm_(mathematics)#Examples" class="wiki">here</a> for common examples.</p>
</aside><details><summary><p>Remarks</p>
</summary><div class="proof remark">
<p><span class="proof-title"><em>Remark</em> (Derived properties from Definition&nbsp;1). </span>We note that a norm, per Definition&nbsp;1, in fact, <strong>implies</strong> the following properties:</p>
<ol type="1">
<li><p>In Definition&nbsp;1, we can always replace <strong>positive definiteness</strong> with the stronger claim, namely that <img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5Ctext%7BFor%20a%20$%5Cmathbf%7Bx%7D%20%5Cin%20V$,%20if%20$%5ClVert%20%5Cmathbf%7Bx%7D%20%5CrVert%20=%200%20%5Ciff%20%5Cmathbf%7Bx%7D%20=%20%5Cmathbf%7B0%7D_%7BV%7D$.%7D%0A%5Cend%7Bequation%7D"> In short, we want to show that the reverse implication to <strong>positive definiteness</strong> always holds, i.e., <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D%20=%20%5Cmathbf%7B0%7D_%7BV%7D%20%5Cimplies%20%5ClVert%20%5Cmathbf%7Bx%7D%20%5CrVert%20=%200">. To prove this observe that using <strong>absolute homogeneity</strong> in Definition&nbsp;1, we have: <img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5ClVert%20%5Cmathbf%7Bx%7D%20%5CrVert%0A=%20%5ClVert%20%5Cmathbf%7B0%7D_%7BV%7D%20%5CrVert%0A=%20%5ClVert%200%20(%5Cmathbf%7B0%7D_%7BV%7D)%20%5CrVert%0A=%20%7C0%7C%20%5ClVert%20%5Cmathbf%7B0%7D_%7BV%7D%20%5CrVert%20=%200%0A%5Cend%7Bequation%7D"> As required.</p></li>
<li><p>We also have that <img src="https://latex.codecogs.com/png.latex?%5ClVert%20%5Cmathbf%7Bx%7D%20%5CrVert%20%5Cgeq%200">, for a <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D%20%5Cin%20V">. To see this, observe that for a <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D%20%5Cin%20V"> <img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5Cbegin%7Bsplit%7D%0A0%0A&amp;%20=%20%5ClVert%20%5Cmathbf%7B0%7D_%7BV%7D%20%5CrVert%0A%5Cquad%5Ctext%7B(by%20previous%20part%20of%20this%20remark)%7D%5C%5C%0A&amp;%20=%20%5ClVert%20%5Cmathbf%7Bx%7D%20+%20(-%5Cmathbf%7Bx%7D)%20%5CrVert%20%5C%5C%0A&amp;%5Cleq%20%5ClVert%20%5Cmathbf%7Bx%7D%20%5CrVert%20+%20%5ClVert%20-%5Cmathbf%7Bx%7D%20%5CrVert%0A%5Cquad%5Ctext%7B(by%20the%20triangle%20inequality)%7D%20%5C%5C%0A&amp;=%20%5ClVert%20%5Cmathbf%7Bx%7D%20%5CrVert%20+%0A%20%20%20%20%5Clvert%20-1%20%5Crvert%20%5ClVert%20%5Cmathbf%7Bx%7D%20%5CrVert%0A%20%20%20%20%5Cquad%5Ctext%7B(by%20absolute%20homogeneity)%7D%20%5C%5C%0A&amp;=%202%20%5ClVert%20%5Cmathbf%7Bx%7D%20%5CrVert%20%5C%5C%0A%5Cimplies%20%5ClVert%20%5Cmathbf%7Bx%7D%20%5CrVert%0A&amp;%20%5Cgeq%200%0A%5Cend%7Bsplit%7D%0A%5Cend%7Bequation%7D"> In effect this means the co-domain can <em>always</em> be changed from <img src="https://latex.codecogs.com/png.latex?%5ClVert%20%5Ccdot%20%5CrVert_%7BV%7D:%20V%20%5Cto%20%5Cmathbb%7BR%7D"> to <img src="https://latex.codecogs.com/png.latex?%5ClVert%20%5Ccdot%20%5CrVert_%7BV%7D:%20V%20%5Cto%20%5Cmathbb%7BR%7D_%7B%5Cgeq%200%7D">.</p></li>
<li><p>Since these can always be derived directly from Definition&nbsp;1, as shown, we can keep Definition&nbsp;1 in its minimal form as noted here.</p></li>
<li><p>These ideas work for <em>seminorms</em> as well, see <a href="https://en.wikipedia.org/wiki/Seminorm#Definition" class="wiki">here</a> for more details.</p></li>
</ol>
</div>
</details></section><section id="main-theorem" class="level1 page-columns page-full"><h1>Main theorem</h1>
<aside><p><br><br> This is based on <span class="citation" data-cites="robinson2020introfuncanalysis_book">(Lemmas 3.3-3.4 Robinson 2020)</span>.</p>
</aside><div id="thm-normtrichar" class="theorem">
<p><span class="theorem-title"><strong>Theorem 1 (Characterization of norm triangle inequality)</strong></span> Let <img src="https://latex.codecogs.com/png.latex?N:%20V%20%5Cto%20%5Cmathbb%7BR_%7B%5Cgeq%200%7D%7D">, be a function satisfying the following two properties<sup>2</sup>.</p>
<ol type="1">
<li>
<strong>Positive definiteness:</strong> For a <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D%20%5Cin%20V">, if <img src="https://latex.codecogs.com/png.latex?N(%5Cmathbf%7Bx%7D)%20=%200"> then <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D%20=%20%5Cmathbf%7B0%7D_%7BV%7D">.</li>
<li>
<strong>Absolute homogeneity:</strong> <img src="https://latex.codecogs.com/png.latex?N(%5Clambda%20%5Cmathbf%7Bx%7D)%20=%20%7C%20%5Clambda%20%7C%20N(%5Cmathbf%7Bx%7D)">, for a <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D%20%5Cin%20V,%20%5Clambda%20%5Cin%20%5Cmathbb%7BR%7D">.</li>
</ol>
<p>We then have that: <span id="eq-normtrichar-01"><img src="https://latex.codecogs.com/png.latex?%0A%20%20%20%20N(%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D)%20%5Cleq%20N(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)%0A%20%20%20%20%5Ctext%7B,%20for%20each%20%7D%20%5Cmathbf%7Bx%7D,%20%5Cmathbf%7By%7D%20%5Cin%20V%0A%20%20%20%20%5Ciff%20%5Cmathbb%7BB%7D%20:=%20%5C%7B%5Cmathbf%7Bz%7D%20%5Cin%20V%20%5C:%7C%5C:%20N(%5Cmathbf%7Bz%7D)%20%5Cleq%201%20%5C%7D%0A%20%20%20%20%5Ctext%7B%20is%20convex%7D%0A%5Ctag%7B1%7D"></span></p>
</div>
<p>In simple terms, the importance of Theorem&nbsp;1 (as captured by Equation&nbsp;1) can be summarized as follows:</p>
<blockquote class="blockquote">
<p>Let <img src="https://latex.codecogs.com/png.latex?N%20:%20V%20%5Cto%20%5B0,%20%5Cinfty)"> be a function satisfying positive definiteness and absolute homogeneity. Then <img src="https://latex.codecogs.com/png.latex?N"> satisfies the triangle inequality if and only if the unit ba induced by <img src="https://latex.codecogs.com/png.latex?N">, i.e., <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D%20:=%20%5C%7B%5Cmathbf%7Bz%7D%20%5Cin%20V%20%5C:%7C%5C:%20N(%5Cmathbf%7Bz%7D)%20%5Cleq%201%20%5C%7D">, is a convex set.</p>
</blockquote>
<details><summary><p>Remarks</p>
</summary><div class="proof remark">
<p><span class="proof-title"><em>Remark</em>. </span>In Theorem&nbsp;1, we note the following:</p>
<ol type="1">
<li>The function <img src="https://latex.codecogs.com/png.latex?N%20:%20V%20%5Cto%20%5Cmathbb%7BR%7D_%7B%5Cgeq%200%7D">, is a <em>norm-like</em> function, and only becomes a valid norm per Definition&nbsp;1 <strong><em>once</em></strong> we establish the triangle inequality, i.e., <img src="https://latex.codecogs.com/png.latex?N(%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D)%20%5Cleq%20N(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)">.</li>
<li>To prove the triangle inequality for <img src="https://latex.codecogs.com/png.latex?N%20:%20V%20%5Cto%20%5Cmathbb%7BR%7D_%7B%5Cgeq%200%7D">, the necessary condition of Theorem&nbsp;1 to establish is: <span id="eq-normtrichar-02"><img src="https://latex.codecogs.com/png.latex?%0A%5Cmathbb%7BB%7D%20:=%20%5C%7B%5Cmathbf%7Bz%7D%20%5Cin%20V%20%5C:%7C%5C:%20N(%5Cmathbf%7Bz%7D)%20%5Cleq%201%20%5C%7D%0A%5Ctext%7B%20is%20convex%7D%0A%5Ctag%7B2%7D"></span> which will imply the triangle inequality for <img src="https://latex.codecogs.com/png.latex?N"> - huzzah!</li>
<li>The nice thing is, proving the convexity of <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D"> can be <em>much easier</em> to show than trying to prove the triangle inequality property of <img src="https://latex.codecogs.com/png.latex?N"> directly, as we will soon see.</li>
<li>
<strong>Subtle point:</strong> note that here we had to <em>assume</em> that the co-domain of <img src="https://latex.codecogs.com/png.latex?N"> is non-negative (not <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BR%7D">), i.e., <img src="https://latex.codecogs.com/png.latex?N%20:%20V%20%5Cto%20%5Cmathbb%7BR%7D_%7B%5Cgeq%200%7D">. This is because in a typical norm, which satisfies the triangle inequality, is always shown to be non-negative (see remark below Definition&nbsp;1 for more details). Here we <em>impose</em> non-negativity of <img src="https://latex.codecogs.com/png.latex?N"> as an additional constraint to <em>establish</em> the triangle inequality property for <img src="https://latex.codecogs.com/png.latex?N">. This is not an issue, since one would always first check the non-negativity of a candidate <em>norm-like</em> function <img src="https://latex.codecogs.com/png.latex?N">.</li>
</ol>
</div>
</details></section><section id="applications-minkowski-inequalities" class="level1 page-columns page-full"><h1>Applications: Minkowski inequalities</h1>
<p>Before getting into the details of the proof, let’s just see what Theorem Theorem&nbsp;1 can do! We’ll consider two related applications taken from <span class="citation" data-cites="robinson2020introfuncanalysis_book">(Lemma 3.6, Example 3.13 Robinson 2020)</span>, respectively.</p>
<section id="application-1-ell_p-norm-triangle-inequality-in-mathbbfn" class="level3 page-columns page-full"><h3 class="anchored" data-anchor-id="application-1-ell_p-norm-triangle-inequality-in-mathbbfn">Application 1: <img src="https://latex.codecogs.com/png.latex?%5Cell_%7Bp%7D">-norm triangle inequality in <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BF%7D%5E%7Bn%7D">
</h3>
<div id="exm-normtrilpsum" class="theorem example">
<p><span class="theorem-title"><strong>Example 1 (Minkowski inequality in finite dimensions)</strong></span> Let us consider <img src="https://latex.codecogs.com/png.latex?(%5Cmathbb%7BF%7D%5E%7Bn%7D,%20%5Cmathbb%7BF%7D)">, where <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BF%7D%20=%20%5Cmathbb%7BR%7D%20%5Ctext%7B%20or%20%7D%20%5Cmathbb%7BC%7D">. We then define the <em>norm-like</em> function <img src="https://latex.codecogs.com/png.latex?N_%7B%5Cell%5E%7Bp%7D%7D:%20%5Cmathbb%7BF%7D%5E%7Bn%7D%20%5Cto%20%5Cmathbb%7BR%7D_%7B%5Cgeq%200%7D">: <span id="eq-normtrilpsum-01"><img src="https://latex.codecogs.com/png.latex?%0A%20%20%20%20N_%7B%5Cell%5E%7Bp%7D%7D(%5Cmathbf%7Bx%7D)%0A%20%20%20%20:=%5Cleft(%5Csum_%7Bj=1%7D%5E%7Bn%7D%5Cleft%7Cx_%7Bj%7D%5Cright%7C%5E%7Bp%7D%5Cright)%5E%7B1%20/%20p%7D%0A%20%20%20%20,%20%5Cquad%201%20%5Cleq%20p%3C%5Cinfty%0A%5Ctag%7B3%7D"></span></p>
</div>
<p>One can show that <img src="https://latex.codecogs.com/png.latex?N_%7B%5Cell%5E%7Bp%7D%7D"> satisfies positive definiteness and absolute homogeneity. To show that <img src="https://latex.codecogs.com/png.latex?N_%7B%5Cell%5E%7Bp%7D%7D"> is a norm function we need to prove the triangle inequality. We will use Theorem&nbsp;1. Let us define <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D%20:=%20%5C%7B%5Cmathbf%7Bz%7D%20%5Cin%20%5Cmathbb%7BF%7D%5E%7Bn%7D%20%5C:%7C%5C:%20N_%7B%5Cell%5E%7Bp%7D%7D(%5Cmathbf%7Bz%7D)%20%5Cleq%201%20%5C%7D%20=%20%5C%7B%5Cmathbf%7Bz%7D%20%5Cin%20%5Cmathbb%7BF%7D%5E%7Bn%7D%20%5C:%7C%5C:%20N_%7B%5Cell%5E%7Bp%7D%7D%5E%7Bp%7D(%5Cmathbf%7Bz%7D)%20%5Cleq%201%20%5C%7D">. We now need to show that <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D"> is convex. We will need to use the fact that for each <img src="https://latex.codecogs.com/png.latex?t%20%5Cin%20%5Cmathbb%7BR%7D,%20t%20%5Cmapsto%20%7Ct%7C%5E%7Bp%7D"> is convex. Let <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D,%20%5Cmathbf%7By%7D%20%5Cin%20%5Cmathbb%7BB%7D">, we then have that for <img src="https://latex.codecogs.com/png.latex?%5Clambda%20%5Cin%20%5B0,%201%5D">:</p>
<aside><p><strong>Note:</strong> <img src="https://latex.codecogs.com/png.latex?t%20%5Cmapsto%20%7Ct%7C%5E%7Bp%7D">, is convex, for each <img src="https://latex.codecogs.com/png.latex?t%20%5Cin%20%5Cmathbb%7BR%7D"> and <img src="https://latex.codecogs.com/png.latex?p%20%5Cin%20%5B1,%20%5Cinfty)">. <strong>Sketch:</strong> We have, <img src="https://latex.codecogs.com/png.latex?%7Ct%7C%5E%7Bp%7D%20=:%20h(t)%20:=%20(g%20%5Ccirc%20f)%20(t)">. Here, for each <img src="https://latex.codecogs.com/png.latex?x%20%5Cin%20%5Cmathbb%7BR%7D">, we observe <img src="https://latex.codecogs.com/png.latex?g%20:%20x%20%5Cmapsto%20x%5E%7Bp%7D"> is increasing and convex, and <img src="https://latex.codecogs.com/png.latex?f%20:%20x%20%5Cmapsto%20%7Cx%7C"> is convex. Thus, <img src="https://latex.codecogs.com/png.latex?h(t)%20:=%20%7Ct%7C%5E%7Bp%7D"> is convex. <img src="https://latex.codecogs.com/png.latex?%5Cblacksquare"></p>
</aside><img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5Cbegin%7Bsplit%7D%0A%20%20%20%20N_%7B%5Cell%5E%7Bp%7D%7D%5E%7Bp%7D(%5Clambda%20%5Cmathbf%7Bx%7D%20+%20(1%20-%20%5Clambda)%20%5Cmathbf%7By%7D)%0A%20%20%20%20&amp;%20=%20%5Csum_%7Bj=1%7D%5E%7Bn%7D%7C%5Clambda%7C%20x_%7Bj%7D%7C+(1-%5Clambda)%7C%20y_%7Bj%7D%7C%7C%5E%7Bp%7D%0A%20%20%20%20%5Cquad%5Ctext%7B(by%20definition)%7D%20%5C%5C%0A%20%20%20%20&amp;%20%5Cleq%20%5Csum_%7Bj=1%7D%5E%7Bn%7D%20%5Clambda%5Cleft%7Cx_%7Bj%7D%5Cright%7C%5E%7Bp%7D+(1-%5Clambda)%5Cleft%7Cy_%7Bj%7D%5Cright%7C%5E%7Bp%7D%0A%20%20%20%20%5Cquad%5Ctext%7B(since%20$t%20%5Cmapsto%20%7Ct%7C%5E%7Bp%7D$%20is%20convex%20for%20each%20$t%20%5Cin%20%5Cmathbb%7BR%7D$)%7D%20%5C%5C%0A%20%20%20%20&amp;%20=%20%5Clambda%20%5Csum_%7Bj=1%7D%5E%7Bn%7D%20%5Cleft%7Cx_%7Bj%7D%5Cright%7C%5E%7Bp%7D%0A%20%20%20%20+%20(1%20-%20%5Clambda)%20%5Csum_%7Bj=1%7D%5E%7Bn%7D%20%5Cleft%7Cy_%7Bj%7D%5Cright%7C%5E%7Bp%7D%20%5C%5C%0A%20%20%20%20&amp;%20%5Cleq%201%0A%20%20%20%20%5Cquad%5Ctext%7B(since%20$%5Cmathbf%7Bx%7D,%20%5Cmathbf%7By%7D%20%5Cin%20%5Cmathbb%7BB%7D$.)%7D%0A%5Cend%7Bsplit%7D%0A%5Cend%7Bequation%7D">
<p>It follows that <img src="https://latex.codecogs.com/png.latex?N_%7B%5Cell%5E%7Bp%7D%7D(%5Clambda%20%5Cmathbf%7Bx%7D%20+%20(1%20-%20%5Clambda)%20%5Cmathbf%7By%7D)%20%5Cleq%201">, and so <img src="https://latex.codecogs.com/png.latex?%5Clambda%20%5Cmathbf%7Bx%7D%20+%20(1%20-%20%5Clambda)%20%5Cmathbf%7By%7D%20%5Cin%20%5Cmathbb%7BB%7D">, as required <img src="https://latex.codecogs.com/png.latex?%5Cblacksquare">.</p>
<aside><p>This triangle inequality is proved in just four lines 🔥!</p>
</aside><p>In fact, since it <img src="https://latex.codecogs.com/png.latex?N_%7B%5Cell%5E%7Bp%7D%7D"> satisfies the three conditions for a norm per Definition&nbsp;1 we can now denote it using the conventional <img src="https://latex.codecogs.com/png.latex?%5Cell_%7Bp%7D">-norm form, i.e., <img src="https://latex.codecogs.com/png.latex?%5C%7C%20%5Cmathbf%7Bx%7D%20%5C%7C_%7B%5Cell%5E%7Bp%7D%7D%20:=%20N_%7B%5Cell%5E%7Bp%7D%7D(%5Cmathbf%7Bx%7D)"></p>
</section><section id="application-2-l_p-norm-triangle-inequality" class="level3 page-columns page-full"><h3 class="anchored" data-anchor-id="application-2-l_p-norm-triangle-inequality">Application 2: <img src="https://latex.codecogs.com/png.latex?L_%7Bp%7D">-norm triangle inequality</h3>
<p>We can also similarly prove the triangle inequality norms involving integrals efficiently. This is seen in the next example.</p>
<aside><p>Here <img src="https://latex.codecogs.com/png.latex?C(%5B0,%201%5D)"> is the space of continuous functions on the interval <img src="https://latex.codecogs.com/png.latex?%5B0,%201%5D">.</p>
</aside><div id="normtrilpint" class="example" name="Minkowski inequality in integral form">
<p>Let us consider <img src="https://latex.codecogs.com/png.latex?(C(%5B0,%201%5D),%20%5Cmathbb%7BR%7D)">. We then define the <em>norm-like</em> function <img src="https://latex.codecogs.com/png.latex?N_%7BL%5E%7Bp%7D%7D:%20C(%5B0,%201%5D)%20%5Cto%20%5Cmathbb%7BR%7D_%7B%5Cgeq%200%7D">: <span id="eq-normtrilpint-01"><img src="https://latex.codecogs.com/png.latex?%0A%20%20%20%20N_%7BL%5E%7Bp%7D%7D(%5Cmathbf%7Bx%7D)%0A%20%20%20%20:=%5Cleft(%5Cint_%7B0%7D%5E%7B1%7D%5Cleft%7Cf(x)%5Cright%7C%5E%7Bp%7D%5Cright)%5E%7B1%20/%20p%7D%0A%20%20%20%20,%20%5Cquad%201%20%5Cleq%20p%3C%5Cinfty%0A%5Ctag%7B4%7D"></span></p>
</div>
<p>Let us define <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D%20:=%20%5C%7Bh%20%5Cin%20C(%5B0,%201%5D)%20%5C:%7C%5C:%20N_%7BL%5E%7Bp%7D%7D(h)%20%5Cleq%201%20%5C%7D%20%20=%20%5C%7Bh%20%5Cin%20C(%5B0,%201%5D)%20%5C:%7C%5C:%20N_%7BL%5E%7Bp%7D%7D%5E%7Bp%7D(h)%20%5Cleq%201%20%5C%7D">. We now need to show that <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D"> is convex. Let <img src="https://latex.codecogs.com/png.latex?f,%20g%20%5Cin%20%5Cmathbb%7BB%7D">, we then have that for <img src="https://latex.codecogs.com/png.latex?%5Clambda%20%5Cin%20%5B0,%201%5D">:</p>
<aside><p>Once again, one can show that <img src="https://latex.codecogs.com/png.latex?N_%7B%5Cell%5E%7Bp%7D%7D"> satisfies positive definiteness and absolute homogeneity.</p>
</aside><img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5Cbegin%7Bsplit%7D%0A%20%20%20%20N_%7BL%5E%7Bp%7D%7D%5E%7Bp%7D(%5Clambda%20f%20+%20(1%20-%20%5Clambda)%20g)%0A%20%20%20%20&amp;%20=%20%5Cint_%7B0%7D%5E%7B1%7D%7C%5Clambda%20f(x)%20+%20(1-%5Clambda)%20g(x)%7C%5E%7Bp%7D%20dx%0A%20%20%20%20%5Cquad%5Ctext%7B(by%20definition)%7D%20%5C%5C%0A%20%20%20%20&amp;%20%5Cleq%20%5Cint_%7B0%7D%5E%7B1%7D%5Clambda%20%7Cf(x)%7C%5E%7Bp%7D%20+%20(1-%5Clambda)%20%7Cg(x)%7C%5E%7Bp%7D%20dx%0A%20%20%20%20%5Cquad%5Ctext%7B(since%20$t%20%5Cmapsto%20%7Ct%7C%5E%7Bp%7D$%20is%20convex%20for%20each%20$t%20%5Cin%20%5Cmathbb%7BR%7D$)%7D%20%5C%5C%0A%20%20%20%20&amp;%20=%20%5Clambda%20%5Cint_%7B0%7D%5E%7B1%7D%20%7Cf(x)%7C%5E%7Bp%7D%20dx%20+%20(1-%5Clambda)%20%5Cint_%7B0%7D%5E%7B1%7D%20%7Cg(x)%7C%5E%7Bp%7D%20dx%20%5C%5C%0A%20%20%20%20&amp;%20%5Cleq%201%0A%20%20%20%20%5Cquad%5Ctext%7B(since%20$f,%20g%20%5Cin%20%5Cmathbb%7BB%7D$.)%7D%0A%5Cend%7Bsplit%7D%0A%5Cend%7Bequation%7D">
<p>It follows that <img src="https://latex.codecogs.com/png.latex?N_%7BL%5E%7Bp%7D%7D(%5Clambda%20f%20+%20(1%20-%20%5Clambda)%20g)%20%5Cleq%201">, and so <img src="https://latex.codecogs.com/png.latex?%5Clambda%20f%20+%20(1%20-%20%5Clambda)%20g%20%5Cin%20%5Cmathbb%7BB%7D">, as required <img src="https://latex.codecogs.com/png.latex?%5Cblacksquare">.</p>
<p>Again, we can now denote <img src="https://latex.codecogs.com/png.latex?N_%7BL%5E%7Bp%7D%7D"> using the conventional <img src="https://latex.codecogs.com/png.latex?L_%7Bp%7D">-norm form, i.e., <img src="https://latex.codecogs.com/png.latex?%5C%7C%20f%20%5C%7C_%7BL%5E%7Bp%7D%7D%20:=%20N_%7BL%5E%7Bp%7D%7D(f)">.</p>
</section></section><section id="punchline-what-did-theorem-1-buy-us" class="level1 page-columns page-full"><h1>Punchline: what did Theorem 1 buy us?</h1>
<p>We just saw that applying Theorem&nbsp;1 enabled us to write <strong>very short proofs</strong> of <a href="https://en.wikipedia.org/wiki/Minkowski_inequality" class="wiki"><strong>Minkowski’s inequality</strong></a> in <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BF%7D%5E%7Bn%7D"> and <img src="https://latex.codecogs.com/png.latex?C(%5B0,%201%5D)">.</p>
<p>To appreciate this approach, note that proving Minkowski’s inequality typicay requires one to first prove <a href="https://en.wikipedia.org/wiki/Young%27s_inequality_for_products" class="wiki"><strong>Young’s inequality</strong></a> and then <a href="https://en.wikipedia.org/wiki/H%C3%B6lder%27s_inequality" class="wiki"><strong>Hölder’s inequality</strong></a>. Moreover these need to be done separately in <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BF%7D%5E%7Bn%7D"> and <img src="https://latex.codecogs.com/png.latex?C(%5B0,%201%5D)">. Using Theorem&nbsp;1 aowed us to achieve both of these goals using near identical style of proofs 🎉!</p>
<aside><p><strong>Note:</strong> The proofs of Young’s and Hölder’s inequality are beautiful and studying them is also insightful.</p>
</aside></section><section id="proof-of-theorem-1" class="level1 page-columns page-full"><h1>Proof of Theorem 1</h1>
<p>Assuming <img src="https://latex.codecogs.com/png.latex?N:%20V%20%5Cto%20%5Cmathbb%7BR_%7B%5Cgeq%200%7D%7D"> satisfies the two properties in Theorem Theorem&nbsp;1, we need to prove both implications in Equation Equation&nbsp;1.</p>
<section id="proof---easy-direction" class="level3"><h3 class="anchored" data-anchor-id="proof---easy-direction">Proof - easy direction</h3>
<p>Assume that <img src="https://latex.codecogs.com/png.latex?N(%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D)%20%5Cleq%20N(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)">, for each <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D,%20%5Cmathbf%7By%7D%20%5Cin%20V">. Let <img src="https://latex.codecogs.com/png.latex?%5Clambda%20%5Cin%20%5B0,%201%5D"> be arbitrary. We need to show that this implies for each <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D,%20%5Cmathbf%7By%7D%20%5Cin%20%5Cmathbb%7BB%7D"> that the expression <img src="https://latex.codecogs.com/png.latex?%5Clambda%20%5Cmathbf%7Bx%7D%20+%20(1%20-%20%5Clambda)%20%5Cmathbf%7By%7D%20%5Cin%20%5Cmathbb%7BB%7D"> holds. This implies the convexity of <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D">.</p>
<details><summary><p>Proof</p>
</summary><div class="proof">
<p><span class="proof-title"><em>Proof</em>. </span>(<img src="https://latex.codecogs.com/png.latex?%5Cimplies">) We proceed directly.</p>
<p>Assume that <img src="https://latex.codecogs.com/png.latex?N(%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D)%20%5Cleq%20N(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)">, for each <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D,%20%5Cmathbf%7By%7D%20%5Cin%20V">. Let <img src="https://latex.codecogs.com/png.latex?%5Clambda%20%5Cin%20%5B0,%201%5D"> be arbitrary. We need to show that this implies for each <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D,%20%5Cmathbf%7By%7D%20%5Cin%20%5Cmathbb%7BB%7D"> that the expression <img src="https://latex.codecogs.com/png.latex?%5Clambda%20%5Cmathbf%7Bx%7D%20+%20(1%20-%20%5Clambda)%20%5Cmathbf%7By%7D%20%5Cin%20%5Cmathbb%7BB%7D"> holds. This implies the convexity of <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D">.</p>
<p>We observe that for <img src="https://latex.codecogs.com/png.latex?%5Clambda%20%5Cin%20%5C%7B0,%201%5C%7D"> our required expression is equal to either <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D"> or <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7By%7D"> which are both in <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D">, by assumption. Now fix <img src="https://latex.codecogs.com/png.latex?%5Clambda%20%5Cin%20(0,%201)">. We then note:</p>
<img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5Cbegin%7Bsplit%7D%0A%20%20%20%20N(%5Clambda%20%5Cmathbf%7Bx%7D%20+%20(1%20-%20%5Clambda)%20%5Cmathbf%7By%7D)%0A%20%20%20%20&amp;%20%5Cleq%20N(%5Clambda%20%5Cmathbf%7Bx%7D)%20+%20N((1%20-%20%5Clambda)%20%5Cmathbf%7By%7D)%0A%20%20%20%20%5Cquad%5Ctext%7B($N$%20satisfies%20triangle%20inequality)%7D%20%5C%5C%0A%20%20%20%20&amp;%20=%20%5Clvert%20%5Clambda%20%5Crvert%20N(%5Cmathbf%7Bx%7D)%20+%20%5Clvert%201%20-%20%5Clambda%20%5Crvert%20N(%5Cmathbf%7By%7D)%0A%20%20%20%20%5Cquad%5Ctext%7B(by%20absolute%20homogeneity%20of%20$N$)%7D%20%5C%5C%0A%20%20%20%20&amp;%20=%20%5Clambda%20N(%5Cmathbf%7Bx%7D)%20+%201%20-%20%5Clambda%20N(%5Cmathbf%7By%7D)%0A%20%20%20%20%5Cquad%5Ctext%7B(since%20$%5Clambda%20%3E%200$)%7D%20%5C%5C%0A%20%20%20%20&amp;%20%5Cleq%20(%5Clambda)%20(1)%20+%20(1%20-%20%5Clambda)%20(1)%0A%20%20%20%20%5Cquad%5Ctext%7B(since%20$N(%5Cmathbf%7Bz%7D)%20%5Cleq%201$,%20for%20$%5Cmathbf%7Bz%7D%20%5Cin%20%5Cmathbb%7BB%7D$)%7D%20%5C%5C%0A%20%20%20%20&amp;%20=%201%20%5C%5C%0A%5Cimplies%20%5Clambda%20%5Cmathbf%7Bx%7D%20+%20(1%20-%20%5Clambda)%20%5Cmathbf%7By%7D%0A%20%20%20%20&amp;%20%5Cin%20%5Cmathbb%7BB%7D%0A%5Cend%7Bsplit%7D%0A%5Cend%7Bequation%7D">
<p>Which implies the convexity of <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D">, as required. <img src="https://latex.codecogs.com/png.latex?%5Cblacksquare"></p>
</div>
</details></section><section id="proof---interesting-direction" class="level3 page-columns page-full"><h3 class="anchored" data-anchor-id="proof---interesting-direction">Proof - interesting direction</h3>
<p>Assume <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D"> is a convex set. We need to show that this implies that <img src="https://latex.codecogs.com/png.latex?N(%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D)%20%5Cleq%20N(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)">, for each <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D,%20%5Cmathbf%7By%7D%20%5Cin%20V">.</p>
<aside><p><strong>Tip:</strong> In linear algebra proofs, it is best to <strong>first</strong> deal with the zero vector, <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7B0%7D_%7BV%7D">, separately.</p>
</aside><details><summary><p>Proof</p>
</summary><div class="proof">
<p><span class="proof-title"><em>Proof</em>. </span>(<img src="https://latex.codecogs.com/png.latex?%5Cimpliedby">) We proceed directly.</p>
<p>Assume <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D"> is a convex set. We need to show that this implies that <img src="https://latex.codecogs.com/png.latex?N(%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D)%20%5Cleq%20N(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)">, for each <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D,%20%5Cmathbf%7By%7D%20%5Cin%20V">.</p>
<p>Let <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D,%20%5Cmathbf%7By%7D%20%5Cin%20V">. We will consider four cases.</p>
<p><strong>Case 1:</strong> Let <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D%20=%20%5Cmathbf%7By%7D%20=%20%5Cmathbf%7B0%7D_%7BV%7D">. Then <img src="https://latex.codecogs.com/png.latex?N(%5Cmathbf%7Bx%7D)%20=%20N(%5Cmathbf%7By%7D)%20=%20N(%5Cmathbf%7B0%7D_%7BV%7D)%20=%20N(0%20%5Cmathbf%7B0%7D_%7BV%7D)%20%20=%20%7C0%7C%20N(%5Cmathbf%7B0%7D_%7BV%7D)=%200">, by absolute homogeneity of <img src="https://latex.codecogs.com/png.latex?N">. Indeed we then have that <img src="https://latex.codecogs.com/png.latex?N(%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D)%20=%20N(%5Cmathbf%7B0%7D_%7BV%7D)%20=%200%20=%20N(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)">, as required.</p>
<p><strong>Case 2:</strong> Let <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D%20=%20%5Cmathbf%7B0%7D_%7BV%7D,%20%5Cmathbf%7By%7D%20%5Cin%20V%20%5Csetminus%20%5C%7B%5Cmathbf%7B0%7D_%7BV%7D%5C%7D">. Then <img src="https://latex.codecogs.com/png.latex?N(%5Cmathbf%7By%7D)%20=%200">, and it follows that <img src="https://latex.codecogs.com/png.latex?N(%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D)%20=%20N(%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7B0%7D_%7BV%7D)%20=%20N(%5Cmathbf%7Bx%7D)%20%20=%20N(%5Cmathbf%7Bx%7D)%20+%200%20=%20N(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)">, as required.</p>
<p><strong>Case 3:</strong> Let <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D%20%5Cin%20V%20%5Csetminus%20%5C%7B%5Cmathbf%7B0%7D_%7BV%7D%5C%7D,%20%5Cmathbf%7By%7D%20=%20%5Cmathbf%7B0%7D_%7BV%7D">. Same as <strong>Case 2</strong>, with the roles of <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D,%20%5Cmathbf%7By%7D"> reversed.</p>
<p><strong>Case 4:</strong> Let <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bx%7D,%20%5Cmathbf%7By%7D%20%5Cin%20V%20%5Csetminus%20%5C%7B%5Cmathbf%7B0%7D_%7BV%7D%5C%7D">. It then follows that <img src="https://latex.codecogs.com/png.latex?N(%5Cmathbf%7Bx%7D),%20N(%5Cmathbf%7By%7D)%20%3E%200">, since <img src="https://latex.codecogs.com/png.latex?N(%5Cmathbf%7Bz%7D)%20%5Cgeq%200">, for each <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bz%7D%20%5Cin%20V">, and <img src="https://latex.codecogs.com/png.latex?N(%5Cmathbf%7Bz%7D)%20=%200%20%5Ciff%20%5Cmathbf%7Bz%7D%20=%20%5Cmathbf%7B0%7D_%7BV%7D">. Moreover we then have that <img src="https://latex.codecogs.com/png.latex?%5Clvert%20N(%5Cmathbf%7Bx%7D)%20%5Crvert%20=%20N(%5Cmathbf%7Bx%7D)%20%3E%200"> and <img src="https://latex.codecogs.com/png.latex?%5Clvert%20N(%5Cmathbf%7By%7D)%20%5Crvert%20=%20N(%5Cmathbf%7By%7D)%20%3E%200">. So we can safely divide by these quantities. Let us then define <img src="https://latex.codecogs.com/png.latex?%5Ctilde%7B%5Cmathbf%7Bx%7D%7D%20:=%20%5Cfrac%7B%5Cmathbf%7Bx%7D%7D%7BN(%5Cmathbf%7Bx%7D)%7D,%20%5Ctilde%7B%5Cmathbf%7By%7D%7D%20:=%20%5Cfrac%7B%5Cmathbf%7By%7D%7D%7BN(%5Cmathbf%7By%7D)%7D">. We then have by absolute homogeneity of <img src="https://latex.codecogs.com/png.latex?N"> that, <img src="https://latex.codecogs.com/png.latex?N(%5Ctilde%7B%5Cmathbf%7Bx%7D%7D)%20:=%20N%5Cleft(%5Cfrac%7B%5Cmathbf%7Bx%7D%7D%7BN(%5Cmathbf%7Bx%7D)%7D%5Cright)%20=%20%5Cleft%20%5Clvert%20%5Cfrac%7B1%7D%7BN(%5Cmathbf%7Bx%7D)%7D%20%5Cright%20%5Crvert%20N(%5Cmathbf%7Bx%7D)%20=%201%20%5Cimplies%20%5Ctilde%7B%5Cmathbf%7Bx%7D%7D%20%5Cin%20%5Cmathbb%7BB%7D">. Similarly <img src="https://latex.codecogs.com/png.latex?%5Ctilde%7B%5Cmathbf%7By%7D%7D%20%5Cin%20%5Cmathbb%7BB%7D">. Let us denote <img src="https://latex.codecogs.com/png.latex?%5Clambda%20:=%20%5Cfrac%7BN(%5Cmathbf%7Bx%7D)%7D%7BN(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)%7D%20%5Cin%20(0,%201)">, and <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bz%7D%20:=%20%5Cfrac%7B%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D%7D%7BN(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)%7D">. We then have: <img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5Cbegin%7Bsplit%7D%0A%20%20%20%20%5Cmathbf%7Bz%7D%0A%20%20%20%20&amp;%20:=%20%5Cfrac%7B%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D%7D%7BN(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)%7D%20%5C%5C%0A%20%20%20%20&amp;%20=%20%5Cleft(%5Cfrac%7BN(%5Cmathbf%7Bx%7D)%7D%7BN(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)%7D%5Cright)%0A%20%20%20%20%20%20%20%20%5Cleft(%5Cfrac%7B%5Cmathbf%7Bx%7D%7D%7BN(%5Cmathbf%7Bx%7D)%7D%5Cright)%20+%0A%20%20%20%20%20%20%20%20%5Cleft(%5Cfrac%7BN(%5Cmathbf%7By%7D)%7D%7BN(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)%7D%5Cright)%0A%20%20%20%20%20%20%20%20%5Cleft(%5Cfrac%7B%5Cmathbf%7By%7D%7D%7BN(%5Cmathbf%7By%7D)%7D%5Cright)%20%5C%5C%0A%20%20%20%20&amp;%20=%20%5Cleft(%5Cfrac%7BN(%5Cmathbf%7Bx%7D)%7D%7BN(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)%7D%5Cright)%0A%20%20%20%20%20%20%20%20%5Ctilde%7B%5Cmathbf%7Bx%7D%7D%20+%0A%20%20%20%20%20%20%20%20%5Cleft(%5Cfrac%7BN(%5Cmathbf%7By%7D)%7D%7BN(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)%7D%5Cright)%0A%20%20%20%20%20%20%20%20%5Ctilde%7B%5Cmathbf%7By%7D%7D%20%5C%5C%0A%20%20%20%20&amp;%20=%20%5Clambda%20%5Ctilde%7B%5Cmathbf%7Bx%7D%7D%20+%0A%20%20%20%20%20%20%20%20(1%20-%20%5Clambda)%20%5Ctilde%7B%5Cmathbf%7By%7D%7D%20%5C%5C%0A%20%20%20%20&amp;%20%5Cin%20%5Cmathbb%7BB%7D%0A%5Cend%7Bsplit%7D%0A%5Cend%7Bequation%7D"></p>
<p>By the assumed convexity of <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D">. We then have that <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Bz%7D%20:=%20%5Cfrac%7B%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D%7D%7BN(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)%7D%20%20%5Cin%20%5Cmathbb%7BB%7D%20%5Cimplies%20N(%5Cmathbf%7Bz%7D)%20%5Cleq%201">. We then observe: <img src="https://latex.codecogs.com/png.latex?%5Cbegin%7Bequation%7D%0A%5Cbegin%7Bsplit%7D%0A%20%20%20%20N(%5Cmathbf%7Bz%7D)%0A%20%20%20%20&amp;%20%5Cleq%201%0A%20%20%20%20%5Cquad%5Ctext%7B(since%20$%5Cmathbf%7Bz%7D%20%5Cin%20%5Cmathbb%7BB%7D$.)%7D%20%5C%5C%0A%5Ciff%20N%5Cleft(%20%5Cfrac%7B%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D%7D%7BN(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)%7D%5Cright)%0A%20%20%20%20&amp;%20%5Cleq%201%0A%20%20%20%20%5Cquad%5Ctext%7B(by%20definition%20of%20$%5Cmathbf%7Bz%7D$.)%7D%20%5C%5C%0A%5Ciff%20%5Cleft%5Clvert%20%5Cfrac%7B1%7D%7BN(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)%7D%5Cright%5Crvert%0A%20%20%20%20%20N(%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D)%0A%20%20%20%20&amp;%20%5Cleq%201%0A%20%20%20%20%5Cquad%5Ctext%7B(absolute%20homogeneity%20of%20$N$.)%7D%20%5C%5C%0A%5Ciff%20%5Cfrac%7B1%7D%7BN(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)%7D%0A%20%20%20%20%20N(%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D)%0A%20%20%20%20&amp;%20%5Cleq%201%0A%20%20%20%20%5Cquad%5Ctext%7B(since%20$N(%5Cmathbf%7Bx%7D),%20N(%5Cmathbf%7By%7D)%20%3E%200$.)%7D%20%5C%5C%0A%5Ciff%20N(%5Cmathbf%7Bx%7D%20+%20%5Cmathbf%7By%7D)%0A%20%20%20%20&amp;%20%5Cleq%20N(%5Cmathbf%7Bx%7D)%20+%20N(%5Cmathbf%7By%7D)%0A%5Cend%7Bsplit%7D%0A%5Cend%7Bequation%7D"></p>
<p>As required. <img src="https://latex.codecogs.com/png.latex?%5Cblacksquare"></p>
</div>
</details></section></section><section id="recap" class="level1"><h1>Recap</h1>
<p>In this article we learned the following about Theorem&nbsp;1:</p>
<ul>
<li>It gives an alternative way to <strong>characterize</strong> the triangle inequality for <em>norm-like</em> functions.</li>
<li>Using this characterization <strong>we can prove the triangle inequality</strong> for such norm-like functions using the convexity of the unit ba induced by such functions.</li>
<li>This is usuay easier since we have lots of <strong>tools from convex analysis</strong> to help us prove the convexity of <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BB%7D">.</li>
<li>We saw this in action since Theorem&nbsp;1 enabled us to write <strong>very short proofs</strong> of <strong>Minkowski’s inequality</strong> in <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BF%7D%5E%7Bn%7D"> and <img src="https://latex.codecogs.com/png.latex?C(%5B0,%201%5D)">.</li>
</ul>
<p>In summary, if you have a norm-like function for which you are trying to establish the triangle inequality, try out Theorem&nbsp;1 💯!</p>
</section><div id="quarto-appendix" class="default"><section id="acknowledgements" class="level1 appendix"><h2 class="anchored quarto-appendix-heading">Acknowledgements</h2><div class="quarto-appendix-contents">
<p>I thank <a href="https://warwick.ac.uk/fac/sci/maths/people/staff/james_robinson">Prof.&nbsp;James Robinson</a> for providing several technical clarifications on Theorem&nbsp;1. I thank <a href="https://mpopov.com/about/">Mikhail Popov</a> for creating the <a href="https://bearloga.github.io/wikipediapreview-r/"><code>wikipediapreview</code> R package</a>, which enable an easy interface for Wikipedia <a href="https://chimeces.com/context-cards/">Context Cards</a> in <code>Rmd</code> files. These Context Cards enable the hover over preview for Wikipedia articles. I thank <a href="https://jeweljohnsonj.github.io/jewel_resume/">Jewel Johnson</a> for providing <a href="https://jeweljohnsonj.github.io/jeweljohnson.github.io/posts/2021-12-18-quality-of-life-modifications-for-your-distill-webistes/#making-the-table-of-contents-more-useful">this helpful guide</a> to enable fixed TOC for this article. I thank <a href="https://www.joelnitta.com/">Dr.&nbsp;Joel Nitta</a> for providing <a href="https://www.joelnitta.com/posts/2021-11-24_using-giscus/">these instructions</a> to enable me to switch to the <a href="https://giscus.app/">giscus</a> comments system. Much of these distill site improvements were brought to our attention due to the excellent <a href="https://distillery.rbind.io/tips_and_tricks.html">distillery</a> site run by <a href="https://www.jhelvy.com/">Prof.&nbsp;John Paul Helveston</a>.</p>



</div></section><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-robinson2020introfuncanalysis_book" class="csl-entry">
Robinson, James C. 2020. <em><span class="nocase">An Introduction to Functional Analysis</span></em>. Cambridge University Press.
</div>
</div></section><section id="footnotes" class="footnotes footnotes-end-of-document"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>
<ol>
<li id="fn1"><p><strong>Note:</strong> The presentation in this post is <strong><em>intentionay</em></strong> verbose. The goal is to give lots of intuition of the key result and its usefulness, and ensure that the proofs are rigorous. It is written with an empathetic mindset to newcomers, and to myself for future reference.↩︎</p></li>
<li id="fn2"><p>We refer to such an <img src="https://latex.codecogs.com/png.latex?N:%20V%20%5Cto%20%5Cmathbb%7BR_%7B%5Cgeq%200%7D%7D"> satisfying these properties, as a <em>norm-like</em> function.↩︎</p></li>
</ol></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a></div></div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{shrotriya2022,
  author = {Shrotriya, Shamindra},
  title = {Characterizing Norm Triangle Inequalites via Convexity},
  date = {2022-02-12},
  url = {https://www.shamindras.com/posts/2021-12-31-shrotriya2021normtriconvexity/},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-shrotriya2022" class="csl-entry quarto-appendix-citeas">
Shrotriya, Shamindra. 2022. <span>“Characterizing Norm Triangle
Inequalites via Convexity.”</span> February 12, 2022. <a href="https://www.shamindras.com/posts/2021-12-31-shrotriya2021normtriconvexity/">https://www.shamindras.com/posts/2021-12-31-shrotriya2021normtriconvexity/</a>.
</div></div></section></div> ]]></description>
  <category>linear algebra</category>
  <category>math</category>
  <category>norms</category>
  <guid>https://www.shamindras.com/posts/2021-12-31-shrotriya2021normtriconvexity/</guid>
  <pubDate>Fri, 11 Feb 2022 14:00:00 GMT</pubDate>
  <media:content url="https://www.shamindras.com/posts/2021-12-31-shrotriya2021normtriconvexity/images/preview-shrotriya2021normtriconvexity.png" medium="image" type="image/png" height="81" width="144"/>
</item>
<item>
  <title>Shamindra’s January 2020 Roundup</title>
  <dc:creator>Shamindra Shrotriya</dc:creator>
  <link>https://www.shamindras.com/posts/2020-01-27-shrotriya2020january20roundup/</link>
  <description><![CDATA[ <section id="introduction" class="level2"><h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>Welcome to the January 2020 roundup! Similar to <a href="https://www.shamindras.com/posts/2019-09-19-shrotriya2019september19roundup/" target="_blank">last time</a> I’m going to experiment with documenting anything interesting I come across (articles, lectures, books, papers etc.) and any activities I get up to. This is more for my personal benefit but may also help others.</p>
</section><section id="interesting-articles" class="level2"><h2 class="anchored" data-anchor-id="interesting-articles">Interesting Articles</h2>
<ul>
<li>
<p>Came across this <a href="https://medium.com/aclu-tech-analytics/check-yo-data-before-you-wreck-yo-results-53f0e919d0b9" target="_blank">nice article on <code>R</code> error handling</a>. See here for the <a href="https://twitter.com/brookLYNevery1/status/1221932342102646784">original source</a>.</p>
<details><summary><p>Key Takeaways</p>
</summary><ul>
<li><p>This the latest post from the <a href="https://medium.com/aclu-tech-analytics" target="_blank">ACLU Tech &amp; Analytics blog</a>. This post explains the key focus of the ACLU analytics team on having clean data pipelines and using testing and assertions to facilitate this process</p></li>
<li><p>Using functions like <code>assertthat::noNA(df$source)</code> will return a <code>FALSE</code> if in fact there are no <code>NA</code> values in the <code>df$source</code> column. This seems like a very useful function to use in <code>%&gt;%</code> operations in my pipelines!</p></li>
<li><p>Used in combination with <code>assertthat::noNA(df$source)</code> will return the actual observations that have <code>NA</code> values, which is super useful!</p></li>
<li>
<p>These operations are <code>%&gt;%</code> friendly and can be used to verify join operations perform as expected, for example:</p>
<blockquote class="blockquote">
<p>Does the join have the same number of rows as the original left-hand table or did the data structure of the right-hand table create new rows?</p>
</blockquote>
<blockquote class="blockquote">
<p>How much of the right-hand table of the join falls away in the left join?</p>
</blockquote>
</li>
<li>
<p>These checks are notably useful for the ACLU to also check for missingness in their data pipelines. They note:</p>
<blockquote class="blockquote">
<p>A helpful check to assess whether missingness grossly misrepresents our results is to quantify the severity of the problem. What level of missingness are we willing to live with?</p>
</blockquote>
</li>
<li><p>This definitely seems useful to me, as I use ad-hoc approaches to these same issues e.g.&nbsp;<code>na.omit</code> without doing thorough assertions. Perhaps using this with <code>tidylog</code> will be useful in doing EDA. Let’s try and revisit this.</p></li>
</ul></details>
</li>
<li>
<p>This is a really insightful article on <a href="https://medium.com/@EpiEllie/a-regular-persons-guide-to-outbreak-preparedness-5cece749123" target="_blank">A regular person’s guide to outbreak preparedness</a>, <a href="https://twitter.com/EpiEllie/status/1222173158230450176">by Prof.&nbsp;Eleanor Murray</a>:</p>
<details><summary><p>Key Takeaways</p>
</summary><ul>
<li><p>In the event of well publicized (ready mass hysteria) virus spreads such as the recent Coronavirus outbreak, it is important to listen to level-headed healthcare professionals. In this case it is Prof.&nbsp;Elie Murray, an epidimiologist from Boston University</p></li>
<li><p>Since I’m definitely a newbie to understanding this epidemic, I found this to be a very pragmatic guide to help prepare and prevent any further spread of such diseases</p></li>
<li>
<p>In terms of general healthy practices in the outbreak the key takeaways are to:</p>
<ul>
<li>Wash your hands regularly</li>
<li>Focus on improving the immune system</li>
<li>Try to not catch other infections, and ensure you recover well from any existing infections</li>
<li>Don’t panic</li>
</ul>
</li>
<li>
<p>In terms of good practices to do in the event that you are sick, the key takeaways are to:</p>
<ul>
<li>Stay home and recover</li>
<li>Cover your mouth e.g.&nbsp;sneeze into the inner elbow</li>
<li>Call a medical professional if you or a relative was in Wuhan recently</li>
<li>Seek urgent medical care if you feel really sick</li>
</ul>
</li>
<li><p>Please read the article on more detail on each of the above points and also to considerations for high risk individuals, a sick family member/friend, and if you are a healthcare responder</p></li>
<li><p>Overall, great practical advice! It is great to see statisticians such as Prof.&nbsp;Murray take the lead and address the community at large with their knowledge and expertise, when we live in an era of misinformation</p></li>
<li><p>I enjoyed the emphasisis on solving this challenge (like many others) as a community</p></li>
</ul></details>
</li>
</ul></section><section id="teaching" class="level2"><h2 class="anchored" data-anchor-id="teaching">Teaching</h2>
<ul>
<li>I’m a TA for the STAT 36-350, the <em>undergraduate</em> statiscal computing course at CMU. This is a welcome change of pace from my <a href="https://www.shamindras.com/posts/2019-09-19-shrotriya2019september19roundup/#teaching" target="_blank">previous TA assignment</a> taught by <a href="http://www.stat.cmu.edu/~pfreeman/" target="_blank">Prof.&nbsp;Freeman</a>, with whom I had the pleasure of teaching the course in Spring 2019.</li>
<li>This time we have around 150 students and, as Head-TA, I have the pleasure of managing a motivated team of 9 graduate and undergraduate TAs. Here’s to a wonderful teaching and research semester 💯.</li>
</ul>


</section><div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a></div></div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{shrotriya2020,
  author = {Shrotriya, Shamindra},
  title = {Shamindra’s {January} 2020 {Roundup}},
  date = {2020-01-27},
  url = {https://www.shamindras.com/posts/2020-01-27-shrotriya2020january20roundup/},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-shrotriya2020" class="csl-entry quarto-appendix-citeas">
Shrotriya, Shamindra. 2020. <span>“Shamindra’s January 2020
Roundup.”</span> January 27, 2020. <a href="https://www.shamindras.com/posts/2020-01-27-shrotriya2020january20roundup/">https://www.shamindras.com/posts/2020-01-27-shrotriya2020january20roundup/</a>.
</div></div></section></div> ]]></description>
  <category>personal</category>
  <category>roundup</category>
  <category>rstats</category>
  <category>math</category>
  <guid>https://www.shamindras.com/posts/2020-01-27-shrotriya2020january20roundup/</guid>
  <pubDate>Sun, 26 Jan 2020 14:00:00 GMT</pubDate>
  <media:content url="https://www.shamindras.com/posts/2020-01-27-shrotriya2020january20roundup/images/preview-january-2020-01.png" medium="image" type="image/png" height="85" width="144"/>
</item>
<item>
  <title>Shamindra’s September 2019 Roundup</title>
  <dc:creator>Shamindra Shrotriya</dc:creator>
  <link>https://www.shamindras.com/posts/2019-09-19-shrotriya2019september19roundup/</link>
  <description><![CDATA[ <section id="introduction" class="level2"><h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>Welcome to the September 2019 roundup! Similar to <a href="https://www.shamindras.com/posts/2019-09-01-shrotriya2019august19roundup/" target="_blank">last time</a> I’m going to experiment with, namely documenting anything interesting I come across (articles, lectures, books, papers etc.) and any activities I get up to. This is more for my personal benefit but may also help others.</p>
</section><section id="interesting-articles" class="level2"><h2 class="anchored" data-anchor-id="interesting-articles">Interesting Articles</h2>
<ul>
<li><p>Came across this <a href="https://socviz.co/appendix.html#a-little-more-about-r" target="_blank">amazing guide to reading an R help file</a>. Experienced <code>R</code> users can use this fantastic pedagogical tool by <a href="https://twitter.com/kjhealy" target="_blank">Kieran Healy</a> to teach new <code>R</code> users on how to read internal <code>R</code> help documentation.</p></li>
<li>
<p>Came across this <a href="https://www.espn.com/espn/story/_/id/27593253/why-grandmasters-magnus-carlsen-fabiano-caruana-lose-weight-playing-chess" target="_blank">fascinating article on how calorie burning being a chess grandmaster is</a> by <a href="https://twitter.com/kumaraishwarya" target="_blank">Aishwarya Kumar</a></p>
<details><summary><p>Key Takeaways</p>
</summary><ul>
<li><p>Article notes that chess grandmasters can burn as much as 6000 calories individually during an intense day of sedentary chess playing!</p></li>
<li><p>Initial focus is on Fabiano Caruana, an American grandmaster in chess, and current world No.&nbsp;2. Caruana has to maintain a very strict diet and exercise routine, particularly during tournaments</p></li>
<li><p>Primary reasons for the calorie loss are heavy mental stress of the tournament, constantly thinking of chess, thus leaving limited time to think about and consume food</p></li>
<li><p>Interesting quote:</p></li>
</ul>
<blockquote class="blockquote">
<p>…India’s first grandmaster, Viswanathan Anand, does two hours of cardio each night to tire himself out so he doesn’t dream about chess</p>
</blockquote>
<ul>
<li><p>Magnus Carlsen, reigning No.&nbsp;1, for example consulted a professional nutritionist who recommended that he stop drinking orange juice (to avoid sugar spikes) and replace it with a less sugary regular/chocolate milk blend</p></li>
<li><p>Carlsen has also optimized <em>sitting</em>. This is quite amazing and something to think about personally as someone who spends many hours daily in front of a screen</p></li>
<li><p>Carlsen has also undertaken <em>load management</em> (minimizing competitions participated) to increase the amount of recuperation time between tournaments</p></li>
<li><p>In short, there are a lot of parallels to the research life which I undertake, and a lot of useful tips to optimize energy and time spent doing what I enjoy for longer</p></li>
</ul></details>
</li>
<li>
<p>This is a really insightful interview with <a href="https://qz.com/1661487/hadley-wickham-on-the-future-of-r-python-and-the-tidyverse/" target="_blank">Hadley Wickham</a>, a recent <a href="http://bulletin.imstat.org/2019/09/copss-presidents-award-hadley-wickham/" target="_blank">COPSS award winner</a>, on the future of the <code>R</code> programming language:</p>
<details><summary><p>Key Takeaways</p>
</summary><ul>
<li><p>Wickham notes that <code>R</code> vs <code>Python</code> language wars are not constructive in moving data science and other fields forward.</p></li>
<li><p>I agree wholeheartedly on this and firmly believe in using the best tools for the statistical job at hand. What should matter are more critical aspects like code readability, usability, and reproducibility in light of the given task</p></li>
<li><p>Interestingly Wickham notes:</p></li>
</ul>
<blockquote class="blockquote">
<p>A pattern that I see is that the data science team in a company uses R and the data engineering team uses Python</p>
</blockquote>
<ul>
<li>Wickham also has focused on bridging divides within the <code>R</code> community itself, namely in developing the <code>dtplyr</code> package to convert <code>dplyr</code> code to the alternative <code>data.table</code> package syntax. This is a promising direction ahead where <code>tidyverse</code> and <code>data.table</code> users can collaborate much more easily</li>
<li>There is also a focus on encouraging diversity in <code>R</code> usage and actively developing communities. He asks:</li>
</ul>
<blockquote class="blockquote">
<p>Can we take the R-Ladies model and help other groups that are currently underserved?</p>
</blockquote>
<ul>
<li>Overall it is good that Wickham was recognized recently with the famous COPSS medal in statistics and that the community is embracing software development and design as a key aspect of our profession. It seems that the future is bright for statistics!</li>
</ul></details>
</li>
<li><p>This is a <a href="https://martinctc.github.io/blog/first-world-problems-very-long-rmarkdown-documents/" target="_blank">nice blogpost on making modular <code>Rmarkdown</code> files</a>. In fact this modular <code>Rmd</code> approach is now used in <a href="https://github.com/shamindras/ss_personal_distill_blog/blob/master/_posts/2019-07-15-shrotriya2019tidyfunpt1/shrotriya2019tidyfunpt1.Rmd#L244" target="_blank">my blog for common footer files</a>. Did not realize how nicely the <code>here</code> package works with references in <code>Rmd</code> chunks.</p></li>
</ul></section><section id="interesting-presentations" class="level2"><h2 class="anchored" data-anchor-id="interesting-presentations">Interesting Presentations</h2>
<ul>
<li>
<p>This thoughtful <a href="https://www.youtube.com/watch?v=rWaoNNAuhBI" target="_blank">presentation on Design at Quora</a> by <a href="https://twitter.com/artypapers?lang=en" target="_blank">Rebecca Cox</a> (VP of design at Quora). I’ve summarized what I feel are the key points from this important presentation below.</p>
<details><summary><p>Key Takeaways</p>
</summary><ul>
<li>Cox notes that it is a “great time to be a designer” because design has proven again and again to be a clear competitive advantage in tech</li>
<li>She notes her awareness of Quora’s apparent minimalist design interface i.e.&nbsp;dark, red, and text heavy</li>
<li>Cox asks - what is Design? Some say it is the visual style, for some the user interaction, and for others “it begins and ends with the logo”</li>
<li>For Cox, her definition is abstract, and summarized as:</li>
</ul>
<blockquote class="blockquote">
<p>The set of decisions about a product</p>
</blockquote>
<ul>
<li>Not just an interface, logo etc. Designing is about making product decisions</li>
<li>Benefits of this broad <em>decision-driven</em> definition for Quora are:
<ul>
<li>A clear relationship between the product and the interface i.e.&nbsp;why should a dropdown even exist?</li>
<li>Concentrates attention on where it matters most i.e.&nbsp;company goals</li>
<li>Enables a role within Quora that balances authority and responsibility i.e.&nbsp;Designers should do more than “apply a coat of paint to a feature at the end”</li>
</ul>
</li>
<li>To Cox:</li>
</ul>
<blockquote class="blockquote">
<p>Great design is all the work you don’t ask people who use your products to do</p>
</blockquote>
<ul>
<li><p>There are a lot of deep direct applications to my statistics research i.e.&nbsp;ensure all theoretical and empirical tools are seamlessly able to be conveyed to end users in science, industry, or academia.</p></li>
<li><p>I will be coming back to this over time periodically and reflect if I have undertaken this definition of design and applied it in my work and daily life</p></li>
</ul></details>
</li>
<li>
<p>This is a <a href="https://resources.rstudio.com/rstudio-conf-2019/r-at-the-aclu-joining-tables-to-to-reunite-families?utm_content=buffer4211f&amp;utm_medium=social&amp;utm_source=twitter&amp;utm_campaign=buffer" target="_blank">really inspiring presentation</a> on how data science is used at the ACLU specifically in the recent border immigration policies <a href="https://twitter.com/brookLYNevery1" target="_blank">by Brooke Watson Madubuonwu</a>.</p>
<details><summary><p>Key Takeaways</p>
</summary><ul>
<li>Utilizing <code>tidyverse</code> to sort through messy data linkage issues in a consistent framework is well thought out by the team with useful packaged functions created for use by the wider ACLU team</li>
<li>Here both statistics and law are used to tackle a major humanitarian issue i.e.&nbsp;child border separation. This is deeply inspiring and the kind of applied work that I would like to contribute to meaningfully in the future</li>
<li>I particularly appreciated the general data source skepticism showed by the ACLU team. As a statistician it is important to not only explore data but be very skeptical of the source quality i.e.&nbsp;competing legal bodies may not provide the ACLU unbiased data!</li>
</ul></details>
</li>
</ul></section><section id="teaching" class="level2"><h2 class="anchored" data-anchor-id="teaching">Teaching</h2>
<ul>
<li>I’m a TA for the <a href="https://36-750.github.io" target="_blank">amazing graduate statiscal computing course at CMU</a>. This is an intensive (but very rewarding) programming course designed by CMU statistics professors <a href="https://www.refsmmat.com/" target="_blank">Alex Reinhart</a> and <a href="http://www.stat.cmu.edu/~genovese/?p=research" target="_blank">Chris Genovese</a>. I highly recommend checking out this course website as a general programming reference in daily work/research. I know that I certainly will be 😄.</li>
</ul>


</section><div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a></div></div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{shrotriya2019,
  author = {Shrotriya, Shamindra},
  title = {Shamindra’s {September} 2019 {Roundup}},
  date = {2019-09-30},
  url = {https://www.shamindras.com/posts/2019-09-19-shrotriya2019september19roundup/},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-shrotriya2019" class="csl-entry quarto-appendix-citeas">
Shrotriya, Shamindra. 2019. <span>“Shamindra’s September 2019
Roundup.”</span> September 30, 2019. <a href="https://www.shamindras.com/posts/2019-09-19-shrotriya2019september19roundup/">https://www.shamindras.com/posts/2019-09-19-shrotriya2019september19roundup/</a>.
</div></div></section></div> ]]></description>
  <category>personal</category>
  <category>roundup</category>
  <category>rstats</category>
  <category>math</category>
  <guid>https://www.shamindras.com/posts/2019-09-19-shrotriya2019september19roundup/</guid>
  <pubDate>Sun, 29 Sep 2019 14:00:00 GMT</pubDate>
  <media:content url="https://www.shamindras.com/posts/2019-09-19-shrotriya2019september19roundup/images/preview-september-2019-01.png" medium="image" type="image/png" height="85" width="144"/>
</item>
<item>
  <title>Shamindra’s August 2019 Roundup</title>
  <dc:creator>Shamindra Shrotriya</dc:creator>
  <link>https://www.shamindras.com/posts/2019-09-01-shrotriya2019august19roundup/</link>
  <description><![CDATA[ <section id="introduction" class="level2"><h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>Welcome to the August 2019 roundup! Similar to <a href="https://www.shamindras.com/posts/2019-07-30-shrotriya2019july19roundup/" target="_blank">last time</a> I’m going to experiment with, namely documenting anything interesting I come across (articles, lectures, books, papers etc.) and any activities I get up to. This is more for my personal benefit but may also help others.</p>
</section><section id="interesting-articles" class="level2"><h2 class="anchored" data-anchor-id="interesting-articles">Interesting Articles</h2>
<ul>
<li>Came across this <a href="http://mirrors.concertpass.com/tex-archive/biblio/bibtex/base/xampl.bib" target="_blank">exhaustive <code>BibTeX</code> example file</a> which will be a really handy reference going forward for <img src="https://latex.codecogs.com/png.latex?%5CLaTeX"> documents</li>
<li>The document is written by the Oren Patashnik, the co-creator of BibTeX (😮) and the co-author of the great book <span class="citation" data-cites="grahamknuthpatashnik1994concrete_book">(Graham, Knuth, and Patashnik 1994)</span>
</li>
</ul></section><section id="interesting-books" class="level2 page-columns page-full"><h2 class="anchored" data-anchor-id="interesting-books">Interesting Books</h2>
<section id="fiction" class="level3 page-columns page-full"><h3 class="anchored" data-anchor-id="fiction">Fiction</h3>
<ul>
<li>Started reading this fantastic book <span class="citation" data-cites="granville2019primesuspects_book">(Granville, Granville, and Lewis 2019)</span> called the <em>Prime Suspects</em> by <strong>Andrew Granville, Jennifer Granville, and Robert J. Lewis (illustrator)</strong>. Here is a <a href="https://www.youtube.com/watch?v=82c2HDp-ntg&amp;feature=youtu.be" target="_blank">youtube trailer for the book</a> to get you excited!</li>
</ul>
<aside><div id="main-src-cover" class="quarto-figure quarto-figure-center anchored">
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-09-01-shrotriya2019august19roundup/images/prime-suspects-book.png" class="img-fluid figure-img" alt="Image of the cover of the book &quot;Prime Suspects&quot; by Granville et. al."></p>
<figcaption>Prime Suspects cover</figcaption></figure>
</div>
</aside><details><summary><p>Key Takeaways</p>
</summary><ul>
<li>This is essentially an introduction to analytic number theory disguised as a fast-moving graphic novel murder mystery</li>
<li>For any mathematics fans (who isn’t though?) there are lots of funny easter eggs to be found in the frame backgrounds</li>
<li>This a very unique exposition on number theory, a subject in which I have negligible knowledge (like most subjects)</li>
<li>The pedagogy is gentle and yet exciting emphasizing not just mathematics but the importance of communication of mathematical ideas to the wider public i.e.&nbsp;a meta novel if you like</li>
<li>I hope to see more books in this mathematical graphic novel genre. The last one I read (and know of) is Logicomix <span class="citation" data-cites="doxiadis2009logicomix_book">(Doxiadis et al. 2009)</span> which I highly recommend as well for anyone wishing to venture into the mysteries of infinity!</li>
</ul></details></section></section><section id="interesting-interviews" class="level2 page-columns page-full"><h2 class="anchored" data-anchor-id="interesting-interviews">Interesting Interviews</h2>
<ul>
<li>Really enjoyed <a href="http://www.careeryoga.life/440ebcdf?fbclid=IwAR2BWeyMdhTg2fbdHp5U-D9gCy2oqLZBk2ljRBMhjtyAEtSgqBCt7kMlSFk">this interview</a> with Prof.&nbsp;Noga Alon a leading mathematician specializing in combinatorics, graph theory etc. Fantastic insights into the life of a (leading) theoretical researcher and certainly someone for me to look up to and learn from. I enjoyed the fact that it was so brief but dense as I normally don’t have much time for podcasts. I may check out a few more scientific based interviews from this <a href="http://www.careeryoga.life/">Career Yoga podcast</a> going forward.</li>
</ul>
<aside><p><strong>Note:</strong> This interview was co-conducted Ms.&nbsp;Narkis Alon, the daughter of Prof. Alon which led to a really personal dynamic!</p>
</aside><details><summary><p>Key Takeaways</p>
</summary><ul>
<li>This 20min interview is really part of a podcast on careers, and the focus here being the lessons/insights learned from a very successful career in theoretical mathematical research from Prof.&nbsp;Alon</li>
<li>Prof.&nbsp;Alon appears to be extremely organized in all aspects of life, including packing for trips. Was asked specifically not to prepare for this interview 😄</li>
<li>I’ve paraphrased my summaries below, any transcription errors are mine. Please listen to the original interview.</li>
<li>Question: What does it mean to be a mathematician?</li>
</ul>
<blockquote class="blockquote">
<p>To mostly think about mathematical problems, there are many mathematical problems that have rich history, many are interesting in their own sense. It means to ask the right questions, think about interesting questions and tell the difference between what is beautiful and what is not beautiful</p>
</blockquote>
<ul>
<li>Question: What does your day look like?</li>
</ul>
<blockquote class="blockquote">
<p>Many procedural things - teaching, meeting graduate students, reading mathematical papers.</p>
</blockquote>
<blockquote class="blockquote">
<p>Part of the time I’m just thinking! Sometimes with other people over chalkboard/whiteboard, looking at a piece of paper on the table i.e.&nbsp;trying to do some computations that are relevant, thinking of relationships to the problem. Finding problems that are similar enough.</p>
</blockquote>
<ul>
<li>Question: It is so difficult to grasp the idea of just thinking! Most of the careers are based on the idea of responding to things. Often when visiting you in Princeton it seems you are in a room staring in the air, in another room people another mathematician is staring in the air, it seems like you are not doing anything!</li>
</ul>
<blockquote class="blockquote">
<p>Right, and indeed in much of time you are not doing anything. <strong>Most of the time you are failing and you need to get used to to it</strong> Part of the satisfaction is this process is to think about something for a very long time without having an idea. Sometimes you solve something related</p>
</blockquote>
<ul>
<li>Question: Do you sometimes try to initiate situations that will inspire you to solve problems</li>
</ul>
<blockquote class="blockquote">
<p>You go to conferences, talk to people, read papers etc. Many times you just need to be in a different state of mind e.g.&nbsp;if you forget someones name, just thinking about it does not always make you remember, just need to try something else at times. This may explain why you see people staring in the air! Sometimes you can go and take walks.</p>
</blockquote>
<ul>
<li>Question: When did you know you wanted to be a mathematician?</li>
</ul>
<blockquote class="blockquote">
<p>As a child, before I was 10 years old I knew I was interested in mathematical puzzles. I was good at it and interested in mathematics but didn’t really know what it involved. I always liked that it is <strong>objective</strong>. I was able to explain a solution to an adult at a party on the puzzle of the Eurovision song contest. The power of convincing someone is really powerful.</p>
</blockquote>
<ul>
<li>Question: Was the long list of awards you aimed for?</li>
</ul>
<blockquote class="blockquote">
<p>No, it’s nice to get such prizes but never done this with the intent. In every field it is important, but the glory is very limited. This is nice but you don’t do things with this aim in mind</p>
</blockquote>
<ul>
<li>Question: In one of your discoveries, did you ever feel “this was something I was dreaming on and I accomplished that”</li>
</ul>
<blockquote class="blockquote">
<p>I had a few things where I was very happy. Because I had thought about it for a long time and found something new. Don’t think I had a specific time where I sat back and said this is the best discovery of their life. One should always think that the best discoveries are ahead of them.</p>
</blockquote>
<ul>
<li>Question: What do mathematicians do after leaving research?</li>
</ul>
<blockquote class="blockquote">
<p>Some scientists go into scientific management. Some go into industry, but this is rare. As long as what I do is what I find interesting and challenging, and what I do is not as good as my best results I would still keep doing this.</p>
</blockquote>
<ul>
<li>Question: Does being a grandfather and becoming older change your priorities and motivation?</li>
</ul>
<blockquote class="blockquote">
<p>Yes, in general you realize you want to spend time with family, children, and grandchildren. I don’t think it comes <strong>instead</strong> of science. I hope to keep doing good work and spend time with family.</p>
</blockquote>
</details></section><section id="personal-blogging" class="level2"><h2 class="anchored" data-anchor-id="personal-blogging">Personal Blogging</h2>
<p>Besides this post 😄 the main things I got up to on the personal blogging front were:</p>
<ul>
<li>Updating the distill blog settings, with a <a href="https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/" target="_blank">detailed step-by-step guide</a>
</li>
<li>Wrote another <a href="https://www.shamindras.com/posts/2019-07-21-shrotriya2019reprtitanic/" target="_blank">fun blogpost</a> on using the <code>tidyverse</code> to reproduce a plot on the survivorship of the Titanic. Always so cool to be able to reproduce such famous plots using modern tools.</li>
</ul></section><section id="concluding-thoughts" class="level2"><h2 class="anchored" data-anchor-id="concluding-thoughts">Concluding Thoughts</h2>
<p>Overall August 2019 was the end of summer and the start of a new year of graduate school - yay!</p>
<p>Please feel free to leave a comment if you found any useful articles, lectures, books, papers etc which I may find interesting.</p>



</section><div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-doxiadis2009logicomix_book" class="csl-entry">
Doxiadis, A., C. H. Papadimitriou, A. Papadatos, and A. Di Donna. 2009. <em><span class="nocase">Logicomix: An Epic Search for Truth</span></em>. Bloomsbury USA. <a href="https://books.google.com/books?id=sBpkPgAACAAJ">https://books.google.com/books?id=sBpkPgAACAAJ</a>.
</div>
<div id="ref-grahamknuthpatashnik1994concrete_book" class="csl-entry">
Graham, Ronald L, Donald E Knuth, and Oren Patashnik. 1994. <em><span class="nocase">Concrete mathematics: a foundation for computer science</span></em>. 2nd ed. Addison-Wesley Publishing Company.
</div>
<div id="ref-granville2019primesuspects_book" class="csl-entry">
Granville, Andrew, Jennifer Granville, and Robert J. Lewis. 2019. <em><span class="nocase">Prime suspects : the anatomy of integers and permutations</span></em>. Princeton University Press.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a></div></div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{shrotriya2019,
  author = {Shrotriya, Shamindra},
  title = {Shamindra’s {August} 2019 {Roundup}},
  date = {2019-08-31},
  url = {https://www.shamindras.com/posts/2019-09-01-shrotriya2019august19roundup/},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-shrotriya2019" class="csl-entry quarto-appendix-citeas">
Shrotriya, Shamindra. 2019. <span>“Shamindra’s August 2019
Roundup.”</span> August 31, 2019. <a href="https://www.shamindras.com/posts/2019-09-01-shrotriya2019august19roundup/">https://www.shamindras.com/posts/2019-09-01-shrotriya2019august19roundup/</a>.
</div></div></section></div> ]]></description>
  <category>personal</category>
  <category>roundup</category>
  <category>rstats</category>
  <category>math</category>
  <guid>https://www.shamindras.com/posts/2019-09-01-shrotriya2019august19roundup/</guid>
  <pubDate>Fri, 30 Aug 2019 14:00:00 GMT</pubDate>
  <media:content url="https://www.shamindras.com/posts/2019-09-01-shrotriya2019august19roundup/images/preview-august-2019-01.png" medium="image" type="image/png" height="72" width="144"/>
</item>
<item>
  <title>Tidyverse Fun - Part 2</title>
  <dc:creator>Shamindra Shrotriya</dc:creator>
  <link>https://www.shamindras.com/posts/2019-08-21-shrotriya2019tidyfunpt2/</link>
  <description><![CDATA[ <section id="task-generating-latex-newcommand-macros" class="level2"><h2 class="anchored" data-anchor-id="task-generating-latex-newcommand-macros">Task: Generating LaTeX newcommand macros</h2>
<section id="the-central-problem" class="level3"><h3 class="anchored" data-anchor-id="the-central-problem">The central problem</h3>
<p>In a custom <img src="https://latex.codecogs.com/png.latex?%5CLaTeX"> macro file I needed to generate several sequential <img src="https://latex.codecogs.com/png.latex?%5CLaTeX"> <code>newcommand</code> entries of the form:</p>
<pre class="markup"><code>\newcommand{\bfa}{\mathbf{a}}
\newcommand{\bfA}{\mathbf{A}}</code></pre>
<p>Where using <code>$\bfa$</code> produces <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7Ba%7D"> and using <code>$\bfA$</code> produces <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BA%7D"> i.e the lowecase/uppercase <code>mathbf</code> commands respectively.</p>
<p>Specifically I needed to construct 52 such combined sequential entries for both lowercase/uppercase letter versions of these <code>newcommand</code> <img src="https://latex.codecogs.com/png.latex?%5CLaTeX"> macros. Rather than do this manually, I realized that this would be another fun scripting exercise with using the <code>tidyverse</code> packages <code>glue</code>, <code>purrr</code>, and <code>stringr</code> similar to this similar <a href="https://www.shamindras.com/posts/2019-07-15-shrotriya2019tidyfunpt1/">previous post here</a>.</p>
<p><strong>Goal:</strong> Create 52 such lowercase/uppercase <code>newcommand</code> entries and print to the console to directly-copy paste to my <img src="https://latex.codecogs.com/png.latex?%5CLaTeX"> macros file.</p>
</section><section id="the-tidy-approach" class="level3"><h3 class="anchored" data-anchor-id="the-tidy-approach">The <code>tidy</code> approach</h3>
<p>First step is to write a function that takes as an input the following:</p>
<ul>
<li>a single letter (case-sensitive) e.g.&nbsp;<code>"a"</code>
</li>
<li>the macro shortcut command prefix you prefer e.g <code>"bf"</code> (for <strong>b</strong>old <strong>f</strong>ont in case you were wondering!)</li>
<li>the specific <img src="https://latex.codecogs.com/png.latex?%5CLaTeX"> command that we are creating a macro shortcut for i.e.&nbsp;<code>"mathbf"</code> in this case</li>
</ul>
<p>The function then outputs a single <code>newcommand</code> entry for that lecture i.e <code>\newcommand{\bfa}{\mathbf{a}}</code> in this case. Let’s do it!</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Load required libraries</span></span>
<span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;"><a href="https://tidyverse.tidyverse.org">tidyverse</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;"><a href="https://glue.tidyverse.org/">glue</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span></span>
<span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create LaTeX macro newcommand</span></span>
<span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">get_lec_newcmd</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">inp_letr</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">mac_type</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">mac_ref</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span>    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">out_str</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://glue.tidyverse.org/reference/glue.html">glue</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'\\newcommand{\\&lt;mac_type&gt;&lt;inp_letr&gt;}{\\&lt;mac_ref&gt;{&lt;inp_letr&gt;}}'</span>,</span>
<span>                    .open <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;"</span>, .close <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&gt;"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span>    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;"><a href="https://rdrr.io/r/base/function.html">return</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">out_str</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</div>
<p>Let’s just test this out quickly:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"a"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://purrr.tidyverse.org/reference/map.html">map_chr</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>.x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>, .f <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_lec_newcmd</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>inp_letr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.x</span>,</span>
<span>                                       mac_type <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bf"</span>,</span>
<span>                                       mac_ref <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mathbf"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/cat.html">cat</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>, sep <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"\n"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>\newcommand{\bfa}{\mathbf{a}}
\newcommand{\bfA}{\mathbf{A}}</code></pre>
</div>
</div>
<p>Great - looks like it is working as required!</p>
<p>Note that we can easily generate other <img src="https://latex.codecogs.com/png.latex?%5CLaTeX"> macros like follows</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"a"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://purrr.tidyverse.org/reference/map.html">map_chr</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>.x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>, .f <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_lec_newcmd</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>inp_letr <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.x</span>,</span>
<span>                                       mac_type <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mc"</span>,</span>
<span>                                       mac_ref <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mathcal"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/cat.html">cat</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>, sep <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"\n"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>\newcommand{\mca}{\mathcal{a}}
\newcommand{\mcA}{\mathcal{A}}</code></pre>
</div>
</div>
<p>Which generates the corresponding <code>mathcal</code> macros for <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%7Ba%7D"> and <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%7BA%7D"> respectively.</p>
<p>So finally we can generate all 52 letter macros at time by simply replacing <code>c("a", "A")</code> with <code>c(letters, LETTERS)</code> which uses the input lowercase/uppercase <code>letters</code>/<code>LETTERS</code> vectors in base <code>R</code>:</p>
<details closed=""><summary><span title="Click to Expand"> Full newcommand Demo Output </span>
</summary><div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"></span>
<span id="cb7-2">\newcommand{\bfa}{\mathbf{a}}</span>
<span id="cb7-3">\newcommand{\bfb}{\mathbf{b}}</span>
<span id="cb7-4">\newcommand{\bfc}{\mathbf{c}}</span>
<span id="cb7-5">\newcommand{\bfd}{\mathbf{d}}</span>
<span id="cb7-6">\newcommand{\bfe}{\mathbf{e}}</span>
<span id="cb7-7">\newcommand{\bff}{\mathbf{f}}</span>
<span id="cb7-8">\newcommand{\bfg}{\mathbf{g}}</span>
<span id="cb7-9">\newcommand{\bfh}{\mathbf{h}}</span>
<span id="cb7-10">\newcommand{\bfi}{\mathbf{i}}</span>
<span id="cb7-11">\newcommand{\bfj}{\mathbf{j}}</span>
<span id="cb7-12">\newcommand{\bfk}{\mathbf{k}}</span>
<span id="cb7-13">\newcommand{\bfl}{\mathbf{l}}</span>
<span id="cb7-14">\newcommand{\bfm}{\mathbf{m}}</span>
<span id="cb7-15">\newcommand{\bfn}{\mathbf{n}}</span>
<span id="cb7-16">\newcommand{\bfo}{\mathbf{o}}</span>
<span id="cb7-17">\newcommand{\bfp}{\mathbf{p}}</span>
<span id="cb7-18">\newcommand{\bfq}{\mathbf{q}}</span>
<span id="cb7-19">\newcommand{\bfr}{\mathbf{r}}</span>
<span id="cb7-20">\newcommand{\bfs}{\mathbf{s}}</span>
<span id="cb7-21">\newcommand{\bft}{\mathbf{t}}</span>
<span id="cb7-22">\newcommand{\bfu}{\mathbf{u}}</span>
<span id="cb7-23">\newcommand{\bfv}{\mathbf{v}}</span>
<span id="cb7-24">\newcommand{\bfw}{\mathbf{w}}</span>
<span id="cb7-25">\newcommand{\bfx}{\mathbf{x}}</span>
<span id="cb7-26">\newcommand{\bfy}{\mathbf{y}}</span>
<span id="cb7-27">\newcommand{\bfz}{\mathbf{z}}</span>
<span id="cb7-28">\newcommand{\bfA}{\mathbf{A}}</span>
<span id="cb7-29">\newcommand{\bfB}{\mathbf{B}}</span>
<span id="cb7-30">\newcommand{\bfC}{\mathbf{C}}</span>
<span id="cb7-31">\newcommand{\bfD}{\mathbf{D}}</span>
<span id="cb7-32">\newcommand{\bfE}{\mathbf{E}}</span>
<span id="cb7-33">\newcommand{\bfF}{\mathbf{F}}</span>
<span id="cb7-34">\newcommand{\bfG}{\mathbf{G}}</span>
<span id="cb7-35">\newcommand{\bfH}{\mathbf{H}}</span>
<span id="cb7-36">\newcommand{\bfI}{\mathbf{I}}</span>
<span id="cb7-37">\newcommand{\bfJ}{\mathbf{J}}</span>
<span id="cb7-38">\newcommand{\bfK}{\mathbf{K}}</span>
<span id="cb7-39">\newcommand{\bfL}{\mathbf{L}}</span>
<span id="cb7-40">\newcommand{\bfM}{\mathbf{M}}</span>
<span id="cb7-41">\newcommand{\bfN}{\mathbf{N}}</span>
<span id="cb7-42">\newcommand{\bfO}{\mathbf{O}}</span>
<span id="cb7-43">\newcommand{\bfP}{\mathbf{P}}</span>
<span id="cb7-44">\newcommand{\bfQ}{\mathbf{Q}}</span>
<span id="cb7-45">\newcommand{\bfR}{\mathbf{R}}</span>
<span id="cb7-46">\newcommand{\bfS}{\mathbf{S}}</span>
<span id="cb7-47">\newcommand{\bfT}{\mathbf{T}}</span>
<span id="cb7-48">\newcommand{\bfU}{\mathbf{U}}</span>
<span id="cb7-49">\newcommand{\bfV}{\mathbf{V}}</span>
<span id="cb7-50">\newcommand{\bfW}{\mathbf{W}}</span>
<span id="cb7-51">\newcommand{\bfX}{\mathbf{X}}</span>
<span id="cb7-52">\newcommand{\bfY}{\mathbf{Y}}</span>
<span id="cb7-53">\newcommand{\bfZ}{\mathbf{Z}}</span></code></pre></div></div>
</details><p><br></p>
<p>Hope you have fun using this to quickly generate your <img src="https://latex.codecogs.com/png.latex?%5CLaTeX"> <code>newcommand</code> macros ✌️.</p>
</section></section><div id="quarto-appendix" class="default"><section id="acknowledgments" class="level2 appendix"><h2 class="anchored quarto-appendix-heading">Acknowledgments</h2><div class="quarto-appendix-contents">
<p>I’d like to thank Salil Shrotriya for creating the preview image for this post. The hex sticker <code>png</code> files were sourced from <a href="https://github.com/rstudio/hex-stickers">here</a>.</p>


</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a></div></div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{shrotriya2019,
  author = {Shrotriya, Shamindra},
  title = {Tidyverse {Fun} - {Part} 2},
  date = {2019-08-24},
  url = {https://www.shamindras.com/posts/2019-08-21-shrotriya2019tidyfunpt2/},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-shrotriya2019" class="csl-entry quarto-appendix-citeas">
Shrotriya, Shamindra. 2019. <span>“Tidyverse Fun - Part 2.”</span>
August 24, 2019. <a href="https://www.shamindras.com/posts/2019-08-21-shrotriya2019tidyfunpt2/">https://www.shamindras.com/posts/2019-08-21-shrotriya2019tidyfunpt2/</a>.
</div></div></section></div> ]]></description>
  <category>tidyverse</category>
  <category>rstats</category>
  <guid>https://www.shamindras.com/posts/2019-08-21-shrotriya2019tidyfunpt2/</guid>
  <pubDate>Fri, 23 Aug 2019 14:00:00 GMT</pubDate>
  <media:content url="https://www.shamindras.com/posts/2019-08-21-shrotriya2019tidyfunpt2/images/logo-01.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Upgrading Distill Blog Settings</title>
  <dc:creator>Shamindra Shrotriya</dc:creator>
  <link>https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/</link>
  <description><![CDATA[ 





<section id="step-0-introduction" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="step-0-introduction">Step 0: Introduction</h2>
<p>This is a meta blogpost and a second-part in a series to describe how I setup this personal academic blog using the amazing <a href="https://rstudio.github.io/distill/" target="_blank">distill</a> package by the <a href="h//www.rstudio.com/" target="_blank">RStudio</a> team.</p>
<p>The first part of this meta blogpost series can be <a href="https://www.shamindras.com/posts/2019-07-11-setting-up-a-distill-blog-with-netlify/" target="_blank">found here</a>, where I detailed the steps to setup this blog using Netlify and Google Domains. If you haven’t setup a <code>distill</code> themed blog then you are encouraged to check it out before reading this post.</p>
<p>Fortunately <code>distill</code> comes with easy to configure settings as well see below. I’ve only implemented some of the options available. I should note that the RStudio <code>distill</code> team has already created an <a href="https://rstudio.github.io/distill/blog.html" target="_blank">excellent distill blog creation tutorial</a> which I thoroughly used and highly recommend to new users to check out.</p>
<aside>
<p>Admittedly this blogpost is verbose, but hopefully the details help <strong>new users</strong> of the <code>distill</code> blogging package.</p>
</aside>
<p>With that said, here are some key upgrades I made to this blog.</p>
</section>
<section id="step-1-setup-disqus-comments" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="step-1-setup-disqus-comments">Step 1: Setup Disqus comments</h2>
<p>I really wanted to setup some comments system for each blogpost. This way I can learn new tips from readers and find out how to improve posts going forward. I will go with the recommended <a href="https://disqus.com" target="_blank">Disqus comments option</a> from the <a href="https://rstudio.github.io/distill/blog.html#comments-and-sharing" target="_blank">distill blog</a>. I simply created a <a href="https://disqus.com" target="_blank">Disqus</a> account and selected <strong>Get Started</strong>. I then clicked the following button to <em>Install Disqus on my site</em>.</p>
<div id="step-01-02-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/images/step_01_disqus_02.png" class="img-fluid figure-img" alt="Screenshot of getting started with Disqus"></p>
<figcaption>Getting Started with Disqus</figcaption>
</figure>
</div>
<p>I was then presented with the following Disqus site configuration menu. I entered <code>https:://www.shamindras.com/</code> for my <strong>Website Name</strong> and manually set my <strong>Disqus shortname</strong> to be <code>shamindras-distill</code> to be easier to remember and specific to this site, in case I make more websites later on. This Disqus shortname is important to note down (🖊) as we’ll see shortly.</p>
<div id="step-01-03-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/images/step_01_disqus_03.png" class="img-fluid figure-img" alt="Screenshot of setting up Disqus shortname"></p>
<figcaption>Setup Disqus shortname</figcaption>
</figure>
</div>
<p>After clicking <strong>Create Site</strong> in the previous menu I proceeded to select the <em>free</em> plan option by subscribing to the <em>Basic, Free, Ads Supported</em> comments option as seen below:</p>
<aside>
<p>As a student got to always know when to get a freebie 😄</p>
</aside>
<div id="step-01-04-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/images/step_01_disqus_04.png" class="img-fluid figure-img" alt="Screenshot of select basic (Free, Ads supported) mode"></p>
<figcaption>Select Basic (Free, Ads supported) mode</figcaption>
</figure>
</div>
<p>In terms of implementing <code>Disqus</code> on my site, I clicked on the following button to install Disqus on my site manually:</p>
<div id="step-01-05-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/images/step_01_disqus_05.png" class="img-fluid figure-img" alt="Screenshot of manual installation of Disqus"></p>
<figcaption>Manual installation of Disqus</figcaption>
</figure>
</div>
<p>Before finishing the manual installation of <code>Disqus</code> I ensured that I set the following configuration options. I particularly like setting an opiononated comments policy and selected the <a href="https://grist.org/grist-comment-policy/" target="_blank">Grist Comment Policy</a>:</p>
<div id="step-01-06-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/images/step_01_disqus_06.png" class="img-fluid figure-img" alt="Screenshot of Disqus configuration settings"></p>
<figcaption>Disqus Configuration Settings</figcaption>
</figure>
</div>
<p>Finally to ensure that the implementation is completed I added the following line to the <code>_site.yml</code> post using the <strong>Disqus shortname</strong> set earlier i.e. <code>shamindras-distill</code> and ensuring <code>hidden: true</code> so that the comments are not expanded by default:</p>
<aside>
<p><strong>Note:</strong> You can see my <code>_site.yml</code> with these settings <a href="https://github.com/shamindras/ss_personal_distill_blog/blob/master/_site.yml">here</a></p>
</aside>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">collections:</span></span>
<span id="cb1-2">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">posts:</span></span>
<span id="cb1-3">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">disqus:</span></span>
<span id="cb1-4">      <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">shortname:</span> shamindras-distill</span>
<span id="cb1-5">      <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">hidden:</span> true</span></code></pre></div></div>
</div>
<p>We now see the following comments option at the bottom of every post:</p>
<div id="step-01-07-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/images/step_01_disqus_07.png" class="img-fluid figure-img" alt="Screenshot of Distill Disqus comments selection"></p>
<figcaption>Distill Disqus Comments Selection</figcaption>
</figure>
</div>
<p>You can read more about setting up comments from the official <code>distill</code> blog <a href="https://rstudio.github.io/distill/blog.html#comments-and-sharing">here</a></p>
</section>
<section id="step-2-setup-google-analytics-tracking" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="step-2-setup-google-analytics-tracking">Step 2: Setup Google Analytics tracking</h2>
<p>I also wanted to setup basic user viewing tracking for my site. Fortunately <code>distill</code> can be easily configured to work with <a href="https://analytics.google.com/analytics/web" target="_blank">Google Analytics</a>. In order to set this up I simply created an account for <code>Google Analytics</code> (using my personal gmail account). I then logged in and selected the option to track my website as follows:</p>
<div id="step-02-01-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/images/step_02_ga_01.png" class="img-fluid figure-img" alt="Screenshot of Google Analytics settings"></p>
<figcaption>Google Analytics Settings</figcaption>
</figure>
</div>
<p>Note that I specified the <strong>Website Name</strong> field to be <code>shamindras-distill</code>. This is indeed the same as the Disqus shortname from earlier but did not have to be. I just did it for consistency and easy reference. I was then given a <strong>Google Analytics token</strong> and concluded this setup by adding the token to the <code>_site.yml</code> file as follows:</p>
<aside>
<p><strong>Note:</strong> You can see my <code>_site.yml</code> with these settings <a href="https://github.com/shamindras/ss_personal_distill_blog/blob/master/_site.yml">here</a></p>
</aside>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">google_analytics:</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UA-145015693-1"</span></span></code></pre></div></div>
</div>
<p>You can read more about setting up Google Analytics from the official <code>distill</code> blog <a href="https://rstudio.github.io/distill/website.html#google-analytics">here</a></p>
</section>
<section id="step-3-add-netlify-status-badge" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="step-3-add-netlify-status-badge">Step 3: Add Netlify Status Badge</h2>
<p>Since <a href="https://www.netlify.com" target="_blank">Netlify</a> is the web hosting platform for my site (see setup details <a href="https://www.shamindras.com/posts/2019-07-11-setting-up-a-distill-blog-with-netlify/#step-8-deploy-your-website" target="_blank">here</a>). I just logged into my Netlify account and went to my <strong>Site Details</strong> and obtained the following code from the <strong>Status Badges</strong> option.</p>
<div id="step-03-01-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/images/step_03_netlify_01.png" class="img-fluid figure-img" alt="Screenshot of Netlify badge code"></p>
<figcaption>Netlify Badge Code</figcaption>
</figure>
</div>
<p>I copy-pasted the above code in at the top of my site <code>README.md</code> file. This let’s me quickly know whether my website is up and running as expected by simply checking out my <a href="https://github.com/shamindras/ss_personal_distill_blog" target="_blank">github page</a>.</p>
<aside>
<p><strong>Note:</strong> You can see my <code>README.md</code> with these settings <a href="https://github.com/shamindras/ss_personal_distill_blog/blob/master/README.md">here</a></p>
</aside>
</section>
<section id="step-4-add-blog-post-sharing-options" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="step-4-add-blog-post-sharing-options">Step 4: Add blog post sharing options</h2>
<p>It is easy to configure distill to allow for easy sharing of posts using a variety of social media platforms. I allow for <strong>twitter, linkedin, pinterest, and facebook.</strong> I did this by simply adding the following line in the <code>_site.yml</code> file:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">collections:</span></span>
<span id="cb3-2">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">posts:</span></span>
<span id="cb3-3">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">share:</span> [twitter, linkedin, pinterest, facebook]</span></code></pre></div></div>
</div>
<p>Now the following sharing options appear at the bottom of every post:</p>
<div id="step-04-01-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/images/step_04_sharing_01.png" class="img-fluid figure-img" alt="Screenshot of Distill sharing options"></p>
<figcaption>Distill Sharing Options</figcaption>
</figure>
</div>
<p>I also added in the following lines to <code>_site.yml</code> to ensure that <a href="https://rstudio.github.io/distill/metadata.html#twitter-card" target="_blank">twitter cards</a> are correctly generated when posts are shared on twitter:</p>
<aside>
<p><strong>Note:</strong> You can see my <code>_site.yml</code> with these settings <a href="https://github.com/shamindras/ss_personal_distill_blog/blob/master/_site.yml">here</a></p>
</aside>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">twitter:</span></span>
<span id="cb4-2">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">site:</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"@shamindraas"</span></span>
<span id="cb4-3">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">creator:</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"@shamindraas"</span></span></code></pre></div></div>
</div>
</section>
<section id="step-5-add-correctionschange-tracking-and-rss-feed" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="step-5-add-correctionschange-tracking-and-rss-feed">Step 5: Add Corrections/Change Tracking and RSS feed</h2>
<p>I frequently make edits to blogposts and intend to do so going forward. Fortunately <code>distill</code> makes it easy <strong>track changes/corrections</strong> made to blogposts. I did this by simply adding the site repo url to the <code>_site.yml</code> as follows:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb5-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">repository_url:</span> https://github.com/shamindras/ss_personal_distill_blog</span></code></pre></div></div>
</div>
<p>Now the following appears at the bottom of all blogposts:</p>
<div id="step-05-01-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/images/step_05_trackcorr_01.png" class="img-fluid figure-img" alt="Screenshot of changes and corrections tracking"></p>
<figcaption>Changes and Corrections Tracking</figcaption>
</figure>
</div>
<p>So users can easily track changes or file any concerns as issues, though hopefully the <code>Disqus</code> comment feature makes this easier for everyone.</p>
<p>Finally it is easy to add an <strong>RSS feed</strong> for the blog by simply adding the following to <code>_site.yml</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb6-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">base_url:</span> https://www.shamindras.com/</span>
<span id="cb6-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">navbar:</span></span>
<span id="cb6-3">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">left:</span></span>
<span id="cb6-4">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">-</span> icon: fa fa-rss</span>
<span id="cb6-5">      <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">href:</span> index.xml</span></code></pre></div></div>
</div>
<aside>
<p><strong>Note:</strong> You can see my <code>_site.yml</code> with these settings <a href="https://github.com/shamindras/ss_personal_distill_blog/blob/master/_site.yml">here</a></p>
</aside>
<p>The critical elements are adding in the <code>base_url</code> fields and adding in <code>fa fa-rss</code> which is derived from the <code>index.xml</code> file. The <code>index.xml</code> file is automatically generated from the <code>index.Rmd</code> when you render the <code>distill</code> blog using the usual command:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb7-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">rmarkdown::render_site</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">here::here()</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span></code></pre></div></div>
</div>
</section>
<section id="next-steps" class="level2">
<h2 class="anchored" data-anchor-id="next-steps">Next Steps</h2>
<p>In terms of core <code>distill</code> blog settings, these are the main options that I’m happy to implement for now. For me the next steps are more about <strong>customizing my own blog workflow</strong>. This will involve setting up utilities to automatically:</p>
<ul>
<li><strong>Wrap Rmd files</strong> to 80 characters for consistency</li>
<li>Quickly <strong>delete unused files</strong> e.g.&nbsp;<code>DS_Store</code> files on mac</li>
<li><strong>Clear knitr cache</strong> for all posts and thoroughly re-render the site</li>
</ul>
<p>I expect to do this using a combination of <code>R</code> functions/<code>Makefile</code> workflow, but do stay tuned!</p>
</section>
<section id="concluding-thoughts" class="level2">
<h2 class="anchored" data-anchor-id="concluding-thoughts">Concluding Thoughts</h2>
<p>As it can be seen it is quite easy to customize <code>distill</code> for commonly required features. Really great work by the RStudio team in making such customizations so user-friendly 👍.</p>


</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a></div></div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{shrotriya2019,
  author = {Shrotriya, Shamindra},
  title = {Upgrading {Distill} {Blog} {Settings}},
  date = {2019-07-31},
  url = {https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-shrotriya2019" class="csl-entry quarto-appendix-citeas">
Shrotriya, Shamindra. 2019. <span>“Upgrading Distill Blog
Settings.”</span> July 31, 2019. <a href="https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/">https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/</a>.
</div></div></section></div> ]]></description>
  <category>distill</category>
  <guid>https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/</guid>
  <pubDate>Tue, 30 Jul 2019 14:00:00 GMT</pubDate>
  <media:content url="https://www.shamindras.com/posts/2019-07-31-shrotriya2019distillpt2/images/step_01_disqus_02.png" medium="image" type="image/png" height="116" width="144"/>
</item>
<item>
  <title>Shamindra’s July 2019 Roundup</title>
  <dc:creator>Shamindra Shrotriya</dc:creator>
  <link>https://www.shamindras.com/posts/2019-07-30-shrotriya2019july19roundup/</link>
  <description><![CDATA[ <section id="introduction" class="level2"><h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>This is a new feature I’m going to experiment with, namely documenting anything interesting I come across (articles, lectures, books, papers etc.) and any activities I get up to. This is more for my personal benefit but may also help others. Let’s see how this experiment goes!</p>
</section><section id="interesting-articles" class="level2"><h2 class="anchored" data-anchor-id="interesting-articles">Interesting Articles</h2>
<ul>
<li><p>Came across this <a href="http://mirrors.concertpass.com/tex-archive/biblio/bibtex/base/xampl.bib" target="_blank">exhaustive <code>BibTex</code> example file</a> which will be a really handy reference going forward for <img src="https://latex.codecogs.com/png.latex?%5CLaTeX"> documents</p></li>
<li>
<p>This <a href="https://holtzy.github.io/Pimp-my-rmd/#highlight_a_piece_of_text" target="_blank">Pimp my RMD: a few tips for R Markdown</a> document is a very good site to help deal with really slick features of editing <code>Rmd</code> documents.</p>
<ul>
<li>One nice feature I noticed was to use <code>HTML</code> to <a href="https://holtzy.github.io/Pimp-my-rmd/#center_an_image" target="_blank">center an image</a>
</li>
</ul>
</li>
</ul></section><section id="interesting-books" class="level2 page-columns page-full"><h2 class="anchored" data-anchor-id="interesting-books">Interesting Books</h2>
<section id="non-fiction" class="level3 page-columns page-full"><h3 class="anchored" data-anchor-id="non-fiction">Non-fiction</h3>
<ul>
<li>Continued reading this fantastic book <span class="citation" data-cites="steele2004cauchyscwarzmaster_book">(Steele 2004)</span> called the <em>Art of Mathematical inequalities</em> by <a href="http://www-stat.wharton.upenn.edu/~steele/" target="_blank">Prof.&nbsp;Michael Steele</a>. This book is simply amazing in that Prof.&nbsp;Steele walks through deriving mathematical inequalities as if you were having a casual chat together using a whiteboard. I’ve been working through through the problems in detail and they are a great challenge! I’ll blog more about this as I finish the book in the August 2019 roundup.</li>
</ul>
<aside><strong>Note:</strong> the text contains full solutions making it ideal for self-study (but I refuse to peek for now)
</aside></section><section id="fiction" class="level3"><h3 class="anchored" data-anchor-id="fiction">Fiction</h3>
<ul>
<li>Read Celeste Ng’s <a href="https://www.celesteng.com/everything-i-never-told-you" target="_blank">Everything I Never Told You</a>. Very nicely written debut novel by Ng, though quite dark and brooding in tone. Would not recommend as a pick me up but certainly would for a nice American-Asian character study set in the 1970s.</li>
</ul></section></section><section id="interesting-papers" class="level2"><h2 class="anchored" data-anchor-id="interesting-papers">Interesting Papers</h2>
<ul>
<li>Particularly enjoyed reading this paper on the mathematical description of the carbon cycle <span class="citation" data-cites="rothman14_earth_carbon_cycle">(Rothman 2014)</span>. Really useful to get a good idea of the simple but powerful use of simple stochastic differential equations used to model climate change processes at various <em>global scales</em>.</li>
</ul></section><section id="personal-blogging" class="level2"><h2 class="anchored" data-anchor-id="personal-blogging">Personal Blogging</h2>
<p>Besides this post 😄 the main things I got up to on the personal blogging front were:</p>
<ul>
<li>Setting up this very blog, with a <a href="https://www.shamindras.com/posts/2019-07-11-setting-up-a-distill-blog-with-netlify/" target="_blank">detailed step-by-step guide</a> on the fun setup process with the <a href="https://rstudio.github.io/distill/blog.html" target="_blank">RStudio distill package</a> and also <a href="https://netlify.com" target="_blank">Netlify</a> and <a href="https://domains.google" target="_blank">Google Domains</a>
</li>
<li>Wrote a <a href="https://www.shamindras.com/posts/2019-07-15-shrotriya2019tidyfunpt1/" target="_blank">fun blogpost</a> on solving a couple of quick text-based tasks using the <code>tidyverse</code> including <a href="https://www.shamindras.com/posts/2019-07-15-shrotriya2019tidyfunpt1/#task-1-generating-oxford-comma-triples" target="_blank">generating Oxford Comma triples</a> and also <a href="https://www.shamindras.com/posts/2019-07-15-shrotriya2019tidyfunpt1/#task-2-generating-numbered-bibtex-entries" target="_blank">Generating numbered BibTeX entries</a>
</li>
</ul></section><section id="concluding-thoughts" class="level2"><h2 class="anchored" data-anchor-id="concluding-thoughts">Concluding Thoughts</h2>
<p>Overall July 2019 was a somewhat productive summer month. Though things are never quite as productive as I like them to be in graduate school, but always got to keep trying.</p>
<p>I liked documenting this personal <strong>July 2019 roundup</strong>. Normally I’m not the type to share much about my personal life, but I thought documenting what I get up to gives me more stake in the respective activities and forces me to commit to them enthusiastically. I also like sharing cool stuff that I come across with friends, so dual benefit.</p>
<p>I think I’ll keep these monthly roundups going for a while. Let’s see how this experiment goes when semester starts 😄.</p>
<p>Please post in the comments any questions/feedback you may have or anything interesting resources you came across in July 2019 👍.</p>



</section><div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-rothman14_earth_carbon_cycle" class="csl-entry">
Rothman, Daniel H. 2014. <span>“<span class="nocase">Earth’s Carbon Cycle: a Mathematical Perspective</span>.”</span> <em>Bulletin of the American Mathematical Society</em> 52 (1): 47–64. <a href="https://doi.org/10.1090/s0273-0979-2014-01471-5">https://doi.org/10.1090/s0273-0979-2014-01471-5</a>.
</div>
<div id="ref-steele2004cauchyscwarzmaster_book" class="csl-entry">
Steele, J Michael. 2004.<em><span class="nocase">The Cauchy-Schwarz master class: an introduction to the art of mathematical inequalities </span></em>. Cambridge University Press.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a></div></div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{shrotriya2019,
  author = {Shrotriya, Shamindra},
  title = {Shamindra’s {July} 2019 {Roundup}},
  date = {2019-07-30},
  url = {https://www.shamindras.com/posts/2019-07-30-shrotriya2019july19roundup/},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-shrotriya2019" class="csl-entry quarto-appendix-citeas">
Shrotriya, Shamindra. 2019. <span>“Shamindra’s July 2019
Roundup.”</span> July 30, 2019. <a href="https://www.shamindras.com/posts/2019-07-30-shrotriya2019july19roundup/">https://www.shamindras.com/posts/2019-07-30-shrotriya2019july19roundup/</a>.
</div></div></section></div> ]]></description>
  <category>personal</category>
  <category>roundup</category>
  <category>rstats</category>
  <category>math</category>
  <guid>https://www.shamindras.com/posts/2019-07-30-shrotriya2019july19roundup/</guid>
  <pubDate>Mon, 29 Jul 2019 14:00:00 GMT</pubDate>
  <media:content url="https://www.shamindras.com/posts/2019-07-30-shrotriya2019july19roundup/images/preview-july-2019-02.png" medium="image" type="image/png" height="74" width="144"/>
</item>
<item>
  <title>Reproducibility Challenge: Titanic Survivors Plot</title>
  <dc:creator>Shamindra Shrotriya</dc:creator>
  <link>https://www.shamindras.com/posts/2019-07-21-shrotriya2019reprtitanic/</link>
  <description><![CDATA[ <section id="background" class="level2 page-columns page-full"><h2 class="anchored" data-anchor-id="background">Background</h2>
<p>In the February 2019 issue of <a href="https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1740-9713.2019.01229.x">Significance Magazine</a> notably featured a story of the titanic disaster <span class="citation" data-cites="friendly2019titanicviz">(Friendly, Symanzik, and Onder 2019)</span> and visualization of key survival statistics. As a fan of <code>R</code> and data visualization I enjoyed this article and recommended it to anyone with similar interests. Although the subject is rather tragic, by reading the article I did get a better appreciation of how the information of the crash survivorship was conveyed to the general public through data visualization.</p>
<aside><div id="main-src-cover" class="quarto-figure quarto-figure-center anchored">
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-07-21-shrotriya2019reprtitanic/images/feb-2019-significance-cover.png" class="img-fluid figure-img" style="width:24cm" alt="cover alt-text"></p>
<figcaption>cover</figcaption></figure>
</div>
</aside></section><section id="reproducibility-challenge" class="level2 page-columns page-full"><h2 class="anchored" data-anchor-id="reproducibility-challenge">Reproducibility Challenge</h2>
<p>Of particular note in the article was the following data visualization poster printed shortly after the tragedy:</p>
<div id="main-src-poster" class="quarto-figure quarto-figure-center anchored">
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-07-21-shrotriya2019reprtitanic/images/main-titanic-poster.png" class="img-fluid figure-img" style="width:12cm" alt="G.Bron's chart of The Loss of the Titanic, from The Sphere, 4 May 1912"></p>
<figcaption>G.Bron’s chart of “The Loss of the ‘Titanic’”, from <em>The Sphere</em>, 4 May 1912</figcaption></figure>
</div>
<p>I found this to be a very cool data visualization of the survivorship by class, gender, and adulthood. As a statistics graduate student, I care a lot about reproducibility of results not only as a basic check, but to really appreciate the results and more importantly any implicit assumptions behind the results. So this led to the following goal and effectively this blogpost:</p>
<aside><p><strong>Note:</strong> Replicability is better, but reproducibility is a good start and often a more practically feasible undertaking</p>
</aside><p><strong>Goal:</strong> Given the same Titanic survivors data could we recreate a similar looking chart using <code>R</code> and specifically the <code>tidyverse</code> set of tools?</p>
</section><section id="collecting-and-cleaning-the-data" class="level2"><h2 class="anchored" data-anchor-id="collecting-and-cleaning-the-data">Collecting and cleaning the data</h2>
<p>First let’s begin by loading our required data cleaning and plotting packages. First we will load the required libraries needed for the analysis.</p>
<p>In the article the authors cite several resources for collecting the data for this task. Per the article we note that the data is already <em>pre-baked</em> into <code>R</code> and located in <code><a href="https://rdrr.io/r/datasets/Titanic.html">datasets::Titanic</a></code> when <code>R</code> loads, which is convenient 😎.</p>
<p>We can source the data and start cleaning it for our exploration, using the handy <code>clean_names</code> function for column name cleaning and converting various categorical variables (<em>age, sex, survivorship, and passenger class</em>) to factors for easy plotting later.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Basic cleaning of names and filtering out non-zero counts</span></span>
<span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">t1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">datasets</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">::</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/datasets/Titanic.html">Titanic</a></span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as_tibble</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">clean_names</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>dat <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/stats/filter.html">filter</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>.data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">n</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>.data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>,</span>
<span>                      new_sex <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">age</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Child"</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">age</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">sex</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>,</span>
<span>                      n_sgnd <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">survived</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No"</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">n</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">n</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">class</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">new_sex</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">survived</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">n_sgnd</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span></span>
<span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Passenger (non-crew) level aggregation</span></span>
<span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">t2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">t1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/stats/filter.html">filter</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">class</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Crew"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>class <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pass."</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">class</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">new_sex</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">survived</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarize</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>n_sgnd <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/sum.html">sum</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">n_sgnd</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<div class="cell-output cell-output-stderr">
<pre><code>`summarise()` has regrouped the output.
ℹ Summaries were computed grouped by class, new_sex, and survived.
ℹ Output is grouped by class and new_sex.
ℹ Use `summarise(.groups = "drop_last")` to silence this message.
ℹ Use `summarise(.by = c(class, new_sex, survived))` for per-operation grouping
  (`?dplyr::dplyr_by`) instead.</code></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Crew (non-passenger) level aggregation</span></span>
<span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">t3</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">t1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>class <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pass.\nCrew"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">class</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">new_sex</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">survived</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarize</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>n_sgnd <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/sum.html">sum</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">n_sgnd</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<div class="cell-output cell-output-stderr">
<pre><code>`summarise()` has regrouped the output.
ℹ Summaries were computed grouped by class, new_sex, and survived.
ℹ Output is grouped by class and new_sex.
ℹ Use `summarise(.groups = "drop_last")` to silence this message.
ℹ Use `summarise(.by = c(class, new_sex, survived))` for per-operation grouping
  (`?dplyr::dplyr_by`) instead.</code></pre>
</div>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Combined cleaned plotting dataset</span></span>
<span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">ttnc_cln</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">t1</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">t2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">t3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>.data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>,</span>
<span>                            class <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/factor.html">as.factor</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">class</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>,</span>
<span>                            new_sex <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/factor.html">as.factor</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">new_sex</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>,</span>
<span>                            survived <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/factor.html">as.factor</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">survived</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span></span>
<span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display first 8 rows in a nice centered table</span></span>
<span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">ttnc_cln</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">slice</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>.data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>, align <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'c'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<thead><tr class="header">
<th style="text-align: center;">class</th>
<th style="text-align: center;">new_sex</th>
<th style="text-align: center;">survived</th>
<th style="text-align: center;">n_sgnd</th>
</tr></thead>
<tbody>
<tr class="odd">
<td style="text-align: center;">3rd</td>
<td style="text-align: center;">Child</td>
<td style="text-align: center;">No</td>
<td style="text-align: center;">-35</td>
</tr>
<tr class="even">
<td style="text-align: center;">3rd</td>
<td style="text-align: center;">Child</td>
<td style="text-align: center;">No</td>
<td style="text-align: center;">-17</td>
</tr>
<tr class="odd">
<td style="text-align: center;">1st</td>
<td style="text-align: center;">Male</td>
<td style="text-align: center;">No</td>
<td style="text-align: center;">-118</td>
</tr>
<tr class="even">
<td style="text-align: center;">2nd</td>
<td style="text-align: center;">Male</td>
<td style="text-align: center;">No</td>
<td style="text-align: center;">-154</td>
</tr>
<tr class="odd">
<td style="text-align: center;">3rd</td>
<td style="text-align: center;">Male</td>
<td style="text-align: center;">No</td>
<td style="text-align: center;">-387</td>
</tr>
<tr class="even">
<td style="text-align: center;">Crew</td>
<td style="text-align: center;">Male</td>
<td style="text-align: center;">No</td>
<td style="text-align: center;">-670</td>
</tr>
<tr class="odd">
<td style="text-align: center;">1st</td>
<td style="text-align: center;">Female</td>
<td style="text-align: center;">No</td>
<td style="text-align: center;">-4</td>
</tr>
<tr class="even">
<td style="text-align: center;">2nd</td>
<td style="text-align: center;">Female</td>
<td style="text-align: center;">No</td>
<td style="text-align: center;">-13</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Looks nice. As you can see, the data cleaning was done in stages where 3 datasets <code>t1, t2, t3</code> were built up. Essentially by staring at the plot it is clear that plots are split by class i.e.&nbsp;<img src="https://latex.codecogs.com/png.latex?1%5E%7Bst%7D"> Class, <img src="https://latex.codecogs.com/png.latex?2%5E%7Bnd%7D"> Class etc. This is the cleaned <code>t1</code> data frame. However there are aggregate versions of these classes at combined <em>Passenger</em> level and <em>Passenger and Crew</em> level which are the <code>t2</code> and <code>t3</code> tibbles respectively. Finally we concatenate them together into <code>ttnc_cln</code> and ensure our categorical variables are cast as <code>factors</code>.</p>
<p>Next step - plotting!</p>
</section><section id="plotting-the-data" class="level2"><h2 class="anchored" data-anchor-id="plotting-the-data">Plotting the Data</h2>
<p>The main chart object is a barplot by sex and adult status and faceted by passenger class i.e.&nbsp;first class, second class etc. Great, let’s do it!</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">out_plot</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">ttnc_cln</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span>              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>,</span>
<span>                              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">new_sex</span>, y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">n_sgnd</span>, fill <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">survived</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span>              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_bar</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>stat <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"identity"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span>              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">class</span>, ncol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,</span>
<span>                                  strip.position <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"right"</span>,</span>
<span>                                  scales <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"free_y"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span>              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span>              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>values<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#3C4144"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#D2D3D1"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span>              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span>              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>panel.background <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_rect</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>fill <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#969898"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>,</span>
<span>                             panel.grid.major <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>,</span>
<span>                             panel.grid.minor <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>,</span>
<span>                             axis.title.x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>,</span>
<span>                             axis.title.y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>,</span>
<span>                             strip.text.y <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>angle <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">360</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>,</span>
<span>                             legend.position <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span>              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>breaks<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/seq.html">seq</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1500</span>,<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">600</span>,<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">150</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span>              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>title <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'The LOSS of the "TITANIC"'</span>,</span>
<span>                            subtitle <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">glue</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://glue.tidyverse.org/reference/glue.html">glue</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"The Results Analyzed and Shown"</span>,</span>
<span>                                                  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'in a special "Sphere" Diagram'</span>,</span>
<span>                                                  .sep <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>,</span>
<span>                            caption <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">glue</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://glue.tidyverse.org/reference/glue.html">glue</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Note: The Black color indicates"</span>,</span>
<span>                                                 <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Passengers and Crew NOT SAVED."</span>,</span>
<span>                                                 <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"The White color indicates SAVED."</span>,</span>
<span>                                                  .sep <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span></span>
<span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">out_plot</span></span></code></pre></div></div>
<div class="cell-output-display">
<div>
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-07-21-shrotriya2019reprtitanic/index_files/figure-html/setup_ttnic_01_02-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</section><section id="conclusion" class="level2"><h2 class="anchored" data-anchor-id="conclusion">Conclusion</h2>
<ul>
<li>Overall looks like the plot was able to be reproduced to a decent level of accuracy</li>
<li>To get the colors to be close to the plot, I simply opened the <a href="https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1740-9713.2019.01229.x">article online</a> and used the <a href="http://colorzilla.com/chrome/">Colorzilla for Chrome</a> addin to select the color manually. This is a really nice tool to use for reproducing colors viewed through a browser</li>
<li>I don’t quite like that the non-survivors here are shown on a negative scale, but this was the quick hack I could perform to get bars flipped for non-survivors vs.&nbsp;survivors</li>
<li>
<strong>Summary:</strong> Overall this was a really fun challenge and I learned a lot about old-school data visualization using the glorius modern <code>tidyverse</code> ecosystem we have at our fingertips. Will do a similar reproducibility challenge again for sure ✌️. Have fun playing around with the above and please post in the comments any questions/feedback you may have 👍.</li>
</ul></section><div id="quarto-appendix" class="default"><section id="acknowledgments" class="level2 appendix"><h2 class="anchored quarto-appendix-heading">Acknowledgments</h2><div class="quarto-appendix-contents">
<p>I’d like to thank Salil Shrotriya for creating the preview image for this post. The hex sticker <code>png</code> files were sourced from <a href="https://github.com/rstudio/hex-stickers">here</a>.</p>



</div></section><section class="quarto-appendix-contents" id="quarto-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0">
<div id="ref-friendly2019titanicviz" class="csl-entry">
Friendly, Michael, Jürgen Symanzik, and Ortac Onder. 2019. <span>“<span class="nocase">Visualising the Titanic disaster</span>.”</span> <em>Significance</em> 16 (1): 14–19. <a href="https://doi.org/10.1111/j.1740-9713.2019.01229.x">https://doi.org/10.1111/j.1740-9713.2019.01229.x</a>.
</div>
</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a></div></div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{shrotriya2019,
  author = {Shrotriya, Shamindra},
  title = {Reproducibility {Challenge:} {Titanic} {Survivors} {Plot}},
  date = {2019-07-21},
  url = {https://www.shamindras.com/posts/2019-07-21-shrotriya2019reprtitanic/},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-shrotriya2019" class="csl-entry quarto-appendix-citeas">
Shrotriya, Shamindra. 2019. <span>“Reproducibility Challenge: Titanic
Survivors Plot.”</span> July 21, 2019. <a href="https://www.shamindras.com/posts/2019-07-21-shrotriya2019reprtitanic/">https://www.shamindras.com/posts/2019-07-21-shrotriya2019reprtitanic/</a>.
</div></div></section></div> ]]></description>
  <category>tidyverse</category>
  <category>rstats</category>
  <category>reproducibility</category>
  <guid>https://www.shamindras.com/posts/2019-07-21-shrotriya2019reprtitanic/</guid>
  <pubDate>Sat, 20 Jul 2019 14:00:00 GMT</pubDate>
  <media:content url="https://www.shamindras.com/posts/2019-07-21-shrotriya2019reprtitanic/images/logo-01.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Tidyverse Fun - Part 1</title>
  <dc:creator>Shamindra Shrotriya</dc:creator>
  <link>https://www.shamindras.com/posts/2019-07-15-shrotriya2019tidyfunpt1/</link>
  <description><![CDATA[ <style type="text/css">/**
  * Author: Mikhail Popov
  * License: MIT
  */
a.wiki {
    /* color: #0645ad; */
    text-decoration: none;
    border-bottom: 1px dotted #0645ad;
}
.wiki::after {
    font-family: serif;
    content: " W";
    vertical-align: super;
    font-size: 6pt;
}</style>
<script src="https://unpkg.com/wikipedia-preview@1.8.0/dist/wikipedia-preview.production.js" type="text/javascript"></script><script type="text/javascript">
    window.onload = function() {
      wikipediaPreview.init({
        lang: 'en',
        selector: '.wiki',
        detectLinks: true
      });
    };</script><section id="task-1-generating-oxford-comma-triples" class="level2 page-columns page-full"><h2 class="anchored" data-anchor-id="task-1-generating-oxford-comma-triples">Task 1: Generating Oxford Comma Triples</h2>
<section id="the-central-problem" class="level3"><h3 class="anchored" data-anchor-id="the-central-problem">The central problem</h3>
<p>Based on a fun conversation with my statistics cohort over dinner we got to discussing the famous <a href="https://en.wikipedia.org/wiki/Serial_comma" class="wiki"><em>Oxford Comma</em></a> (or <em>Serial Comma</em> depending on your persuasion). I’ve never really adopted the use but my friends made a compelling argument on it’s apparent general lack of ambiguity when applied appropriately.</p>
<p>We will use the Oxford comma on the famously <em>ambiguous</em> phrase (here used without the Oxford Comma before <em>leaves</em>):</p>
<blockquote class="blockquote">
<p>Eats, shoots and leaves</p>
</blockquote>
<p>After adding in the Oxford Comma this would become:</p>
<blockquote class="blockquote">
<p>Eats, shoots, and leaves</p>
</blockquote>
<p><strong>Goal:</strong> A fun experiment would be to generate <em>all permutations</em> of this phrase with and without the Oxford Comma using <code>R</code> and specifically the <code>tidyverse</code> packages.</p>
</section><section id="generating-all-word-triple-permutations-the-tidy-way" class="level3 page-columns page-full"><h3 class="anchored" data-anchor-id="generating-all-word-triple-permutations-the-tidy-way">Generating all word-triple permutations the <code>tidy</code> way</h3>
<p>First, let’s load our required packages.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;"><a href="https://yihui.org/knitr/">knitr</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org">magrittr</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;"><a href="https://tidyverse.tidyverse.org">tidyverse</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;"><a href="https://glue.tidyverse.org/">glue</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
</div>
<p>Let’s also define our unique global word values used to construct the required phrases:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">WORD_VALS</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"eats"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"shoots"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"leaves"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
</div>
<p>Generate all unique 3-word permutations <em>without replacement</em> from the three unique words. We’ll create a helper function to check that a vector of words is unique.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">is_unq_perm</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">word1</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">word2</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">word3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span>    <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">words_vec</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">word1</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">word2</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">word3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span>    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;"><a href="https://rdrr.io/r/base/function.html">return</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/length.html">length</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">words_vec</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/length.html">length</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">words_vec</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</div>
<p>We can now simply generate every possible triple <em>with replacement</em> using the <code><a href="https://tidyr.tidyverse.org/reference/expand.html">tidyr::crossing</a></code> function. We proceed to <em>filter</em> these <img src="https://latex.codecogs.com/png.latex?3%5E3%20=%2027"> triples for unique triples using our <code>is_unq_perm</code> helper function applied <em>row-by-row</em> using <code><a href="https://purrr.tidyverse.org/reference/pmap.html">purrr::pmap_lgl</a></code>. The <code>_lgl</code> simply returns a <code>TRUE/FALSE</code> logical value as intended by the applied function.</p>
<aside><strong>Note:</strong> The <code><a href="https://tidyr.tidyverse.org/reference/expand.html">tidyr::crossing</a></code> generates a <em>Cartesian product</em> of all the 3 word triples, very handy
</aside><div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Generate the unique word-triples</span></span>
<span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">all_perms</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tidyr</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://tidyr.tidyverse.org/reference/expand.html">crossing</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>word1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">WORD_VALS</span>,</span>
<span>                             word2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">WORD_VALS</span>,</span>
<span>                             word3 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">WORD_VALS</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>.data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>,</span>
<span>                       is_unq_perm <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">purrr</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://purrr.tidyverse.org/reference/pmap.html">pmap_lgl</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>.l <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>,</span>
<span>                                                     <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">is_unq_perm</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>.data <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">is_unq_perm</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">is_unq_perm</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span></span>
<span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display output in a nice centered table</span></span>
<span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">all_perms</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/pkg/knitr/man/kable.html">kable</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>, align <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'c'</span>,</span>
<span>        col.names <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Word 1"</span>,</span>
<span>                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Word 2"</span>,</span>
<span>                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Word 3"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<thead><tr class="header">
<th style="text-align: center;">Word 1</th>
<th style="text-align: center;">Word 2</th>
<th style="text-align: center;">Word 3</th>
</tr></thead>
<tbody>
<tr class="odd">
<td style="text-align: center;">eats</td>
<td style="text-align: center;">leaves</td>
<td style="text-align: center;">shoots</td>
</tr>
<tr class="even">
<td style="text-align: center;">eats</td>
<td style="text-align: center;">shoots</td>
<td style="text-align: center;">leaves</td>
</tr>
<tr class="odd">
<td style="text-align: center;">leaves</td>
<td style="text-align: center;">eats</td>
<td style="text-align: center;">shoots</td>
</tr>
<tr class="even">
<td style="text-align: center;">leaves</td>
<td style="text-align: center;">shoots</td>
<td style="text-align: center;">eats</td>
</tr>
<tr class="odd">
<td style="text-align: center;">shoots</td>
<td style="text-align: center;">eats</td>
<td style="text-align: center;">leaves</td>
</tr>
<tr class="even">
<td style="text-align: center;">shoots</td>
<td style="text-align: center;">leaves</td>
<td style="text-align: center;">eats</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Great - that part is done! Now we just need to generate for each triple of words an oxford comma and non-oxford comma version. This is done easily using the amazing <code>glue</code> package as seen below:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">exprs</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">all_perms</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>non_oxford_comma <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span></span>
<span>                   <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://glue.tidyverse.org/reference/glue.html">glue_data</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>.x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>,</span>
<span>                             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"{word1}, {word2} and {word3}"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>,</span>
<span>                 oxford_comma <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span></span>
<span>                   <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://glue.tidyverse.org/reference/glue.html">glue_data</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>.x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>,</span>
<span>                             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"{word1}, {word2}, and {word3}"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">non_oxford_comma</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">oxford_comma</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
</div>
<p>We can display the side-by-side output of the Non-Oxford Comma vs.&nbsp;Oxford comma for the <img src="https://latex.codecogs.com/png.latex?6"> generated triples as follows:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display output in a nice centered table</span></span>
<span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">exprs</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/pkg/knitr/man/kable.html">kable</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>,</span>
<span>        align <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'c'</span>,</span>
<span>        col.names <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Non-Oxford Comma"</span>,</span>
<span>                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Oxford Comma"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<div class="cell-output-display">
<table class="caption-top table table-sm table-striped small">
<thead><tr class="header">
<th style="text-align: center;">Non-Oxford Comma</th>
<th style="text-align: center;">Oxford Comma</th>
</tr></thead>
<tbody>
<tr class="odd">
<td style="text-align: center;">eats, leaves and shoots</td>
<td style="text-align: center;">eats, leaves, and shoots</td>
</tr>
<tr class="even">
<td style="text-align: center;">eats, shoots and leaves</td>
<td style="text-align: center;">eats, shoots, and leaves</td>
</tr>
<tr class="odd">
<td style="text-align: center;">leaves, eats and shoots</td>
<td style="text-align: center;">leaves, eats, and shoots</td>
</tr>
<tr class="even">
<td style="text-align: center;">leaves, shoots and eats</td>
<td style="text-align: center;">leaves, shoots, and eats</td>
</tr>
<tr class="odd">
<td style="text-align: center;">shoots, eats and leaves</td>
<td style="text-align: center;">shoots, eats, and leaves</td>
</tr>
<tr class="even">
<td style="text-align: center;">shoots, leaves and eats</td>
<td style="text-align: center;">shoots, leaves, and eats</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>So there you have it. Have fun generating your own version of Oxford Comma triples to engage in civil discussions with your fellow grammar focused friends 😄.</p>
</section></section><section id="task-2-generating-sequentially-numbered-bibtex-entries" class="level2 page-columns page-full"><h2 class="anchored" data-anchor-id="task-2-generating-sequentially-numbered-bibtex-entries">Task 2: Generating Sequentially Numbered BibTeX Entries</h2>
<section id="the-central-problem-1" class="level3"><h3 class="anchored" data-anchor-id="the-central-problem-1">The central problem</h3>
<p>In this case I needed to generate several BibTeX entries of the form:</p>
<pre class="markup"><code>@misc{doe2019_lec1,
author        = {Doe, John},
title         = {Lecture Note 1 - STAT10A},
month         = {March},
year          = {2018},
url           = {https://statschool/~doe/stats10A/Lectures/Lecture01.pdf},
}</code></pre>
<p>As it can be seen the lectures are numbered sequentially and change in the main BibTeX <code>id</code>, the <code>title</code>, and the <code>url</code> field.</p>
<p>Specifically I needed to construct 30 such sequential entries for lectures <code>1-30</code>. Rather than do this manually, I realized that this would be fun scripting exercise with using the <code>tidyverse</code> packages <code>glue</code>, <code>purrr</code>, and <code>stringr</code>.</p>
<p><strong>Goal:</strong> Create 30 such BibTeX entries and print to the console to directly-copy paste to my BibTeX file.</p>
</section><section id="the-tidy-approach" class="level3 page-columns page-full"><h3 class="anchored" data-anchor-id="the-tidy-approach">The <code>tidy</code> approach</h3>
<p>First step is to write a function that takes a lecture number (integer) as an input and then outputs a single BibTeX entry for that lecture.</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Generate BibTeX entry for a single lecture number</span></span>
<span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">get_lec_bibtex</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">lec_num</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get the 2 character padded lecture number i.e. 1 -&gt; "01"</span></span>
<span>  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">lec_num_pad</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://stringr.tidyverse.org/reference/str_pad.html">str_pad</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>string <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">lec_num</span>, width <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span>                         side <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"left"</span>, pad <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span></span>
<span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Construct the BibTeX entry</span></span>
<span>  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">out_bbtex_str</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://glue.tidyverse.org/reference/glue.html">glue</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span></span>
<span>    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"@misc{doe2019_lec&lt;lec_num&gt;,</span></span>
<span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    author = {Doe, John},</span></span>
<span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    title  = {Lecture Note &lt;lec_num&gt; - STAT10A},</span></span>
<span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    month  = {March},</span></span>
<span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    year   = {2018},</span></span>
<span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">    url    = {https://www.hpg/~doe/st10A/lecs/lec&lt;lec_num_pad&gt;.pdf}}"</span>,</span>
<span>    .open <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;"</span>,</span>
<span>    .close <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&gt;"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span></span>
<span>  <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;"><a href="https://rdrr.io/r/base/function.html">return</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">out_bbtex_str</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</div>
<p>Note that by default <code>glue</code> allows you to substitute input text in between <code>{</code> and <code>}</code> markers. However BibTeX entries <em>already have</em> literal default <code><a href="https://rdrr.io/r/base/Paren.html">{}</a></code> tags that we need to include in our function output. Rather than escaping them the <code>glue</code> package conveniently allows us to change the default opening and closing markers 💯! We simply set these to be angle brackets <code>&lt; &gt;</code> using the <code>.open</code> and <code>.close</code> options above.</p>
<aside><strong>Note:</strong> Luckily we don’t have <em>literal</em> angle brackets in our BibTeX output to deal with here
</aside><p>Let’s just test this out quickly:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">lec_no</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_lec_bibtex</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>lec_num <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">lec_no</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>@misc{doe2019_lec1,
author = {Doe, John},
title  = {Lecture Note 1 - STAT10A},
month  = {March},
year   = {2018},
url    = {https://www.hpg/~doe/st10A/lecs/lec01.pdf}}</code></pre>
</div>
</div>
<p>Great - looks like it is working as required with the correct string padding in the lecture number in the pdf filename!</p>
<aside><strong>Note:</strong> We used the <code>stringr</code> <code>str_pad</code> to convert <code>1</code> to <code>"01"</code>
</aside></section><section id="apply-to-all-lectures-using-purrr" class="level3"><h3 class="anchored" data-anchor-id="apply-to-all-lectures-using-purrr">Apply to all lectures using <code>purrr</code>
</h3>
<p>Let’s finish this by creating all the entries using <code>purrr</code>:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb11" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">lec_nums</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">lec_nums</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://purrr.tidyverse.org/reference/map.html">map_chr</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>.x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>, .f <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_lec_bibtex</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>lec_num <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.x</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/cat.html">cat</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">.</span>, sep <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"\n\n"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>@misc{doe2019_lec1,
author = {Doe, John},
title  = {Lecture Note 1 - STAT10A},
month  = {March},
year   = {2018},
url    = {https://www.hpg/~doe/st10A/lecs/lec01.pdf}}

@misc{doe2019_lec30,
author = {Doe, John},
title  = {Lecture Note 30 - STAT10A},
month  = {March},
year   = {2018},
url    = {https://www.hpg/~doe/st10A/lecs/lec30.pdf}}</code></pre>
</div>
</div>
<p>Yay - this works as expected! We can now paste into BibTeX as required.</p>
<p>Note that we only created it for lectures 1 and 30 for easy scrolling. But for all lectures we can just replace <code>c(1, 30)</code> with <code>1:30</code> in the above code.</p>
</section></section><section id="conclusion" class="level2"><h2 class="anchored" data-anchor-id="conclusion">Conclusion</h2>
<p>This post was for me to document and serve as a guide to automating a couple of fun text-based tasks that I came across in my work (and social life!). Using the <code>tidy</code> framework can be a fun way to solve these tasks (but certainly not the only way in <code>R</code>). Have fun playing around with the above and please post in the comments any questions/feedback you may have 👍.</p>
<p>Stay tuned for more blogposts solving more such tasks.</p>
</section><div id="quarto-appendix" class="default"><section id="acknowledgments" class="level2 appendix"><h2 class="anchored quarto-appendix-heading">Acknowledgments</h2><div class="quarto-appendix-contents">
<p>I’d like to thank Salil Shrotriya for creating the preview image for this post. The hex sticker <code>png</code> files were sourced from <a href="https://github.com/rstudio/hex-stickers">here</a>.</p>


</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a></div></div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{shrotriya2019,
  author = {Shrotriya, Shamindra},
  title = {Tidyverse {Fun} - {Part} 1},
  date = {2019-07-15},
  url = {https://www.shamindras.com/posts/2019-07-15-shrotriya2019tidyfunpt1/},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-shrotriya2019" class="csl-entry quarto-appendix-citeas">
Shrotriya, Shamindra. 2019. <span>“Tidyverse Fun - Part 1.”</span> July
15, 2019. <a href="https://www.shamindras.com/posts/2019-07-15-shrotriya2019tidyfunpt1/">https://www.shamindras.com/posts/2019-07-15-shrotriya2019tidyfunpt1/</a>.
</div></div></section></div> ]]></description>
  <category>tidyverse</category>
  <category>rstats</category>
  <guid>https://www.shamindras.com/posts/2019-07-15-shrotriya2019tidyfunpt1/</guid>
  <pubDate>Sun, 14 Jul 2019 14:00:00 GMT</pubDate>
  <media:content url="https://www.shamindras.com/posts/2019-07-15-shrotriya2019tidyfunpt1/images/logo-01.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Setting up a Distill Blog with Netlify</title>
  <dc:creator>Shamindra Shrotriya</dc:creator>
  <link>https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/</link>
  <description><![CDATA[ <section id="step-0-introduction" class="level2 page-columns page-full"><h2 class="anchored" data-anchor-id="step-0-introduction">Step 0: Introduction</h2>
<p>This is a meta blogpost to describe how I setup this personal academic blog. It is based on the relatively new <a href="https://rstudio.github.io/distill/" target="_blank">distill</a> package by the <a href="https://www.rstudio.com/" target="_blank">RStudio</a> team. The main tools used I used to create this blog are:</p>
<ul>
<li>My personal <a href="https://github.com/shamindras" target="_blank">Github account</a>
</li>
<li>The <a href="https://www.rstudio.com/products/rstudio/" target="_blank">RStudio editor</a>
</li>
<li>The <code>R</code> packages <a href="https://github.com/rstudio/distill" target="_blank"><code>distill</code></a> and <a href="https://github.com/r-lib/here" target="_blank"><code>here</code></a>
</li>
<li>A macbook pro (2017 edition) and the <a href="https://www.iterm2.com/" target="_blank">iterm2</a> terminal</li>
<li>My personal <a href="https://app.netlify.com" target="_blank">netlify account</a> and also my personal domain bought from <a href="https://domains.google/" target="_blank">Google Domains</a>
</li>
</ul>
<p>The details of <em>how</em> I used the tools used are all noted below in a step-by-step manner.</p>
<p>Importantly, I should note that the RStudio <code>distill</code> team has already created an <a href="https://rstudio.github.io/distill/blog.html" target="_blank">excellent distill blog creation tutorial</a> which I thoroughly used and highly recommend to new users. I wrote this meta blogpost in my own words so that I can personally remember the details going forward. I also added more details on deployment with Google Domains and Netlify that would hopefully be useful to new <code>R</code> users waiting to deploy a similar <code>distill</code> blog.</p>
<aside><p>Admittedly this blogpost is verbose, but hopefully the details help users new to the <code>distill</code> blogging package.</p>
</aside></section><section id="step-1-create-new-distill-blog-repo" class="level2 page-columns page-full"><h2 class="anchored" data-anchor-id="step-1-create-new-distill-blog-repo">Step 1: Create new distill blog repo</h2>
<p>I opted to manage my blog versioning using Git/Github. I started by going to my personal <code>github</code> account and create a new repository. I called mine <code>ss_personal_distill_blog</code> and also initialized it with a <code>README.md</code> and included an <code>.gitignore</code> for <code>R</code> since that will the blogging language of choice here 😄. This is shown in the screenshot below.</p>
<div id="step-01-01-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/images/01_01_create_github_distill_repo.png" class="img-fluid figure-img" alt="Screenshot of image of setting up the site github repo"></p>
<figcaption>Setting up the Site Github repo</figcaption></figure>
</div>
<aside><p>Options for creating the Github repo for the <code>distill</code> blog</p>
</aside><p>Once created the repo will appear in <code>github</code> as seen in the following screenshot</p>
<div id="step-01-02-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/images/01_02_newly_created_distill_repo.png" class="img-fluid figure-img" alt="Screenshot of setting up new site github repo with README.md"></p>
<figcaption>New Site Github repo with README.md</figcaption></figure>
</div>
<aside><p>Newly created Github repo for the <code>distill</code> blog</p>
</aside></section><section id="step-2-clone-the-repo-locally" class="level2"><h2 class="anchored" data-anchor-id="step-2-clone-the-repo-locally">Step 2: Clone the repo locally</h2>
<p>With the <code>github</code> repo created, I switched locally on my mac to <code>iterm2</code> terminal and cloned the repo locally using the following command:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> clone git@github.com:shamindras/ss_personal_distill_blog.git</span></code></pre></div></div>
</div>
<p>And the cloning quickly finished with the following output</p>
<pre class="markup"><code>Cloning into 'ss_personal_distill_blog'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (4/4), done.</code></pre>
<p>Now I simply changed into the newly cloned blog directory by running the following terminal command:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">cd</span> ss_personal_distill_blog</span></code></pre></div></div>
</div>
<p>I then ran the following terminal command:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">tree</span></span></code></pre></div></div>
</div>
<p>This resulted in the following directory structure so far:</p>
<pre class="markup"><code>.
├── .git
├── .gitignore
└── README.md</code></pre>
<p>Great, now the repo was setup locally. At this stage there is just a simple <code>README.md</code> which will get added to a bit later, but the main focus is to start creating the <code>distill</code> blog within this directory locally.</p>
</section><section id="step-3-create-the-distill-blog-files" class="level2 page-columns page-full"><h2 class="anchored" data-anchor-id="step-3-create-the-distill-blog-files">Step 3: Create the distill blog files</h2>
<p>In order to start creating the blog contents I opened up an instance of <code>RStudio</code> from within my new directory on my macbook via the following terminal command:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb6-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">open</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-a</span> /Applications/RStudio.app .</span></code></pre></div></div>
</div>
<aside><p><strong>Note:</strong> The <code>.</code> at the end of the command ensures that <code>RStudio</code> opens in this newly created blog directory</p>
</aside><p>With <code>RStudio</code> opened we can now run the following <code>R</code> commands in just the <code>console</code> to create the install the required and <code>distill</code> blog setup packages:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">req_pckgs</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"distill"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"here"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>pkgs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">req_pckgs</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;"><a href="https://here.r-lib.org/">here</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;"><a href="https://github.com/rstudio/distill">distill</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
</div>
<p>Now we can create our blog using the following 2 commands from the freshly installed <code>distill</code> package using the following command run in the <code>console</code></p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distill</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">create_blog</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>dir <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">here</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://here.r-lib.org/reference/here.html">here</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>,</span>
<span>                     title <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Shamindra's Shrotriya's blog"</span>,</span>
<span>                     gh_pages <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
</div>
<p>Note that we set <code>gh_pages = TRUE</code> to ensure that we can host this blog on <a href="https://pages.github.com/" target="_blank">github pages</a> down the line if needed. You can omit this if you don’t want the option to have <em>github pages</em> as your host in the future. I will be using <code>Netlify</code> to host my blog (see below), but it is good to have an additional host option in the future.</p>
<p>My local <code>distill</code> blog directory now looked like this (again after running the <code>tree</code> command in the terminal):</p>
<pre class="markup"><code>.
├── .git
├── .gitignore
├── .nojekyll
├── README.md
├── _posts
├── _site.yml
├── about.Rmd
├── docs
├── index.Rmd
└── ss_personal_distill_blog.Rproj</code></pre>
<p>Pretty cool! Note that there is a newly created <code>_posts</code> directory for future blogposts. And there is a directory called <code>docs</code> to store all our processed blogposts later. If we had set <code>gh_pages = FALSE</code> the <code>docs</code> directory would be automatically replaced by a <code>_site</code> directory. More on this point later.</p>
</section><section id="step-4-customize-the-welcome-blogpost" class="level2 page-columns page-full"><h2 class="anchored" data-anchor-id="step-4-customize-the-welcome-blogpost">Step 4: Customize the welcome blogpost</h2>
<p>So <code>distill</code> already had us underway with a default welcome blogpost contained in the <code>welcome.Rmd</code> file for us. There are a bunch of javascript related files automatically generated in the <code>_posts/welcome/welcome_files</code> directory but these don’t need to be altered by the user. I just needed to modify <code>welcome.Rmd</code> contents per my preference as with any regular <code>Rmd</code> file and click <code>Knit</code> in RStudio to refresh it. We can see this in the <code>_posts</code> directory:</p>
<pre class="markup"><code>./_posts/welcome
├── welcome.Rmd
├── welcome.html
└── welcome_files</code></pre>
<p>One thing that slightly bothered me is that the default <strong>welcome</strong> blogpost has no <strong>date</strong> prefix in the directory. This would be nice to have in order to sort all future blogposts chronologically. I could’ve modified this default welcome blogpost <code>Rmd</code> and directory to include the date prefix manually. For simplicity I opted to delete the default welcome directory altogether and recreated it with the date prefix as I prefer as detailed below.</p>
<p>To delete the default welcome directory, I just ran the following code at my terminal:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb11-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rm</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-rf</span> _posts/welcome</span></code></pre></div></div>
</div>
<aside><p><strong>Note:</strong> ⚠️ Always be careful using <code>rm -rf</code></p>
</aside><p>With the default welcome blogpost deleted, I created my own custom welcome blogpost as follows:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb12" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distill</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">create_post</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>title <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Welcome to Shamindra’s Blog"</span>,</span>
<span>                     author <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Shamindra Shrotriya"</span>,</span>
<span>                     date_prefix <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
</div>
<p>Now the welcome blogpost has this nice <strong>date prefix</strong> structure since we passed this option as <code>TRUE</code>. Let’s see what the <code>_posts</code> directory looks like now</p>
<pre class="markup"><code>_posts/2019-07-10-welcome-to-shamindras-blog
└── welcome-to-shamindras-blog.Rmd`</code></pre>
<p>Neat - just how I like it! I then modified the content of the new welcome blogpost by going to the following file:</p>
<pre class="markup"><code>_posts/2019-06-21-welcome-to-shamindras-blog/welcome-to-shamindras-blog.Rmd</code></pre>
<p>I modified the contents and then <strong>knitted</strong> the <code>Rmd</code> file once done to refresh and save the contents.</p>
<p>Now I had locally created my first personalized content, a simple welcome post 😎.</p>
<aside><p>My welcome blog entry can be found <a href="https://github.com/shamindras/ss_personal_distill_blog/blob/master/_posts/2019-07-10-shrotriya2019welcome/shrotriya2019welcome.Rmd">here</a> for reference.</p>
</aside></section><section id="step-5-customize-your-blog-layout" class="level2 page-columns page-full"><h2 class="anchored" data-anchor-id="step-5-customize-your-blog-layout">Step 5: Customize your blog layout</h2>
<p>Now I needed to customize the blog header banner and setup links and update contents as required.</p>
<p>We will start with the <code>_site.yml</code> contents which controls the page layout. I modified the <code>_site.yml</code> file which contains default metadata settings for the blog to have the following contents:</p>
<pre class="markup"><code>name: "test_distill_blog"
title: "Shamindra's Blog"
description: |
  Shamindra Shrotriya's personal blog/ site. Some fun posts
  on math, statistics and the PhD student life.
output_dir: "_site"
navbar:
  right:
    - text: "Home"
      href: index.html
    - text: "About"
      href: about.html
    - icon: fa fa-rss
      href: index.xml
collections:
  posts:
    share: [twitter, linkedin]
base_url: https://www.shamindras.com/
output: distill::distill_article</code></pre>
<aside><p>My <code>_site.yml</code> file can be found <a href="https://github.com/shamindras/ss_personal_distill_blog/blob/master/_site.yml" target="_blank">here</a> for reference.</p>
</aside><p>I updated the <code>About.Rmd</code> file as required and knit it. This is a default <code>Rmd</code> that <code>distill</code> conveniently creates this file to give readers some background on the site purpose and of course about the author.</p>
<aside><p>My <code>About.Rmd</code> file can be found <a href="https://github.com/shamindras/ss_personal_distill_blog/blob/master/about.Rmd" target="_blank">here</a> for reference.</p>
</aside><p>No need to update the default <code>distill</code> <code>Index.Rmd</code> file that is automatically created. I simply opened it and <code>knit</code> it manually in <code>RStudio</code> to update the site contents.</p>
<p>I also updated the <code>README.md</code> to add some useful information (for any users who stumble onto the <code>github</code> page) and saved it. No need to knit anything here as it is a simple <code>markdown file</code>.</p>
<aside><p>My <code>README.md</code> can be found <a href="https://github.com/shamindras/ss_personal_distill_blog/blob/master/README.md" target="_blank">here</a> for reference.</p>
</aside><p>Now in <code>Rstudio</code> I just knit the <code>welcome.Rmd</code> post and also ran the following command in the <code>console</code></p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb16" style="background: #f1f3f5;"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rmarkdown</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://pkgs.rstudio.com/rmarkdown/reference/render_site.html">render_site</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>input <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">here</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;"><a href="https://here.r-lib.org/reference/here.html">here</a></span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
</div>
<p>The locally created <code>distill</code> blog was now created and rendered and looked like this in the <code>RStudio</code> viewer pane:</p>
<div id="step-05-02-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/images/05_01_newlyr_created_distill_blog.png" class="img-fluid figure-img" alt="Screenshot of newly created distill blog (local)"></p>
<figcaption>Newly Created Distill Blog (local)</figcaption></figure>
</div>
<p>Pretty cool - I now had a working local version of our blog in <code>RStudio</code>.</p>
</section><section id="step-6-commit-and-push-changes-to-github" class="level2"><h2 class="anchored" data-anchor-id="step-6-commit-and-push-changes-to-github">Step 6: Commit and push changes to github</h2>
<p>Note that all our changes are so far in our local git repo. We need to get this blog online! A first step is to <code>commit</code> and <code>push</code> them to our <code>github</code> repo. I did this in my local directory in the terminal as follows: in git at my terminal as follows:</p>
<div class="cell">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb17-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> add <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-A</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Add all new changes</span></span>
<span id="cb17-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> commit <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-m</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ENH: Created welcome post with date prefix, deleted default post"</span></span>
<span id="cb17-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">git</span> push origin master</span></code></pre></div></div>
</div>
<p>And the changes are now reflected in the <code>github</code> <code>master</code> branch!</p>
</section><section id="step-7-buy-a-domain-name-optional" class="level2"><h2 class="anchored" data-anchor-id="step-7-buy-a-domain-name-optional">Step 7: Buy a Domain name (optional)</h2>
<p>Although the blog was our blog contents are in a public online place i.e. <code>github</code>, I just needed to link it to a service that deploys websites from <code>github</code>. But first I needed to go buy a domain name for my blog. I went to <a href="https://domains.google/#/">Google Domains</a> and bought <code>www.shamindras.com</code> for about $15/yr.</p>
<p>There are free alternatives e.g.&nbsp;<a href="https://pages.github.com/" target="_blank">Github Pages</a>, but I wanted to have ownership on my page and found the annual fee to be reasonable with Google Domains.</p>
</section><section id="step-8-deploy-your-website-with-netlify" class="level2 page-columns page-full"><h2 class="anchored" data-anchor-id="step-8-deploy-your-website-with-netlify">Step 8: Deploy your website with Netlify</h2>
<p>Now that the domain name is bought, I just needed to deploy the newly created blog contents on the registered domain name. Enter <a href="https://www.netlify.com/" target="_blank">netlify</a>! This is a free (and awesome) deployment service. I created a personal account following the intructions on Netlify website.</p>
<p>I then logged in to Netlify and clicked on the green <code>New site from Git</code> button to get started. In the following menu I clicked the <code>Github Continuous Deployment</code> icon:</p>
<div id="step-08-01-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/images/08_01_netlify_github_continuous_deployment.png" class="img-fluid figure-img" alt="Screenshot of creating new site with Netlify"></p>
<figcaption>Creating New Site with Netlify</figcaption></figure>
</div>
<p>I then manually searched for my blog repo i.e.&nbsp;<code>ss_personal_distill_blog</code>. Initially this did not appear, so I clicked the green <strong>Configure the Netlify app on GitHub</strong> link at the bottom and gave Netlify permissions to access this site. This is so Netlify can automatically sync with the github repo and deploy changes going forward as I make them directly to my <code>github</code> blog repo.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/images/08_02_netlify_give_personal_blog_access.png" class="img-fluid figure-img" alt="Screenshot of giving Netlify new github repo access"></p>
<figcaption>Giving Netlify New Github repo Access</figcaption></figure>
</div>
<p>I clicked on my site that appears and then ensured that I selected to ensure that the <strong>Branch to Deploy</strong> option is set to <code>master</code>.</p>
<div id="step-08-03-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/images/08_03_netlify_deploy_master_branch_blog.png" class="img-fluid figure-img" alt="Screenshot of configuring Netlify build options"></p>
<figcaption>Configuring Netlify Build Options</figcaption></figure>
</div>
<aside><p>This simply means that netlify will only build the site based on what happens in my <code>master</code> branch in my <a href="https://github.com/shamindras/ss_personal_distill_blog">github repo</a></p>
</aside><p>I then clicked <strong>Deploy Site</strong> and then saw the following deployment settings:</p>
<div id="step-08-04-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/images/08_04_netlify_deployment_settings.png" class="img-fluid figure-img" alt="Screenshot of default Netlify site name"></p>
<figcaption>Default Netlify Site Name</figcaption></figure>
</div>
<p>I clicked thee <strong>Site Settings</strong> button. Looks like my site name on <code>Netlify</code> is <code>goofy-babbage-7f05c8</code>. Cute, though I’ll personalize by clicking the <strong>Change Site Name</strong> button. I changed it to <code>ss-personal-distill-blog</code> for my easy reference.</p>
<p>I clicked the <strong>Build and Deploy</strong> button next and after clicking the <strong>Edit Settings</strong> button modified the <strong>Publish directory</strong> to be <code>_site</code> as shown below:</p>
<div id="step-08-05-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/images/08_05_netlify_continous_deployment_settings.png" class="img-fluid figure-img" alt="Screenshot of setup continuous deployment with Netlify"></p>
<figcaption>Setup Continuous Deployment with Netlify</figcaption></figure>
</div>
<p>This is where all our blogposts in our <code>github</code> repo will be rendered to <code>html</code> by <code>distill</code> once we <code>knit</code> them. Netlify will just pick them up from here everytime you refresh them and deploy our website accordingly</p>
<p>Next I need to manage the domain i.e.&nbsp;tell Netlify to deploy my site on the custom domain I just purchased from Google Domains.</p>
<div id="step-08-06-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/images/08_06_netlify_adding_custom_domain.png" class="img-fluid figure-img" alt="Screenshot customize site domains with Netlify"></p>
<figcaption>Customize Site Domains with Netlify</figcaption></figure>
</div>
<p>After clicking verify we have the following domains now set, with <code>www.shamindras.com</code> being the primary domain.</p>
<div id="step-08-07-screenshot" class="quarto-figure quarto-figure-center anchored">
<figure class="figure"><p><img src="https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/images/08_07_netlify_checking_custom_domains.png" class="img-fluid figure-img" alt="Screenshot of all custom domains for site with Netlify"></p>
<figcaption>All Custom Domains for Site with Netlify</figcaption></figure>
</div>
<p>Netlify also tells me that the truncated url <code>shamindras.com</code> will also get routed to the blog. So I don’t event need to write the <code>www.</code> going forward. Thanks Netlify 🙏.</p>
</section><section id="step-9-patiently-wait-for-deployment" class="level2"><h2 class="anchored" data-anchor-id="step-9-patiently-wait-for-deployment">Step 9: Patiently wait for deployment</h2>
<p>With everything setup and configured on github/Netlify the deployment should be near instantaneous. But after about 20 mins my blog appeared at <a href="www.shamindras.com" target="_blank">www.shamindras.com</a>. So effectively Netlify and github were now talking to each other and site is setup!</p>
</section><section id="step-10-future-additions-and-extras" class="level2"><h2 class="anchored" data-anchor-id="step-10-future-additions-and-extras">Step 10: Future additions and extras</h2>
<p>Now that the blog/site is created there are a number of features I’d like to add. The most important being more blogposts and personal content. However it would also be nice to have the following features:</p>
<ul>
<li>Documenting a general <code>distill</code> blogging workflow</li>
<li>Setting up <a href="https://disqus.com/" target="_blank">Disqus</a> to enable user comments on blogposts</li>
<li>How to setup <strong>Blog Gallery</strong> for featured posts</li>
<li>How to setup an <strong>email subscription</strong> service for this blog</li>
<li>How to setup <strong>Google Analytics</strong> service for basic user activity tracking</li>
</ul>
<p>I will make sure to document the setup process as part of a series of future blog posts</p>
</section><section id="concluding-thoughts" class="level2"><h2 class="anchored" data-anchor-id="concluding-thoughts">Concluding Thoughts</h2>
<p>If you managed to read this far, then I sincerely thank you. I hope to make even better technical and personal blogposts going forward. Please feel free to leave a friendly comment below for any questions you may have or any feedback for future blogposts.</p>


</section><div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a></div></div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{shrotriya2019,
  author = {Shrotriya, Shamindra},
  title = {Setting up a {Distill} {Blog} with {Netlify}},
  date = {2019-07-11},
  url = {https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-shrotriya2019" class="csl-entry quarto-appendix-citeas">
Shrotriya, Shamindra. 2019. <span>“Setting up a Distill Blog with
Netlify.”</span> July 11, 2019. <a href="https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/">https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/</a>.
</div></div></section></div> ]]></description>
  <category>distill</category>
  <guid>https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/</guid>
  <pubDate>Wed, 10 Jul 2019 14:00:00 GMT</pubDate>
  <media:content url="https://www.shamindras.com/posts/2019-07-11-shrotriya2019distillpt1/images/08_06_netlify_adding_custom_domain.png" medium="image" type="image/png" height="79" width="144"/>
</item>
<item>
  <title>Welcome to Shamindra’s Site</title>
  <dc:creator>Shamindra Shrotriya</dc:creator>
  <link>https://www.shamindras.com/posts/2019-07-10-shrotriya2019welcome/</link>
  <description><![CDATA[ <section id="welcome---lets-get-statistical" class="level2"><h2 class="anchored" data-anchor-id="welcome---lets-get-statistical">Welcome - Let’s Get Statistical!</h2>
<p>Hi there! I’m <strong>Shamindra Shrotriya</strong>, a graduate student in the <a href="http://www.stat.cmu.edu/">Department of Statistics and Data Science</a> at the wonderful <a href="https://www.cmu.edu/">Carnegie Mellon University</a>. I’ve decided to start blogging to document my learning and development in statistics as a graduate student.</p>
<p>I’d like it to be a fun place to document interesting things I like to read about in the statistics and machine learning space (<strong>statistical theory/methodology</strong>, <strong>research</strong>, <strong>rstats</strong>, <strong>python</strong> …) as well as anything else I am generally into e.g.&nbsp;<strong>books</strong>, <strong>sports</strong> etc.</p>
<p>Feel free to pull up a chair, leave a comment, and join me so that we can explore together.</p>
<p>You can also learn more about me from my <a href="https://www.shamindras.com/data/pdfs/CV.pdf" target="_blank">CV</a>, <a href="https://www.shamindras.com/data/pdfs/resume.pdf" target="_blank">résumé</a>, and <a href="https://www.shamindras.com/software.html" target="_blank">open-source software</a> contributions.</p>
</section><section id="credits" class="level2"><h2 class="anchored" data-anchor-id="credits">Credits</h2>
<p>The credit to starting this blog goes to the following people. I hope to not disappoint and create some useful content here 🖖.</p>
<ul>
<li>The <a href="https://www.rstudio.com/" target="_blank">Rstudio team</a> - for co-developing the fantastic <a href="https://quarto.org/" target="_blank"><code>quarto</code></a> package upon which this site is based.</li>
<li>
<a href="http://www.fast.ai/">Rachel Thomas</a> for posting this <a href="http://www.fast.ai/2017/04/06/alternatives/" target="_blank">fantastic blog post</a> encouraging people like me to (finally!) create a blog</li>
<li>
<strong>My parents</strong> for encouraging to communicate my passion for statistics. I secretly think that this is their way of minimizing my passionate rants about the bootstrap in our regular Skype chats (the rants will still continue though…😄).</li>
</ul></section><div id="quarto-appendix" class="default"><section id="acknowledgments" class="level2 appendix"><h2 class="anchored quarto-appendix-heading">Acknowledgments</h2><div class="quarto-appendix-contents">
<p>I’d like to thank Salil Shrotriya for taking my profile pic which is the preview image for this post.</p>


</div></section><section class="quarto-appendix-contents" id="quarto-reuse"><h2 class="anchored quarto-appendix-heading">Reuse</h2><div class="quarto-appendix-contents"><div><a rel="license" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a></div></div></section><section class="quarto-appendix-contents" id="quarto-citation"><h2 class="anchored quarto-appendix-heading">Citation</h2><div><div class="quarto-appendix-secondary-label">BibTeX citation:</div><pre class="sourceCode code-with-copy quarto-appendix-bibtex"><code class="sourceCode bibtex">@online{shrotriya2019,
  author = {Shrotriya, Shamindra},
  title = {Welcome to {Shamindra’s} {Site}},
  date = {2019-07-10},
  url = {https://www.shamindras.com/posts/2019-07-10-shrotriya2019welcome/},
  langid = {en}
}
</code></pre><div class="quarto-appendix-secondary-label">For attribution, please cite this work as:</div><div id="ref-shrotriya2019" class="csl-entry quarto-appendix-citeas">
Shrotriya, Shamindra. 2019. <span>“Welcome to Shamindra’s Site.”</span>
July 10, 2019. <a href="https://www.shamindras.com/posts/2019-07-10-shrotriya2019welcome/">https://www.shamindras.com/posts/2019-07-10-shrotriya2019welcome/</a>.
</div></div></section></div> ]]></description>
  <category>personal</category>
  <guid>https://www.shamindras.com/posts/2019-07-10-shrotriya2019welcome/</guid>
  <pubDate>Tue, 09 Jul 2019 14:00:00 GMT</pubDate>
  <media:content url="https://www.shamindras.com/posts/2019-07-10-shrotriya2019welcome/images/about-profile-circular-scaled-hex.jpg" medium="image" type="image/jpeg"/>
</item>
</channel>
</rss>
