<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>The Lucid Manager on Lucid Manager</title>
    <link>https://lucidmanager.org/</link>
    <description>Recent content in The Lucid Manager on Lucid Manager</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-gb</language>
    <managingEditor>Peter Prevos</managingEditor>
    <webMaster>Peter Prevos</webMaster>
    
    
    <lastBuildDate>Sat, 28 Jan 2012 00:00:00 +0000</lastBuildDate>
    
	<atom:link href="https://lucidmanager.org/index.xml" rel="self" type="application/rss+xml" />
    
    
    
    <item>
      <title>Marketing for Engineers: Engineering Customer Satisfaction</title>
      <link>https://lucidmanager.org/marketing/marketing-for-engineers/</link>
      <pubDate>Fri, 31 Aug 2018 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/marketing-for-engineers/</guid>
      <description>
	
&lt;p&gt;
Like most engineers, I completed an &lt;a href=&#34;https://lucidmanager.org/tags/mba/&#34;&gt;MBA&lt;/a&gt; to broaden my skills. At our first marketing lecture, the professor asked us why we did this subject. My friend and I facetiously responded that marketing plays no role in my job as an engineer. Professor Walker subsequently proved me wrong and convinced me that marketing for engineers is as important as knowing technology. This article discusses some of the basic principles of marketing and how this relates to engineers. The following four topics delve a little deeper into what marketing is and how it relates to the work of engineers.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Definition of Marketing
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;When asking people to mention a word that they associate with marketing, they will most certainly mention advertising or selling. The scope of the marketing team in an engineering project is often limited to promoting and selling the product or service that the engineers create. The reach of marketing is, however, broader than communicating with potential and existing customers.&lt;/p&gt;
&lt;p&gt;
Just like any other social concept, marketing can mean different things. Blogger Heidi Cohen has collected &lt;a href=&#34;https://heidicohen.com/marketing-definition/&#34;&gt;72 marketing definitions&lt;/a&gt; from professional and academic sources. I have downloaded these definitions and &lt;a href=&#34;https://lucidmanager.org/data-science/marketing-wordcloud/&#34;&gt;visualised&lt;/a&gt; them in a word cloud. The more often a word is used in these definitions, the larger the text. This diagram thus shows that marketing is about products and services and customers. The cloud shows that advertising is only a small part of marketing.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/marketing-definition.png&#34; alt=&#34;Wordcloud of 72 definitions of marketing&#34; title=&#34;Wordcloud of 72 definitions of marketing&#34;/&gt;
&lt;figcaption&gt;
Wordcloud of 72 definitions of marketing.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
These definitions position marketing as a process to sell products and services to customers. Engineering is, however, often about more than selling stuff. Many disciplines of engineering seek to improve society overall. The American Marketing Association provides a more formal and broader definition of marketing:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Marketing is the activity, set of institutions, and processes for creating, communicating, delivering, and exchanging offerings that have value for customers, clients, partners, and society at large.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
American Marketing Association (2013).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
This definition consists of three major parts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;em&gt;process&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;that has &lt;em&gt;value&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;for &lt;em&gt;beneficiaries&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The following three sections of this article discuss these three aspects of this definition concerning the work of engineers.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Marketing Process
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Most introductory text books about marketing start with the marketing mix. This is a tool to structure marketing activities that helps managers considers all relevant aspects of their project. One of the most common versions of the marketing mix is the so-called 4Ps of marketing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Product (creating)&lt;/li&gt;
&lt;li&gt;Promotion (communicating)&lt;/li&gt;
&lt;li&gt;Place (distribution)&lt;/li&gt;
&lt;li&gt;Price (exchange)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The terms in brackets show how the AMA definition of marketing relates to the marketing mix. These four aspects of marketing are a simplification of the process of marketing, but they provide a good stating point to understand the foundations.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Product
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The product is the most obvious aspect of marketing for engineers. Designing and creating new products and services is the &lt;a href=&#34;https://lucidmanager.org/marketing/engineering-marketing-interface/&#34;&gt;core job of an engineer&lt;/a&gt;. Although technology is important, marketing helps engineers to create better products.&lt;/p&gt;
&lt;p&gt;
Marketing helps engineers to create products that meet the needs of customers. Engineering focuses on the technical aspects of a product such as a car or a computer. Marketing tries to understand how customers extract value from these objects.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://horizonofreason.com/culture/first-law-of-consumer-behaviour/&#34;&gt;first law of consumer behaviour&lt;/a&gt; is that customers buy stuff for what it means to them, not what it does. Consequently, this law implies that creating new products not only requires knowledge of engineering; it also requires engineers to understand psychology.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://horizonofreason.com/images/consumer-behaviour/Swish_Jeans_-_1996_-_Eva_Herzigova_by_Luca_Alban.jpg&#34; alt=&#34;Swish Jeans advertisement visualses the first law of consumer behaviour&#34; title=&#34;Swish Jeans advertisement visualses the first law of consumer behaviour&#34;/&gt;
&lt;figcaption&gt;
Luca Albanese (1996), Swish Jeans advertisement with Eva Herzigová visualses the first law of consumer behaviour.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Place
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The place component of the marketing mix can cover a range of things, such as a retail place such as a shop or a place of service, such as a barber shop. The place component also relates to the distribution of products from manufacturing to the customer. Supply chain logistics is a common problem for engineers who design facilities to ship products and services around the world or create infrastructure to manage e-commerce. The place component is therefore a common problem for engineers to solve.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Promotion
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Advertising is the most visible aspects of marketing, which is the reason the two are often seen as synonymous. The need to promote a product in a competitive market is fairly obvious. Almost certainly, without advertising and other forms of promotion, any product will languish in obscurity.&lt;/p&gt;
&lt;p&gt;
The promotion dimension of the marketing mix includes all communication with the beneficiaries of the project, whether they are customers or the community overall. In public engineering projects, the promotion dimension includes engaging the community that will benefit from the engineering works.&lt;/p&gt;
&lt;p&gt;
Building infrastructure is a highly specialised task, and engineers can become so focused on the inherent complexity of their job that they forget to consider the people that are impacted by the project. Community engagement is a crucial aspect of any public engineering works that will require marketing skills.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Price
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Determining the price of a project is a common task for engineers. Many engineers spend a lot of time estimating the cost of a future project or controlling the costs of works in progress. Engineering price estimates use technical considerations, such as the cost of materials and labour and external services.&lt;/p&gt;
&lt;p&gt;
When a marketer determines the price of a product or service, they don&amp;#39;t only look at internal aspects, but also how much the customer is willing to pay. Setting the price of a market offering requires knowledge of psychology.&lt;/p&gt;
&lt;p&gt;
In technical, commercial projects, the technical craft of the cost estimator and the psychological knowledge of the marketer to determine the best possible price.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Defining Value
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;From an economic perspective, value is the difference between costs and benefits. Traditional models of economics limit this equation to monetary value. In contrast, the marketing perspective includes aspects beyond financial costs and benefits.&lt;/p&gt;
&lt;p&gt;
The benefits of a product are first that which the product does for the customer. A car has the obvious benefit of moving people and things from A to B. The service benefit is about the ease of using the product, after-sales support and so on. Lastly, the personal benefit relates to how the product makes people feel about owning or using it.&lt;/p&gt;
&lt;p&gt;
The cost equation of a product or service is not only the monetary cost of purchase and operation, but also time and psychological energy. The time cost that a consumer incurs relates to the level of convenience they get. The energy cost relates to possible frustrations because of badly designed products.&lt;/p&gt;
&lt;p&gt;
From this model it follows that engineers can maximise customer value of a product they create by minimising the cost the consumer and by increasing the benefits.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/marketing/value-balance.png&#34; alt=&#34;The balance of customer value&#34; title=&#34;The balance of customer value&#34;/&gt;
&lt;figcaption&gt;
The balance of customer value.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Beneficiaries
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Marketing is traditionally only about customers and commercial relationships between buyers and sellers. Contemporary views of marketing are more inclusive and relate to every relationship where one party provides benefits to another. These new theories are certainly more useful to describe the contemporary complexities of commercial relationships.&lt;/p&gt;
&lt;p&gt;
The addition of society overall as beneficiary of marketing makes a lot of sense for engineers. Engineering is a method to improve the world in which we live; either through commercial products or public engineering. Whichever way, the purpose of good engineering is to add value to society overall.&lt;/p&gt;
&lt;p&gt;
Finally, marketing and engineering are perfect partners. Engineers that understand the principles of marketing are therefore able to maximise the value they provide to their customers, clients, partners, and society at large.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Why Use Emacs</title>
      <link>https://lucidmanager.org/productivity/why-use-emacs/</link>
      <pubDate>Fri, 07 May 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/why-use-emacs/</guid>
      <description>
	
&lt;p&gt;
Most people believe that the first step in becoming more productive is finding the perfect suite of software tools to manage the vast amounts of information we consume daily. I also used to hop from application to application to perform what I needed—jumping from the action list to my schedule, onward to the word processor and spreadsheet, PDF reader and so on. Wouldn&amp;#39;t it be nice if there was one program that could help you with almost all your tasks?&lt;/p&gt;
&lt;p&gt;
Welcome to the Emacs computing system, the Swiss army chainsaw of productivity.&lt;/p&gt;
&lt;p&gt;
This article explains why you should use Emacs for writing and undertake almost every task in your writing project, from ideation to publication in one application. This article is part of the &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt; starter kit, which explains how to use Emacs to write and publish articles, books, theatre or film scripts and websites. &lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the most recent configuration files on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
What is Emacs?
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The official tagline of &lt;a href=&#34;https://www.gnu.org/software/emacs/&#34;&gt;GNU Emacs&lt;/a&gt; is that it is an &amp;#34;extensible self-documenting text editor&amp;#34;. However, these words barely do justice to Emacs because they focus on its original purpose as a software development tool.&lt;/p&gt;
&lt;p&gt;
Emacs is a multi-purpose computing environment that can help you manage your information, track projects, write and publish articles, books, websites and any other text-based activity. Emacs is a text processor on steroids. The first version of Emacs was released forty years ago, which might seem obsolete software. However, a vibrant community of developers continually improves the system.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Emacs is not a productivity hack; it is a productivity hacking system.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The term text editor requires clarification because it is more akin to developing software. Emacs is not merely a text editor but a &lt;em&gt;text processor&lt;/em&gt;, which is more than just a word processor. Editing is the last step in the process of writing an article or book. Software developers refer to the whole process as editing.&lt;/p&gt;
&lt;p&gt;
When you use a computer, you more than likely write a memo in a word processor, then switch to a spreadsheet to create a graph, which you copy and paste into your memo. Next, you open your email client to send the message to your colleague. The last step is to close the action in your productivity tool. After this hard work, you might play a game and open Tetris. When using these pieces of software, you have to learn different skills for each program. You have to use the software the way the developers intended you to use it.&lt;/p&gt;
&lt;p&gt;
Working with Emacs is a different experience. You write the memo in Emacs, create the graph with Emacs, email the result and close the action with Emacs. Finally, you &lt;a href=&#34;https://www.masteringemacs.org/article/fun-games-in-emacs&#34;&gt;play the game&lt;/a&gt;, you guessed it, within Emacs. If you use Emacs, you only need to learn one piece of software, and you can configure and extend it to how you prefer to use it, not how a programmer wants you to use the software.&lt;/p&gt;
&lt;p&gt;
At first instance, Emacs looks more like an &lt;a href=&#34;https://www.urbandictionary.com/define.php?term=angry%20fruit%20salad&#34;&gt;angry fruit salad&lt;/a&gt; than a modern piece of software. The default interface looks dreary, but don&amp;#39;t let these simple looks fool you. Under the hood, Emacs is a modern and robust computing environment that is &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;fully configurable&lt;/a&gt; to your liking.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Why use Emacs?
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs is a &lt;a href=&#34;https://malleable.systems/blog/2020/04/01/the-most-successful-malleable-system-in-history/&#34;&gt;malleable software&lt;/a&gt; platform, which means that you are free to change and enhance how it works. This malleability ensures that  Emacs can perform any task that you can undertake with a keyboard. Emacs is, as such, the Swiss Army Chainsaw of productivity.&lt;/p&gt;
&lt;p&gt;
The first principle of malleable software is that it is easy to change. You can build applications using the Emacs LISP language (Elisp). This task might sound daunting, but it is about the possibility. Writing code is optional because most Emacs users share what they have developed through thousands of external packages you can freely install.&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Emacs Writing Studio&lt;/em&gt; makes it easy for you to get started as this configuration has almost everything you need to write prose.&lt;/p&gt;
&lt;p&gt;
Users can configure almost everything in the system with little knowledge of Elisp. This knowledge requirement might seem like a hurdle, but learning how to use it will give you virtually unlimited power over how you use your computer. Software should adjust to the user, not vice versa, as is the case with most modern packages.&lt;/p&gt;
&lt;p&gt;
The advantage of this approach is that you have complete freedom in using this software. You can instruct it to do almost anything you like and configure it to your specific needs. The disadvantage is that it requires a different computing approach than contemporary software. Using Emacs throws you back to the original intent of using a computer and genuine user-friendliness.&lt;/p&gt;
&lt;p&gt;
Are you ready to change the way you use your computer? To paraphrase a famous scene from The Matrix:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You take the blue Microsoft pill—the story ends, and everything stays the same. You take the purple Emacs pill—you stay in Wonderland, and I show you how deep the rabbit hole goes.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Redefining user-friendliness
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs&amp;#39; lack of a slick graphical interface might discourage new users. Unfortunately, most software developers confuse user-friendliness with a smooth design and using a mouse. However, the graphical mouse-driven approach is not user-friendly because your dominant hand constantly moves between the mouse and the keyboard. Graphically-driven software is a gilded cage. It might be pleasant, but it is still a cage.&lt;/p&gt;
&lt;p&gt;
Emacs is a &lt;a href=&#34;https://en.wikipedia.org/wiki/Plain_text&#34;&gt;plain text&lt;/a&gt; editor, which means that there is limited markup, such as images, bold and italics. Plain text is not the same as &lt;a href=&#34;https://en.wikipedia.org/wiki/Plain_English&#34;&gt;plain English&lt;/a&gt;; it relates to how the information is stored on disk. Plain text is the opposite of rich text, which includes hidden definitions for font sizes, colours and other text and formatting attributes.&lt;/p&gt;
&lt;p&gt;
Plain text is not formatted and most commonly has a &lt;code class=&#34;verbatim&#34;&gt;.txt&lt;/code&gt; extension. There are, however, many other plain text formats, such as HTML, Markdown, LaTeX and Emacs Org Mode. Windows users might be familiar with the venerable Notepad software (which is, by the way, almost as old as Emacs, but with only limited functionality).&lt;/p&gt;
&lt;p&gt;
Plain text is intelligible across computer systems, so you never have to worry about locking your writing into a proprietary format and being locked-in by a software package. The internet runs on plain text files, which is highly unlikely to change in the long term.&lt;/p&gt;
&lt;p&gt;
Text modes can display ‘graphics’. In primary school in the 1970s our teacher showed us some art printed with a computer. The art consisted of a series of keyboard characters that resemble a picture, such as this cute stegosaurus below, borrowed from the &lt;a href=&#34;https://www.asciiart.website/index.php?art=creatures/dragons&#34;&gt;ASCII Art Website&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&#34;example&#34;&gt;
                         .       .
                        / `.   .’ \
                .---.  &amp;lt;    &amp;gt; &amp;lt;    &amp;gt;  .---.
                |    \  \ - ~ ~ - /  /    |
                 ~-..-~             ~-..-~
             \~~~\.&amp;#39;                    `./~~~/
   .-~~^-.    \__/                        \__/
 _/  O    \     /               /       \  \
(_____,    `._.&amp;#39;               |         }  \/~~~/
 `----.          /       }     |        /    \__/
       `-.      |       /      |       /      `. ,~~|
           ~-.__|      /_ - ~ ^|      /- _      `..-&amp;#39;   f: f:
                |     /        |     /     ~-.     `-. _||_||_
                |_____|        |_____|         ~ - . _ _ _ _ _&amp;gt;
&lt;/pre&gt;
&lt;p&gt;
The main benefit of using plain text over rich text is that it provides a distraction-free writing environment. In word processors, the screen looks like a printed page. While this might be aesthetically pleasing, it distracts the writer from creating content and instead fiddle with the design.&lt;/p&gt;
&lt;p&gt;
Only a tiny part of written text is printed on paper, so the &lt;a href=&#34;https://en.wikipedia.org/wiki/WYSIWYG&#34;&gt;What You See is What You Get&lt;/a&gt; (WYSIWYG) approach does not make much sense in the digital age. Plain text writing follows a different philosophy and uses the &lt;a href=&#34;https://en.wikipedia.org/wiki/WYSIWYM&#34;&gt;What You See Is What You Mean&lt;/a&gt; (WYSIWYM) approach.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
What You See is What You Mean
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Graphical interfaces simulate the physical world by making objects on the screen look like pieces of paper and folders on a desk. You point, click and drag documents into folders; documents appear as they would on paper and when done, they go into the rubbish bin. Graphical interfaces are a magic trick that makes you believe you are doing something physical. This approach might be convenient, but it moves the user away from understanding how a computer works.&lt;/p&gt;
&lt;p&gt;
The WYSIWYG approach distracts the mind from the content and lures the user into fiddling with style instead of writing text. Office workers around the globe waste a lot of time trying to format or typeset documents. Following the Emacs way will help you become more productive by not worrying about the document’s design until you complete the text. As I write this book, it only takes a few keystrokes to convert the text into a fully formatted ebook or web page, ready for distribution.&lt;/p&gt;
&lt;p&gt;
As I write this website, I don’t see what it will look like in published form. In Emacs, I only see text, images and some instructions for the computer on what the final product should look like (the What You Mean  part of WYSIWYM). This approach lets me focus on writing text instead of worrying about the end product.&lt;/p&gt;
&lt;p&gt;
The image below shows what this looks like in action. The left side shows this article while writing it. The right side shows the result after creating the content. The colours on the screen indicate the function of the text, such as headers, italic text, or metadata, instead of the actual colour. The fonts are uniform, and Org mode hides images to allow me to focus on the text. Org mode can show the images inside the text with a simple keystroke. The image and the text remain separate files. I rarely view a live preview of the eventual output, as that negates the benefits of writing in plain text. &lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/wysiwym.jpg&#34; alt=&#34;The WYSIWYM approach with Emacs Org mode and Hugo.&#34; title=&#34;The WYSIWYM approach with Emacs Org mode and Hugo.&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
The WYSIWYM approach: Left: this article as I am writing it in Emacs. Right: The exported result in Firefox.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Principles of writing plain text
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;When I export this document to a web page or any other format, a template and/or style sheet are attached to the text, which define the design of the published work. Another advantage of this approach is that your text can be easily exported to multiple formats.&lt;/p&gt;
&lt;p&gt;
In my workflow, the &lt;a href=&#34;https://lucidmanager.org/productivity/create-websites-with-org-mode-and-hugo/&#34;&gt;Hugo software&lt;/a&gt; converts the text in Emacs to a usable website using my &lt;a href=&#34;https://github.com/pprevos/hugo-thirdhemisphere&#34;&gt;custom template&lt;/a&gt; and a CSS style sheet. When I convert a text to PDF, the LaTeX software attaches a document class to the text to define the layout and typography. Each export format has its own method to convert plain text to published content.&lt;/p&gt;
&lt;p&gt;
To publish any text your text will have four elements:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Content: The text itself.&lt;/li&gt;
&lt;li&gt;Semantics: Context (markers for headings, rich text, tables, images and so on).&lt;/li&gt;
&lt;li&gt;Template: Translates the structure of the document&lt;/li&gt;
&lt;li&gt;Style sheet: The design of the publication.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In a WYSIWYG word processor, all these elements are embedded in one file, but only the text is visible with the semantics and style sheet applied to show the printed result. In plain text, the content and semantics are directly visible, depending on the text format. Please note that &lt;code class=&#34;verbatim&#34;&gt;TXT&lt;/code&gt; files don’t contain any semantics; they are the simplest form of plain text. The table below shows how italic text is signified in four common plain text formats.&lt;/p&gt;
&lt;figure&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Format&lt;/th&gt;
&lt;th&gt;Italic semantics&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;https://www.w3.org/&#34;&gt;HTML&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;&amp;lt;i&amp;gt;Italic Text&amp;lt;/i&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;https://www.latex-project.org/&#34;&gt;LaTeX&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;\emph{Italic Text}&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;https://www.markdownguide.org/&#34;&gt;Markdown&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;**Italic Text**&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;https://orgmode.org/&#34;&gt;Org mode&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;/Italic Text/&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;figcaption&gt;
Italic text in common plain text formats.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The style sheet exists separate from the text. This means that you can easily export your document to various formats with fine control over the end result. &lt;a href=&#34;https://lucidmanager.org/productivity/publishing-with-org-mode-export/&#34;&gt;Org mode has a versatile export engine&lt;/a&gt; that allows you to convert your writings to a website, ebook or physical book with just a few keystrokes and some configuration.&lt;/p&gt;
&lt;p&gt;
These are only some example of using plain text for writing projects. Many other markup and markdown formats are available to turn your thoughts into a published work. For example, &lt;a href=&#34;https://lilypond.org/index.html&#34;&gt;LilyPond&lt;/a&gt; is a plain text music notation format and &lt;a href=&#34;https://fountain-mode.org/&#34;&gt;Fountain&lt;/a&gt; is a format to write screenplays.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
The Emacs learning curve
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The second hurdle is the steep learning curve. To make Emacs work for you, you will need to learn the &lt;a href=&#34;https://lucidmanager.org/productivity/getting-started-with-emacs/&#34;&gt;basics principles&lt;/a&gt; and learn some of the associated add-on packages. As Emacs is old software, some default settings and terminology differ from contemporary graphical software. For example, opening a file is &amp;#39;visiting a file&amp;#39;. Pasting a text is&amp;#39; yanking&amp;#39;; cutting it is the same as killing. Emacs terminology is certainly more poetic than the current handicraft terms, such as cutting and pasting. Closing Emacs itself is called killing.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The steeper the learning curve, the bigger the reward.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The key to learning Emacs is to not get overwhelmed by the virtually infinite configuration options but to only learn those bits of functionality that you need to do what you need to do. Even without any configuration, you can do a lot with Emacs. &lt;/p&gt;
&lt;p&gt;
Learning some Elisp enables you to configure the software to your wishes. While that might sound daunting, you can simply copy and paste (kill and yank) examples from the Internet. Even better, &lt;em&gt;Emacs Writing Studio&lt;/em&gt; is a starter kit to shorten this learning curve as it optimises Emacs for the writing workflow.&lt;/p&gt;
&lt;p&gt;
The articles on this website guide you through what you need to know for Emacs to become your favourite writing tool. You can also download and use the complete configuration file from these articles to get you started.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Advantages of using Emacs
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In summary, these are some of the significant advantages of using Emacs to create written content:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;One piece of software to undertake most of your computing activities makes you more productive because you only need to master one system.&lt;/li&gt;
&lt;li&gt;You store all your information in plain text files. You will never have any problems with compatibility due to esoteric file formats.&lt;/li&gt;
&lt;li&gt;You can modify almost everything in the software to suit your workflow.&lt;/li&gt;
&lt;li&gt;Emacs runs on all major operating systems: All Linux flavours, &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-windows/&#34;&gt;Windows&lt;/a&gt;, &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-chromebook/&#34;&gt;Chrome OS&lt;/a&gt;, and macOS.&lt;/li&gt;
&lt;li&gt;Emacs is open source and supported by a large community willing to help.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Limitations of Emacs
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;After singing the praises of this multi-functional editor, you would almost think that Emacs is the omnipotent god of software. Some people even have established the &lt;a href=&#34;https://www.emacswiki.org/emacs/ChurchOfEmacs&#34;&gt;Church of Emacs&lt;/a&gt; as a mock religion to express their admiration.&lt;/p&gt;
&lt;p&gt;
Emacs can display images and integrate them with text. Still, it has limited functionality to create or &lt;a href=&#34;https://lucidmanager.org/productivity/using-emacs-image-dired/&#34;&gt;modify graphical files&lt;/a&gt;. If you need to create or edit pictures, consider using GIMP (&lt;a href=&#34;https://www.gimp.org/&#34;&gt;GNU Image Manipulation Program&lt;/a&gt;). Video content is currently not supported and cannot be easily integrated with text other than hyperlinks to a file or web page.&lt;/p&gt;
&lt;p&gt;
The focus on text limits working in Emacs to serial thinking to the exclusion of &lt;a href=&#34;https://en.wikipedia.org/wiki/Visual_thinking&#34;&gt;visual thinking&lt;/a&gt;. I like to scribble little diagrams in my notebook to help me solve problems. Emacs is limited to text. But you can import your doodles as images.&lt;/p&gt;
&lt;p&gt;
The second disadvantage is that Emacs does not have a fully operational web browser. There are packages to surf the web within Emacs, but they have limited functionality.&lt;/p&gt;
&lt;p&gt;
Emacs has the risk of becoming a productivity sink. But remember that just because you can configure everything does not mean you should. Don&amp;#39;t spend too much time worrying about the minutia of your workflow. Spend this time inside your workflow and create new things. Most productivity hacks do not affect your output because you write with your mind, not the keyboard.&lt;/p&gt;
&lt;p&gt;
The best way to learn Emacs is one step at a time. Start with a simple configuration and then build on this starting point once you need further enhancements.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, and everybody has personal preferences on how to undertake a task and configure Emacs. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The next article discusses &lt;a href=&#34;https://lucidmanager.org/productivity/getting-started-with-emacs/&#34;&gt;getting started with Emacs&lt;/a&gt; and introduces the basic principles.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Getting Started with Emacs</title>
      <link>https://lucidmanager.org/productivity/getting-started-with-emacs/</link>
      <pubDate>Fri, 07 May 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/getting-started-with-emacs/</guid>
      <description>
	
&lt;p&gt;
Emacs has a reputation for being hard to use. This article crushes that myth and describes getting started with Emacs without any configuration. Once you understand the basic principles, you will soon play the software like a virtuoso plays the piano.&lt;/p&gt;
&lt;p&gt;
Emacs will take some getting used to because the first version of the software was released almost forty years ago. Although Emacs is one of the oldest continuously developed software packages, it has evolved into a versatile contemporary computing system. But, just like biological organisms have vestigial features that originated in the distant past, Emacs also has some quirky features and terminology that stem from its long history. This article guides you through the basics of using Emacs to get you started by explaining the principles.&lt;/p&gt;
&lt;p&gt;
This article is an abridged chapter of &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt; (EWS) — a configuration, website and book that explains how to use Emacs to undertake research and write and publish articles, books, and websites. Emacs Writing Studio is available as an e-book with expanded content from your favourite retailer.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Installing Emacs
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The first point of call is to install Emacs on your computer. The Emacs computing environment works on almost all operating systems, but best integrates with GNU / Linux. You can install it on your Linux distribution with the relevant package manager. If you use another OS, follow the links below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://lucidmanager.org/productivity/emacs-windows/&#34;&gt;Windows&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://lucidmanager.org/productivity/emacs-chromebook/&#34;&gt;Chromebook&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://brew.sh/&#34;&gt;Apple&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The EWS configuration is independent of your operating system.&lt;/p&gt;
&lt;p&gt;
This video by Marcus Birkenkrahe provides a succinct overview of installing Emacs on Windows or MacOS.&lt;/p&gt;
&lt;p&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/maNgdDV7cIA?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
Emacs is also an interface to various other free software packages for such tasks as checking spelling, read PDF files or typesetting and formatting (e)books. The &lt;a href=&#34;https://github.com/pprevos/emacs-writing-studio/&#34;&gt;EWS GitHub repository&lt;/a&gt; contains a list of these programs and their function.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Getting Started with Emacs
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Now that you have cleared the first hurdle, it is time to open Emacs and look around. When you first start Emacs, you see a splash screen with links to help files. Click on the link to read the tutorial, or press the &lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt; button to remove the screen and keep reading this article.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/emacs-splash-screen.png&#34; alt=&#34;The Emacs splash screen.&#34; title=&#34;The Emacs splash screen.&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
The Emacs splash screen (Emacs 29.1).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Pressing &lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt; is the standard method to close (kill) read-only screens in Emacs. When the splash screen closes, you enter the ’scratch buffer’, which you can use for temporary notes. Emacs does not save the content of the scratch buffer, so don’t start writing your dissertation just yet.&lt;/p&gt;
&lt;p&gt;
Emacs has a mouse-driven menu system, with drop-down menus on the top of the screen. Most users ignore this convenience and rely on keyboard-driven instructions. There is no real agreement on whether using a keyboard or a mouse is most efficient. What is clear is that regularly moving your hands between the keyboard and the mouse can be annoying and impede your workflow. When you misspell a word in most software, you move your hand from the keyboard to the mouse, click on the offending word and select the desired spelling. In Emacs, you use one keystroke and the misspelled word automatically changes to the most likely correct version, and you keep on writing.&lt;/p&gt;
&lt;p&gt;
One advantage of the menu system is that it helps discovering functionality in Emacs, but you don&amp;#39;t need a mouse for this. Just press &lt;code class=&#34;verbatim&#34;&gt;F10&lt;/code&gt; and use the arrow keys to find what you need.&lt;/p&gt;
&lt;p&gt;
Emacs is mostly written in the Emacs Lisp (Elisp) language, which means that every action runs an Elisp function. Most functions are only for internal processes, but the user can call some functions (the commands) interactively. So every command is a function, but not every function is a command.&lt;/p&gt;
&lt;p&gt;
The default way to activate commands is by typing &lt;code&gt;ALT-x&lt;/code&gt; and then the name of the command and the enter key. For example type &lt;code&gt;ALT-x tetris ENTER&lt;/code&gt; to play tetris. Don&amp;#39;t get too distracted, just press &lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt; three times to exit the game.&lt;/p&gt;
&lt;p&gt;
Typing the full function name every time is too much work for us Emacs users who seek ultimate efficiency. The &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-completion-system/&#34;&gt;minibuffer completion&lt;/a&gt; system helps you to find the command you seek. In standard Emacs, that would be &lt;code&gt;ALT-x tet TAB ENTER&lt;/code&gt;. But that method is not on the efficiency frontier. To meet this demand, Emacs uses keyboard shortcuts.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Working with the keyboard
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs is a keyboard-driven system. You can use the mouse, but you;ll find that there is no need to remove your hand from the keyboard. The standard computer keyboard has five types of keys: alphanumeric / punctuation, editing, function, escape key, and modifier keys. &lt;/p&gt;
&lt;p&gt;
Alphanumeric and punctuation keys activate the &lt;code&gt;self-insert&lt;/code&gt; function, which adds text to the computer’s memory and displays it on the screen. The editing keys, such as arrow keys, page up and down, delete, backspace, enter and tab, do what it says on their label. These are the only keys you need to writing prose, but we like to do more than insert text.&lt;/p&gt;
&lt;p&gt;
Function and multimedia keys perform specified tasks. For example, pressing &lt;code class=&#34;verbatim&#34;&gt;F10&lt;/code&gt; in Emacs show the menu bar. Multimedia keys activate predefined tasks, such as increasing the screen brightness or playing music.&lt;/p&gt;
&lt;p&gt;
The escape key is the most potent key on the board. Like Dorothy’s Ruby Slippers in the &lt;em&gt;Wizard of Oz&lt;/em&gt;, this key gets you out of trouble by clicking it three times.&lt;/p&gt;
&lt;p&gt;
These keys cover about 100 options, but more are needed to manage the thousands of possible commands you might want your computer to perform. The modifier keys on a modern PC or Apple keyboard are shift, control, alt/option and windows/command. Some programmable keyboards might have additional modifier keys, such as &lt;code class=&#34;verbatim&#34;&gt;Fn&lt;/code&gt;. Modifier keys have no effect when pressed by themselves. As the name suggests, these keys modify other keys when pressed simultaneously. In Emacs vocabulary, these are called chords.&lt;/p&gt;
&lt;p&gt;
Emacs documentation uses a special notation for key chords. Some of the Emacs terminology for modifier keys stems from a time when the current standard keyboard layout did not yet exist. What we now call the Alt key used to be the &lt;em&gt;Meta&lt;/em&gt; key. What was the &lt;em&gt;Super&lt;/em&gt; key in the olden days is now the Windows key on PC keyboards. The image below shows an old Space-Cadet keyboard with now non-existing modifier keys.&lt;/p&gt;
&lt;figure&gt;
&lt;a title=&#34;Retro-Computing Society of Rhode Island, CC BY-SA 3.0 &amp;lt;https://creativecommons.org/licenses/by-sa/3.0&amp;gt;, via Wikimedia Commons&#34; href=&#34;https://commons.wikimedia.org/wiki/File:Space-cadet.jpg&#34;&gt;&lt;img width=&#34;960&#34; alt=&#34;Space-cadet&#34; src=&#34;https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Space-cadet.jpg/960px-Space-cadet.jpg?utm_source=commons.wikimedia.org&amp;utm_campaign=index&amp;utm_content=thumbnail&#34;&gt;&lt;/a&gt;
&lt;figcaption&gt;
Symbolics LM-2 Lisp machine space-cadet keyboard.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Emacs documentation uses abbreviations, such as &lt;code class=&#34;verbatim&#34;&gt;C-a&lt;/code&gt;, which stands for the Control and &lt;code class=&#34;verbatim&#34;&gt;a&lt;/code&gt; keys, or &lt;code class=&#34;verbatim&#34;&gt;M-a&lt;/code&gt;, which stands for &lt;code class=&#34;verbatim&#34;&gt;Alt-a&lt;/code&gt;. Each modifier key has its own letter, as shown in the table below. The dash indicates that the keys are pressed while keeping the modifier key down. You can combine modifier keys, occasionally leading to awkward combinations, such as &lt;code class=&#34;verbatim&#34;&gt;C-M-S a&lt;/code&gt; (Control, Alt and Shift &lt;code class=&#34;verbatim&#34;&gt;a&lt;/code&gt;), which requires the nimble fingers of a sleight-of-hand artist to execute smoothly. The shift modifier is often not mentioned in Emacs notation, &lt;code class=&#34;verbatim&#34;&gt;C-M A&lt;/code&gt; is the same as &lt;code class=&#34;verbatim&#34;&gt;C-M-S a&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
The most critical chord is &lt;code class=&#34;verbatim&#34;&gt;C-g&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;keyboard-quit&lt;/code&gt;), which cancels a partially typed command or one still running. This command can quit running functions, unlike the triple escape key.&lt;/p&gt;
&lt;p&gt;
The Windows key on PC keyboards is mapped to the old Super key. Your operating system uses Chords with this key, so Emacs does not use this modifier by default. Lastly, the Hyper key is a leftover from the old keyboards.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Modifier&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Shift&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;S-8&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;*&lt;/code&gt; sign on US keyboard&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Control&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-e&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;End of line&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Alt&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;M-d&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Delete (kill) word&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;s-&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Used by the operating system&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hyper&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;H-&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Not mapped to regular keys&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
These modifier keys provide thousands of possible key chords to instruct Emacs. But wait, there is more. Emacs also uses prefix keys. When you press these, the system will wait for further input. For example, &lt;code class=&#34;verbatim&#34;&gt;C-x C-f&lt;/code&gt; means that you first press Control and &lt;code class=&#34;verbatim&#34;&gt;x&lt;/code&gt; and then Control and &lt;code class=&#34;verbatim&#34;&gt;f&lt;/code&gt;, the default sequence for finding a file to open with the &lt;code&gt;find-file&lt;/code&gt; function. The standard prefix keys are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;C-x&lt;/code&gt;: Mostly used for built-in Emacs commands&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;C-c&lt;/code&gt;: Mostly used by packages&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;C-h&lt;/code&gt;: Help functions&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;M-x&lt;/code&gt;: Execute commands&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This means that the standard &lt;a href=&#34;https://en.wikipedia.org/wiki/IBM_Common_User_Access&#34;&gt;Common User Access&lt;/a&gt; keyboard shortcuts for cutting text (&lt;code class=&#34;verbatim&#34;&gt;Ctrl+x&lt;/code&gt;) does not work in Emacs.&lt;/p&gt;
&lt;p&gt;
If you want to find out which command relates to a specific shortcut, then use &lt;code class=&#34;verbatim&#34;&gt;C-h k&lt;/code&gt; and enter the key sequence to see what it is bound to for the mode you currently use. If you want to read the Emacs tutorial, the use &lt;code class=&#34;verbatim&#34;&gt;C-h t&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
Two more prefix keys need mentioning. Lots of commands have alternative states, which means that they can do things in different ways. You activate an alternative state by adding &lt;code class=&#34;verbatim&#34;&gt;C-u&lt;/code&gt; before the regular key-chord.&lt;/p&gt;
&lt;p&gt;
Lastly, adding a number after &lt;code class=&#34;verbatim&#34;&gt;Control&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;Alt&lt;/code&gt; repeats the next keystroke. For example &lt;code class=&#34;verbatim&#34;&gt;M-80 *&lt;/code&gt; adds eighty asterisks to your text.&lt;/p&gt;
&lt;p&gt;
You can change how a keyboard behaves at three levels. Some high-end keyboards are programmable and let you define the output of each key. You could map the right control key as the Hyper key so you can use it in key chords. At the second level, your operating system interprets the input from the keyboard. In Windows, &lt;code class=&#34;verbatim&#34;&gt;s-E&lt;/code&gt; opens the file explorer, but you can erase this binding so that it becomes available in Emacs. Each operating system has its own methods to change keyboard maps (keymaps). Some experienced Emacs users remap the caps lock key to act as the control key to make it easier to use.&lt;/p&gt;
&lt;p&gt;
Last but not least, you can define keys within Emacs itself. Some people don’t like the Emacs defaults because it requires frequent use of the &lt;code class=&#34;verbatim&#34;&gt;ALT&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;Control&lt;/code&gt; keys. These people suggest that repetitive use of these keys causes a strain injury, the dreaded’ Emacs pinky’. Several packages, such as &lt;a href=&#34;https://github.com/emacs-evil/evil&#34;&gt;Evil Mode&lt;/a&gt; or &lt;a href=&#34;https://www.emacswiki.org/emacs/ViperMode&#34;&gt;Viper mode&lt;/a&gt;, exist within the Emacs ecosystem that changes the default keybindings to a different model. &lt;em&gt;Emacs Writing Studio&lt;/em&gt; follows the standard conventions.&lt;/p&gt;
&lt;p&gt;
You might be dazzled by this detailed description of how Emacs uses the keyboard. Don’t worry about it for now. You will gradually understand its intricacies and eventually drive the system like a virtuoso.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Modes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs is a versatile tool that accomplishes the different tasks it is capable of through the use of major and minor modes. &lt;/p&gt;
&lt;p&gt;
A major mode determines the main functionality for an open buffer. Each buffer has at least one major mode and each major mode has its own functionality and key bindings. The articles on this website mainly describe how to use &lt;a href=&#34;https://orgmode.org/&#34;&gt;Org mode&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
A major mode is like opening an app within the Emacs environment. For example, Org mode provides a task management system and publication tools. Artist mode is a quirky tool in Emacs to create plain text drawings with the mouse and keyboard. Other common plain text writing major modes are plain text, Markdown and Fountain. All major modes provide specialise functions for working with these text formats. All major modes share the same underlying Emacs functionality, such as copying and pasting (killing and yanking). &lt;/p&gt;
&lt;p&gt;
Minor modes provide additional functionality, such as spell-checking, text completion or displaying line numbers. A minor mode is an auxiliary program that enhances the functionality of a major mode. While each buffer has only one major mode, a buffer can have one or more active minor modes. A minor mode can also apply to the whole Emacs session.&lt;/p&gt;
&lt;p&gt;
Each mode defines how a buffer displays text. For example, each heading level in Org mode has a different colour (depending on your theme). The different colours and fonts help finding your way around the text. However, how the text looks on the screen differs from how it will look when you print it or export it to a PDF of another format. This is a &lt;em&gt;What you See is What You Mean&lt;/em&gt; approach, which &lt;a href=&#34;https://lucidmanager.org/productivity/why-use-emacs/&#34;&gt;this article explains in more detail&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
Emacs automatically selects the relevant major mode using the extension of the file and displays it in the mode line below each buffer. Minor modes have to be enabled explicitly on top of a major mode.&lt;/p&gt;
&lt;p&gt;
The available keyboard shortcuts depend on the major and minor modes that are active at the time. Each mode can have its own keymap. Some keymaps are global and apply to the whole of Emacs, other maps are specific to a mode. Some shortcuts remain the same for all modes (such as &lt;code class=&#34;verbatim&#34;&gt;M-u&lt;/code&gt;, which converts a word to uppercase), unless a mode overrides this binding. Packages can change or add shortcuts, depending on the required functionality. So a shortcut like &lt;code class=&#34;verbatim&#34;&gt;C c c-c&lt;/code&gt; is used by different modes for different actions, depending on the context it is used.&lt;/p&gt;
&lt;p&gt;
If you are lost and like to see all possible keyboard shortcuts for the active buffer (screen), call &lt;code class=&#34;verbatim&#34;&gt;C-h b&lt;/code&gt; to view a list of all available shortcuts. Note that some shortcuts can relate to a specific mode and will thus only work when the mode is active.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Frames and Windows
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;When you open Emacs, the software runs within a frame. In most operating systems, a frame is called a window. To confuse matters further, you can divide an Emacs frame into windows. You can also open multiple frames on a desktop, for example, one on each monitor. &lt;/p&gt;
&lt;p&gt;
By default, a frame has one window. You can duplicate the current window horizontally or vertically by pressing &lt;code class=&#34;verbatim&#34;&gt;C-x 2&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;C-x 3&lt;/code&gt; (&lt;code&gt;split-window-below&lt;/code&gt; and &lt;code&gt;split-window-right&lt;/code&gt;). The &lt;code class=&#34;verbatim&#34;&gt;C-x 0&lt;/code&gt; shortcut (&lt;code&gt;delete-window&lt;/code&gt;) removes your current window, and &lt;code class=&#34;verbatim&#34;&gt;C-x 1&lt;/code&gt; removes all other windows (&lt;code&gt;delete-other-windows&lt;/code&gt;), so you work in the full frame again.&lt;/p&gt;
&lt;p&gt;
When splitting a window, the same buffer can appear on both sides, each with point at a different location in the text. Using &lt;code class=&#34;verbatim&#34;&gt;M-x&lt;/code&gt; &lt;code&gt;follow-mode&lt;/code&gt; flows the text so it becomes like a two-column document. This function toggles the follow function as a minor mode, so you can switch it on and off with the same function.&lt;/p&gt;
&lt;p&gt;
To move between windows, use the &lt;code class=&#34;verbatim&#34;&gt;C-x o&lt;/code&gt; shortcut (&lt;code&gt;other-window&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;
The bottom of each window has a mode line, and the bottom of the frame contains the mini buffer. The mode line provides information, such as the open file name, current line number and other helpful information. The mini buffer is where Emacs provides feedback or seeks your input.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/emacs-frame-components.jpg&#34; alt=&#34;Emacs frame with three windows.&#34; title=&#34;Emacs frame with three windows.&#34;/&gt;
&lt;figcaption&gt;
Emacs frame with three windows.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Buffers
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A buffer holds the text that is displayed in a window. Buffers can also contain a user interface or output from functions. The name of the buffer or its associated file is shown in the status bar at the bottom of the window. Special buffers, such as &lt;code class=&#34;verbatim&#34;&gt;*Messages*&lt;/code&gt; start with an asterisk. This buffer shows the output of any commands you run.&lt;/p&gt;
&lt;p&gt;
You can have multiple buffers open at the same time so that you can easily switch between buffers. Emacs is highly stable and some Emacs users have hundreds of open buffers as they rarely need to restart the program. The &lt;code class=&#34;verbatim&#34;&gt;C-x b&lt;/code&gt; shortcut (&lt;code&gt;switch-to-buffer&lt;/code&gt;) lets you select another buffer to move to.&lt;/p&gt;
&lt;p&gt;
With the &lt;code class=&#34;verbatim&#34;&gt;C-x left&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;C-x right&lt;/code&gt; key sequences (&lt;code&gt;previous-buffer&lt;/code&gt; and &lt;code&gt;next-buffer&lt;/code&gt;), you can move between buffers in chronological activation order.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Files
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Most buffers, except those surrounded by an asterisk, are linked to a file. Like office software, you are working on the version in memory (the buffer), and the previous version is on disk (the file). Emacs works precisely the same way.&lt;/p&gt;
&lt;p&gt;
Opening files in Emacs is called &lt;em&gt;visiting a file&lt;/em&gt;. You first need to find it with the &lt;code&gt;find-file&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-x C-f&lt;/code&gt;) to visit a file.  Emacs will open the file and display the contents in the buffer. Emacs will create a new file when you type a name that does not yet exist. If you open a directory, Emacs will show the contents of that directory in &lt;a href=&#34;https://lucidmanager.org/productivity/manage-files-with-emacs/&#34;&gt;the file manager&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
Emacs will ask you to nominate a file or folder in the mini buffer. When you hit the &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; button twice, all the available files and folders appear in the mini buffer. To complete the file name, start typing the filename and hit &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; again.&lt;/p&gt;
&lt;p&gt;
After you complete your edits, &lt;code class=&#34;verbatim&#34;&gt;C-x C-s&lt;/code&gt; (&lt;code&gt;save-buffer&lt;/code&gt;) saves your buffer. To save all open buffers, press &lt;code class=&#34;verbatim&#34;&gt;C-x s&lt;/code&gt; (&lt;code&gt;save-some-buffers&lt;/code&gt;) and follow the prompts in the minibuffer at the bottom of the screen. To save a buffer under a new name, you can use &lt;code class=&#34;verbatim&#34;&gt;C-x C-w&lt;/code&gt;.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Keystroke&lt;/th&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-x C-f&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;find-file&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Find (open) a file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-x C-s&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;save-buffer&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Save the current buffer to its file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-x s&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;save-some-buffers&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Save all open buffers (with confirmation)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-x C-w&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;write-file&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Write current buffer to a file (Save as)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Exiting Emacs
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;After your first practice round, it is time to close (kill) Emacs. The &lt;code class=&#34;verbatim&#34;&gt;C-x C-c&lt;/code&gt; kills the Emacs session, checking for unsaved buffers first (&lt;code&gt;save-buffers-kill-terminal&lt;/code&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
Learn more
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This article only discussed the basic principles of using Emacs. If you like to know more, then I encourage you to follow the built-in Emacs tutorial, which you activate with &lt;code class=&#34;verbatim&#34;&gt;C-h t&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
There are many great YouTube videos that explain how to use Emacs. The video below by David Williamson provides a detailed introduction into how to use Emacs. The blog posts and YouTube videos by &lt;a href=&#34;https://protesilaos.com/&#34;&gt;Protesilaos Stavrou&lt;/a&gt; also provide useful insights.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/48JlgiBpw_I?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
The Absolute Beginner&amp;#39;s Guide to Emacs (System Crafters).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-10&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
You can do a lot with Emacs without any configuration, but you will need to configure the system to make it behave how you want it to. The next article introduces the principles of &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;configuring Emacs&lt;/a&gt; to convert it into your own writing studio.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Configure Emacs Writing Studio</title>
      <link>https://lucidmanager.org/productivity/configure-emacs/</link>
      <pubDate>Fri, 07 May 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/configure-emacs/</guid>
      <description>
	
&lt;p&gt;
Commercial software is usually good at doing one thing really well. You write documents in LibreOffice Writer or Google Docs. You create presentation slides in PowerPoint or Keynote and manage tasks with Trello or Todoist. If you are lucky, the developers let you change the configuration to customise the software’s behaviour and optimise your workflow. In most cases, however, you are bound by the choices the developers have made for you. Linking the information that is held in these programs can be problematic. Emacs does not have such limitations. You do almost all tasks in one program, but you have to configure it to make it behave the way you want.&lt;/p&gt;
&lt;p&gt;
This article explains how to configure Emacs to transform it into a personalised productivity suite for authors. Please note that this configuration assumes that you are using the latest version of Emacs, which at the time of writing is 29.4.&lt;/p&gt;
&lt;p&gt;
This article is part of &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt;, a book that explains how to use Emacs to undertake research and write and publish articles, books, and websites. Emacs Writing Studio is also available as an e-book from your favourite retailer.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Configuring Emacs
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A vanilla version of Emacs has a lot of functionality out of the box and you could easily write a book without any configuration. But to truly leverage its capabilities, Emacs needs external packages and additional configuration.&lt;/p&gt;
&lt;p&gt;
Some Emacs users use pre-configured systems, such as &lt;a href=&#34;https://github.com/hlissner/doom-emacs&#34;&gt;Doom Emacs&lt;/a&gt;,  or &lt;a href=&#34;https://github.com/syl20bnr/spacemacs/tree/develop&#34;&gt;Spacemacs&lt;/a&gt;, or one of the other &lt;a href=&#34;https://www.emacswiki.org/emacs/StarterKits&#34;&gt;starter kits&lt;/a&gt;. While these configurations are helpful, they sometimes provide ‘everything but the kitchen sink’.&lt;/p&gt;
&lt;p&gt;
On the other side of the spectrum, you can configure your system from scratch, which can become a productivity sink as you wade your way through highly technical instructions written by experts.&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Emacs Writing Studio&lt;/em&gt; (EWS) seeks the golden mean by providing a minimal configuration. The main objective of EWS is to get you started writing in Emacs and generate sufficient curiosity for you to further develop your skills and keep improving your configuration.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Initialisation File
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;When you start Emacs, it loads the &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html&#34;&gt;initialisation file&lt;/a&gt;, or init file in short. This file contains Lisp code that configures Emacs and loads additional packages. &lt;/p&gt;
&lt;p&gt;
The first time you start Emacs, it will create the configuration directory. The init file lives in this location, which will also contain the packages and other files needed to personalise your system.&lt;/p&gt;
&lt;p&gt;
Emacs looks for a file called &lt;code class=&#34;verbatim&#34;&gt;.emacs&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;.emacs.el&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;init.el&lt;/code&gt;. The dot in front of the file means that it is hidden from view to prevent cluttering your directories. The location of the configuration folder depends on your operating system and Emacs version. The Emacs help functionality can tell you where to store the &lt;code class=&#34;verbatim&#34;&gt;init.el&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;
Type &lt;code class=&#34;verbatim&#34;&gt;C-h v&lt;/code&gt; (&lt;code&gt;describe-variable&lt;/code&gt;), and type &lt;code class=&#34;verbatim&#34;&gt;user-emacs-directory&lt;/code&gt; and Enter (or &lt;code class=&#34;verbatim&#34;&gt;user-e TAB&lt;/code&gt;) in the minibuffer at the bottom of the screen. The help buffer that now appears provides the correct folder name, for example &amp;#34;&lt;code class=&#34;verbatim&#34;&gt;Its value is &amp;#34;~/.config/emacs/&lt;/code&gt;&amp;#34;.&lt;/p&gt;
&lt;p&gt;
You can now visit (open or create) the &lt;code class=&#34;verbatim&#34;&gt;init.el&lt;/code&gt; file in your Emacs directory and copy and write your configuration. Your init file will become active after you restart Emacs (use &lt;code&gt;M-x restart-emacs&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;
You can download the complete EWS configuration file from GitHub and save it in the user directory. Copy the &lt;code class=&#34;verbatim&#34;&gt;init.el&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;ews.el&lt;/code&gt; files to your user directory. The first file contains the Emacs configuration and the second file contains bespoke EWS functions.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Please note that when you start Emacs with the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration for the first time, Emacs will download several packages from their online repositories and compile them. This process might generate scary-looking text, but you can ignore it, as it only appears when you install new packages.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Emacs Lisp
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;While using commercial software is like renting a fully furnished house, using Emacs is more like buying a new empty house. Your new digital home needs some paint and new carpets, which means you need to configure Emacs to make it your digital home.&lt;/p&gt;
&lt;p&gt;
Commercial software provides graphical menus to define how the software operates. Like the examples below, you might tick a box, select an item in a list, or enter a value in a text box to configure the program to your wishes. &lt;/p&gt;
&lt;figure&gt;
&lt;div class= &#34;tile is-ancestor&#34;&gt;
  &lt;div class=&#34;tile is-12 is-horizontal is-parent&#34; style= &#34;text-align: center; border-style: ridge; border-color: lightgray;&#34;&gt;
    &lt;div class= &#34;tile is-child box&#34;&gt;
      &lt;div class=&#34;field&#34;&gt;
	&lt;label class=&#34;label&#34;&gt;Inhibit startup message&lt;/label&gt;
	&lt;div class=&#34;control&#34; style=&#34;text-align: center;&#34;&gt;
	  &lt;label class=&#34;checkbox&#34;&gt;
	    &lt;input type=&#34;checkbox&#34; name=&#34;question&#34; checked&gt;
	  &lt;/label&gt;
	&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class= &#34;tile is-child box&#34;&gt;
      &lt;div class=&#34;field&#34;&gt;
	&lt;label class=&#34;label&#34;&gt;Initial scratch message&lt;/label&gt;
        &lt;textarea class=&#34;textarea&#34; rows=&#34;2&#34; placeholder=&#34;Hello world&#34;&gt;&lt;/textarea&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class= &#34;tile is-child box&#34;&gt;
      &lt;div class=&#34;field&#34;&gt;
	&lt;label class=&#34;label&#34;&gt;Cursor Type&lt;/label&gt;
	&lt;div class=&#34;select&#34;&gt;
	  &lt;select name=&#34;color&#34;&gt;
	    &lt;option value=&#34;nil&#34;&gt;Nil&lt;/option&gt;
	    &lt;option value=&#34;box&#34;&gt;Box&lt;/option&gt;
	    &lt;option value=&#34;hollow&#34;&gt;Hollow&lt;/option&gt;
	    &lt;option selected value=&#34;bar&#34;&gt;Bar&lt;/option&gt;
	  &lt;/select&gt;
	&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;figcaption&gt;
Typical graphical configuration screen.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Being a plain text program, Emacs doesn&amp;#39;t use a graphical interface but a programming language called Lisp. The code below is equivalent to the graphical user interface shown above. &lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq-default&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;inhibit-startup-message&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#963&#34;&gt;initial-scratch-message&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Hello world&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#963&#34;&gt;cursor-type&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;bar&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Although the text-based method is superficially more complex than ticking boxes, writing text and selecting a drop-down list, it is far more potent than a graphical interface.  Writing code to configure your computer may not seem user-friendly initially because we are used to the graphical interface. However, once you learn how to write simple Emacs Lisp programs, you will find that Emacs is the most user-friendly system because it gives you so much power over your computer. But with that power comes great responsibility and a steep learning curve.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Using Emacs Lisp is the epitome of ease of use. You control how your computer behaves instead of the computer controlling your behaviour.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
A Lisp program consists of expressions, which are statements enclosed in parentheses. Each expression starts with the name of a function (&lt;code class=&#34;verbatim&#34;&gt;setq-default&lt;/code&gt;), followed by some parameters.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;setq-default&lt;/code&gt; function is commonly used to set the default value of a parameter. For example, &lt;code class=&#34;verbatim&#34;&gt;(setq-default inhibit-startup-message t)&lt;/code&gt; has the same effect as putting a checkmark in the inhibit-startup-message box, while &lt;code class=&#34;verbatim&#34;&gt;inhibit-startup-message nil&lt;/code&gt; is the same as removing the checkmark in that box. The expression in this example determines whether Emacs displays a startup message when you open it for the first time.&lt;/p&gt;
&lt;p&gt;
You don’t have to learn to program Lisp to configure Emacs. The examples on this site provide sensible defaults to turn vanilla Emacs into your personal writing studio. Each article offers a thoroughly documented configuration. Many Emacs users share their configuration with the community so that you can copy their code. The copy-and-paste method is a shortcut to learning more about Emacs Lisp because you can change the settings and examine the results of your changes.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
The Emacs Writing Studio Configuration
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Checking external software requirements
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Emacs is not just a text editor but a Lisp computing environment that can interface with command line tools. For &lt;em&gt;Emacs Wring Studio&lt;/em&gt; to function fully, it needs to have access to a bunch of external programs, which are listed in the relevant articles. &lt;/p&gt;
&lt;p&gt;
A bespoke &lt;em&gt;Emacs Writing Studio&lt;/em&gt; function (&lt;code&gt;ews-missing-executables&lt;/code&gt;) tests wether the relevant external executable files are available. This function displays an error message into the &lt;code class=&#34;verbatim&#34;&gt;*Messages*&lt;/code&gt; buffer if it cannot find one or more of the external tools. Emacs will still work, but some functionality might be unavailable.&lt;/p&gt;
&lt;p&gt;
Each article in the Emacs Writing Studio series explains which external software is required an how to obtain it. The core functionality of Emacs will work fine without these, but some specialised tasks require assistance from this software.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;soffice&lt;/code&gt; (&lt;a href=&#34;https://www.libreoffice.org/&#34;&gt;LibreOffice&lt;/a&gt;): View and create office documents&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;zip&lt;/code&gt;: Unpack ePub documents&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;pdftotext&lt;/code&gt; (&lt;a href=&#34;https://poppler.freedesktop.org/&#34;&gt;poppler-utils&lt;/a&gt;): Convert PDF to text&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;djvu&lt;/code&gt; (&lt;a href=&#34;http://djvu.org/&#34;&gt;DjVuLibre&lt;/a&gt;): View DjVu files&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;curl&lt;/code&gt;: Reading RSS feeds&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;dot&lt;/code&gt; (&lt;a href=&#34;https://graphviz.org/&#34;&gt;GraphViz&lt;/a&gt;): Create note network diagrams&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Convert image files&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;convert&lt;/code&gt; (&lt;a href=&#34;https://imagemagick.org/&#34;&gt;ImageMagick&lt;/a&gt;)  &lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;gm&lt;/code&gt; (&lt;a href=&#34;http://www.graphicsmagick.org/&#34;&gt;GraphicsMagick&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code class=&#34;verbatim&#34;&gt;latex&lt;/code&gt; (&lt;a href=&#34;https://www.latex-project.org/get/&#34;&gt;TexLive, MacTex or MikTeX&lt;/a&gt;): Preview LaTex and export Org to PDF&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;divpng&lt;/code&gt;: Part of LaTeX&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;hunspell&lt;/code&gt;: Spellcheck. Also requires a hunspell dictionary&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Search inside files&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;grep&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;ripgrep&lt;/code&gt;: Faster alternative for grep&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;View PDF files&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;gs&lt;/code&gt; (&lt;a href=&#34;https://www.ghostscript.com/&#34;&gt;GhostScript&lt;/a&gt;): View PDF files&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;mutool&lt;/code&gt; (&lt;a href=&#34;https://mupdf.com/&#34;&gt;MuPDF&lt;/a&gt;): View PDF files&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Play music&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;mpg321&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;ogg123&lt;/code&gt; (&lt;a href=&#34;https://www.xiph.org/&#34;&gt;vorbis-tools&lt;/a&gt;), &lt;code class=&#34;verbatim&#34;&gt;mplayer&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;mpv&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;vlc&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Loading Packages
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The Emacs base system has extensive functionality, but you can extend its capability with external packages. Many people write packages in Emacs Lisp to improve or enhance what the system can do. You can also download Lisp files directly from GitHub or other sources. Developers of these packages often share their work through public package repositories, which are websites that let you easily download and install packages. The two most important ones are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ELPA: &lt;a href=&#34;https://elpa.gnu.org/&#34;&gt;GNU Emacs Lisp Package Archive&lt;/a&gt; — the official package archive, enabled by default.&lt;/li&gt;
&lt;li&gt;MELPA: &lt;a href=&#34;https://melpa.org/&#34;&gt;Milkypostman’s Emacs Lisp Package Archive&lt;/a&gt; — Unofficial archive.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The next blob of Elisp (Emacs Lisp) code adds the MELPA archive to the packages archive list. The ELPA archive is installed by default. This code appends the configuration (&lt;code&gt;add-to-list&lt;/code&gt;) and does not override the default. Just ensure you add a trailing slash (at the end of the URL), otherwise, Emacs gets confused when downloading the package index.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;package&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;add-to-list&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;package-archives&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                 &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;melpa&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;https://melpa.org/packages/&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;package-initialize&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
You can explore the list of packages with the &lt;code class=&#34;verbatim&#34;&gt;list-packages&lt;/code&gt; function. This function has no keyboard shortcut, so first press &lt;code class=&#34;verbatim&#34;&gt;M-x&lt;/code&gt; and type the function name, followed by the Enter key.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Configuring Packages
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;John Wiggle has developed the &lt;code class=&#34;verbatim&#34;&gt;use-package&lt;/code&gt; software, which simplifies configuring packages. Computer scientists call this approach ‘syntactic sugar’ because it makes the syntax of a configuration file a bit easier to read and write. Most configurations on this website use this method to install and configure Emacs extensions.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;use-package-always-ensure&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;package-native-compile&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;warning-minimum-level&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;:error&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This is the basic setup required to run any other configurations in this series of articles.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Keeping your packages up-to-date
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Packages are constantly updated by their developers. To ensure you get the latest version, you can use the &lt;code class=&#34;verbatim&#34;&gt;package-upgrade-all&lt;/code&gt; function, which has no default keybinding. This might seem a strange name for this function, &lt;code class=&#34;verbatim&#34;&gt;upgrade-all-packages&lt;/code&gt; would seem a bit more linguistically sound. However, the convention for naming Emacs Lisp functions is that the first word is the package name, which is &lt;code class=&#34;verbatim&#34;&gt;package&lt;/code&gt;. So, for example, all &lt;em&gt;Emacs Writing Studio&lt;/em&gt; functions start with &lt;code class=&#34;verbatim&#34;&gt;ews-&lt;/code&gt;.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
Changing keyboard shortcuts
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;https://lucidmanager.org/productivity/getting-started-with-emacs/&#34;&gt;previous article&lt;/a&gt; explained how Emacs uses the keyboard and the use of shortcuts to run functions. Emacs comes with a lot of default key bindings, all of which you can change or you can add new ones for functions you need to use regularly that don&amp;#39;t have a default shortcut.&lt;/p&gt;
&lt;p&gt;
For example, adding this line to your configuration lets you play Tetris whenever you hit &lt;code class=&#34;verbatim&#34;&gt;F8&lt;/code&gt;.  So this line associates the keyboard shortcut &lt;code&gt;(kbd &amp;#34;&amp;lt;f8&amp;gt;&amp;#34;)&lt;/code&gt; in the global keymap with the &lt;code&gt;tetris&lt;/code&gt; function.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#963&#34;&gt;keymap-set&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;global-map&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;lt;f8&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;#&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#963&#34;&gt;tetris&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
EWS deploys the &lt;code class=&#34;verbatim&#34;&gt;use-package&lt;/code&gt; configuration, which has a slightly different convention. You can as such change any of the keyboard shortcuts in this EWS configuration to your preference by simply changing the bit between quotation marks. Please note that function keys and other special keys are between &lt;code class=&#34;verbatim&#34;&gt;&amp;lt;&amp;gt;&lt;/code&gt; to prevent them being interpreted as individual keys.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;emacs&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt; (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;lt;f8&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;tetris&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-10&#34;&gt;
Emacs Writing Studio configuration
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Besides crafting your own configuration or using a starter kit, Emacs has a customisation menu that lets you configure Emacs without writing code. This system writes the required Emacs Lisp code to the init file.&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Emacs Wring Studio&lt;/em&gt; uses two separate init files to prevent Emacs from changing your hand-crafted config. The configuration below changes the automated configuration file’s name to &lt;code class=&#34;verbatim&#34;&gt;custom.el&lt;/code&gt; and evaluates it when it exists.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq-default&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;custom-file&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;expand-file-name&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;custom.el&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;user-emacs-directory&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;when&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;file-exists-p&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;custom-file&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;load&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;custom-file&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The first lines of code instruct Emacs to use a separate file for the internal configuration system (&lt;code class=&#34;verbatim&#34;&gt;custom.el&lt;/code&gt;). The &lt;code class=&#34;verbatim&#34;&gt;expand-file-name&lt;/code&gt; expression adds the filename to the location of the Emacs user directory. This method ensures the code works irrespective of the Emacs user directory location.&lt;/p&gt;
&lt;p&gt;
The last two lines load this file when it exists (&lt;code class=&#34;verbatim&#34;&gt;file-exists-p&lt;/code&gt;). As this is the first action in the configuration, your personal init file will override any settings in the custom file.&lt;/p&gt;
&amp;nbsp;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-11&#34;&gt;
Emacs Writing Studio variables
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;For convenience, the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; defines some variables to configure the system. &lt;/p&gt;
&lt;p&gt;
You can change these, and any other variable in Emacs, variables with the &lt;code&gt;customize-variable&lt;/code&gt; function, search for &lt;code class=&#34;verbatim&#34;&gt;ews&lt;/code&gt;, and pick the variable you seek to change. Alternatively, use &lt;code&gt;customize-group&lt;/code&gt; and search for &lt;code class=&#34;verbatim&#34;&gt;ews&lt;/code&gt; to see all variables. You can then change the entry in the text field to your preference and hit the &lt;code class=&#34;verbatim&#34;&gt;Apply and save&lt;/code&gt; button. Emacs saves the new value(s) to the &lt;code class=&#34;verbatim&#34;&gt;custom.el&lt;/code&gt; file and they will be loaded next time you start Emacs.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/customisation-menu.png&#34; alt=&#34;Emacs customisation screen&#34; title=&#34;Emacs customisation screen&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Emacs customisation screen.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The Emacs customisation functionality is a low-code option to configure your system and the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; is configured so that the variables set with this method will override the default configuration presented in these pages. Alternatively you can of course hack your init file directly.&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Emacs Writing Studio&lt;/em&gt; also includes a handful of bespoke convenience functions, which are discussed in their relevant pages. All bespoke configuration is stored in the &lt;code class=&#34;verbatim&#34;&gt;ews.el&lt;/code&gt; file on GitHub. &lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-12&#34;&gt;
Is Emacs a Productivity Sink?
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Configuring Emacs can be a daunting task and become a productivity sink because of the ease by which it can be done. Within the Emacs community, a discussion emerges every now and then about the need to make so many changes to the vanilla software to get it to behave how you like it.&lt;/p&gt;
&lt;p&gt;
A commonly asked question is why can&amp;#39;t Emacs have &amp;#39;sensible default&amp;#39; values? This may seem like a reasonable question, but what is sensible to one user is an annoyance for another. Emacs developers are as such quite conservative when it comes to changing the default settings.&lt;/p&gt;
&lt;p&gt;
The Emacs developers cannot cater to every personal preference, so they provide a skeleton system you must enhance to suit your workflow. Emacs Lisp is like a box of Lego. You can play with it out of the box using vanilla Emacs, but it is much more fun when you create your own toys. Working on your Emacs configuration is like building with Lego and eventually you configure Emacs to perfectly meet your needs.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/emacs-configuration-lego.jpg&#34; alt=&#34;Emacs configuration and Lego&#34; title=&#34;Emacs configuration and Lego&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Emacs configuration and Lego.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
It can be tempting to constantly fine-tune your configuration. Wielding the power to create a bespoke Emacs system is a temptation that can lead to fake productivity, which is one of the three forms of procrastination:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;Nihilistic procrastination&lt;/em&gt;: Watching TV or playing computer games.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Sophisticated procrastination&lt;/em&gt;: Fake productivity, e.g. Emacs hacking, switching productivity tools, taking notes for volume instead of quality.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Productive procrastination&lt;/em&gt;: Daydreaming.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Tinkering with your Emacs configuration is not as bad as nihilistic procrastination but can become a form of fake productivity. The productivity gains from fine-tuning your Emacs to cut out a few keystrokes can take more time than you will save with your new workflow. Writing is more than the number of words you can type into your buffer. Writing is as much a contemplative act as it is about productivity. Don’t get sucked into trying as many packages as possible. It will lead to what Emacs aficionados call Dot Emacs bankruptcy, which occurs when your init file is so enormous and disorganised that it becomes unmanageable.&lt;/p&gt;
&lt;p&gt;
The best way to learn how to configure your Emacs system is to search the web for examples and copy them to your init file. Initially, the code might look gibberish, but its logic will become more apparent as you do this more often. Emacs has an extensive help system that you can use to explore functions or variables you like to know more about. Use &lt;code class=&#34;verbatim&#34;&gt;C-h o&lt;/code&gt; (&lt;code&gt;describe-symbol&lt;/code&gt;) to search for any function or variable.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://imgs.xkcd.com/comics/is_it_worth_the_time.png&#34; alt=&#34;https://imgs.xkcd.com/comics/is_it_worth_the_time.png&#34; title=&#34;https://imgs.xkcd.com/comics/is_it_worth_the_time.png&#34; /&gt;&lt;figcaption&gt;
Source: xbd.com
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Hopefully, the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration will help you reduce the time it takes to configure Emacs to suit your preferred workflow.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-13&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, and everybody has personal preferences on how to undertake a task and configure Emacs. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the contact form to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
 The next article explains the principles of &lt;a href=&#34;https://lucidmanager.org/productivity/writing-prose-with-emacs/&#34;&gt;writing prose in Emacs&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Writing Prose with Emacs</title>
      <link>https://lucidmanager.org/productivity/writing-prose-with-emacs/</link>
      <pubDate>Sun, 10 Dec 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/writing-prose-with-emacs/</guid>
      <description>
	
&lt;p&gt;
Emacs is known as an extensible text editor, but this is a confusing description to authors. Computer programmers refer to writing code as editing, while for an author, the term editing refers to the last stage in the writing process. A text editor is a tool to write text for computers to read. However, Emacs can be a tool for editing code and writing for humans.&lt;/p&gt;
&lt;p&gt;
This article explains the basics of how to write prose using Emacs as an advanced typewriter. This article is part of &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt;, which explains how to use Emacs to undertake research and write and publish articles, books, and websites. &lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Writing modes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs is like a Swiss Army knife in that it can undertake several different functions through so-called major modes.&lt;/p&gt;
&lt;p&gt;
An Emacs major mode controls how a buffer (the currently open file) behaves. A text file could be a movie script, a to-do list, the next great novel, computer code, or however you express your creativity. In commercial software, each file could be a different file type that you can only read in specialised software. Emacs automatically recognises the type of file you open and modifies its behaviour accordingly.&lt;/p&gt;
&lt;p&gt;
In Emacs, text mode is for simple text files. &lt;a href=&#34;https://fountain-mode.org/&#34;&gt;Fountain mode&lt;/a&gt; helps you write movie or theatre scripts. &lt;a href=&#34;https://orgmode.org/&#34;&gt;Org mode&lt;/a&gt; excels at managing your to-do lists and creative writing. Many other modes with specialised functions are available in the package repositories.&lt;/p&gt;
&lt;p&gt;
Each buffer can only have one major mode operating at a time, but it can have several minor modes. A minor mode provides optional extras, such as Flyspell, for on-the-fly spell checking.&lt;/p&gt;
&lt;p&gt;
Org mode is arguably the most versatile major mode in Emacs. A large portion of these articles describe how to use this package.&lt;/p&gt;
&lt;p&gt;
The remainder of this article focuses on the principles that apply to all text modes.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Basic principles
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The foundational &lt;a href=&#34;https://lucidmanager.org/productivity/getting-started-with-emacs/&#34;&gt;major mode&lt;/a&gt; for writing prose is &lt;code&gt;text-mode&lt;/code&gt;. Emacs documentation describes it as the mode for writing text for humans to read, in contrast to &lt;code&gt;prog-mode&lt;/code&gt;, which is for writing code that computers read. Text mode forms the foundation for all other prose formats. This means that all these modes use the same basic functionality for writing.&lt;/p&gt;
&lt;p&gt;
The basic principle of writing in Emacs is easy: you just start. However, some differences exist between standard word processors and the Emacs way. Once you get used to the convenience of writing in Emacs, you never want to use other software again, as you will miss the extensive editing functionality to jump around your text with ease.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Moving around in a buffer
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;You can move the cursor with arrow keys and other standard navigation keys. Emacs documentation sometimes refers to the cursor as a point; technically, the cursor is the character displayed on the screen (a line or a box), and a point indicates where the next typed character will appear. In most situations, the terms cursor and point are used interchangeably.&lt;/p&gt;
&lt;p&gt;
In addition to the standard methods to move around a buffer, Emacs provides additional functionality to help you navigate your project. For example, &lt;code class=&#34;verbatim&#34;&gt;C-p&lt;/code&gt; (&lt;code&gt;previous-line&lt;/code&gt;) does the same as the up key (see table below). Some people prefer these keys so their hands can stay in the default position for fast touch-typing. However, writing is more about thinking than maximising keystrokes per minute, but feel free to try them out.&lt;/p&gt;
&lt;figure&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Direction&lt;/th&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Key&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Left&lt;/td&gt;
&lt;td&gt;&lt;code&gt;left-char&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-b&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;&amp;lt;left&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Right&lt;/td&gt;
&lt;td&gt;&lt;code&gt;right-char&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-f&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;&amp;lt;right&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Up&lt;/td&gt;
&lt;td&gt;&lt;code&gt;previous-line&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-p&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;&amp;lt;up&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Down&lt;/td&gt;
&lt;td&gt;&lt;code&gt;next-line&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-n&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;&amp;lt;down&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Previous word&lt;/td&gt;
&lt;td&gt;&lt;code&gt;backwar-word&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;M-b&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;C-&amp;lt;left&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Next word&lt;/td&gt;
&lt;td&gt;&lt;code&gt;forward-word&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;M-f&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;C-&amp;lt;right&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scroll down&lt;/td&gt;
&lt;td&gt;&lt;code&gt;scroll-down-command&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-v&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;&amp;lt;PageDown&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scroll up&lt;/td&gt;
&lt;td&gt;&lt;code&gt;scroll-up-command&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;M-v&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;&amp;lt;PageUp&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Start of line&lt;/td&gt;
&lt;td&gt;&lt;code&gt;move-beginning-of-line&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-a&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;&amp;lt;home&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;End of line&lt;/td&gt;
&lt;td&gt;&lt;code&gt;move-end-of-line&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-e&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;&amp;lt;end&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Start of buffer&lt;/td&gt;
&lt;td&gt;&lt;code&gt;beginning-of-buffer&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;M-&amp;lt;&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;C-&amp;lt;home&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;End of buffer&lt;/td&gt;
&lt;td&gt;&lt;code&gt;end-of-buffer&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;M-&amp;gt;&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;C-&amp;lt;end&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;figcaption&gt;
Moving around a buffer in Emacs.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Making a mark
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;You will undoubtedly have the experience of moving from one part of a document to another and then like to jump back but lose your place, so you search through the document to get back to where you left off.&lt;/p&gt;
&lt;p&gt;
In Emacs, you can save the cursor&amp;#39;s current position with &lt;code class=&#34;verbatim&#34;&gt;C-space&lt;/code&gt;, which marks the current location of the point. You can now move to another part of your document, edit or read what you need, and jump back with &lt;code class=&#34;verbatim&#34;&gt;C-u C-space&lt;/code&gt;. &lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Focusing
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Getting lost in a sea of words on your screen is easy. Some simple keystrokes can help you to focus your eyes quickly. Keying &lt;code class=&#34;verbatim&#34;&gt;C-l&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;recenter-top-bottom&lt;/code&gt;) moves the line that your cursor is on to the centre of the screen.&lt;/p&gt;
&lt;p&gt;
If you repeat this keystroke, the cursor will move to the top of the screen. If you do this three times in a row, the cursor moves to the bottom of the screen.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Copying and pasting text the Emacs way
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The most apparent difference between Emacs and typical word processors is that it does not use the standard &lt;a href=&#34;https://en.wikipedia.org/wiki/IBM_Common_User_Access&#34;&gt;Common User Access&lt;/a&gt; (CUA) keys standard for selecting, copying, cutting and pasting text used in modern applications. But the trade-off for the minor inconvenience of learning a new method to edit text is that the Emacs way is much more versatile than other software.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Selecting text
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;With the shift and arrow keys, you can select text in almost all major modes. Because the shift and arrow keys in Org mode are reserved for editing lists, you must use a more advanced way to select a text block. You first set a mark with &lt;code class=&#34;verbatim&#34;&gt;C-space&lt;/code&gt; and then move to the end of the section to select your text, which is highlighted.&lt;/p&gt;
&lt;p&gt;
To select a complete paragraph, use the &lt;code class=&#34;verbatim&#34;&gt;M-h&lt;/code&gt; key. Repeatedly pressing &lt;code class=&#34;verbatim&#34;&gt;M-h&lt;/code&gt; will select subsequent sections. Using &lt;code class=&#34;verbatim&#34;&gt;C-x h&lt;/code&gt; will select all text in the buffer.&lt;/p&gt;
&lt;p&gt;
Once the text is marked, you can act on this block by deleting, copying or moving it.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Copy and paste text
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;In modern computing language, copying and pasting are handicraft analogues for moving text from one place to another. Emacs terminology is more evocative. Copying a text is the same as saving it to the &amp;#39;kill-ring&amp;#39; and yanking a text retrieves it from that seemingly bleak location.&lt;/p&gt;
&lt;p&gt;
While the clipboard in most systems only retains the last entry, the kill ring provides access to a  history of killing actions. In other words, Emacs stores a history of all text you copy and cut from a buffer to the kill ring. The length of this history is stored in &lt;code&gt;kill-ring-max&lt;/code&gt;, which is 60 entries by default. Once the kill ring is full, the oldest item vanishes. Emacs erases the content of the kill ring when you exit the program. Use the following keyboard shortcuts to copy and move the text to and from the kill ring:&lt;/p&gt;
&lt;figure&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Shortcut&lt;/th&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;M-w&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kill-ring-save&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Copy a selection to the kill ring&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-W&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kill-region&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Move a selection to the kill ring&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-y&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;yank&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Paste the most recent entry in the kill ring to the buffer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;M-y&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;yank-pop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Replace the previously yanked text with the next kill ring entry&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;figcaption&gt;
Copying and pasting in Emacs.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The &lt;code&gt;kill*&lt;/code&gt; commands copy or move text to the kill ring and the system clipboard. The &lt;code&gt;yank*&lt;/code&gt; commands copy an entry from the kill ring to the current buffer. The &lt;code&gt;yank-pop&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;M-y&lt;/code&gt;) command cycles through the contents of the kill ring so you can access the history. When you use advanced &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-completion-system/&#34;&gt;completion systems&lt;/a&gt;, you see a list of all available previous selections in the minibuffer. Use the arrow keys or search to pick what you like to yank into the active buffer. &lt;/p&gt;
&lt;p&gt;
If you prefer using the familiar keyboard shortcuts, enable &lt;code&gt;cua-mode&lt;/code&gt; for convenience. With this mode, you can use &lt;code class=&#34;verbatim&#34;&gt;C-z&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;C-x&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;C-c&lt;/code&gt;, and &lt;code class=&#34;verbatim&#34;&gt;C-v&lt;/code&gt; to undo, cut, copy, and paste in addition to the standard Emacs bindings. The &lt;code class=&#34;verbatim&#34;&gt;C-x&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;C-c&lt;/code&gt; keys only activate when you mark a region. You can enable this mode by adding &lt;code&gt;(cua-mode t)&lt;/code&gt; to your init file. This mode is not enabled in the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
Search and replace
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The most common search method in Emacs is incremental. An incremental search (&lt;code class=&#34;verbatim&#34;&gt;C-s&lt;/code&gt;) begins searching as soon as you type the first character of the search string. As you type in the search term, Emacs shows you where the term is found. When you have typed enough characters to identify the place you want, you can terminate the search explicitly with &lt;code class=&#34;verbatim&#34;&gt;ENTER&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;C-g&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;C-s&lt;/code&gt; shortcut searches incrementally from the cursor. You cycle through the search results by repeatedly pressing &lt;code class=&#34;verbatim&#34;&gt;C-s&lt;/code&gt;. Using &lt;code class=&#34;verbatim&#34;&gt;C-r&lt;/code&gt; searches the text before the cursor.&lt;/p&gt;
&lt;p&gt;
Emacs saves search terms in the search ring. Typing &lt;code class=&#34;verbatim&#34;&gt;C-s C-s&lt;/code&gt; will show the previous search term. Using &lt;code class=&#34;verbatim&#34;&gt;C-p&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;C-n&lt;/code&gt; lets you scroll through previous search terms.&lt;/p&gt;
&lt;p&gt;
To search and replace text in a buffer, use &lt;code class=&#34;verbatim&#34;&gt;M %&lt;/code&gt; and follow the prompts in the mini buffer.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-10&#34;&gt;
Correcting mistakes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The most convenient aspect of writing on an electric screen is that it is easy to change your mind or correct a mistake without having to resort to correction fluids or other archaic methods. The following basic editing commands are available to modify text. Please note that commands that start with &lt;code class=&#34;verbatim&#34;&gt;kill&lt;/code&gt; store the deleted text on the kill ring. &lt;/p&gt;
&lt;figure&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Key&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Delete character after point&lt;/td&gt;
&lt;td&gt;&lt;code&gt;delete-char&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-d&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;&amp;lt;delete&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delete character before point&lt;/td&gt;
&lt;td&gt;&lt;code&gt;delete-backward-char&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;&amp;lt;backspace&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delete the next word&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kill-word&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;M-d&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;C-&amp;lt;delete&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delete to the end of the line&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kill-line&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-k&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;figcaption&gt;
Emacs deletion commands.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Besides removing unwanted characters, you can also swap them with a series of transposing commands. When you accidentally reverse two letters in a word, you can switch their order with the &lt;code&gt;transpose-char&lt;/code&gt; command with the cursor between them (&lt;code class=&#34;verbatim&#34;&gt;C-t&lt;/code&gt;). Swapping words is quickly done with the &lt;code&gt;transpose-words&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;M-t&lt;/code&gt;) command.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-11&#34;&gt;
Undo the Emacs way
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The Emacs &lt;code&gt;undo&lt;/code&gt; command is mapped to &lt;code class=&#34;verbatim&#34;&gt;C-/&lt;/code&gt;. If you need to undo the step, use &lt;code class=&#34;verbatim&#34;&gt;C-?&lt;/code&gt; (&lt;code&gt;undo-redo&lt;/code&gt;). Each consecutive command will undo earlier changes. Any command other than an undo command breaks the sequence. &lt;/p&gt;
&lt;p&gt;
Although each editing command usually makes a separate entry in the undo records, simple commands (single key press) may be grouped together.&lt;/p&gt;
&lt;p&gt;
The Emacs undo system recovers any past text version. In contrast, the standard undo/redo system can lose past edits as soon as you redo. Getting lost in a sequence of undo and redo commands is easy. The &lt;a href=&#34;https://www.dr-qubit.org/undo-tree.html&#34;&gt;Undo Tree&lt;/a&gt; package by Toby Cubitt helps you keep track of your changes by visualising them as a tree. Use the ~ undo-tree-visualise ~ (&lt;code class=&#34;verbatim&#34;&gt;C-x u&lt;/code&gt;) command to walk through previous versions of your text.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/undo-tree.png&#34; alt=&#34;Example of an undo tree&#34; title=&#34;Example of an undo tree&#34; width=&#34;300&#34;/&gt;
&lt;figcaption&gt;
Example of an undo tree.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The current buffer will change as you work your way through its history with the arrow keys where &lt;code class=&#34;verbatim&#34;&gt;x&lt;/code&gt; marks the spot of the selected step. Use &lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt; to select the chosen edit and continue writing. The &lt;code class=&#34;verbatim&#34;&gt;C-q&lt;/code&gt; chord jumps out of the undo tree without making changes.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;undo-tree&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;global-undo-tree-mode&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;undo-tree-auto-save-history&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
There is also a nuclear option. You can discard all the changes since the buffer was last visited or saved with &lt;code&gt;M-x revert-buffer&lt;/code&gt;, which reloads the file from the disk.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-12&#34;&gt;
Configure text modes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The original purpose of Emacs is to edit computer code, so by default, the editor does not wrap lines at the end of the screen. While this behaviour is great for developing software, it isn&amp;#39;t very pleasant for writing prose. The &lt;code class=&#34;verbatim&#34;&gt;visual-line-mode&lt;/code&gt; minor mode enables line-wrapping, which is common in word processors. You can run the function separately for each buffer, but ideally, you link (hook) it to all text modes.&lt;/p&gt;
&lt;p&gt;
The second change is that when you select (mark) a section of text and start typing, Emacs will not replace the selected text by default. To enable Emacs to overwrite selected text, you set the &lt;code class=&#34;verbatim&#34;&gt;delete-selection-mode&lt;/code&gt; variable, as below.&lt;/p&gt;
&lt;p&gt;
Another sensible default for authors is to ensure that Emacs lets you use the &lt;code class=&#34;verbatim&#34;&gt;page-up&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;page-down&lt;/code&gt; buttons to go all the way to the first and last line in the buffer.&lt;/p&gt;
&lt;p&gt;
The last line better integrates the system clipboard with the Emacs kill ring.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Sensible line-breaking&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;add-hook&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;text-mode-hook&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;visual-line-mode&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Overwrite selected text&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;delete-selection-mode&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Scroll to the first and last line of the buffer&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq-default&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;scroll-error-top-bottom&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Copy the system clipboard to the kill ring&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;save-interprogram-paste-before-kill&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-13&#34;&gt;
Checking spelling
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Emacs minor mode Flyspell provides an interface to the &lt;a href=&#34;https://hunspell.github.io/&#34;&gt;Hunspell spell-checking software&lt;/a&gt;. To enable spell-checking, you thus first need to ensure that Hunspell is available on your computer. Hunspell is easy to install on Linux computers but is also available for &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-windows/&#34;&gt;Windows&lt;/a&gt; and &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-chromebook/&#34;&gt;Chromebook&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The configuration below enables Flyspell for all text modes and sets Hunspell as the default checking program. The &lt;code class=&#34;verbatim&#34;&gt;M-F7&lt;/code&gt; key checks the spelling for all words in the buffer, and &lt;code class=&#34;verbatim&#34;&gt;F7&lt;/code&gt; checks the word on which the cursor is standing.&lt;/p&gt;
&lt;p&gt;
A more productive method is to use the &lt;code&gt;flyspell-auto-correct-previous-word&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-;&lt;/code&gt;) function. This function provides the most likely correction of the first spelling error before the cursor. Emacs will show the list of possible corrections in the mini buffer. Repeatedly pressing &lt;code class=&#34;verbatim&#34;&gt;C-;&lt;/code&gt; will cycle through the options until you return to the original. This function prevents you from having to jump to your spelling mistakes.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Spell-checking&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Requires Hunspell&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;flyspell&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;ispell-program-name&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;hunspell&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;ispell-default-dictionary&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;en_AU&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:hook&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;text-mode&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;flyspell-mode&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt; ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;M-&amp;lt;f7&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;flyspell-buffer&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;flyspell-correct&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:after&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;flyspell&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt; ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;flyspell-auto-correct-previous-word&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;lt;f7&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;flyspell-correct-wrapper&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
You must modify the configuration to set your preferred dictionary as the default. The available English dictionaries in Hunspell are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;en_US&lt;/code&gt; (American)&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;en_CA&lt;/code&gt; (Canadian)&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;en_GB&lt;/code&gt; (British)&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;en_AU&lt;/code&gt; (Australian)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Hunspell supports a lot of other dictionaries, so you can install and choose your own when English is not your preferred language. &lt;/p&gt;
&lt;p&gt;
If you are multilingual, you can set a different language for each buffer by adding a file variable to the relevant buffer. Ass the text below as the last lines in your Org mode file, where you replace &lt;code class=&#34;verbatim&#34;&gt;nederlands&lt;/code&gt; (Dutch) with your preferred language:&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;,# Local Variables:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;,# ispell-local-dictionary: nederlands
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;,# End:&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Emacs evaluates this line and activates the dictionary when you run &lt;code class=&#34;verbatim&#34;&gt;M-x normal-mode&lt;/code&gt; and the next time you open the file. This dictionary only applies to the relevant file; all other buffers remain in the default language.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-14&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-14&#34;&gt;
Counting words
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-14&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To count the words in a buffer, or part thereof, use the &lt;code class=&#34;verbatim&#34;&gt;count-word-region-function&lt;/code&gt;, which is bound to &lt;code&gt;M-=&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
The result appears in the minibuffer. When you select a portion of text, this function will count only the selection. Adding the &lt;code class=&#34;verbatim&#34;&gt;C-u&lt;/code&gt;, prefix counts the words for the hole buffer (&lt;code class=&#34;verbatim&#34;&gt;C-u M-=&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;
For Org mode buffers, the &lt;code&gt;ews-org-count-words&lt;/code&gt; command counts the words in each section and adds the word count as a property. Refer to &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;Distration-Free Writing with Org mode&lt;/a&gt; for details.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-15&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-15&#34;&gt;
Text size
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-15&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To temporarily increase the height of the text in the current buffer, type &lt;code class=&#34;verbatim&#34;&gt;C-x C-+&lt;/code&gt;. To decrease it, type &lt;code class=&#34;verbatim&#34;&gt;C-x C--&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
To restore the default (global) face height, type &lt;code class=&#34;verbatim&#34;&gt;C-x C-0&lt;/code&gt;. These keys are all bound to the &lt;code&gt;text-scale-adjust&lt;/code&gt; function, which looks at the last key typed to determine which action to take.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-16&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-16&#34;&gt;
Text Completion
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-16&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs developers have also written many completion systems to help you write text. These packages fall into two categories: &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-completion-system/&#34;&gt;minibuffer completion&lt;/a&gt; and expansion systems for prose and code.&lt;/p&gt;
&lt;p&gt;
Expanding text in human languages comes in two forms. You either start typing a word, and Emacs predicts what should go next, or you write a predefined abbreviation that expands into a word, a paragraph, a table or whatever else you define it as.&lt;/p&gt;
&lt;p&gt;
Predictive text is one of these technologies that can be both a blessing and a curse. Use it cautiously because it can hinder your writing when used too eagerly.&lt;/p&gt;
&lt;p&gt;
Company mode is a versatile package that can help you with completing long words. Its primary purpose is to assist developers with writing code, but it can also help you complete words.&lt;/p&gt;
&lt;p&gt;
Company mode provides suggested completions in a dropdown menu whenever you type a defined number of characters. It derives these options from all open text buffers. Use the arrow keys and enter to select your option, or ignore the menu and keep typing.&lt;/p&gt;
&lt;p&gt;
This configuration only activates when entering at least four characters and only shows words of eight or more letters. The wraparound option lets you cycle through the completions menu with the down and up arrow keys.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Auto completion&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;company&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;company-minimum-prefix-length&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;4&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;company-dabbrev-minimum-length&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;8&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;company-selection-wrap-around&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:init&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;global-company-mode&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
When using variable pitch fonts, the dropdown menu for text completion gets distorted because the letters are not all the same size. The &lt;a href=&#34;https://github.com/tumashu/company-posframe&#34;&gt;company-posframe package&lt;/a&gt; by Tumashu solves this problem. A post frame is a floating child frame that can pop up anywhere on the screen, usually to show additional information.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Required for variable pitch&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;company-posframe&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;company-posframe-mode&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-17&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-17&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-17&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, and everybody has personal preferences on how to undertake a task and configure Emacs. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the contact form to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The next article dives into getting productive with Emacs by explaining how to &lt;a href=&#34;https://lucidmanager.org/productivity/improving-the-emacs-user-interface/&#34;&gt;improve the Emacs user interface&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Improving the Emacs User Interface</title>
      <link>https://lucidmanager.org/productivity/improving-the-emacs-user-interface/</link>
      <pubDate>Fri, 25 Aug 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/improving-the-emacs-user-interface/</guid>
      <description>
	
&lt;p&gt;
A minimalist interface means that your Emacs becomes a place of rest and contemplation away from the cacophony of contemporary software, filled with buttons and functionality you don&amp;#39;t need. Emacs is an ugly duckling that you can configure into a beautiful swan. This article further explains how to improve the Emacs user interface. These settings are obviously opinionated, so this article is, more than anything else, an example of how to configure Emacs to your personal preferences.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Improving the Emacs user interface
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The default Emacs user interface is a hybrid between keyboard and mouse-driven operations. While using the mouse might seem convenient, a keyboard-driven system is more efficient because you don&amp;#39;t have to move your hand that much and switch contexts when finding icons.&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Emacs Writing Studio&lt;/em&gt; is a keyboard-centric configuration and removed any distractions from the Emacs. The following code snippet modifies the Emacs interface to remove these distractions. The first line inhibits the splash or startup screen. If you want to see it again for nostalgia, use &lt;code class=&#34;verbatim&#34;&gt;C-h C-a&lt;/code&gt; (&lt;code&gt;about-emacs&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;
Emacs has the &lt;a href=&#34;https://www.youtube.com/watch?v=ZFJlxBPvzE0&#34;&gt;paternalistic habbit&lt;/a&gt; of asking for confirmation with either &lt;code class=&#34;verbatim&#34;&gt;y / n&lt;/code&gt; or with &lt;code class=&#34;verbatim&#34;&gt;yes / no&lt;/code&gt;, depending on the situation. The basic philosophy is that typing the whole word prevents accidentally killing unsaved buffers. While this functionality is a nice gesture, it can be annoying and confusing. The last line sets all yes / no confirmations to the one-letter abbreviation. The &lt;code class=&#34;verbatim&#34;&gt;use-short-answers&lt;/code&gt; variable defines this behaviour.&lt;/p&gt;
&lt;p&gt;
The following three lines remove the tool, menu and scroll bars because we don&amp;#39;t need these in a keyboard-driven system. These lines don&amp;#39;t set a variable but disable the various minor modes that control these graphical elements.&lt;/p&gt;
&lt;p&gt;
This configuration also removes the menu bar. While the menus are a useful tool to discover functionality, there is no need to constantly keep it on the screen. You can access it by pressing &lt;code class=&#34;verbatim&#34;&gt;F10&lt;/code&gt; (&lt;code&gt;menu-bar-open&lt;/code&gt;) and selecting menu options with the arrow keys and &lt;code class=&#34;verbatim&#34;&gt;ENTER&lt;/code&gt;. You exit the menu with &lt;code class=&#34;verbatim&#34;&gt;C-g&lt;/code&gt; (&lt;code&gt;keyboard-quit&lt;/code&gt;). But after using Emacs for a while, you&amp;#39;ll quickly build muscle memory and revert to keyboard shortcuts.&lt;/p&gt;
&lt;p&gt;
If you like to see the effect of each line of code, place your cursor at the end of each line and press &lt;code class=&#34;verbatim&#34;&gt;C-x C-e&lt;/code&gt; to evaluate the expression (&lt;code&gt;eval-last-sexp&lt;/code&gt;). If the cursor is inside the parenthesis, then use &lt;code class=&#34;verbatim&#34;&gt;C-M-x&lt;/code&gt; (&lt;code&gt;eval-defun&lt;/code&gt;). To evaluate all code in a buffer, run &lt;code class=&#34;verbatim&#34;&gt;M-x eval-buffer&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; LOOK AND FEEL&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Keyboard-centric user interface&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq-default&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;inhibit-startup-message&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#963&#34;&gt;use-short-answers&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;tool-bar-mode&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;-1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;menu-bar-mode&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;-1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;scroll-bar-mode&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;-1&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Themes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A theme is a set of instructions describing the colours of headings and other text parts. Colours in a text editor play a different role than in a word processor. &lt;a href=&#34;https://lucidmanager.org/productivity/why-use-emacs/&#34;&gt;Colours in Emacs are semantic&lt;/a&gt;, meaning they indicate the type of text, not how it looks when published. A heading might have a different colour than the text or metadata, which helps you find your way through the document.&lt;/p&gt;
&lt;p&gt;
Emacs does this through &lt;code class=&#34;verbatim&#34;&gt;font-lock-mode&lt;/code&gt;. Font locking assigns faces to (or &amp;#39;fontifies&amp;#39; in Emacs speak) various parts of your text using logical rules. Typing &lt;code class=&#34;verbatim&#34;&gt;M-x font-lock-mode&lt;/code&gt; toggles between your buffer&amp;#39;s themed and plain versions. Try this to see the effect of themes.&lt;/p&gt;
&lt;p&gt;
Two basic classes of themes exist for text editors: light and dark. Light backgrounds, common with most modern word processing software, &lt;a href=&#34;https://www.thewindowsclub.com/is-dark-mode-better-for-your-eyes&#34;&gt;can cause asthenopia&lt;/a&gt; (eye strain) after you stare at the screen for a while. Many text editor users, therefore, prefer dark themes. Light themes are, however, useful when you work in a brightly lit room.&lt;/p&gt;
&lt;p&gt;
The code snippet below installs and activates the most recent version of Prot&amp;#39;s &lt;a href=&#34;https://protesilaos.com/emacs/modus-themes&#34;&gt;Modus themes&lt;/a&gt;. The Modus themes each have four versions. The &lt;code class=&#34;verbatim&#34;&gt;modus-operandi&lt;/code&gt; theme is the primary light theme, while &lt;code class=&#34;verbatim&#34;&gt;modus-vivendi&lt;/code&gt; is its dark counterpart.&lt;/p&gt;
&lt;p&gt;
The primary Modus themes maximise contrast between background and foreground following the Web Content Accessibility Guidelines (WCAG). The Modus themes comply with the triple-A standard of the WCAG, which specifies &lt;a href=&#34;https://www.w3.org/WAI/WCAG22/Understanding/contrast-enhanced.html&#34;&gt;contrast ratio between background and foreground of 7:1&lt;/a&gt;. This high contrast ratio is legible for people with moderately low vision. Prot has also optimised versions for red-green and blue-yellow colour blindness (deuteranopia and tritanopia).&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Emacs Writing Studio&lt;/em&gt; uses the tinted versions as default. These versions have a slightly lower contrast ratio than the default and are as such suitable for people with normal vision. The Modus themes do not prescribe any keyboard shortcuts, so I have defined some for EWS. The &lt;code class=&#34;verbatim&#34;&gt;C-c w m&lt;/code&gt; shortcut toggles between the light and dark side (insert Star Wars pun here). Using &lt;code class=&#34;verbatim&#34;&gt;C-c w M&lt;/code&gt; provides a selection menu of all Modus themes. &lt;em&gt;Emacs Writing Studio&lt;/em&gt; uses &lt;code class=&#34;verbatim&#34;&gt;C-c w&lt;/code&gt; as its default keybinding for its specific functionality, where the &lt;code class=&#34;verbatim&#34;&gt;w&lt;/code&gt; is a mnemonic for writing and &lt;code class=&#34;verbatim&#34;&gt;m/M&lt;/code&gt; for Modus themes.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Modus Themes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;modus-themes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;modus-themes-italic-constructs&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;modus-themes-bold-constructs&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;modus-themes-mixed-fonts&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;modus-themes-headings&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;((&lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.5&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                             (&lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.3&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                             (&lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.1&lt;/span&gt;))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;modus-themes-to-toggle&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;(&lt;span style=&#34;color:#963&#34;&gt;modus-operandi-tinted&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;modus-vivendi-tinted&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w m&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;modus-themes-toggle&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w M&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;modus-themes-select&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:init&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;load-theme&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;modus-operandi-tinted&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;:no-confirm&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Let&amp;#39;s unpack what this piece of code means. The &lt;code class=&#34;verbatim&#34;&gt;use-package&lt;/code&gt; declaration has three sections.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;:custom&lt;/code&gt; section does the same as the &lt;code class=&#34;verbatim&#34;&gt;setq-default&lt;/code&gt; function described previously. This configuration adds more variety to the theme, such as italic text, bold text, mixed fonts, and headings are rendered a bit larger than the normal text. This configuration uses the &lt;code class=&#34;verbatim&#34;&gt;*-tinted&lt;/code&gt; versions of the Modus themes (medium contrast).&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;:bind&lt;/code&gt; section binds the relevant keys to the function that toggles between light and dark Modus themes.&lt;/p&gt;
&lt;p&gt;
Lastly, the &lt;code class=&#34;verbatim&#34;&gt;:init&lt;/code&gt; section defines the functions run when the package is loaded. In this case, we load the tinted version of the dark Modus theme without confirmation.&lt;/p&gt;
&lt;p&gt;
If you like your configuration to default to the high-contrast versions of the theme or one of the two colour blindness-safe versions, then customise the &lt;code&gt;modus-themes-to-toggle&lt;/code&gt; variable to override this default and change the init version to the one you like Emacs to start with.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Other Themes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Several themes are part of Vanilla Emacs, which you can customise with the &lt;code&gt;customize-themes&lt;/code&gt; function. When you click the &lt;em&gt;Save Theme Settings&lt;/em&gt; function, the theme will be loaded next time you start Emacs. You will have to remove the Modus themes code to ensure that your other choice is loaded. When the theme is used for the first time, Emacs might ask you to confirm that it can run Elisp code.&lt;/p&gt;
&lt;p&gt;
Emacs users have developed a ragtag collection of themes. You can browse the &lt;a href=&#34;https://emacsthemes.com/&#34;&gt;Emacs Themes Gallery&lt;/a&gt; to pick your favourite. If the theme is available in the ELPA or MELPA package repositories, change the package and theme name in the code below to match the name of your favourite theme.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;dracula-theme&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:init&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;load-theme&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;dracula&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Setting the fonts
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The default font in Emacs is a fixed-pitch (mono-spaced) font designed for writing code. In a fixed-pitch font, all characters have the same width. An &lt;code class=&#34;verbatim&#34;&gt;i&lt;/code&gt; or an &lt;code class=&#34;verbatim&#34;&gt;m&lt;/code&gt; will use the same amount of space, just like the traditional typewriters. This type of letter is ideal when writing code because it helps to align the text. Mono-spaced fonts are also necessary to create fantastic ASCII art, such as the dinosaur shown in &lt;a href=&#34;https://lucidmanager.org/productivity/why-use-emacs/&#34;&gt;another article&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
A variable-pitch font is easier on the eye when writing prose. Not all characters have the same width in a variable-pitch font, as is common in natural writing. Ideally, we want the best of both worlds and configure Emacs to use the best font category for the best situation. For example, Emacs can define a different font for certain parts of the text, for individual buffers, or for a major mode.&lt;/p&gt;
&lt;p&gt;
The configuration below uses Alex Branham&amp;#39;s &lt;a href=&#34;https://gitlab.com/jabranham/mixed-pitch&#34;&gt;mixed-pitch package&lt;/a&gt;, which assigns fixed and variable pitch fonts to the relevant elements in the buffer. For example, tables in Org mode become fixed pitch so that all columns are the same size. The &lt;code class=&#34;verbatim&#34;&gt;use-package&lt;/code&gt; call hooks the mixed-pitch mode to all text modes, including Org mode.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Set default, fixed and variable pitch fonts&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;mixed-pitch&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:hook&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;text-mode&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;mixed-pitch-mode&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration does not specify any particular fonts and use your system&amp;#39;s defaults. You can configure your favourite fonts, provided they are available on your computer. You need to define three font variable:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;default&lt;/code&gt;: The default face settings when nothing else is specified (a fixed-pitch font).&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;fixed-pitch&lt;/code&gt;: The font used for computer code .&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;variable-pitch&lt;/code&gt;: The settings for prose.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In Emacs, a &amp;#39;face&amp;#39; is a collection of attributes for displaying text. It defines the font, foreground colour, background colour, optional underlining, etc. Various &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/elisp/Face-Attributes.html&#34;&gt;face attributes&lt;/a&gt; are available for configuration. The ones we use here are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;font&lt;/code&gt;: The name of the font&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;height&lt;/code&gt;: The font height as an integer in units of 1/10 point.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The settings of the last two categories override the default. The &lt;code class=&#34;verbatim&#34;&gt;nil&lt;/code&gt; in the &lt;code class=&#34;verbatim&#34;&gt;set-face-attribute&lt;/code&gt; function sets the parameters for all Emacs frames.&lt;/p&gt;
&lt;p&gt;
You can also use the customisation menu by evoking &lt;code&gt;customize-face&lt;/code&gt; and select &lt;code class=&#34;verbatim&#34;&gt;default&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;fixed-pich&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;variable-pitch&lt;/code&gt; and enter the font name in the &lt;em&gt;Font Family&lt;/em&gt; box. Click &lt;em&gt;Apply and Save&lt;/em&gt; for each font. This action saves the font settings to the &lt;code class=&#34;verbatim&#34;&gt;custom.el&lt;/code&gt; file, which Emacs evaluates at the end of the startup sequence. See &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;Configure Emacs&lt;/a&gt; for more information about the initialisation process.&lt;/p&gt;
&lt;p&gt;
Please note that anything you configure here will override the theme settings, so only customise font family and size.&lt;/p&gt;
&lt;p&gt;
To see which fonts are available, you can set the fonts in a graphical window, run &lt;code&gt;menu-set-font&lt;/code&gt;. When you use the GUI to set the default font, the change is immediate but transient. Use &lt;code&gt;menu-bar-options-save&lt;/code&gt; to save your default font and size to the &lt;code class=&#34;verbatim&#34;&gt;custom.el&lt;/code&gt; file. &lt;/p&gt;
&lt;p&gt;
Alternatively, add the following three lines, with your fonts of choice to your &lt;code class=&#34;verbatim&#34;&gt;init.el&lt;/code&gt; file.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;set-face-attribute&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;default&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;:font&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;DejaVu Sans Mono&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;:height&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;130&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;set-face-attribute&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;fixed-pitch&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;:font&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;DejaVu Sans Mono&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;set-face-attribute&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;variable-pitch&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;:font&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;DejaVu Sans&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This video by Prot explains the principles of setting fonts in Emacs beautifully.&lt;/p&gt;
&lt;p&gt;
#+caption:Emacs: customize fonts (generic method and &amp;#39;fontaine&amp;#39; package).
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/qR8JRYr4BKE?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;
&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Tooltips
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Emacs supports &lt;a href=&#34;https://www.gnu.org/s/emacs/manual/html_node/emacs/Tooltips.html&#34;&gt;tooltips&lt;/a&gt; when the mouse hovers over when there is a pause in mouse movement over parts of text in a window, the mode line, or some other part of the Emacs frame such as a tool bar button or menu item.&lt;/p&gt;
&lt;p&gt;
The layout and typography of these tooltips is in most cases controlled by the window manager. To disable this behaviour, customise the variable &lt;code&gt;use-system-tooltips&lt;/code&gt; to &lt;code&gt;nil&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
With this option you can finetune the appearance of the tooltip by customising `tooltip-frame-parameters` and change the font with for example: &lt;code&gt;(set-face-attribute &amp;#39;tooltip nil :font &amp;#34;Monospace-16&amp;#34;)&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; (EWS) book. this book explains everything you need to know to research, write and publish articles and books with Emacs in a no-code environment. &lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The next article dives into enhancing the &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-completion-system/&#34;&gt;minibuffer completion system&lt;/a&gt; to make it easier to find files, buffers and other information.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Enhancing Minibuffer Completion</title>
      <link>https://lucidmanager.org/productivity/emacs-completion-system/</link>
      <pubDate>Sat, 03 Jul 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/emacs-completion-system/</guid>
      <description>
	
&lt;p&gt;
Even with the advent of speech-to-text software, the keyboard is still the most common method to convert thoughts to text. While computers might one day even read our minds, there is something to be said about using your fingers to do the talking. Who would want their’ ums’ and’ ahs’ written down, or their uncensored stream of consciousness committed to text? Writing is as much about thinking and crafting a stream of words as it is about maximising keystrokes per minute.&lt;/p&gt;
&lt;p&gt;
Completion systems are like predictive text on a mobile phone. You start typing some characters, and the computer lets you complete your choice. Emacs has an extendable completion system that helps you complete long words, find files, remember function names and other menial tasks. This article explains the basic minibuffer completion engine and introduces some packages extending this functionality.&lt;/p&gt;
&lt;p&gt;
This article is part of &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt;, a book that explains how to use Emacs to undertake research and write and publish articles, books, and websites. Emacs Writing Studio is also available as an e-book from your favourite retailer.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Emacs Completion Systems
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs has three types of &lt;a href=&#34;https://www.emacswiki.org/emacs/Completion&#34;&gt;completion systems&lt;/a&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;Minibuffer completion&lt;/em&gt; assists with picking choices in the minibuffer, such as function names, files and other selections.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Keychord completion&lt;/em&gt;: Systems to help with keyboard shortcuts.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Text completion&lt;/em&gt; helps you complete words you type in the buffer (see &lt;a href=&#34;https://lucidmanager.org/productivity/writing-prose-with-emacs/&#34;&gt;Writing Prose with Emacs&lt;/a&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Minibuffer completion
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The minibuffer is where you find files, call functions and other vital aspects. The minibuffer completion system aims to make it easier to find what you need by providing a search mechanism that provides a list of possible options.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/emacs/Completion.html&#34;&gt;standard minibuffer Emacs completion system&lt;/a&gt; focuses on entering functions, filenames, buffer names and any other selection process in the minibuffer. When typing a partial function or file name, you can hit the &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; key. Emacs will display completion candidates in the minibuffer.&lt;/p&gt;
&lt;p&gt;
For example, to evaluate the &lt;code class=&#34;verbatim&#34;&gt;visual-line-mode&lt;/code&gt; function to change how Emacs wraps paragraphs, you type &lt;code class=&#34;verbatim&#34;&gt;M-x visu&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt;. If you hit &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; after each letter, you’ll notice that Emacs narrows the completion candidates as you get closer to your desired selection.&lt;/p&gt;
&lt;p&gt;
This principle also works with variable names and filenames. As you start looking for a filename, use the &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; key to prevent having to type the whole filename. The &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; key is your secret weapon to help you remember and discover functions, variables, file names, buffer names and other selection candidates.&lt;/p&gt;
&lt;p&gt;
The minibuffer completion system is highly configurable, and several packages extend this functionality. The approach in this configuration uses a stack of connected packages that provide a seamless experience. This approach showcases the extensibility of Emacs as a modular computing environment. &lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Vertico
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/minad/vertico&#34;&gt;Vertico&lt;/a&gt; package enhances minibuffer completion. This extension uses incremental search, meaning the list of completion candidates is shortened to match your entry as soon as you type a letter.&lt;/p&gt;
&lt;p&gt;
When, for example, opening a file with &lt;code class=&#34;verbatim&#34;&gt;C-c C-f&lt;/code&gt;, you can start typing any part of the filename to locate the file  you seek. Use &lt;code class=&#34;verbatim&#34;&gt;C-backspace&lt;/code&gt; keys to move to a higher directory.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;savehist&lt;/code&gt; package remembers your selections and saves your minibuffer history when exiting Emacs. This package ensures that your most popular choices remain on top for further convenience.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; MINIBUFFER COMPLETION&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Enable vertico&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;vertico&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:init&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;vertico-mode&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;vertico-sort-function&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;vertico-sort-history-alpha&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Persist history over Emacs restarts.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;savehist&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:init&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;savehist-mode&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-4&#34;&gt;
Orderless
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;To further enhance our ability to find completion candidates, the &lt;a href=&#34;https://github.com/oantolin/orderless&#34;&gt;orderless package&lt;/a&gt; matches patterns, irrespective of the order they are typed in.&lt;/p&gt;
&lt;p&gt;
For example, typing &lt;code class=&#34;verbatim&#34;&gt;use pack TAB&lt;/code&gt; provides the same results as &lt;code class=&#34;verbatim&#34;&gt;pack use TAB&lt;/code&gt;. The basic configuration sets some variables for integration with the Vertico completion package.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;orderless&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;completion-styles&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;(&lt;span style=&#34;color:#963&#34;&gt;orderless&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;basic&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;completion-category-defaults&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;completion-category-overrides&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;((&lt;span style=&#34;color:#963&#34;&gt;file&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;styles&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;partial-completion&lt;/span&gt;)))))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-5&#34;&gt;
Marginalia
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;Emacs is a self-documenting computing environment, which means that every function and variable includes a text describing what it does.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://github.com/minad/marginalia&#34;&gt;marginala&lt;/a&gt; package displays these texts next to your completion candidates. When you now type &lt;code class=&#34;verbatim&#34;&gt;M-x&lt;/code&gt;, you will see a list of functions and a brief description of what they do, making it even easier to find the function you need.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Enable richer annotations using the Marginalia package&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;marginalia&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:init&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;marginalia-mode&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/mini-buffer-completion.jpg&#34; alt=&#34;Minibuffer completion with Vertico, Orderless and Marginalia&#34; title=&#34;Minibuffer completion with Vertico, Orderless and Marginalia&#34;/&gt;
&lt;figcaption&gt;
Minibuffer completion with Vertico, Orderless and Marginalia.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This video by Emacs guru Prot explains minibuffer completion in great detail.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/d3aaxOqwHhI?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Emacs: modern minibuffer packages (vertico, consult etc.).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Help with keyboard shortcuts
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Completion shortens the amount of text you must type and is terrific for discovering new functionality you did not yet realise existed. However, we usually don’t type function names but use keyboard shortcuts.&lt;/p&gt;
&lt;p&gt;
The Marginalia package shows the relevant keyboard shortcut when displaying the completion candidates to help you discover these shortcuts.&lt;/p&gt;
&lt;p&gt;
Remembering which keyboard shortcut you need in your next action takes some effort. The &lt;a href=&#34;https://github.com/justbur/emacs-which-key#introduction&#34;&gt;which-key&lt;/a&gt; package is not so much a completion system but a great help when trying to remember which keyboard shortcut to use. This package provides a minor mode that displays the key bindings following the currently-entered incomplete command (a prefix) in a popup.&lt;/p&gt;
&lt;p&gt;
Many keyboard shortcuts have multiple parts, such as &lt;code class=&#34;verbatim&#34;&gt;C-x C-f&lt;/code&gt;. The which-key package shows a popup menu that lists all the available options. When, for example, you press &lt;code class=&#34;verbatim&#34;&gt;C-x&lt;/code&gt;, the menu will list all follow-up keys and the function they are bound to. Where it says &lt;code class=&#34;verbatim&#34;&gt;prefix&lt;/code&gt; in the popup, this means that there is a deeper level.&lt;/p&gt;
&lt;p&gt;
If the number of shortcuts is too large to fit in the popup window, then you can move to the next page with &lt;code class=&#34;verbatim&#34;&gt;C-h n&lt;/code&gt; and the previous page with &lt;code class=&#34;verbatim&#34;&gt;C-h p&lt;/code&gt;.  Just typing &lt;code class=&#34;verbatim&#34;&gt;C-h&lt;/code&gt; inside the Which-Key popup displays some additional options to navigate the list of key bindings.&lt;/p&gt;
&lt;p&gt;
The configuration below displays the popup at the bottom of the screen after you type the partial keyboard shortcut. &lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Improve keyboard shortcut discoverability&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;which-key&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;which-key-mode&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;which-key-setup-side-window-right&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/which-key-popup-screen.jpg&#34; alt=&#34;Which-Key popup window for Emacs Writing Studio&#34; title=&#34;Which-Key popup window for Emacs Writing Studio&#34;/&gt;
&lt;figcaption&gt;
Which-Key popup window for C-x-w (Emacs Writing Studio).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The next article discusses the &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-workflow/&#34;&gt;Emacs Writing Studio workflow&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Emacs Workflow for Authors</title>
      <link>https://lucidmanager.org/productivity/emacs-workflow/</link>
      <pubDate>Tue, 27 Dec 2022 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/emacs-workflow/</guid>
      <description>
	
&lt;p&gt;
Emacs is the Swiss Army Chainsaw of productivity tools. This venerable software tool can help you undertake almost every task in the writing process, from idea generation to writing and publishing. Experienced users say they &amp;#34;live inside Emacs&amp;#34; as virtually all computing activities can be done in this software. This article describes a possible Emacs workflow for writers.&lt;/p&gt;
&lt;p&gt;
This article is part of &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt;, a book that explains how to use Emacs to undertake research and write and publish articles, books, and websites. Emacs Writing Studio is also available as an e-book from your favourite retailer.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Emacs Workflow
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The process of writing can be chaotic as it involves many iterative cycles. But an orderly pattern emerges when we step back from our daily tasks. We read literature, develop new ideas, work on these ideas and publish the results. Even though reality is never as linear as this list suggests, it is a helpful guide to organise an Emacs configuration.&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration follows a five-step workflow:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;Inspiration&lt;/em&gt;: Reading, listening and watching.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Ideation&lt;/em&gt;: Cultivating ideas (taking notes).&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Production&lt;/em&gt;: Writing and editing.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Publication&lt;/em&gt;: Export Org mode to PDF, ePub or a website.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Administration&lt;/em&gt;: Manage your projects.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Communication&lt;/em&gt;: Tell others about your work and exchange ideas.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The basic principle of this workflow is that the author collects information from literature, the web, email and so on (&lt;em&gt;inspiration&lt;/em&gt;), which they process in a note-taking system (&lt;em&gt;ideation&lt;/em&gt;). These notes are the central repository of information and can be linked to a bibliography. These notes form the foundation of the writing process (&lt;em&gt;production&lt;/em&gt;). When the work is finally completed, the author publishes it in its final format (&lt;em&gt;publication&lt;/em&gt;). Elated with the final result, the author communicates her new work through email or social media (&lt;em&gt;communication&lt;/em&gt;). At the end of a long work day, we must also do some &lt;em&gt;Administration&lt;/em&gt; to keep our systems in good shape, which is the bonus step.&lt;/p&gt;
&lt;p&gt;
The image below summarises the packages that &lt;em&gt;Emacs Writing Studio&lt;/em&gt; uses to convert ideas into reality.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/emacs-workflow.png&#34; alt=&#34;Emacs Writing Studio workflow&#34; title=&#34;Emacs Writing Studio workflow&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Emacs Writing Studio workflow.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Inspiration
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Ideas don&amp;#39;t pop into your mind out of thin air. Our thoughts, plans and inspirations depend on what we read, hear or watch.&lt;/p&gt;
&lt;p&gt;
Emacs has extensive facilities to read any plain text format imaginable. Emacs can also display PDF files, ebooks, and images out of the box. Listening to a podcast or watching a video is impossible within an Emacs frame. Still, the system does integrate with external multimedia applications.&lt;/p&gt;
&lt;p&gt;
You can also maintain a bibliography in Emacs with BibTeX files and link these to electronic files for reading inside Emacs or with another program. The &lt;a href=&#34;https://github.com/emacs-citar/citar&#34;&gt;Citar package&lt;/a&gt; by Bruce D&amp;#39;Arcus provides a fast and efficient interface to your bibliography.&lt;/p&gt;
&lt;p&gt;
The Emacs internet browser is called &lt;code class=&#34;verbatim&#34;&gt;eww&lt;/code&gt; (Emacs Web Wowser). This is not a fully-featured browser but a tool that displays the website you like to read to a plain text file. While this approach creates readable websites without distracting crud, it cannot render more complex internet functionality.&lt;/p&gt;
&lt;p&gt;
Elfeed is an extensible web feed reader for Emacs, supporting both Atom and RSS feeds. You can use this package to follow your favourite websites. If you like to keep up to date on Emacs articles on this website, then &lt;a href=&#34;https://lucidmanager.org/tags/emacs/index.xml&#34;&gt;use this feed&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
Emacs can also interface with multimedia players and, as such, be configured to become a complete music and video platform.&lt;/p&gt;
&lt;p&gt;
The following articles on this website discuss how to configure Emacs to read literature or listen to music or podcasts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://lucidmanager.org/productivity/reading-ebooks-with-emacs/&#34;&gt;Reading eBooks and Websites with Emacs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://lucidmanager.org/productivity/emacs-bibtex-mode/&#34;&gt;Manage your literature with Emacs BibTeX Mode&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://lucidmanager.org/productivity/read-rss-feeds-with-emacs-and-elfeed/&#34;&gt;Read RSS feeds with Emacs and Elfeed&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://lucidmanager.org/productivity/configure-emms/&#34;&gt;Configure EMMS — Emacs Multi-Media System on GNU/Linux&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ingesting so many new ideas is only worthwhile if you keep a record of your new-found inspirations. Hence, maintaining research notes is essential to facilitate the ideation process.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/RGUvNnO7lj4?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Emacs Writing Studio: Inspiration (Read e-books, manage a bibliography, surf the web and play music).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Ideation
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;My personal ideation process starts with a physical notebook. This might be a strange thing to admit as somebody who professes admiration for the electronic virtues of Emacs. Physical notebooks have some advantages in the creative process. Firstly, you can use it everywhere. The only exception might be the shower, which is paradoxically where we get our best ideas. Using a notebook is also a slower process than using a keyboard. Writing with a pen forces you to think a bit more deeply about what you are writing. Apparently, writing on paper triggers &lt;a href=&#34;https://doi.org/10.3389/fnbeh.2021.634158&#34;&gt;different neural pathways&lt;/a&gt; than writing electronically.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/emacs-writing-studio-workflow.jpg&#34; alt=&#34;Physical notes on the Emacs workflow&#34; title=&#34;Physical notes on the Emacs workflow&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
My physical notes on the Emacs workflow.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Once ideas have germinated in my notebook, some of these will find a place in my electronic system inside Emacs. As part of my weekly action list, I review my physical notes and transfer the ideas that require archiving to my digital system.&lt;/p&gt;
&lt;p&gt;
Emacs is an ideal tool for storing notes in plain text. Several packages are available to manage your digital brain. The &lt;em&gt;Emacs Writing Studio&lt;/em&gt; revolves around the &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/&#34;&gt;Denote&lt;/a&gt; package by Protesilaos (Prot) Stavrou.&lt;/p&gt;
&lt;p&gt;
I don&amp;#39;t follow any specific, such as &lt;a href=&#34;https://zettelkasten.de/introduction/&#34;&gt;Zettelklasten&lt;/a&gt; or &lt;a href=&#34;https://bulletjournal.com/&#34;&gt;Bullet Journal&lt;/a&gt;, to manage my notes. My collection of notes is a primordial soup of my ideas, categorised using tags and opportunistically linked. Besides extracts from my physical notebooks, Denote collects information I find online, extracts from my email inbox, social media or journal articles and books. Everything worth keeping goes to my Denote collection.&lt;/p&gt;
&lt;p&gt;
Most note-taking systems contain five types of notes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;Fleeting notes&lt;/em&gt;: Quickly take a note while doing something else.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Permanent notes&lt;/em&gt;: Contains new ideas, project files and anything else worth keeping.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Bibliographic notes&lt;/em&gt;: Notes about a book or article linked to the bibliography.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Journals&lt;/em&gt;: Daily or weekly reflections.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Attachments&lt;/em&gt;: Read-only files, such as images, PDFs, videos and anything else that supports the content of the written notes.&lt;/li&gt;
&lt;/ol&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-4&#34;&gt;
Fleeting notes
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;Fleeting notes are collected in the central inbox. The Org mode capture mechanism provides a distraction-free tool to collect and store random ideas for later review.&lt;/p&gt;
&lt;p&gt;
A fleeting note can be an idea, an action item, a URL to review later or whatever else comes my way that has yet to require my attention.&lt;/p&gt;
&lt;p&gt;
Regularly reviewing your fleeting notes will turn them into actions to do later or convert them into permanent notes.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-5&#34;&gt;
Permanent notes
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;The permanent notes form your second brain. Using the Denote package, your collection of notes is structured using a tagging system, and they link together to connect your ideas and form a network of thoughts.&lt;/p&gt;
&lt;p&gt;
Denote can help you implement formal systems, such as Zettelkasten, or lets you use a more organic approach.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-6&#34;&gt;
Bibliographic notes
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;Literature is the lifeblood of the researchers. Every new thought finds its origin in the ideas of others. Therefore, managing a bibliography is an essential skill for a researcher. Many commercial and free tools are available to help you manage your literature. These tools store a literature list and provide access to notes and attachments. &lt;/p&gt;
&lt;p&gt;
Bibliographic notes reference one or more bibliographic items, such as a book or an article. A bibliographic note contains a summary or interpretation of the literature you read. For that purpose, I have written the &lt;a href=&#34;https://lucidmanager.org/productivity/bibliographic-notes-in-emacs-with-citar-denote/&#34;&gt;Citar-Denote package&lt;/a&gt;, which provides functionality to write bibliographic notes. This package enables a many-to-many relationship between notes and bibliographic items. This means you can add multiple notes per bibliographic item or one note for more than one piece of literature.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-7&#34;&gt;
Journals
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;A journal is your personal diary where you can reflect on the past day or week. The Denote package can help you build a journal, whether you like to document your travels or jot down personal reflections.&lt;/p&gt;
&amp;nbsp;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/HFUAKJI0_SI?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Emacs Writing Studio: Ideation (Taking fleeting and permanent notes).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Production
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Once you have gathered your thoughts, it is time to start writing. Emacs developers have published a lot of utilities to assist with the writing process, such as auto-completion, checking spelling and grammar, dictionaries, thesaurus and other tools indispensable to a writer.&lt;/p&gt;
&lt;p&gt;
Emacs Org mode is ideal for writing articles and books or developing websites. Another popular plain text format for writing is Markdown, which does not have the same flexibility as Org mode. Fountain mode is another plain text format designed to write scripts for theatre, film or a YouTube video.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://lucidmanager.org/productivity/writing-prose-with-emacs/&#34;&gt;Writing proce with Emacs&lt;/a&gt; article discusses how to write and edit text in Emacs. The &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;Distraction-Free Writing&lt;/a&gt; article discusses how to mange writing projects with Org mode.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
Publication
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The glorious moment has arrived when you can publish the fruits of your labour. Emacs Org mode has powerful capabilities to export the text to various formats, most importantly PDF for physical books, ePub for ebooks and HTML for websites. The article on &lt;a href=&#34;https://lucidmanager.org/productivity/publishing-with-org-mode-export/&#34;&gt;Publishing Articles and Books with Org Mode Export&lt;/a&gt; discusses creating ebooks in detail.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-10&#34;&gt;
PDF format
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Org mode exports files to PDF through the LaTeX document preparation system popular with technical authors and publishers. Emacs will export your Org files to LaTeX format, which then exports your file to a beautifully designed document. Many journals accept LaTeX submissions, so you can also export your Org mode to a &lt;code class=&#34;verbatim&#34;&gt;.tex&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;PDF&lt;/code&gt; file to send to the editor.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-11&#34;&gt;
ePub format
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Org mode has built-in capabilities to export a file to HTML. The &lt;a href=&#34;https://github.com/ofosos/ox-epub&#34;&gt;ox-epub package&lt;/a&gt; by Mark Meyer leverages this functionality to produce a book in epub format.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-12&#34;&gt;
Word Processor
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The Org mode export functionality has built-in capabilities to export to the standard open document format, which is compatible with all commercial word processors.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-13&#34;&gt;
Websites
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Org mode can not only export to individual HTML files, but it can also publish them to a website. I use the &lt;a href=&#34;https://gohugo.io/&#34;&gt;Hugo software&lt;/a&gt; to convert my collection or Org mode files into my websites. Hugo provides extensive capabilities to use templates for your websites, including shortcodes to dynamically insert HTML in your pages beyond the current capabilities of Org Mode.&lt;/p&gt;
&lt;p&gt;
The article &lt;a href=&#34;https://lucidmanager.org/productivity/create-websites-with-org-mode-and-hugo/&#34;&gt;Create Websites with org Mode and Hugo&lt;/a&gt; discusses how to create a website, such as the one you are reading now.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-14&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-14&#34;&gt;
Communication
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-14&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs can also connect you to the world to communicate with other writers and your readers. &lt;/p&gt;
&lt;p&gt;
The software has built-in capabilities to read and write emails and several external packages, such as &lt;a href=&#34;https://www.djcbsoftware.nl/code/mu/&#34;&gt;mu4e&lt;/a&gt; and &lt;a href=&#34;https://www.cs.unb.ca/~bremner/scratch/notmuch-doc-wip/notmuch-emacs.html&#34;&gt;notmuch&lt;/a&gt; are available to make sense of your email. Using Emacs for email is a very efficient way to grind through your daily dose of electronic mail. Other packages let you connect to IRC, Reddit, Mastodon and other communication protocols.&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Emacs Writing Studio&lt;/em&gt; does not contain any configuration for communication packages.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-15&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-15&#34;&gt;
Administration
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-15&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Working through a writing project is a fantastic journey in creative expression, but there is also some overhead in managing your projects.&lt;/p&gt;
&lt;p&gt;
Emacs interfaces with other GNU software to help you &lt;a href=&#34;https://lucidmanager.org/productivity/manage-files-with-emacs/&#34;&gt;manage your files&lt;/a&gt; using the powerful directory editor (dired). Managing your files is a breeze with this package. You can also use Emacs to manage your photograph collection with the &lt;a href=&#34;https://lucidmanager.org/productivity/using-emacs-image-dired/&#34;&gt;built-in image-dired package&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
Lastly, working on a big project means tracking many tasks. Org mode has a &lt;a href=&#34;https://lucidmanager.org/productivity/getting-things-done-with-emacs/&#34;&gt;fully functional task management system&lt;/a&gt; to help you keep track of your projects. You can implement your personal workflow or use a Getting Things Done (GTD) approach.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-16&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-16&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-16&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The next article discusses how to use Emacs to &lt;a href=&#34;https://lucidmanager.org/productivity/reading-ebooks-with-emacs/&#34;&gt;read ebooks and other electronic documents&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Reading eBooks with Emacs</title>
      <link>https://lucidmanager.org/productivity/reading-ebooks-with-emacs/</link>
      <pubDate>Sat, 02 Sep 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/reading-ebooks-with-emacs/</guid>
      <description>
	
&lt;p&gt;
The first step in the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-workflow/&#34;&gt;workflow&lt;/a&gt; is ingestion (reading, listening and watching) new content. Reading ebooks with Emacs is straightforward as it provides functionality to read several popular types of electronic documents, such as PDF and ePub. The software can also browse the web with an unobtrusive plain text browser.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/RGUvNnO7lj4?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Emacs Writing Studio video demonstration of reading e-books, managing a bibliography, reading websites and listening to music.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Reading Documents
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs is excels at working with plain text in almost every imaginable format. However, it needs assistance from external software to display other document types, such as PDF or office formats. The diagram below shows the various external software packages necessary to render pages from the supported file formats. When you start the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration, you will receive a warning if any of the required packages is unavailable on your system.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/doc-view.png&#34; alt=&#34;Document conversion in Doc-View&#34; title=&#34;Document conversion in Doc-View&#34; width=&#34;300&#34;/&gt;
&lt;figcaption&gt;
Document conversion in Doc-View.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
ePub files
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;An ePub file (Electronic Publication) is a widely used open standard format for digital books, magazines, and other written content. The content can adapt to different screen sizes, making it ideal for e-readers, tablets, and other devices.&lt;/p&gt;
&lt;p&gt;
An ePub file is a website in a box. The content and the layout are stored in a ZIP file. You can see the raw content of an ePub file with an archiving utility. You need to install the &lt;code class=&#34;verbatim&#34;&gt;unzip&lt;/code&gt; package to view the content.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;nov&lt;/code&gt; package by &lt;a href=&#34;https://depp.brause.cc/nov.el/&#34;&gt;Vasilij Schneidermann&lt;/a&gt; lets you read ePub books inside Emacs. The code after the &lt;code class=&#34;verbatim&#34;&gt;:init&lt;/code&gt; line associates files with the &lt;code class=&#34;verbatim&#34;&gt;.epub&lt;/code&gt; extension to this package.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Read ePub files&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;nov&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:init&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;add-to-list&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;auto-mode-alist&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\.epub\\&amp;#39;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;nov-mode&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
You can now open ebooks like any other Emacs file. Use the arrow and &lt;code class=&#34;verbatim&#34;&gt;page-up&lt;/code&gt; / &lt;code class=&#34;verbatim&#34;&gt;page-down&lt;/code&gt; keys to navigate each chapter. Several keyboard shortcuts are available to navigate the book:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;t&lt;/code&gt;: go Table of contents&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;n&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;p&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;[&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;]&lt;/code&gt;: Next or previous chapter&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt;: Quit the ebook reader&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;?&lt;/code&gt;: Help file with list of other keyboard shortcuts&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To increase or decrease the text, use the &lt;code class=&#34;verbatim&#34;&gt;C-x C-+&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;C-c C--&lt;/code&gt; shortcuts. To reset the length of the lines, press &lt;code class=&#34;verbatim&#34;&gt;g&lt;/code&gt; to re-render the document.&lt;/p&gt;
&lt;p&gt;
The ebooks are opened as a read-only file. You can copy and paste text into your bibliographic notes. Opening the file as an archive with the &lt;code class=&#34;verbatim&#34;&gt;a&lt;/code&gt; key shows the document&amp;#39;s structure. From here, you can also copy images from the book with the &lt;code class=&#34;verbatim&#34;&gt;C&lt;/code&gt; keyboard shortcut. For more information about using files in Emacs, read &lt;a href=&#34;https://lucidmanager.org/productivity/manage-files-with-emacs/&#34;&gt;manage files with Emacs&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
PDF files
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Portable Document Format (PDF) is a versatile format developed by Adobe in the early 1990s. This format presents documents consistently, regardless of the software, hardware, or operating system used to view them. This format is codified in an international standard and has become the de facto standard for electronic literature.&lt;/p&gt;
&lt;p&gt;
The layout of PDF documents is fixed, in contrast with other electronic formats, which can adjust to the screen size. A PDF file is usually designed for printing and, as such, follows a traditional physical layout and typography.&lt;/p&gt;
&lt;p&gt;
Emacs can display PDF files out of the box with the DocView major mode. However, you will need some external software for DocView to work. &lt;a href=&#34;https://www.ghostscript.com/&#34;&gt;GhostScript&lt;/a&gt; or &lt;a href=&#34;https://mupdf.com/&#34;&gt;MUPDF&lt;/a&gt; convert PDF files to images and provides them to DocView. This approach works because Emacs has built-in functionality to &lt;a href=&#34;https://lucidmanager.org/productivity/using-emacs-image-dired/&#34;&gt;display and manipulate images&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
This conversion means that DocView can be sluggish with large documents and will warn you. The &lt;code&gt;large-file-warning-threshold&lt;/code&gt; variable sets the threshold for these warnings, which is 10 Mb by default. This value is a bit low for modern systems and in &lt;em&gt;Emacs Writing Studio&lt;/em&gt;, this threshold is 50 Mb.&lt;/p&gt;
&lt;p&gt;
Use the arrow and &lt;code class=&#34;verbatim&#34;&gt;page-up&lt;/code&gt; / &lt;code class=&#34;verbatim&#34;&gt;page-down&lt;/code&gt; keys to turn pages. Several keyboard shortcuts are available to navigate the file:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;P&lt;/code&gt;: Zoom to the full page&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;W&lt;/code&gt;: Fit document width to window&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;H&lt;/code&gt;: Fit height to window&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;+&lt;/code&gt; / &lt;code class=&#34;verbatim&#34;&gt;-&lt;/code&gt;: Zoom in and out&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;M-g g&lt;/code&gt;: Jump to page&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;M-&amp;lt;&lt;/code&gt; / &lt;code class=&#34;verbatim&#34;&gt;M-&amp;gt;&lt;/code&gt;: Jump to first page or last page&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;k&lt;/code&gt;: Kill (close) the file&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;?&lt;/code&gt;: Help file&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To enable searching in PDF and other supported document formats, you must have the &lt;code class=&#34;verbatim&#34;&gt;pdftotext&lt;/code&gt; software installed, which is part of the &lt;code class=&#34;verbatim&#34;&gt;poppler&lt;/code&gt; package, a PDF utility named after a &lt;a href=&#34;https://poppler.freedesktop.org/&#34;&gt;Futurama episode&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
You can search within the document with &lt;code&gt;doc-view-search&lt;/code&gt; (bound to &lt;code class=&#34;verbatim&#34;&gt;C-s&lt;/code&gt;), which starts a search, creates a list of all matching pages and shows how many pages that contain the search query were found. After completing the search, you can jump to the next page containing a match with an additional &lt;code class=&#34;verbatim&#34;&gt;C-s&lt;/code&gt;.  DocView does not highlight the searched term, but pressing &lt;code class=&#34;verbatim&#34;&gt;C-t&lt;/code&gt; (&lt;code&gt;doc-view-show-tooltip&lt;/code&gt;) shows the search results for this page in a tooltip.&lt;/p&gt;
&lt;p&gt;
Poppler also allows you to view a PDF file as a plain text file with the &lt;code class=&#34;verbatim&#34;&gt;C-c t&lt;/code&gt; shortcut (&lt;code&gt;doc-view-open-text&lt;/code&gt;). This option makes it easier to search and copy relevant text. Return to the graphical view of the text by pressing &lt;code class=&#34;verbatim&#34;&gt;C-c C-c&lt;/code&gt; twice.&lt;/p&gt;
&lt;p&gt;
We need some configuration to optimise how DocView displays pages. This code enhances the resolution of the page images to 300 DPI.&lt;/p&gt;
&lt;p&gt;
If you use Emacs 29.1 or higher and have the &lt;code class=&#34;verbatim&#34;&gt;MuPDF&lt;/code&gt; software available, then DocView will convert PDF pages to SVG files instead of PNG files, which provides a crisper image and better for zooming in closely.&lt;/p&gt;
&lt;p&gt;
Lastly, this configuration also moves the threshold for warning against opening large files to 50Mb ($50 \times 2^{20}$ bytes).&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Doc-View&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;doc-view&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;doc-view-resolution&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;300&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;doc-view-mupdf-use-svg&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;large-file-warning-threshold&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;50&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;expt&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;20&lt;/span&gt;))))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This article on the &lt;a href=&#34;https://emacsnotes.wordpress.com/2018/08/09/222/&#34;&gt;Emacs Notes website&lt;/a&gt; also provides a detailed explanation of how to configure and use DocView and enhances the dropdown menu functionality.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
DjVu Books
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The DjVu format is designed primarily to store scanned documents. DocView can read DjVu files when &lt;a href=&#34;https://djvu.sourceforge.net/&#34;&gt;DjVuLibre&lt;/a&gt; is available on your system.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Office Suite Documents
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The built-in DocView package can read Microsoft Office and LibreOffice files (text documents and presentations), but you first need to install the &lt;a href=&#34;https://www.libreoffice.org/&#34;&gt;LibreOffice software&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
When opening an office document, Emacs invokes LibreOffice to convert the file to a PDF, from where the abovementioned functionality is available.&lt;/p&gt;
&lt;p&gt;
There is currently a confirmed bug in Org mode (version 9.6.6) that overrides the associations between LibreOffice and Doc View mode. The code below is a workaround to reinstate the desired behaviour and associates the various file extensions with Doc View. The bug is slotted to be resolved in version 9.7.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Reading LibreOffice files&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ox-odt&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:ensure&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;;; Correct settings &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;add-to-list&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;auto-mode-alist&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\.\\(?:OD[CFIGPST]\\|od[cfigpst]\\)\\&amp;#39;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;doc-view-mode-maybe&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Reading websites
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs has a built-in web browser called &lt;code class=&#34;verbatim&#34;&gt;eww&lt;/code&gt; (The Emacs Web Wowser). This package provides a simple, no-frills experience focusing on readability by displaying a website as a plain text file. It can display images but does not render any CSS for formatting or JavaScript.&lt;/p&gt;
&lt;p&gt;
A wowser is somebody with strong moral views for temperance and abstinence. So perhaps the plain text approach to browsing is a moral stance on the current World Wide Web and its security and privacy issues.&lt;/p&gt;
&lt;p&gt;
You can open a URL or search the web with the command &lt;code class=&#34;verbatim&#34;&gt;M-x eww&lt;/code&gt;. If the input doesn&amp;#39;t look like a URL or domain name, Emacs searches the web with the DuckDuckGo search engine. &lt;/p&gt;
&lt;p&gt;
Use the arrow and page-up / page-down keys to navigate the page. Several keyboard shortcuts are available to navigate the webpage:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;&amp;lt;&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;&amp;gt;&lt;/code&gt;: Beginning and end of the page&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;R&lt;/code&gt;: Readable format (only display the main text)&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;M-I&lt;/code&gt;: Toggle images&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;H&lt;/code&gt;: Browsing history&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;&amp;amp;&lt;/code&gt;: Open the page in the external browser&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;G&lt;/code&gt;: New search or website&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt;: Quit the window&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;?&lt;/code&gt;: Help file with list of other keyboard shortcuts&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When opening a link to a website from inside Emacs, it will open the default browser on your operating system instead of &lt;code class=&#34;verbatim&#34;&gt;eww&lt;/code&gt;. If you prefer to use &lt;code class=&#34;verbatim&#34;&gt;eww&lt;/code&gt; as the default, add this to your configuration file: &lt;code&gt;(setq-default browse-url-browser-function &amp;#39;eww-browse-url)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
Many blogs and podcasts use RSS feeds to notify their readers of new content. The &lt;a href=&#34;https://lucidmanager.org/productivity/read-rss-feeds-with-emacs-and-elfeed/&#34;&gt;Elfeed package&lt;/a&gt; lets you follow your favourite web content using these feeds.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Reading eBooks with Emacs
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This chapter focused on how to read documents in non-text formats. Reading these formats requires external software, in sumarry, to read all these formats you need to install:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Ghostscript (&lt;code&gt;gs&lt;/code&gt;) or MuPDF (&lt;code&gt;mutool&lt;/code&gt;): Reading PDF files&lt;/li&gt;
&lt;li&gt;Poppler (&lt;code&gt;pdftotext&lt;/code&gt;): Converting PDF files to text&lt;/li&gt;
&lt;li&gt;LibreOffice (&lt;code&gt;soffice&lt;/code&gt;): Reading and exporting to office documents&lt;/li&gt;
&lt;li&gt;&lt;code&gt;unzip&lt;/code&gt;: Reading ePub ebooks&lt;/li&gt;
&lt;li&gt;DjVuLibre (&lt;code&gt;ddjvu&lt;/code&gt;): Reading DjVu ebooks&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration issues a warning when any of these packages is unavailable. Emacs will work normally, but some functionality might be unavailable.&lt;/p&gt;
&lt;p&gt;
Emacs can also publish documents in most of these formats, starting with an Org mode file and export this to the desired format. &lt;em&gt;Emacs Writing Studio&lt;/em&gt; discusses:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&#34;https://lucidmanager.org/productivity/publishing-with-org-mode-export/&#34;&gt;Publishing Articles and Books with Org Mode Export&lt;/a&gt; (PDF, office formats and ePub)&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://lucidmanager.org/productivity/create-websites-with-org-mode-and-hugo/&#34;&gt;Create websites with Emacs and Hugo&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, and everybody has personal preferences on how to undertake a task and configure Emacs. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The next article discusses how to read &lt;a href=&#34;https://lucidmanager.org/productivity/read-rss-feeds-with-emacs-and-elfeed/&#34;&gt;RSS feeds&lt;/a&gt; to follow your favourite blogs and podcasts.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Read RSS and Atom feeds with Emacs and Elfeed</title>
      <link>https://lucidmanager.org/productivity/read-rss-feeds-with-emacs-and-elfeed/</link>
      <pubDate>Thu, 17 Dec 2020 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/read-rss-feeds-with-emacs-and-elfeed/</guid>
      <description>
	
&lt;p&gt;
Finding interesting content on the internet can be like sifting your way through a piles of garbage to discover something valuable. Social media can be fun and engaging, but the cacophony of irrelevant content driven by dark algorithms is disheartening. RSS and Atom let you subscribe to the websites and blogs you enjoy, without having to subscribe via email. A feed is an XML file on a web server with recent articles, either the complete text or an excerpt. This article describes reading RSS and Atom files with Org mode and the Elfeed package.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
RSS and Atom Feeds
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://www.technewsworld.com/story/86699.html&#34;&gt;RSS is an elegant mechanism to consume content&lt;/a&gt; because you only get to see those blogs or podcasts that you subscribe to. When you use RSS, no algorithm decides what you can and cannot see. Subscribing to RSS feeds is anonymous, so you will not be spammed with email funnels trying to sell you stuff or services. Some websites have multiple feeds, so readers can subscribe to specific topics. &lt;/p&gt;
&lt;p&gt;
Atom feeds are a newer feed format that clarifies some of the ambiguities in RSS. Both feeds are a form of XML, and you need an aggregator to display the content. Unfortunately, RSS and Atom feeds have lost importance due to the dominance of social media. However, the technology is still alive and used in most websites. Browsers no longer point them out, and websites rarely prominently link to them like they used to, but the feeds still exist.&lt;/p&gt;
&lt;p&gt;
Some websites that offer feeds use the RSS logo. When this is not the case, you can still find the feed. Over 40% of websites use WordPress. In these websites, you can find the feed by adding &lt;code class=&#34;verbatim&#34;&gt;feed&lt;/code&gt; to the end of the URL. If all else fails, you can find the feed by looking at the page source by right-clicking on the page. Search for &lt;code class=&#34;verbatim&#34;&gt;rss-xml&lt;/code&gt;, copy the URL in the &lt;code class=&#34;verbatim&#34;&gt;href&lt;/code&gt; specification and Bob&amp;#39;s your uncle. For example, the RSS feed for Emacs articles on this website is:&lt;/p&gt;
&lt;p&gt;
&lt;code class=&#34;verbatim&#34;&gt;https://lucidmanager.org/tags/emacs/index.xml&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Elfeed
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;https://github.com/skeeto/elfeed&#34;&gt;Elfeed&lt;/a&gt; Emacs package manages and reads your favourite RSS feeds. You can list your favourite feeds and categorise them. The Elfeed browser helps you to navigate through your collection of unread articles or podcasts.&lt;/p&gt;
&lt;p&gt;
The custom section sets the location of the downloaded content to your Emacs configuration folder instead of your home folder. You can remove this line or use a different directory. The second part in the custom section instructs Elfeed to open posts in a separate window. The last line sets the keyboard shortcut to start Elfeed to &lt;code class=&#34;verbatim&#34;&gt;C-c w e&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Configure Elfeed&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;elfeed&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;elfeed-db-directory&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;expand-file-name&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;elfeed&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;user-emacs-directory&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#963&#34;&gt;elfeed-show-entry-switch&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;display-buffer&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w e&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;elfeed&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/elfeed-screendump.jpg&#34; alt=&#34;Emacs Elfeed screendump&#34; title=&#34;Emacs Elfeed screendump&#34; width=&#34;800&#34;/&gt;
&lt;figcaption&gt;
Elfeed screendump.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
You must install the &lt;a href=&#34;https://curl.se/download.html&#34;&gt;cURL program&lt;/a&gt;, which stands for &amp;#39;Client for URLs&amp;#39;. This program assists with downloading files from the internet. If cURL is unavailable, then Elfeed uses the slower built-in Emacs method to extract data. which only works on Unix-based systems.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Adding RSS Feeds
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The basic configuration for Elfeed includes a list of RSS feeds by setting the &lt;code&gt;elfeed-feeds&lt;/code&gt; list variable. You can easily access this variable with the &lt;code&gt;customise-variable&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;
There is, however, a more convenient way to manage your collection of RSS feeds. The &lt;a href=&#34;https://github.com/remyhonig/elfeed-org&#34;&gt;elfeed-org&lt;/a&gt; package lets you configure your list of favourite websites in an Org mode file.&lt;/p&gt;
&lt;p&gt;
The package reads the nominated Org mode file(s) and collects all internet addresses or links in the headers with the &lt;code class=&#34;verbatim&#34;&gt;:elfeed:&lt;/code&gt; tag. You can also attach other tags to any link in a headline to organise your feed by topic.&lt;/p&gt;
&lt;p&gt;
The example below shows how you can structure your Elfeed Org Mode file. Note that a tag applies to all headings at a lower level, so the &lt;code class=&#34;verbatim&#34;&gt;:elfeed:&lt;/code&gt; tag also applies to the Emacs and news headings. To get started, you can copy and paste this example into an Org File. This sample file is also available on the &lt;a href=&#34;https://github.com/pprevos/emacs-writing-studio/&#34;&gt;EWS GitHub repository&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+title: Elfeed configuration
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;* &lt;/span&gt;Blogs                                             :elfeed:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ** Emacs                                            :emacs:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  Anything Emacs related.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  *** https://lucidmanager.org/tags/emacs&lt;span style=&#34;font-style:italic&#34;&gt;/index.xml
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;font-style:italic&#34;&gt;  *** http:/&lt;/span&gt;/www.reddit.com/r&lt;span style=&#34;font-style:italic&#34;&gt;/emacs/&lt;/span&gt;.rss
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  *** https://www.youtube.com/feeds&lt;span style=&#34;font-style:italic&#34;&gt;/videos.xml?channel_id=UCEqYjPJdmEcUVfHmQwJVM9A
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;font-style:italic&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;font-style:italic&#34;&gt;  ** News                                             :news:
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;font-style:italic&#34;&gt;  *** [[https:/&lt;/span&gt;/www.abc.net.au/news/feed/2942460/rss.xml][ABC Australia]]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
You can either use the plain URL or an Org mode hyperlink. A hyperlink in Org mode consists of a nested set of square brackets &lt;code class=&#34;verbatim&#34;&gt;[[link][description]]&lt;/code&gt;. In Org mode, the link looks like a properly formatted hyperlink. You can insert a link with the &lt;code&gt;org-insert-ink&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c C-l&lt;/code&gt;) and follow the prompts in the minibuffer. You can select between many link types but need not worry about these when adding an internet link, just copy the URL and paste it in with &lt;code class=&#34;verbatim&#34;&gt;C-y&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://github.com/alphapapa/org-web-tools&#34;&gt;org-webtools package&lt;/a&gt; helps inserts fully formatted hyperlinks into Org mode. The &lt;code&gt;org-web-tools-insert-link-for-url&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c w w&lt;/code&gt;) constructs an Org mode link from a web address in the kill-ring (when you copy a link) and extracts the link title from the website. &lt;/p&gt;
&lt;p&gt;
The only configuration you need for &lt;code class=&#34;verbatim&#34;&gt;elfeed-org&lt;/code&gt; is to set the name of the Org file(s) you like to use to store your feed links. To add or remove a feed, edit this file and update the feed database with &lt;code class=&#34;verbatim&#34;&gt;M-x elfeed-update&lt;/code&gt;. You can also add text comments, as Elfeed only reads headings.&lt;/p&gt;
&lt;p&gt;
In &lt;em&gt;Emacs Writing Studio&lt;/em&gt;, the location of the Elfeed configuration is stored in the &lt;code&gt;ews-elfeed-config-file&lt;/code&gt; variable, defined in a &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;previous article&lt;/a&gt;. You can customise this variable to meet your needs or simple replace it with a string, e.g. &lt;code class=&#34;verbatim&#34;&gt;&amp;#34;~/Documents/elfeed.org&amp;#34;&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Configure Elfeed with org mode&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;elfeed-org&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;elfeed-org&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;rmh-elfeed-org-files&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;list&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ews-elfeed-config-file&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Easy insertion of weblinks&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-web-tools&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w w&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-web-tools-insert-link-for-url&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
When &lt;em&gt;Emacs Writing Studio&lt;/em&gt; is first loaded, a special function creates an Elfeed note with the Denote package when such a note does not yet exist. You can then find the Elfeed Denote file and start entering your configuration.&lt;/p&gt;
&lt;p&gt;
If you don&amp;#39;t use the full &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration, then remote the &lt;code&gt;:after denote&lt;/code&gt; line and change the expression after &lt;code&gt;rmh-elfeed-org-files&lt;/code&gt; to another name, for example, &lt;code class=&#34;verbatim&#34;&gt;(list &amp;#34;~/Documents/elfeed.org&amp;#34;)&lt;/code&gt;. Please note that this variable has to be a list with the filename(s) as strings.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Using Elfeed
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;You are now ready to read your RSS feeds. The first time you use Elfeed, use the &lt;code class=&#34;verbatim&#34;&gt;elfeed-update&lt;/code&gt; command to establish the database of feed content.&lt;/p&gt;
&lt;p&gt;
Press &lt;code class=&#34;verbatim&#34;&gt;C-c w e&lt;/code&gt; to start the Elfeed browser, which shows a list with the date and title of each entry, the feed&amp;#39;s name and any tags. When you hit &lt;code class=&#34;verbatim&#34;&gt;enter&lt;/code&gt;, Elfeed displays the webpage or a summary with a hyperlink to the web version in another window. You can use the following keystrokes to manage your feed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;G&lt;/code&gt;: Fetch feed updates from the servers&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;s&lt;/code&gt;: Update the search filter&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;c&lt;/code&gt;: Clear the search filter&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;r&lt;/code&gt; Mark the entry as read&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;u&lt;/code&gt;: Mark the entry as unread&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;g&lt;/code&gt;: Refresh view of the feed listing (remove unread items)&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;b&lt;/code&gt;: Open the article in the system browser&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt;: Quit Elfeed&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All new entries are tagged as unread by default. The other tags are derived from your list of RSS feeds.&lt;/p&gt;
&lt;p&gt;
When you remove a feed from your list, all articles that you previously downloaded will remain in the database and will show on your list until they are marked as read.&lt;/p&gt;
&lt;p&gt;
Elfeed has a powerful search filter that you can use to filter by tag, feed name and dates. The filter can process Regex queries. The &lt;a href=&#34;https://github.com/skeeto/elfeed/&#34;&gt;Elfeed manual&lt;/a&gt; describes the functionality in more detail than is warranted in this article.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/RGUvNnO7lj4?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Emacs Writing Studio video demonstration of reading e-books, managing a bibliography, reading websites and listening to music.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, and everybody has personal preferences on how to undertake a task and configure Emacs. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The next article in this series describes how to listen to music with the  &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emms/&#34;&gt;Emacs Multimedia System&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Configure EMMS: Emacs MultiMedia System on GNU/Linux</title>
      <link>https://lucidmanager.org/productivity/configure-emms/</link>
      <pubDate>Thu, 20 Aug 2020 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/configure-emms/</guid>
      <description>
	
&lt;p&gt;
Music is a great tool to boost your productivity. Playing the transcendental music of J.S. Bach or Sepultura&amp;#39;s screeching heavy metal soothes the soul while writing. Scientists have studied the &lt;a href=&#34;https://www.frontiersin.org/articles/10.3389/fnagi.2014.00284/full&#34;&gt;psychological effect of background music&lt;/a&gt; and found that it can improve episodic memory, intelligence, and verbal and visual processing speeds.&lt;/p&gt;
&lt;p&gt;
Emacs might be known as a text editor, but you can also play background music while you write, or listen to podcasts and videos in your information ingestion process. Emacs has several packages, such as &lt;a href=&#34;https://github.com/dbrock/bongo&#34;&gt;Bongo&lt;/a&gt; and &lt;a href=&#34;https://www.gnu.org/software/emms/&#34;&gt;EMMS&lt;/a&gt;, to help you access your collection of sound files. You might already have a great music player on your computer, but not having to switch applications to play music helps to retain your focus. &lt;/p&gt;
&lt;p&gt;
EMMS, the &lt;em&gt;Emacs Multimedia System&lt;/em&gt;, is a comprehensive music and video player for Emacs. It contains an intuitive browser that can show album covers and metadata. This article explains how to configure EMMS to convert your Emacs system into your personal jukebox.&lt;/p&gt;
&lt;p&gt;
This article is part of &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt;, a book that explains how to use Emacs to undertake research and write and publish articles, books, and websites. Emacs Writing Studio is available as an e-book from your favourite retailer.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Basic Installation
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;EMMS does not work out of the box when you install it via GNU ELPA. You will need some configuration and a music player. The minimum configuration for your &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;init file&lt;/a&gt; consists of these  lines:&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Emacs Multimedia System&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;emms&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;require&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;emms-setup&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;require&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;emms-mpris&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;emms-all&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;emms-default-players&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;emms-mpris-enable&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;emms-browser-covers&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;#&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#963&#34;&gt;emms-browser-cache-thumbnail-async&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w m b&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;emms-browser&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w m e&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;emms&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w m p&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;emms-play-playlist&lt;/span&gt; )
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;lt;XF86AudioPrev&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;emms-previous&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;lt;XF86AudioNext&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;emms-next&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;lt;XF86AudioPlay&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;emms-pause&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This configuration initiates EMMS with all its functionality and provides access to default music players. This setup is, however, not enough to fully enjoy your music. EMMS needs access to a music player to create sound and access to software to convert cover images to thumbnails.&lt;/p&gt;
&lt;p&gt;
To play sounds with Emacs, you must install one of the compatible sound players (ogg123, mpg321, mplayer, mpv or VLC). EMMS uses the &lt;code&gt;convert&lt;/code&gt; program of the &lt;a href=&#34;https://imagemagick.org/&#34;&gt;ImageMagick&lt;/a&gt;, a software suite to edit and manipulate digital images. When you run the complete &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration, the system will check whether one of the players and ImageMagick are available.&lt;/p&gt;
&lt;p&gt;
The last step to start playing music is to cache the music files. Evaluate the &lt;code&gt;emms-add-directory-tree&lt;/code&gt; command to scan your collection. EMMS creates a cache in your Emacs configuration directory.&lt;/p&gt;
&lt;p&gt;
EMMS can read metadata in music files for Ogg Vorbis, Opus, FLAC and MP3 files. This process might take a while, depending on the size of your collection. You can start playing music when &lt;code class=&#34;verbatim&#34;&gt;EMMS: All track information loaded&lt;/code&gt; shows in the minibuffer.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Play music with EMMS
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Phew, we can finally start enjoying the music collection. The basic principle is that you move tracks to the playlist buffer.&lt;/p&gt;
&lt;p&gt;
The browser is the most convenient way to select the music of your liking. You start the browser with &lt;code&gt;emms-browser&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c w m b&lt;/code&gt;). Loading the browser for the first time in an Emacs session might take a while if you have an extensive music collection.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/emms-screenshot.png&#34; alt=&#34;/images/emacs/emms-screenshot.png&#34; title=&#34;Screenshot of the EMMS browser&#34;/&gt;
&lt;figcaption&gt;
Screenshot of the EMMS browser.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
When in the EMMS browser, use the &lt;code class=&#34;verbatim&#34;&gt;b&lt;/code&gt; key followed by a number to browse by artist, album, genre, year, composer or performer. The browser is collapsed by default, showing only album covers, artist names, or whatever you select as the browsing category. The browser is hierarchical. When, for example, browsing by genre, the hierarchy has four levels &lt;em&gt;Genre&lt;/em&gt; &amp;gt; &lt;em&gt;Artist&lt;/em&gt; &amp;gt; &lt;em&gt;Album&lt;/em&gt; &amp;gt; &lt;em&gt;Track&lt;/em&gt;. Use the &lt;code class=&#34;verbatim&#34;&gt;1&lt;/code&gt; to collapse and the &lt;code class=&#34;verbatim&#34;&gt;2-4&lt;/code&gt; keys to expand the categories at levels 1 to 3. &lt;/p&gt;
&lt;p&gt;
As is the case in most Emacs applications, press &lt;code class=&#34;verbatim&#34;&gt;?&lt;/code&gt; for a list of available keystrokes, such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;r&lt;/code&gt;: Jump to a random entry&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;s&lt;/code&gt;: Search by album, artist, title, performer or composer&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;Enter&lt;/code&gt;: Add selection to playlist&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;C-j&lt;/code&gt;: Add selection to playlist and play&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;W&lt;/code&gt;: Lookup entry on Wikipedia&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Being an Emacs buffer, standard search commands will also work for visible entries.&lt;/p&gt;
&lt;p&gt;
When the cursor is on a category, such as an album name or a composer, it will add all tracks belonging to that category. So when the cursor is on an album it will add all tracks. When the cursor is on a single track, it will only add that track to  the playlist.&lt;/p&gt;
&lt;p&gt;
You jump to the playlist with &lt;code&gt;emms&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c w m e&lt;/code&gt;), from where you can manage what you play. Press &lt;code class=&#34;verbatim&#34;&gt;?&lt;/code&gt; for a list of keyboard shortcuts, some of which are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;n&lt;/code&gt; / &lt;code class=&#34;verbatim&#34;&gt;p&lt;/code&gt;: Next or previous track&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;r&lt;/code&gt;: Play a random track.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;D&lt;/code&gt;: Remove selected track from playlist&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;C&lt;/code&gt;: Clear playlist&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once you have curated a funky playlist, keep it for future reference. You can save a playlist buffer in &lt;code class=&#34;verbatim&#34;&gt;m3u&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;pls&lt;/code&gt; format for use in other multimedia players using the &lt;code&gt;save-buffer&lt;/code&gt; command (&lt;code class=&#34;verbatim&#34;&gt;C-x s&lt;/code&gt;). The &lt;code&gt;emms-play-playlist&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c w m p&lt;/code&gt;) lets you load and play a saved playlist.&lt;/p&gt;
&lt;p&gt;
The configuration above also sets the multimedia buttons on your keyboard (play, pause, next, previous). The MPRIS (&lt;a href=&#34;https://www.freedesktop.org/wiki/Specifications/mpris-spec/&#34;&gt;Media Player Remote Interfacing Specification&lt;/a&gt;) extension ensures that these buttons also work when you are playing music with EMMS but are not in Emacs.&lt;/p&gt;
&lt;p&gt;
EMMS has many advanced features available for advanced control of your sound collection. Some other useful EMMS functions are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;emms-play-directory&lt;/code&gt;: Add directory to playlist&lt;/li&gt;
&lt;li&gt;&lt;code&gt;emms-play-find&lt;/code&gt;: Plays all files in the music directory that match a given search criterion.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is only the start of using EMMS. The Emacs Multimedia System has a plethora of options you can use to fine-tune your listening experience. Read the &lt;a href=&#34;https://www.gnu.org/software/emms/manual/&#34;&gt;EMMS manual&lt;/a&gt; with the info browser (&lt;code class=&#34;verbatim&#34;&gt;C-h i&lt;/code&gt;) for detailed information about the various options.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, and everybody has personal preferences on how to undertake a task and configure Emacs. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The ingestion process of the Emacs Writing Studio workflow is now complete. The next article in this series starts the ideation process and describes how to &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/&#34;&gt;take notes with Org mode&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Taking Notes With the Emacs Denote Package</title>
      <link>https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/</link>
      <pubDate>Mon, 28 Aug 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/</guid>
      <description>
	
&lt;p&gt;
Over the years I have tried a cornucopia of digital applications to take notes. Emacs has several note-taking packages that extend basic functionality to help you manage your solidified thoughts. This article explains how to use Org mode and the &lt;a href=&#34;https://protesilaos.com/emacs/denote&#34;&gt;Denote package&lt;/a&gt; by Protesilaos Stavrou.&lt;/p&gt;
&lt;p&gt;
Denote excels in its simplicity and the ease by which it can be extended. The most exciting aspect of Denote is that it can help you manage any file type, not only notes in Org mode. I use Denote extensively to manage my Org mode and other types of notes, PDF documents, photographs and videos and anything else. Another advantage is that Denote does not necessarily rely on Emacs, you can search and view your notes with any software that can process plain text files.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/HFUAKJI0_SI?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Emacs Writing Studio: Ideation (Taking fleeting and permanent notes).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Creating Notes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Note-taking seems to have gained popularity in recent years judging by the flood of blog pages and videos that tell you how to best take notes. Whether Luhmann&amp;#39;s &lt;em&gt;Zettelkasten&lt;/em&gt; or Carroll&amp;#39;s &lt;em&gt;Bullet Journal&lt;/em&gt;, they all profess to solve all your personal knowledge management challenges. In my personal experience with paper and digital journals for over thirty years, the structure of your notes is not that important. The sincerity and originality of the thoughts contained within your notes has primacy over following some rigid system. My methodology is a primordial soup of thoughts from which my writings emerge. Even Luhmann himself saw his &lt;a href=&#34;https://niklas-luhmann-archiv.de/bestand/zettelkasten/zettel/ZK_2_NB_9-8a2_V&#34;&gt;Zettelkasten as a septic tank for ideas&lt;/a&gt;. However, we can apply some logic to our workflow.&lt;/p&gt;
&lt;p&gt;
Not all notes are created equal and the relevant workflow depends on their purpose. Broadly speaking, we can distinguish between six types of notes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Fleeting notes&lt;/li&gt;
&lt;li&gt;Permanent notes&lt;/li&gt;
&lt;li&gt;Bibliographic notes&lt;/li&gt;
&lt;li&gt;Journal entries&lt;/li&gt;
&lt;li&gt;Meta notes&lt;/li&gt;
&lt;li&gt;Attachments&lt;/li&gt;
&lt;/ol&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Fleeting notes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Fleeting notes are transient thoughts you store for a future review. You might have a sudden insight or remember a task you need to do. You quickly jot it down in your notebook and move on with whatever you were doing.&lt;/p&gt;
&lt;p&gt;
Physical notebooks or mobile phone applications are good methods to capture fleeting notes. Imagine you are in the middle of writing an article and suddenly you remind myself to put the rubbish bins out. In Org mode you don&amp;#39;t open a special note-taking application and break your focus with a complex workflow. Adding a fleeting note is only a few keystrokes away.&lt;/p&gt;
&lt;p&gt;
When you feel the urge to write a note that is unrelated to the buffer you are currently working in, simply press &lt;code class=&#34;verbatim&#34;&gt;C-c c&lt;/code&gt; and a the Org mode capture screen pops up. You select the relevant template and write your thoughts into the popup buffer and press &lt;code class=&#34;verbatim&#34;&gt;C-c C-c&lt;/code&gt; to save it. If you decide it was not worth storing after all, press &lt;code class=&#34;verbatim&#34;&gt;C-c C-k&lt;/code&gt; to cancel the input. Org mode then returns to where you left off and you happily continue with your task with minimal disturbance.&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration defines two types of fleeting notes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Textual notes&lt;/li&gt;
&lt;li&gt;New tasks&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When you create a new fleeting note, Org mode asks you wether you need a new fleeting note or a task. Any entries are stored under the relevant heading and new notes are placed directly under previous entries.&lt;/p&gt;
&lt;p&gt;
The basic structure of your inbox looks like this:&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+title: Inbox
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;* &lt;/span&gt;Notes
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;* &lt;/span&gt;Tasks&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The configuration below binds the keyboard shortcuts for capturing fleeting notes and links (see below on how to use links). The configuration also uses the &lt;code&gt;ews-inbox-file&lt;/code&gt; variable to store the filename of you fleeting note location, which is &lt;code class=&#34;verbatim&#34;&gt;~/Documents/inbox.org&lt;/code&gt; by default. You can of course customise this location to any filename of your choosing (see &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;configure Emacs&lt;/a&gt; for details).&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Fleeting notes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:after&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#963&#34;&gt;denote&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c c&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-capture&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c l&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-store-link&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-default-notes-file&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ews-inbox-file&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-capture-bookmark&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;;; Capture templates&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-capture-templates&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;f&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Fleeting note&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;item&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#963&#34;&gt;file+headline&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-default-notes-file&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Notes&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;- %?&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;p&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Permanent note&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;plain&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#963&#34;&gt;file&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-last-path&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;#&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#963&#34;&gt;denote-org-capture&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#007020&#34;&gt;:no-save&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#007020&#34;&gt;:immediate-finish&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#007020&#34;&gt;:kill-buffer&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#007020&#34;&gt;:jump-to-captured&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;t&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;New task&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;entry&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#963&#34;&gt;file+headline&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-default-notes-file&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Tasks&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;* TODO %i%?&amp;#34;&lt;/span&gt;))))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
As you create more and more fleeting notes your inbox steadily fills with random musings and actions. In my personal &lt;a href=&#34;https://lucidmanager.org/productivity/getting-things-done-with-emacs/&#34;&gt;Getting Things Done&lt;/a&gt; setup I promise myself to review these notes once per week and process them. You can use the &lt;code class=&#34;verbatim&#34;&gt;C-u C-c c&lt;/code&gt; shortcut to jump to the inbox for your chosen template.&lt;/p&gt;
&lt;p&gt;
The weekly process involves reviewing these entries and either:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Undertaking the actions&lt;/li&gt;
&lt;li&gt;Move the actions to your calendar&lt;/li&gt;
&lt;li&gt;Convert the fleeting note to a permananet note.&lt;/li&gt;
&lt;li&gt;Trashing the fleeting note.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ideally, your Inbox should trend towards zero content. &lt;/p&gt;
&lt;p&gt;
The Org mode capture templates are a versatile system that allows you to craft templates for different types of notes. You could, for example, create a separate entry for a shopping list that you synchronise with your mobile phone.&lt;/p&gt;
&lt;p&gt;
You can access the configuration in the capture menu with the &lt;code class=&#34;verbatim&#34;&gt;C&lt;/code&gt; button, which pops up the customisation screen for the &lt;code&gt;org-capture-templates&lt;/code&gt; variable. Next click the &lt;code class=&#34;verbatim&#34;&gt;INS&lt;/code&gt; button to add another entry and complete the relevant fields as below and save the new variable. The example below create a shopping list stored in a file in your Dropbox folder. Several mobile apps exist that can read Org mode files, so you can take your list to the shops if you have a means to synchronise the relevant files.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/org-capture-customisation.png&#34; alt=&#34;Org capture customisation&#34; title=&#34;Org capture customisation&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Org capture customisation.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The possibilities for capture templates are extensive and depend on your individual use cases. Explaining the configuration of the Org capture options in detail is outside the scope of this website. &lt;a href=&#34;https://orgmode.org/manual/Capture.html&#34;&gt;Section 10.1 of the Org manual&lt;/a&gt; discusses developing capture templates in detail.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Creating notes with Denote
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Denote package is amazingly flexible and can implement whatever note-taking approach you like to use, including a fully-fledged Zettelkasten approach or just a freeform stream of consciousness.&lt;/p&gt;
&lt;p&gt;
The driving force of the Denote package is its file-naming convention. This approach embeds any metadata in the filename so there is no need for complex nested folder structures to find your way through your jungle of notes.&lt;/p&gt;
&lt;p&gt;
The Denote file naming convention has five parts (all in lowercase by default), of which only the first part and file extensions are required:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Timestamp in &lt;a href=&#34;https://en.wikipedia.org/wiki/ISO_8601&#34;&gt;ISO 8601&lt;/a&gt; format with a &lt;code class=&#34;verbatim&#34;&gt;T&lt;/code&gt; separating date and time, e.g. &lt;code class=&#34;verbatim&#34;&gt;20230930T160112&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The signature of the note (freeform letters and numbers), staring with a double equals sign, e.g. &lt;code class=&#34;verbatim&#34;&gt;==9a12&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;Note title separated by dashes (&lt;a href=&#34;https://www.freecodecamp.org/news/snake-case-vs-camel-case-vs-pascal-case-vs-kebab-case-whats-the-difference/&#34;&gt;kebab-case&lt;/a&gt;), staring with a double dash, e.g. &lt;code class=&#34;verbatim&#34;&gt;--taking-notes-with-denote&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Keywords separated by an underscore (&lt;a href=&#34;https://www.freecodecamp.org/news/snake-case-vs-camel-case-vs-pascal-case-vs-kebab-case-whats-the-difference/&#34;&gt;snake_case&lt;/a&gt;), starting with a double underscore, e.g. &lt;code class=&#34;verbatim&#34;&gt;__emacs_productivity&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Filename extension so Emacs recognises your file type.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The default setting is that filenames are in all lowercase. So a full Denote file name for this example looks like this:&lt;/p&gt;
&lt;p&gt;
&lt;code class=&#34;verbatim&#34;&gt;20230930T160112==9a12--taking-notes-with-denote__emacs_productivity.org&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;
By default, Denote enforces lowercase characters in its filenames, but you can change his behaviour and &lt;a href=&#34;https://protesilaos.com/emacs/denote#h:6ae1ab8c-5e36-4216-8e93-f37f4447582c&#34;&gt;control the letter casing of file names&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The timestamp is a unique and immutable identifier that Denote uses for linking notes. The signature indicates a semantic order for notes, such as used in the . Semantic note-taking systems such Zettelkasten method. The keywords define categories the note belongs to. The signature, title and tags are flexible and can change over time without damaging the integrity of the system.&lt;/p&gt;
&lt;p&gt;
If you like to include signatures for your notes, then you need to use the &lt;code&gt;denote-signature&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;
All new notes are stored in the same folder, signified by the &lt;code&gt;denote-directory&lt;/code&gt; variable, which in EWS is mapped to &lt;code&gt;ews-notes-directory&lt;/code&gt;. There is technically no need to store notes in subdirectories, but you can do so with the &lt;code&gt;denote-subdirectory&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;
Using tags is a more versatile method to organise your information than subdirectories. If you use a subdirectory to order files, then part of the meta data for that file disappears as soon as you move or copy the file to another location. Also, a file can only live in one directory, but it can have multiple tags. Modern operating systems can easily manage tens of thousands of files in one directory, so use tags to categorise your information.&lt;/p&gt;
&lt;p&gt;
Configure the &lt;code&gt;denote-prompts&lt;/code&gt; variable to define the default way Denote generates and renames files.&lt;/p&gt;
&lt;p&gt;
Denote has a minor mode that formats compliant filenames in the &lt;a href=&#34;https://lucidmanager.org/productivity/manage-files-with-emacs/&#34;&gt;directory editor&lt;/a&gt; so it is easy to recognise the individual items of the note&amp;#39;s metadata. The filenames not only provide metadata for the note itself, they are also a heuristic to make it easy to find notes based on date, signatures, title or keyword.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/denote-dired.jpg&#34; alt=&#34;Extract of Denote files in Dired&#34; title=&#34;Extract of Denote files in Dired&#34;/&gt;
&lt;figcaption&gt;
Extract of Denote files in Dired.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Denote can generate notes in plain text, Markdown or Org mode. &lt;em&gt;Emacs Writing Studio&lt;/em&gt; uses the Org mode format because it is most suitable for writing bibliographic notes and managing citations. You can also use the Denote file naming convention for any other file types, for example to organise your photographs or PDF documents. So in Denote we can have notes (&lt;code class=&#34;verbatim&#34;&gt;txt&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;md&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;org&lt;/code&gt;) and any other file is an attachment.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Permanent notes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;A permanent note is a piece of information you like to retain long term. In my personal workflow, I regularly convert fleeting notes and writings in my paper notebook to permanent notes. &lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;denote-create-note&lt;/code&gt; function, which you activate with &lt;code class=&#34;verbatim&#34;&gt;C-c w d n&lt;/code&gt; creates new notes. It first asks for a title and then for the relevant keywords. You either select a keyword from the completion list in the minibuffer with the &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; key or you enter new ones, separated by a comma.&lt;/p&gt;
&lt;p&gt;
You can also create a permanent note through the Org capture mechanism with the &lt;code class=&#34;verbatim&#34;&gt;p&lt;/code&gt; option in the capture menu (&lt;code class=&#34;verbatim&#34;&gt;C-c c&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;
The title of the note becomes part of the filename. In Org mode, you can also add a subtitle to the note by adding &lt;code class=&#34;verbatim&#34;&gt;#+subtitle:&lt;/code&gt; to the front matter of your note.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Bibliographic notes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;A bibliographic note is a special category of permanent notes that link to one or more publications in your bibliography. The &lt;code class=&#34;verbatim&#34;&gt;citar-denote&lt;/code&gt; package provides extended functionality to create and manage bibliographic notes, &lt;a href=&#34;https://lucidmanager.org/productivity/bibliographic-notes-in-emacs-with-citar-denote/&#34;&gt;described in detail in another article&lt;/a&gt;.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Journal notes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;You can also use Denote for personal reflection and create a journal. Writing a journal with Denote is easy because the identifier for each note indicates the date and time you created each note. Adding a standard tag, such as &lt;code class=&#34;verbatim&#34;&gt;_journal&lt;/code&gt; makes your journal entries easy to distinguish from other notes.&lt;/p&gt;
&lt;p&gt;
If you like to create a note for an entry in the past, then use the &lt;code&gt;denote-date&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c w d d&lt;/code&gt;). You enter the date in Year-Month-Day (ISO 8601) notation like &lt;code class=&#34;verbatim&#34;&gt;2023-09-06&lt;/code&gt;. Optionally you can add a specific time, e.g: &lt;code class=&#34;verbatim&#34;&gt;2023-09-6 20:30&lt;/code&gt;. If no date and/or time is provided, Denote uses the present date and time. It makes sense to tag each journal entry with a standard keyword, e.g. &lt;code class=&#34;verbatim&#34;&gt;_journal&lt;/code&gt;, or whatever makes sense in your native language.&lt;/p&gt;
&lt;p&gt;
The Denote manual provides some &lt;a href=&#34;https://protesilaos.com/emacs/denote#h:4a6d92dd-19eb-4fcc-a7b5-05ce04da3a92&#34;&gt;extra functionality on keeping a journal or diary&lt;/a&gt;.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Meta notes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;A metanote provides an entry point to other notes about a similar topic. Lets say that you are working on a project to write a paper about the &lt;em&gt;daimonion&lt;/em&gt; (prophetic monitor) that spoke to ancient Greek philosopher Socrates. You read the literature and create a bunch of permanent and bibliographic notes that use the &lt;code class=&#34;verbatim&#34;&gt;_daimonion&lt;/code&gt; keyword. When it is time to gather your thoughts into an integrated view, you can create a new note that links to all your relevant notes.&lt;/p&gt;
&lt;p&gt;
Org mode uses dynamic blocks to achieve this. The &lt;code&gt;denote-org-dblock-insert-links&lt;/code&gt; function  (&lt;code class=&#34;verbatim&#34;&gt;C-c w d D&lt;/code&gt;) will ask you for a regular expression that matches the notes you like to list. The great thing about dynamic blocks is that you can update them in case new notes are added by hitting &lt;code class=&#34;verbatim&#34;&gt;C-c C-c&lt;/code&gt; twice when the cursor is on the &lt;code class=&#34;verbatim&#34;&gt;BEGIN&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;END&lt;/code&gt; line. &lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;#+BEGIN: &lt;/span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;denote-links&lt;/span&gt;&lt;span style=&#34;color:#888&#34;&gt; :regexp &amp;#34;_daimonion&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;- Plato: Apology
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;- Socrates and Plato
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;- Plato: Crito
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;#+END:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
To change the search criteria you change the text between quotation marks after the &lt;code class=&#34;verbatim&#34;&gt;:regexp&lt;/code&gt; part of the first line.&lt;/p&gt;
&lt;p&gt;
You could, for example, use this approach to collate your journal notes for a certain month. Using the regular expression &lt;code class=&#34;verbatim&#34;&gt;^202309.*_journal&lt;/code&gt; will list all your journal entries for September 2023. The regular expression lists filenames that starts with &lt;code class=&#34;verbatim&#34;&gt;202309&lt;/code&gt; and include the &lt;code class=&#34;verbatim&#34;&gt;_journal&lt;/code&gt; keyword. The tilde (&lt;code class=&#34;verbatim&#34;&gt;^&lt;/code&gt;) denotes that you are searching at the start of the filename. The &lt;code class=&#34;verbatim&#34;&gt;.*&lt;/code&gt; in the middle of the regular expression indicates that any character (&lt;code class=&#34;verbatim&#34;&gt;.&lt;/code&gt;) can appear multiple times (&lt;code class=&#34;verbatim&#34;&gt;*&lt;/code&gt;). In other words, this regular expression searches for all notes that start with &lt;code class=&#34;verbatim&#34;&gt;202309&lt;/code&gt;, then some random characters, followed by &lt;code class=&#34;verbatim&#34;&gt;_journal&lt;/code&gt;. The &lt;code class=&#34;verbatim&#34;&gt;.*&lt;/code&gt; expression effectively acts as an AND statement, so we look for a note that starts with &lt;code class=&#34;verbatim&#34;&gt;202309&lt;/code&gt; and contains &lt;code class=&#34;verbatim&#34;&gt;journal&lt;/code&gt;. The only restriction is that the two elements have to appear in this order. Using &lt;code class=&#34;verbatim&#34;&gt;^202308\|_journal&lt;/code&gt; searches for notes that start with &lt;code class=&#34;verbatim&#34;&gt;202308&lt;/code&gt; or contain &lt;code class=&#34;verbatim&#34;&gt;_journal&lt;/code&gt;. Regular expressions are a powerful tool for searching but detailed discussion is outside the scope of the &lt;em&gt;Emacs Writing Studio&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;
The latest version of Denote also lets you transclude the text of other notes inside a note. The &lt;code&gt;denote-org-dblock-insert-text&lt;/code&gt; function works much in the same way as the links version, but includes the text of the referenced notes inside the meta note.&lt;/p&gt;
&lt;p&gt;
The dynamic block option provides a versatile tool to aggregate your thoughts about a topic and link to relevant notes. They provide an easy entry point into your collection of notes and are a great starting point for your writing projects.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Attachments
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Denote&amp;#39;s reliance on a filename to store metadata allows you to manage files other than the three types specified by Denote, which we can call attachments. An attachment in Denote is any file that is not recognised by Denote as a note, but with a compatible filename. Any file stored in the Denote directory that follows the Denote file naming convention will be recognised as an attachment and can be linked from inside a Denote file.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;denote-file-types&lt;/code&gt; variable defines the file types that are considered notes (by default Org mode, Markdown and plain text). You only need to adust this variable if you like to use Denote to &lt;em&gt;create&lt;/em&gt; new notes in a non-standard format. No configuration is required to visit and link to attachments.&lt;/p&gt;
&lt;p&gt;
This means that your digital notes garden can be much more than just text, Markdown or Org files. You can &lt;a href=&#34;https://lucidmanager.org/productivity/using-emacs-image-dired/&#34;&gt;manage your photographs with Denote&lt;/a&gt;, store an archive of PDF files, such as bank statements, course certificates, or scans of your paper archive. Extending the Denote in this way converts your list of notes to a complete information management system with easy heuristics to find your documents and linking your them to notes. Extending the Denote in this way converts your list of notes to a complete information management system with great heuristics to enable finding attachments and linking your them to notes.&lt;/p&gt;
&lt;p&gt;
The use-cases for extending Denote to binary files are numerous. I personally save my &lt;a href=&#34;https://lucidmanager.org/productivity/using-emacs-image-dired/&#34;&gt;photographs&lt;/a&gt; and videos in the Denote file format. I also store numerous PDF files, such as documents I scan or receive in this format. You could store literature as attachments instead of in  &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-bibtex-mode/&#34;&gt;your bibliography&lt;/a&gt;, but then you lose the ability to cite them in your writing.&lt;/p&gt;
&lt;p&gt;
If you like to separate collections of files then you can use &lt;a href=&#34;https://protesilaos.com/emacs/denote#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5&#34;&gt;silos within Denote&lt;/a&gt;. A silos is a group of Denote files that do link to each other. The &lt;code class=&#34;verbatim&#34;&gt;denote-directory&lt;/code&gt; defines the default silo. If you want to link Denote files to each other, then they need to live within the same silo. Alternatively, you can create a symbolic link inside the Denote directory.&lt;/p&gt;
&lt;p&gt;
One use case would be to store all your tax receipts as PDF files. Getting ready for your tax return is than as easy as using a regular expression filter in Dired to mark all the files you need. Alternatively, you can link them all in an Org mode Denote file with a dynamic block using &lt;code&gt;denote-org-dblock-insert-links&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
For example, you tag all your tax records with the &lt;code class=&#34;verbatim&#34;&gt;_tax&lt;/code&gt; keyword and you can then find your 2023 tax files with the &lt;code class=&#34;verbatim&#34;&gt;^2023.*_tax&lt;/code&gt; regular expression, which creates a list of links.&lt;/p&gt;
&lt;p&gt;
You can also link to individual attachments inside a Denote file in the same way as you link your notes. It is obviously not possible to link back from an attachment to a note using Denote. &lt;/p&gt;
&lt;p&gt;
Denote recognises any file in the Denote directory that follows the correct naming convention. So the first step to register your attachment in Denote is giving it a compliant correct name.&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;denote-rename-file&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c w d r&lt;/code&gt;) lets you construct a Denote-compliant file name for attachments from within the &lt;a href=&#34;https://lucidmanager.org/productivity/manage-files-with-emacs/&#34;&gt;dired file manager&lt;/a&gt;. This function uses the filename as a default title, which you can of course modify. The user adds relevant keywords and the last modified timestamp for the file becomes the identifier.&lt;/p&gt;
&lt;p&gt;
However, the creation date on the file system is not always the actual creation date. When working with attachments there are three options for a valid timestamp:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;When the digitised document was created&lt;/li&gt;
&lt;li&gt;When the electronic file was born&lt;/li&gt;
&lt;li&gt;When the electronic file was created on the file system&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Using the universal argument &lt;code class=&#34;verbatim&#34;&gt;C-u&lt;/code&gt; instructs &lt;code&gt;denote-rename-file&lt;/code&gt; to ask the user to enter a date and/or time for the attachment.&lt;/p&gt;
&lt;p&gt;
So in &lt;em&gt;Emacs Writing Studio&lt;/em&gt;, use &lt;code class=&#34;verbatim&#34;&gt;C-u C-c d r&lt;/code&gt; to rename a file and manually provide a timestamp. You need to enter the timestamp is &lt;a href=&#34;https://en.wikipedia.org/wiki/ISO_8601&#34;&gt;ISO 8601 format&lt;/a&gt;, for example: &lt;code class=&#34;verbatim&#34;&gt;2023-11-04 12:32:45&lt;/code&gt;. Alternatively, when you use Org mode, you can customise the &lt;code&gt;denote-date-prompt-use-org-read-date&lt;/code&gt; variable.&lt;/p&gt;
&lt;p&gt;
Over the years I have gradually digitised my paper archives. The oldest timestamp in my Denote library is &lt;code class=&#34;verbatim&#34;&gt;13700623T120000&lt;/code&gt;, which is a scan of a historic document that holds the mortgage of &lt;a href=&#34;https://www.rijckheyt.nl/cultureel-erfgoed/drakenmolen&#34;&gt;the house in which I was born&lt;/a&gt;. The creation date of the document is 20 September 2021. The Denote renaming function uses the file system date, but in this case I need to manually create a timestamp that places the document in the distant past.&lt;/p&gt;
&lt;p&gt;
The second scenario mostly occurs with photographs. The timestamp on the file system might not be the same as the moment the photograph was taken. So in this situation we need to extract the creation date from the file. Several tools, such as &lt;a href=&#34;https://exiftool.org/&#34;&gt;exiftool&lt;/a&gt; are available to extract metadata from photographs and PDF files.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
Finding Notes and Attachments
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;When collecting &lt;a href=&#34;https://lucidmanager.org/productivity/testing-denote-package/&#34;&gt;thousands of notes and attachments&lt;/a&gt; it is important that you have a way into the system to find the information you need or to make new connections between ideas.&lt;/p&gt;
&lt;p&gt;
The most straightforward method to find files is by opening a file in your Denote directory. The &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-completion-system/&#34;&gt;minibuffer completion system&lt;/a&gt; helps you to find what you need.&lt;/p&gt;
&lt;p&gt;
If, for example, you like to filter to all notes tagged as Emacs, type &lt;code class=&#34;verbatim&#34;&gt;C-c C-f&lt;/code&gt; and move to your notes folder and type &lt;code class=&#34;verbatim&#34;&gt;_emacs&lt;/code&gt; and minibuffer completion narrows the options. If you need a note with Emacs in the title, but not as a tag, then use &lt;code class=&#34;verbatim&#34;&gt;-emacs&lt;/code&gt;. If you type &lt;code class=&#34;verbatim&#34;&gt;emacs&lt;/code&gt; without a prefix then you see all posts with Emacs in the signature, title or as a tag.&lt;/p&gt;
&lt;p&gt;
When you use the &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-completion-system/&#34;&gt;minibuffer completion configuration&lt;/a&gt; for the &lt;em&gt;Emacs Writing Studio&lt;/em&gt;, you can separate keywords with spaces in any order. You can apply the same approach to title words and signatures. For example, using the search string &lt;code&gt;--denote _ews ==9a&lt;/code&gt; shows all notes with a title that starts with Denote (using the double hyphen), include the &amp;#34;ews&amp;#34; keyword and have a signature that starts with &amp;#34;9a&amp;#34;.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://github.com/mclear-tools/consult-notes&#34;&gt;consult-notes package&lt;/a&gt; by Colin McLear merges the capabilities of Denote and the Daniel Mendler&amp;#39;s &lt;a href=&#34;https://github.com/minad/consult&#34;&gt;Consult package&lt;/a&gt; to help you find notes without having to remember which directory they live in. This package also provides facilities to search through the content of your notes collection. &lt;/p&gt;
&lt;p&gt;
To find a note by any part of its filename, use the &lt;code&gt;consult-notes&lt;/code&gt; function bound to &lt;code class=&#34;verbatim&#34;&gt;C-c w f&lt;/code&gt;. You can use all methods described in the section on finding notes to narrow your quest for the perfect note. The configuration for Consult-Notes can include your main Denote files and one or more silos, giving you full access to all your files in a convenient interface. &lt;/p&gt;
&lt;p&gt;
Search for titles, tags and other meta data is great, but sometimes you will want to search through the content of your notes. The &lt;code&gt;consult-notes-search-in-all-notes&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c w s&lt;/code&gt;) activates the search facilities. For this purpose, the package uses the &lt;a href=&#34;https://www.gnu.org/software/grep/&#34;&gt;grep software&lt;/a&gt;, which needs to be available on your system. &lt;em&gt;Emacs Writing Studio&lt;/em&gt; checks for the presence of external software at startup and &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;leaves a warning&lt;/a&gt; in the messages buffer.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-10&#34;&gt;
Linking Notes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;You can link notes and attachments with the &lt;code&gt;denote-link-or-create&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c w d i&lt;/code&gt;). This function provides a list of all available notes. Using the minibuffer completion system and the heuristics described in the previous section you can find the note you like to link to and hit &lt;code class=&#34;verbatim&#34;&gt;ENTER&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
The link only stores the identifier, e.g. &lt;code class=&#34;verbatim&#34;&gt;denote:20210208T150244&lt;/code&gt;. This means that you are free to change the signature, title or keywords of notes without having to worry about broken links. If you change the identifier timestamp in the filename, then Denote will be unable to find the linked document.&lt;/p&gt;
&lt;p&gt;
You follow a link in Org mode with the &lt;code&gt;org-open-at-point&lt;/code&gt; command, bound  to &lt;code class=&#34;verbatim&#34;&gt;C-c C-o&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
You can jump to any linked note with &lt;code&gt;denote-link-find-file&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c w d l&lt;/code&gt;). This function shows all notes linked in this file in the minibuffer so you can select the one you like to jump to. This saves you having to find the location of the link and click on it. To find out which notes link to the one that you are currently reading, use the &lt;code&gt;denote-find-backlink&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c w d b&lt;/code&gt;). This will, just like the previous function, show a list of all notes that are linked to the current one.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-11&#34;&gt;
Managing Meta Data
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you need to change the title or signature of a note, you can do so in the front matter inside the file. The &lt;code&gt;denote-rename-file-using-front-matter&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c w d R&lt;/code&gt;) renames the file based on the information in the file.&lt;/p&gt;
&lt;p&gt;
To conveniently change keywords with minibuffer completion, use the &lt;code&gt;denote-keyword-add&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c w d k&lt;/code&gt;) and &lt;code&gt;denote-keyword-remove&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c w d K&lt;/code&gt;) functions.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://lucidmanager.org/productivity/denote-explore/&#34;&gt;Denote-Explore package&lt;/a&gt; provides some additional functionality to manage Denote files.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-12&#34;&gt;
Configuring Denote
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The following lines of Elisp code configure Denote. This configuration sets the &lt;code&gt;ews-notes-directory&lt;/code&gt; variable as the repository for your Denote notes. You can change this location to any one you choose using the customisation menu, or replace  this variable with a string.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Denote&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:init&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;require&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;denote-org-dblock&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;denote-rename-buffer-mode&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;denote-directory&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ews-notes-directory&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:hook&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;dired-mode&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-dired-mode&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom-face&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;denote-faces-link&lt;/span&gt; ((&lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt; (&lt;span style=&#34;color:#007020&#34;&gt;:slant&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;italic&lt;/span&gt;)))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Denote extensions&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;consult-notes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:commands&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;consult-notes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               &lt;span style=&#34;color:#963&#34;&gt;consult-notes-search-in-all-notes&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;consult-notes-file-dir-sources&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#333&#34;&gt;`&lt;/span&gt;((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Denote&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#04d;background-color:#fff0f0&#34;&gt;?d&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;,&lt;/span&gt;&lt;span style=&#34;color:#963&#34;&gt;ews-notes-directory&lt;/span&gt;))))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-13&#34;&gt;
Learn more about Denote
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This article only provides a brief introduction to the Denote package. The extensive manual describes its full functionality in great detail. You can &lt;a href=&#34;https://protesilaos.com/emacs/denote#h:8b542c50-dcc9-4bca-8037-a36599b22779&#34;&gt;read the manual online&lt;/a&gt;, or read it inside Emacs with the &lt;code class=&#34;verbatim&#34;&gt;info&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-h R denote&lt;/code&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-14&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-14&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-14&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The next articles in this series discusses how to &lt;a href=&#34;https://lucidmanager.org/productivity/denote-explore/&#34;&gt;explore your Denote collection&lt;/a&gt; with some enhanced functionality.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Exploring Your Ideas With the Denote-Explore Package</title>
      <link>https://lucidmanager.org/productivity/denote-explore/</link>
      <pubDate>Fri, 08 Sep 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/denote-explore/</guid>
      <description>
	
&lt;p&gt;
The &lt;a href=&#34;https://protesilaos.com/emacs/denote&#34;&gt;Denote package&lt;/a&gt; by Protesilaos (Prot) Stavrou provides extensive functionality to create, retrieve, manage and link files in plain text, Markdown and Org Mode. The most redeeming qualities of this package are its filename convention and modular simplicity. You can also use the package to access other file types, such as PDFs or multimedia files (attachments). This way, Denote becomes a fully-featured file-management system. You can read more about Denote in the context of &lt;em&gt;Emacs Writing Studio&lt;/em&gt; in &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/&#34;&gt;another article&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The Denote-Explore package came into existence as my collection of Denote files grew. I created some auxiliary functions to manage and explore my burgeoning collection of Denote files, which I eventually packaged together. The package provides four types of commands:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;Summary statistics&lt;/em&gt;: Count notes, attachments and keywords.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Random walks&lt;/em&gt;: Generate new ideas using serendipity.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Janitor&lt;/em&gt;: Maintain your denote collection.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Visualisations&lt;/em&gt;: Visualise your Denote files as a network.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This article is part of &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt;, a book that explains how to use Emacs to undertake research and write and publish articles, books, and websites. Emacs Writing Studio is also available as an e-book from your favourite retailer.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
The Denote-Explore package is available on MELPA and GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/denote-explore/&#34; target=&#34;_blank&#34;
   title=&#34;Download denote-explore from GitHub&#34;
   alt=&#34;Download denote-explore from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;denote-explore&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/UylZOHIwnBw?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Emacs Writing Studio (Exploring your Denote digital knowledge garden).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Summary Statistics
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This Denote-Explore package distinguishes between Denote files (notes) and attachments. Denote files are either Org Mode, Markdown, or Plain Text. All other files, such as photographs, PDFs, media files, LaTeX, and HTML, are attachments.&lt;/p&gt;
&lt;p&gt;
After a day of working hard on your digital knowledge garden, you might like to count the notes and attachments in your collection. Two functions provide some basic statistics of your Denote files:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;denote-explore-count-notes&lt;/code&gt;: Count the number of notes and attachments. &lt;/li&gt;
&lt;li&gt;&lt;code&gt;denote-explore-count-keywords&lt;/code&gt;: Count the number of distinct Denote keywords. &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;These functions are informative, but a graph says more than a thousand numbers. The built-in &lt;code class=&#34;verbatim&#34;&gt;chart.el&lt;/code&gt; package by Eric M. Ludlam is a quaint tool for creating bar charts in a plain text buffer. Two commands are available in Denote-Explore to visualise basic statistics:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;denote-explore-keywords-barchart&lt;/code&gt;: Visualise the top &lt;em&gt;n&lt;/em&gt; keywords.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;denote-explore-extensions-barchart&lt;/code&gt;: Visualise used file extensions.&lt;/li&gt;
&lt;/ol&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/denote-keywords-barchart.png&#34; alt=&#34;Example of a bar chart of top-keywords&#34; title=&#34;Example of a bar chart of top-keywords&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Example of a bar chart of top-twenty keywords.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Random Walks
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Creativity springs from a medley of experiences, emotions, subconscious musings, and connecting random ideas. Introducing random elements into the creative process generates avenues of thought you might not have travelled otherwise. Random walks through your notes can be beneficial when you&amp;#39;re stuck in a rut or just like to walk through your files randomly.&lt;/p&gt;
&lt;p&gt;
A random walk is an arbitrary sequence of events without a defined relationship between the steps. You take a random walk by jumping to a random note, either connected or unconnected to the current buffer.&lt;/p&gt;
&lt;p&gt;
The Denote-Explore package provides four commands to inject some randomness into your explorations:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;denote-explore-random-note&lt;/code&gt;: Jump to a random note or attachment.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;denote-explore-random-link&lt;/code&gt;: Jump to a random linked note (either forward or backwards) or attachments (forward only).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;denote-explore-random-keyword&lt;/code&gt;: Jump to a random note or attachment with the same selected keyword(s).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;denote-explore-random-regex&lt;/code&gt;: Jump to a random note that matches a regular expression.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The default state is that these three functions jump to any Denote text file (plain text, Markdown or Org-mode). Adding the universal argument (&lt;code class=&#34;verbatim&#34;&gt;C-u&lt;/code&gt;) includes attachments as candidates for a random jump.&lt;/p&gt;
&lt;p&gt;
Jumping to a randomly linked file only works when the current buffer is a Denote file. A warning appears when the current buffer is an isolated note (no links or backlinks available).&lt;/p&gt;
&lt;p&gt;
When jumping to a random file with selected keywords, you can choose between one or more keywords from the current buffer, or you can override the completion options with free text. When the current buffer only has one keyword, the section process is skipped. When the current buffer is not a Denote file, you can choose any available keyword(s) in your Denote collection. The asterisk symbol &lt;code class=&#34;verbatim&#34;&gt;*&lt;/code&gt; selects all keywords in the completion list. Please note that jumping to a random note with multiple keywords only works when the &lt;code&gt;denote-sort-keywords&lt;/code&gt; is enabled or when the selected keywords are in the same order as in the target file. The following section explains how you can alphabetise your keywords using the Janitor.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Denote-Explore Janitor
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;After using Denote for a while, you might need a janitor to keep your collection organised. A janitor is a member of the maintenance and cleaning staff for buildings. Their primary responsibility is to ensure cleanliness, orderliness, and sanitation, so this role is also perfect to apply to your Denote files. The Denote-Explore package provides a series of commands to assist with cleaning, ordering and sanitising your files.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Duplicate notes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The Denote identifier is a unique string constructed of the note&amp;#39;s creation date and time in ISO 8601 format (e.g., &lt;code class=&#34;verbatim&#34;&gt;2024035T203312&lt;/code&gt;). Denote either uses the current date and time when generating a new note or the date and time the file was created on the file system. The Denote package prevents duplicate identifiers when creating a new note.&lt;/p&gt;
&lt;p&gt;
Besides my Denote-generated notes, I have historical attachments in my collection and manually add identifiers. My &amp;#39;oldest&amp;#39; Denote file is a mortgage document from 23 June 1370. The creation date and time of the file are irrelevant, as I like to keep my files sorted in historical order, so I manually add identifiers (for example &lt;code class=&#34;verbatim&#34;&gt;13700623T120000&lt;/code&gt;). I used the same approach when renaming scanned photographs in Denote format. Adding the Denote identifier manually introduces a risk of duplication. Duplicates can also arise when exporting Denote Org mode files, as the exported files have the same file name but a different extension.&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;denote-explore-identify-duplicate-notes&lt;/code&gt; command lists all duplicate identifiers in a popup buffer. Be careful when changing the identifier of a Denote file, as it can destroy the integrity of your links, so please ensure that the file you rename does not have any links pointing to it. You can use the &lt;code&gt;denote-find-link&lt;/code&gt; and &lt;code&gt;denote-find-backlink&lt;/code&gt; commands to check a file for links.&lt;/p&gt;
&lt;p&gt;
Using this command with the universal argument (&lt;code class=&#34;verbatim&#34;&gt;C-u&lt;/code&gt;), looks for duplicated filenames instead of identifiers. This option thus ignores any duplicated identifiers created when exporting Denote Org mode files.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Isolated notes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Denote implements a linking mechanism that connects notes (either Org mode, Markdown, or plain text) to other notes or attachments. This mechanism allows the user to visualise all notes as a network, as explained below. However, some notes don&amp;#39;t have any links or backlinks. Depending on your note-taking strategy, you might want all your notes linked to another note.&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;denote-explore-isolated-notes&lt;/code&gt; function provides a list in the minibuffer of all notes without links or backlinks for you to peruse. You can select any note and add any links. Calling this function with the universal argument &lt;code class=&#34;verbatim&#34;&gt;C-u&lt;/code&gt; includes attachments in the list of lonely files.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Managing Keywords
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Denote keywords connect notes with similar content. Keywords should not exist in solitude because a category with only one member is not informative. Single keywords can arise because topics need to be fully developed or due to a typo. The &lt;code&gt;denote-explore-single-keywords&lt;/code&gt; command provides a list of file tags that are only used once. The list of single keywords is presented in the minibuffer, from where you can open the relevant note or attachment.&lt;/p&gt;
&lt;p&gt;
You can also find any notes or attachments that don&amp;#39;t have any keywords at all with the &lt;code&gt;denote-explore-zero-keywords&lt;/code&gt;. This command presents all notes and attachments without keywords in the minibuffer, so you can open them and consider adding a keyword or leaving them as is.&lt;/p&gt;
&lt;p&gt;
You can remove or rename keywords with &lt;code&gt;denote-explore-rename-keyword&lt;/code&gt;. Select one or more existing keywords from the completion list and enter the new name of the keyword(s). This function renames all chosen keywords to their new version or removes the original keyword from all existing notes when you enter an empty string as the new keyword. This function cycles through all notes and attachments containing one or more of the selected keywords and asks for confirmation before making any changes. The new keyword list is stored alphabetically, and the front matter is synchronised with the file name.&lt;/p&gt;
&lt;p&gt;
Denote sorts keywords alphabetically when the &lt;code&gt;denote-sort-keywords&lt;/code&gt; variable is enabled. Ordering keywords alphabetically makes searching for files more predictable. If you rename files manually, the keywords might not always be in the correct order. The &lt;code&gt;denote-explore-sort-keywords&lt;/code&gt; function checks all notes and notifies the user if there are any notes where keywords are not alphabetised. The function warns the user before renaming any files. This function also synchronises the front matter with the file name.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Synchronising Meta Data
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Denote stores the metadata for each note in the filename using its ingenious format. Some of this metadata is copied to the front matter of a note, which can lead to differences between the two metadata sources.&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;denote-explore-sync-metadata&lt;/code&gt; function checks all notes and asks the user to rename any file where these two data sets are mismatched. The front matter data is the source of truth. This function also enforces the alphabetisation of keywords, which assists with finding notes.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Visualise Denote
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs is a text processor with limited graphical capabilities. Committing your ideas to text requires a linear way of thinking, as you can only process one word at a time. In my paper journal, I often use diagrams, such as a mind map, rather than a narrative to relate my thoughts. Visual thinking is another way to approach your ideas, and one of the most common methods to visualise interlinked documents is in a network diagram.&lt;/p&gt;
&lt;p&gt;
Viewing your notes as a network can help discover hitherto unseen connections between your thoughts. Visualising your Denote digital garden can be helpful in your creative process.&lt;/p&gt;
&lt;p&gt;
Denote Explore does not provide a live environment to view the structure of your Denote collection. The purpose of network visualisation is to analyse the structure of your notes, not to act as an alternative user interface. Live previews of note networks are dopamine traps. While seeing the network of your thoughts develop in front of your eyes is satisfying, it can also become a distraction. The Denote-Explore visualisation tools provide a surgical tool to analyse and restructure your notes.&lt;/p&gt;
&lt;p&gt;
A network diagram has nodes (vertices) and edges. Each node represents a file in your Denote system, indicated with a circle. Each edge is a link between notes. Denote-Explore provides three types of network diagrams to explore the relationships between your thoughts. The package exports and displays each of these in one of three formats, with SVG files viewed in the browser as the default.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/denote-explore-example.png&#34; alt=&#34;Visualising Denote files as a network&#34; title=&#34;Visualising Denote files as a network&#34; width=&#34;250&#34;/&gt;
&lt;figcaption&gt;
Visualising Denote files as a network.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
You create a network with the &lt;code&gt;denote-explore-network&lt;/code&gt; command. This command will ask the user to select the type of network to create. Each network type requires additional inputs to zoom in to a defined part of your Denote files.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-9&#34;&gt;
Community of Notes
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;A community consists of notes that share part of an ID, name, signature or keyword. The software asks to enter a search term or regular expression. For example, all notes with Emacs as their keyword (&lt;code class=&#34;verbatim&#34;&gt;_emacs&lt;/code&gt;), or all notes with a certain part of a signature, e.g. &lt;code&gt;==ews01&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
The regular expression &lt;code&gt;==ews01.*_emacs&lt;/code&gt; selects all notes with &lt;code class=&#34;verbatim&#34;&gt;ews01&lt;/code&gt; in their signature and &lt;code class=&#34;verbatim&#34;&gt;emacs&lt;/code&gt; and a keyword. The &lt;code class=&#34;verbatim&#34;&gt;.*&lt;/code&gt; in the middle of the regular expression indicates that any character (&lt;code class=&#34;verbatim&#34;&gt;.&lt;/code&gt;) can appear multiple times (&lt;code class=&#34;verbatim&#34;&gt;*&lt;/code&gt;). In other words, this regular expression searches for all notes that contain &lt;code class=&#34;verbatim&#34;&gt;ews01&lt;/code&gt;, then some random characters, followed by &lt;code class=&#34;verbatim&#34;&gt;_emacs&lt;/code&gt;. The &lt;code class=&#34;verbatim&#34;&gt;.*&lt;/code&gt; expression effectively acts as an AND statement. The only restriction is that the two elements have to appear in this order. Using &lt;code&gt;=ews01\|_journal&lt;/code&gt; searches for notes that contain &lt;code&gt;_ews01&lt;/code&gt; OR &lt;code class=&#34;verbatim&#34;&gt;_journal&lt;/code&gt;. Regular expressions are a powerful tool for searching but a detailed discussion is outside the scope of &lt;em&gt;Emacs Writing Studio&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;
A community graph displays all notes matching the search term and their connections. The algorithm prunes any links to non-matching notes (dotted line in the example).&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;denote-explore-network-regex-ignore&lt;/code&gt; variable lets you define a regular expression of notes to ignore in your visualisations. Lets assume you create meta notes with long lists of dynamic links and they have the &lt;code class=&#34;verbatim&#34;&gt;_meta&lt;/code&gt; keyword, then you could exclude this set of nodes by setting this variable to &amp;#34;&lt;code class=&#34;verbatim&#34;&gt;_meta&lt;/code&gt;&amp;#34;.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/denote-explore-community.png&#34; alt=&#34;Community of Denote files with Emacs keyword&#34; title=&#34;Community of Denote files with Emacs keyword&#34; width=&#34;300&#34;/&gt;
&lt;figcaption&gt;
Community of Denote files with Emacs keyword.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
To generate a community graph, use &lt;code&gt;denote-explore-network&lt;/code&gt;, choose community and enter a search string or regular expression.&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;denote-explore-network-regenerate&lt;/code&gt; command recreates the current graph with the same parameters, which is useful when changing the structure of your notes and you like to see the result visualised.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-10&#34;&gt;
Note Neighbourhood
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;The neighbourhood of a note consists of all files linked to it at one or more steps deep. The algorithm selects members of the graph from linked and backlinked notes. This visualisation effectively creates the possible paths you can follow with the &lt;code&gt;denote-explore-random-link&lt;/code&gt; function discussed in the Random Walks session above.&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;denote-explore-network-regex-ignore&lt;/code&gt; variable lets you define a regular expression of notes to ignore in your visualisations. Lets assume you create meta notes with long lists of dynamic links and they have the &lt;code class=&#34;verbatim&#34;&gt;_meta&lt;/code&gt; keyword, then you could exclude this set of nodes by setting this variable to &amp;#34;&lt;code class=&#34;verbatim&#34;&gt;_meta&lt;/code&gt;&amp;#34;.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/denote-explore-neighbourhood.png&#34; alt=&#34;Denote neighbourhood of files&#34; title=&#34;Denote neighbourhood of files&#34; width=&#34;250&#34;/&gt;
&lt;figcaption&gt;
Denote neighbourhood of files (depth = 2).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
To generate a neighbourhood graph from the current Denote note buffer, use &lt;code&gt;denote-explore-network&lt;/code&gt; and enter the graph&amp;#39;s depth. The user enters the required depth, and the software searches all notes linked to the current buffer at that depth. When building this graph from a buffer that is not a Denote note, the system also asks to select a source file (A in the diagram). The system issues a warning when you select a note without links or backlinks. You can identify your Denote files without any links with the &lt;code&gt;denote-explore-isolated-notes&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;denote-explore-network-regenerate&lt;/code&gt; command recreates the current graph with the same parameters, which is useful when you want to change the structure of your notes after viewing the first version of the graph.&lt;/p&gt;
&lt;p&gt;
The complete set of your Denote files is most likely a disconnected Graph, meaning that there is no one path that connects all nodes. Firstly, there will be isolated notes. There will also exist isolated neighbourhoods of notes that connect to each other but not to other files.&lt;/p&gt;
&lt;p&gt;
A depth of more than three links is usually not informative because the network can become very large and hard to read, or you hit the edges of your island of connected notes.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-11&#34;&gt;
Keyword Network
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;The last available method to visualise your Denote collection is to develop a network of keywords. Two keywords are connected when used in the same note. All keywords in a note create a complete network. The union of all complete networks from all files in your Denote collection defines the keywords network. The relationship between two keywords can exist in multiple notes, so the links between keywords are weighted. The line thickness between two keywords indicates the frequency (weight) of their relationship.&lt;/p&gt;
&lt;p&gt;
When generating this graph, you will need to enter a minimum edge weight for the graph. The graph then will only show those keywords that are at least &lt;em&gt;n&lt;/em&gt; times associated with each other. The default is one, which can generate a rather large graph.&lt;/p&gt;
&lt;p&gt;
While the first two graph types are directed (arrows indicate the direction of links), the keyword network is undirected as these are bidirectional associations between keywords. The diagram below shows a situation with two nodes and three possible keywords and how they combine into a keyword network. &lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/denote-explore-keywords.png&#34; alt=&#34;Denote network of keywords example&#34; title=&#34;Denote network of keywords example&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Denote network of keywords example.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Some keywords should be excluded from this graph because they skew the results. For example, when using the &lt;a href=&#34;https://lucidmanager.org/productivity/bibliographic-notes-in-emacs-with-citar-denote/&#34;&gt;Citar Denote&lt;/a&gt; package, you might like to exclude the &lt;code class=&#34;verbatim&#34;&gt;bib&lt;/code&gt; keyword from the diagram because it is only used to minimise the search space for bibliographic notes and has no further semantic value. The &lt;code&gt;denote-explore-network-keywords-ignore&lt;/code&gt; variable lists keywords ignored in this visualisation.&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;denote-explore-network-regenerate&lt;/code&gt; command recreates the current graph with the same parameters, which is useful when you are changing your notes&amp;#39; structure.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-12&#34;&gt;
Network Layout and Presentation
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;Emacs cannot independently generate graphics and thus relies on external software. This package can use three external mechanisms to create graphs (configurable with &lt;code&gt;denote-explore-network-format&lt;/code&gt;), set to GraphViz SVG output by default.&lt;/p&gt;
&lt;p&gt;
The Denote-Explore network algorithm consists of four steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Use the &lt;code&gt;denote-explore-network&lt;/code&gt; function to enter the network type and pass on to another function to enter the required parameters.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The code generates a nested association list that holds all relevant metadata for the selected graph:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Metadata e.g.: &lt;code class=&#34;verbatim&#34;&gt;(meta (directed . t) (type . &amp;#34;Neighbourhood &amp;#39;20210104T194405&amp;#39; (depth: 2)&amp;#34;))&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Association list of nodes and their degrees, e.g., &lt;code class=&#34;verbatim&#34;&gt;(((id . &amp;#34;20210104T194405&amp;#34;) (name . &amp;#34;Platonic Solids&amp;#34;) (keywords &amp;#34;geometry&amp;#34; &amp;#34;esotericism&amp;#34;) (type . &amp;#34;org&amp;#34;) (degree . 4)) ...)&lt;/code&gt;. In the context of Denote, the degree of a network node is the unweighted sum of links and backlinks in a note. &lt;/li&gt;
&lt;li&gt;Association list of edges and their weights, e.g., &lt;code class=&#34;verbatim&#34;&gt;(((source . &amp;#34;20220529T190246&amp;#34;) (target . &amp;#34;20201229T143000&amp;#34;) (weight . 1)) ...)&lt;/code&gt;. The weight of an edge indicates the number of times it occurs, which is the number of time two files are linked or the number of times two keywords appear in the same note.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The package encodes the association list to a GraphViz DOT file, JSON file, or GEXF file. The location and name of this file is configurable with the  &lt;code&gt;denote-explore-network-directory&lt;/code&gt; and &lt;code&gt;denote-explore-network-filename&lt;/code&gt; variables.&lt;/li&gt;
&lt;li&gt;Relevant external software is called upon to display the result.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The &lt;code&gt;denote-explore-network-graph-formats&lt;/code&gt; variable defines the file extension and the relevant functions for encoding and visualisation for each graph format.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-5&#34;&gt;
&lt;h5 id=&#34;headline-13&#34;&gt;
GraphViz
&lt;/h5&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-5&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://graphviz.org/&#34;&gt;GraphViz&lt;/a&gt; is an open-source graph visualisation software toolkit, ideal for this task. The Denote-Explore software saves the graph in the DOT language as a &lt;code class=&#34;verbatim&#34;&gt;.gv&lt;/code&gt; file. The GraphViz software converts the DOT code to an &lt;code class=&#34;verbatim&#34;&gt;SVG&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;
You will need to install the GraphViz software to enable this functionality. Denote-Explore will raise an error when trying to create a GraphViz graph without the required external software available.&lt;/p&gt;
&lt;p&gt;
The configurable &lt;code&gt;denote-explore-network-graphviz-header&lt;/code&gt; variable defines the basic settings for GraphViz graphs, such as the layout method and default node and edge settings.&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;denote-explore-network-graphviz-filetype&lt;/code&gt; variable defines the &lt;a href=&#34;https://graphviz.org/docs/outputs/&#34;&gt;GraphViz output format&lt;/a&gt;. SVG (the default) or PDF provide the best results. The SVG format should be viewed in a web browser to view tooltips of nodes to show their name and other meta data, and to follow hyperlinks. Emacs can display SVG files, but is unable to follow links or show tootltips.&lt;/p&gt;
&lt;p&gt;
Hovering the mouse cursor over a node provides its name and other meta data. You can open the relevant file by clicking on the node, which works best when using &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html&#34;&gt;Emacs as a server&lt;/a&gt;, if you configure your browser to open Org mode, Markdown and text files with the Emacs client. Links only work in neighbourhood and community graphs. These interactive functions are only available when viewing SVG files in a web browser.&lt;/p&gt;
&lt;p&gt;
The diameter $D$ of nodes are sized relative to their degree $d$: $D = \sqrt{d + 1}$. Thus, the most referenced note in your system will be the most visible. For nodes with a degree greater than two, the name is displayed outside the node (top left). When generating a neighbourhood, the source node is marked in a contrasting colour. In keyword graphs, the thickness of the edges indicates the number of times two keywords are associated with each other.&lt;/p&gt;
&lt;p&gt;
The layout of the graph uses the &lt;a href=&#34;https://graphviz.org/docs/layouts/neato/&#34;&gt;Neato spring model&lt;/a&gt; in GraphViz. &lt;/p&gt;
&lt;p&gt;
This method is ideal for viewing small parts of your network. The network will be hard to read when the number of notes becomes too large. I have not yet figured out how to better scale the output based on the number of nodes in a graph.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/denote-explore-neighbourhood-graphviz.png&#34; alt=&#34;Example GraphViz visualisation:title Example GraphViz visualisation&#34; title=&#34;/images/emacs/denote-explore-neighbourhood-graphviz.png&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Example GraphViz visualisation.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-14&#34; class=&#34;outline-5&#34;&gt;
&lt;h5 id=&#34;headline-14&#34;&gt;
D3.js
&lt;/h5&gt;
&lt;div id=&#34;outline-text-headline-14&#34; class=&#34;outline-text-5&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://d3js.org/&#34;&gt;D3.js&lt;/a&gt; is a JavaScript library for data visualisation. This method provides an aesthetically pleasing and interactive view of your note collection. The Denote-Explore package stores the desired network as a JSON file.&lt;/p&gt;
&lt;p&gt;
The JavaScript file is generated with the R language as I have not yet mastered JavaScript to write it myself from scratch. R saves the network as an &lt;code class=&#34;verbatim&#34;&gt;HTML&lt;/code&gt; file in the designated folder with the &lt;a href=&#34;https://christophergandrud.github.io/networkD3/&#34;&gt;networkD3 R package&lt;/a&gt;. Hover over any node to reveal its name.&lt;/p&gt;
&lt;p&gt;
The colours indicate a statistical grouping based on the connections between nodes. This grouping is calculated with the &lt;em&gt;Walktrap&lt;/em&gt; community detection algorithm, which finds communities of nodes by assessing which ones are more connected to each other than to nodes outside the community. &lt;/p&gt;
&lt;p&gt;
To enable this view, you must install the R language on your system. R will install some required libraries when you run this code for the first time. Any JavaScript developers interested in writing a better solution are cordially invited to submit improvements.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/denote-explore-d3js.png&#34; alt=&#34;Example D3.js visualisation&#34; title=&#34;Example D3.js visualisation&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Example D3.js visualisation.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-15&#34; class=&#34;outline-5&#34;&gt;
&lt;h5 id=&#34;headline-15&#34;&gt;
Graph Exchange XML Format
&lt;/h5&gt;
&lt;div id=&#34;outline-text-headline-15&#34; class=&#34;outline-text-5&#34;&gt;
&lt;p&gt;The first two formats provide some analysis of your knowledge network, but there is a lot more you can do with this type of information. While GraphViz and D3 are suitable for analysing parts of your network, this third option is ideal for storing the complete Denote network for further analysis. To do this, use the Community option and enter an empty search string to include all files.&lt;/p&gt;
&lt;p&gt;
Graph Exchange XML Format ( &lt;a href=&#34;https://gexf.net/&#34;&gt;GEXF&lt;/a&gt;) is a language for describing complex network structures. This option saves the network as a &lt;code class=&#34;verbatim&#34;&gt;GEXF&lt;/code&gt; file without opening it in external software. &lt;/p&gt;
&lt;p&gt;
You can analyse the exported file with &lt;a href=&#34;https://gephi.org/gephi-lite/&#34;&gt;Gephi Lite&lt;/a&gt;, a free online network analysis tool. The &lt;code class=&#34;verbatim&#34;&gt;GEXF&lt;/code&gt; file only contains the IDs, names and degree of the nodes, and the edges and their weights. &lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/gephi-lite-export.png&#34; alt=&#34;Example Gephi Lite visualisation:title Example Gephi Lite visualisation&#34; title=&#34;/images/emacs/gephi-lite-export.png&#34; width=&#34;800&#34;/&gt;
&lt;figcaption&gt;
Example Gephi Lite visualisation.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-16&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-16&#34;&gt;
Analysing the Denote Network
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-16&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;A well-trodden trope in network analysis is that all people are linked within &lt;a href=&#34;https://en.wikipedia.org/wiki/Six_degrees_of_separation&#34;&gt;six degrees of separation&lt;/a&gt;. This may also be the case for your notes, but digging more than three layers deep is not very informative as the network can become large and difficult to review.&lt;/p&gt;
&lt;p&gt;
It might seem that adding more connections between your notes improves them, but this is not necessarily the case. The extreme case is a complete network where every file links to every other file. This situation lacks any interesting structure and wouldn&amp;#39;t be very useful for analyses. So, be mindful of your approach to linking notes and attachments.&lt;/p&gt;
&lt;p&gt;
Your Denote network is unlikely to be a fully connected graph. In a connected graph, there is a path from any point to any other point. Within the context of Denote, this means that all files have at least one link or backlink. Your network will most likely have isolated nodes (files without any (back) links) and islands of connected notes. The previously discussed &lt;code&gt;denote-explore-isolated-notes&lt;/code&gt; function lists all files without any links and backlinks to and from the note in the minibuffer.&lt;/p&gt;
&lt;p&gt;
The number of links and backlinks in a file (in mathematical terms, edges connected to a node) is the degree of a node. The &lt;a href=&#34;https://en.wikipedia.org/wiki/Degree_distribution&#34;&gt;degree distribution&lt;/a&gt; of a network is the probability distribution of these degrees over the whole network. The &lt;code&gt;denote-explore-degree-barchart&lt;/code&gt; function uses the built-in chart package to display a simple bar chart of the frequency of degrees. This function might take a few seconds to run, depending on the number of notes in your system. Evaluating this function with the universal argument &lt;code class=&#34;verbatim&#34;&gt;C-u&lt;/code&gt; excludes attachments from the analysis.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-17&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-17&#34;&gt;
Installation and Package Configuration
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-17&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This package is available through MELPA. The configuration below customises all available variables and binds the interactive functions using the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; &lt;code class=&#34;verbatim&#34;&gt;C-c w&lt;/code&gt; prefix key and &lt;code class=&#34;verbatim&#34;&gt;e&lt;/code&gt; for Denote-Explore. You should modify this configuration to suit your needs, as one person&amp;#39;s sensible defaults are another person&amp;#39;s nightmare.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#888&#34;&gt;;; Statistics&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x c&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-count-notes&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x C&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-count-keywords&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x b&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-barchart-keywords&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x e&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-barchart-filetypes&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#888&#34;&gt;;; Random walks&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x r&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-random-note&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x l&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-random-link&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x k&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-random-keyword&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x x&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-random-regex&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#888&#34;&gt;;; Denote Janitor&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x d&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-identify-duplicate-notes&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x z&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-zero-keywords&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x s&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-single-keywords&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x o&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-sort-keywords&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x w&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-rename-keyword&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#888&#34;&gt;;; Visualise denote&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x n&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-network&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x v&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-network-regenerate&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w x D&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-explore-degree-barchart&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The most recent manual is available in Emacs which you can access with &lt;code class=&#34;verbatim&#34;&gt;C-h R denote-explore&lt;/code&gt; or by evaluating &lt;code&gt;(info &amp;#34;denote-explore&amp;#34;)&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-18&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-18&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-18&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, and everybody has personal preferences on how to undertake a task and configure Emacs. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The next article discusses how to &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-bibtex-mode/&#34;&gt;manage literature with BibTeX mode&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Manage Literature with Emacs BibTeX Mode</title>
      <link>https://lucidmanager.org/productivity/emacs-bibtex-mode/</link>
      <pubDate>Fri, 07 May 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/emacs-bibtex-mode/</guid>
      <description>
	
&lt;p&gt;
Authors need three resources: imagination, writing skills and the work of other writers. A common advice for authors to improve their writing is to read a lot. Keeping track of all the books and articles you read can be daunting. This article describes how to manage references and bibliographies with Emacs BibTeX mode. The &lt;code class=&#34;verbatim&#34;&gt;biblio&lt;/code&gt; package helps searching internet databases and add literature, and the &lt;code class=&#34;verbatim&#34;&gt;citar&lt;/code&gt; package provides access to your bibliography.&lt;/p&gt;
&lt;p&gt;
These Emacs packages let you create and manage bibliographies, &lt;a href=&#34;https://lucidmanager.org/productivity/reading-ebooks-with-emacs/&#34;&gt;read electronic documents&lt;/a&gt; and &lt;a href=&#34;https://lucidmanager.org/productivity/bibliographic-notes-in-emacs-with-citar-denote/&#34;&gt;take notes&lt;/a&gt;, turning Emacs into a fully-featured literature management system.&lt;/p&gt;
&lt;p&gt;
This article is part of &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt;, a book that explains how to use Emacs to undertake research and write and publish articles, books, and websites. Emacs Writing Studio is also available as an e-book from your favourite retailer.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Getting started with Emacs BibTeX mode
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs ships with &lt;code class=&#34;verbatim&#34;&gt;bibtex-mode&lt;/code&gt;, a major mode to create and manage bibliographies. This mode, as the name suggests, uses the &lt;a href=&#34;http://www.bibtex.org/&#34;&gt;BibTeX&lt;/a&gt; file format as your default literature database. BibTeX is a plain text format to manage literature and citations and is typically used for LaTeX typesetting, but also perfectly integrates with Org mode. A typical entry for a book will look like this:&lt;/p&gt;
&lt;pre class=&#34;example&#34;&gt;
@article{stallman_1981_emac,
  title      = {{{EMACS}} the Extensible, Customizable Self-Documenting Display Editor},
  author     = {Stallman, Richard M.},
  year       = 1981,
  journal    = {ACM SIGOA Newsletter},
  volume     = 2,
  number     = {1-2},
  pages      = {147--156},
  doi        = {10.1145/1159890.806466},
  keywords   = {Emacs}
  file       = {computing/stallman-1981-emacs.pdf}
}
&lt;/pre&gt;
&lt;p&gt;
Each entry starts with an &lt;code class=&#34;verbatim&#34;&gt;@&lt;/code&gt;-sign and the entry type, followed by a curly brace and a unique citation key. The following lines contain the relevant data about this entry, in this example, the earliest publication about Emacs.&lt;/p&gt;
&lt;p&gt;
BibTeX can process different types of literature, such as articles and conference papers, each of which has its own field types. BibTeX ignores any field names that are not recognised, which provides opportunities to use the file for other purposes, such as attaching files and keywords.&lt;/p&gt;
&lt;p&gt;
BibTeX is a plain text file with the &lt;code class=&#34;verbatim&#34;&gt;.bib&lt;/code&gt; extension. You can store one or more bibliography files in a central folder to refer to them from anywhere in Emacs. You can also attach specific BibTeX files to an Org mode file to set a bibliography for a project.&lt;/p&gt;
&lt;p&gt;
You don’t need to install any packages to get started. Just created an empty file with a &lt;code class=&#34;verbatim&#34;&gt;.bib&lt;/code&gt; extension, and Emacs enables &lt;code class=&#34;verbatim&#34;&gt;bibtex-mode&lt;/code&gt; when you open the file.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Adding new entries
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs &lt;code class=&#34;verbatim&#34;&gt;bibtex-mode&lt;/code&gt; uses templates to add new entries. To add a reference, use the &lt;code&gt;bibtex-entry&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c C-b&lt;/code&gt;). Use the minibuffer completion to select the relevant type. Emacs also provides a shortcut for every kind of literature, which you can see with &lt;code class=&#34;verbatim&#34;&gt;C-c C-e C-h&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
Each entry type has at least one compulsory field. Any optional fields start with &lt;code class=&#34;verbatim&#34;&gt;OPT&lt;/code&gt;. For fields that begin with &lt;code class=&#34;verbatim&#34;&gt;ALT&lt;/code&gt;, such as author or editor, you must complete at least one of them.&lt;/p&gt;
&lt;p&gt;
Jump from field to field with &lt;code class=&#34;verbatim&#34;&gt;C-j&lt;/code&gt; (&lt;code&gt;bibtex-next-field&lt;/code&gt;) and complete all required fields and one of the &lt;code class=&#34;verbatim&#34;&gt;ALT&lt;/code&gt; fields. When you’re done, press &lt;code class=&#34;verbatim&#34;&gt;C-c&lt;/code&gt; twice (&lt;code&gt;bibtex-clean-entry&lt;/code&gt;) to check the syntax and remove empty fields. This function also assigns a citation key to the entry using some configurable rules, but you can also set one manually.&lt;/p&gt;
&lt;p&gt;
To enter names, place the family name first, followed by a comma and the first name or initials. Any additional authors are separated by “and”, e.g. &amp;#34;Hawking, S. and Penrose, R.&amp;#34;.&lt;/p&gt;
&lt;p&gt;
If you copy and paste an author name, or it is automatically inserted using the &lt;code class=&#34;verbatim&#34;&gt;biblio&lt;/code&gt; tool discussed below, the first and family name might be the wrong way around. A nice Emacs hack is to use the &lt;code&gt;org-transpose-words&lt;/code&gt; function, bound to &lt;code class=&#34;verbatim&#34;&gt;M-t&lt;/code&gt;. This function swaps the order of two words, for example from &amp;#34;Richard Stallman&amp;#34; to &amp;#34;Stallman Richard&amp;#34;.&lt;/p&gt;
&lt;p&gt;
To align the lines of each entry, you can also use the &lt;code&gt;bibtex-fill-entry function&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c C-q&lt;/code&gt;). The table below summarises the most salient keyboard shortcuts and functions in &lt;code class=&#34;verbatim&#34;&gt;bibtex-mode&lt;/code&gt;.&lt;/p&gt;
&lt;figure&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Shortcut&lt;/th&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-c C-e a&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bibtex-article&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Add an article&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-c C-e b&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bibtex-book&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Add a book&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-c d&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bibtex-empty-field&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Empty the current field&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-j&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bibtex-next-field&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Jump to next field&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-down&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bibtex-next-entry&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Jump to the next entry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-up&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bibtex-previous-entry&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Jump to the previous entry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-c C-c&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bibtex-clean-entry&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Clean the entry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C-c C-q&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bibtex-fill-entry&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Align the fields&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bibtex-reformat&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Reformat all entries in region or buffer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bibtex-sort-buffer&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sort all entries in the buffer by their keys&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;figcaption&gt;
Overview of keyboard shortcuts to add and edit entries.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Importing existing BibTeX files
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;You can also link another bibliographic database, such as &lt;a href=&#34;https://www.zotero.org/&#34;&gt;Zotero&lt;/a&gt;, to Emacs. The Better &lt;a href=&#34;https://retorque.re/zotero-better-bibtex/&#34;&gt;BibTeX package&lt;/a&gt; in Zotero can export parts of or your complete bibliography as a BibTeX file every time it changes, keeping both version in sync.&lt;/p&gt;
&lt;p&gt;
Any existing bib file created with other software might not be fully compatible with &lt;code class=&#34;verbatim&#34;&gt;bibtex-mode&lt;/code&gt; because some high-level features are unavailable in BibTeX mode. The &lt;code class=&#34;verbatim&#34;&gt;bibtex-convert-alien&lt;/code&gt; function checks whether &lt;code class=&#34;verbatim&#34;&gt;bibtex-mode&lt;/code&gt; can parse an ’alien’ BibTeX file. Files generated with Zotero do not seem to require this conversion step.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Fine-tuning BibTeX mode
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;BibTeX mode works out of the box, but you can fine-tune the variables. This Elisp expression adds optional fields for keywords and files for each entry type. These fields are essential when using the bibliographic files to read electronic documents and take notes. This expression also instructs Emacs to align the equal signs for each entry when you press &lt;code class=&#34;verbatim&#34;&gt;C-q&lt;/code&gt;. &lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Managing Bibliographies&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;bibtex&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;bibtex-dialect&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;BibTeX&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;bibtex-user-optional-fields&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;keywords&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Keywords to describe the entry&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;file&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Link to a document file.&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt; )))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;bibtex-align-at-equal-sign&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
BibTeX is old but stable software that was last updated in 1988 and has, as such, some minor limitations. The BibLaTeX dialect is a newer version. To change &lt;code class=&#34;verbatim&#34;&gt;bibtex-mode&lt;/code&gt; to BibLaTeX, change the &lt;code class=&#34;verbatim&#34;&gt;bibtex-dialect&lt;/code&gt; variable in the configuration to &lt;code class=&#34;verbatim&#34;&gt;biblatex&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;bibtex-set-dialect&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;biblatex&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Jonathan Le Roux publishes a &lt;a href=&#34;http://www.jonathanleroux.org/bibtex-mode.html&#34;&gt;comprehensive manual&lt;/a&gt; on his website that explains some more functionality, such as structuring the citation key, in more detail.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Managing Bibliographies
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Several packages are available to explore bibliography files and connect it to notes. These packages achieve four main tasks:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Edit the bibliography&lt;/li&gt;
&lt;li&gt;Explore bibliographies (searching, narrowing etc) and insert citations&lt;/li&gt;
&lt;li&gt;Access links and attachments for reading&lt;/li&gt;
&lt;li&gt;Relate bibliography to notes note file related to the entry&lt;/li&gt;
&lt;/ol&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Package&lt;/th&gt;
&lt;th&gt;Edit&lt;/th&gt;
&lt;th&gt;Explore&lt;/th&gt;
&lt;th&gt;Assets&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;bibtex-mode (built-in)&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;biblio&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;citar&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;https://lucidmanager.org/productivity/bibliographic-notes-in-emacs-with-citar-denote/&#34;&gt;citar-denote&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;https://joostkremers.github.io/ebib/&#34;&gt;ebib&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;https://github.com/tmalsburg/helm-bibtex&#34;&gt;helm-bibtex /ivy-bibtex&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;https://github.com/org-roam/org-roam-bibtex&#34;&gt;org-roam-bibtex&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;https://github.com/Vidianos-Giannitsis/zetteldesk.el&#34;&gt;zetteldesk-ref&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;https://github.com/emacs-citar/citar-org-roam&#34;&gt;citar-org-roam&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&#34;https://github.com/localauthor/zk&#34;&gt;zk-citar&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
This article further explores using biblio and citar to manage bibliographies. The other packages are provided as alternatives.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-6&#34;&gt;
Using the Biblio package to add new entries
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;BibTeX mode requires you to type all entries manually, which is inefficient and could easily lead to errors. Clément Pit-Claudel’s &lt;a href=&#34;https://github.com/cpitclaudel/biblio.el&#34;&gt;biblio package&lt;/a&gt; lets you browse and import bibliographic references from a range bibliographic sources: &lt;a href=&#34;https://www.crossref.org/&#34;&gt;CrossRef&lt;/a&gt;, &lt;a href=&#34;https://dblp.org/&#34;&gt;DBLP&lt;/a&gt;, &lt;a href=&#34;https://arxiv.org/&#34;&gt;arXiv&lt;/a&gt;, Dissemin, and &lt;a href=&#34;https://dx.doi.org/&#34;&gt;doi.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The configuration for this package is straightforward, as there are no variables to configure. To get &lt;a href=&#34;https://github.com/CrossRef/rest-api-doc#etiquette&#34;&gt;better response times&lt;/a&gt; from CrossRef, you need to customise the &lt;code&gt;biblio-crossref-user-email-address&lt;/code&gt; variable and include your email address in the string.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Biblio package for adding BibTeX records and download publications&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;biblio&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
To use the package, open the relevant BibTeX file, run &lt;code&gt;M-x biblio-lookup&lt;/code&gt;, and select the database and enter a search query. Once the search has completed, a new buffer opens with the results. Select your target with the arrow keys or search in the buffer to select the preferred candidate.&lt;/p&gt;
&lt;p&gt;
Once you have your target, you can insert the BibTeX record into the buffer from where you called the function with &lt;code class=&#34;verbatim&#34;&gt;i&lt;/code&gt;. Alternatively, you can copy the BibTeX record with &lt;code class=&#34;verbatim&#34;&gt;c&lt;/code&gt; and paste it into place later. You quit the search results with &lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt;. To see all possible commands in this buffer, use &lt;code class=&#34;verbatim&#34;&gt;h&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;?&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
If you have a DOI (&lt;a href=&#34;https://en.wikipedia.org/wiki/Digital_object_identifier&#34;&gt;Digital Object Identifier&lt;/a&gt;) for a publication, then use the &lt;code&gt;biblio-doi-insert-bibtex&lt;/code&gt; function to insert a BibTeX record into the current buffer.&lt;/p&gt;
&lt;p&gt;
Unfortunately, large corporate publishers still hold the world’s academic knowledge behind lock and key. However, open access and pre-print publications are slowly becoming the norm. The Dissemin website searches for copies of papers in an extensive collection of open repositories and websites.&lt;/p&gt;
&lt;p&gt;
To use this service with Emacs, evaluate &lt;code&gt;dissemin-lookup&lt;/code&gt; to show information about the open access status of a paper using a DOI number. You can also press &lt;code class=&#34;verbatim&#34;&gt;x&lt;/code&gt; when in the search menu for the &lt;code&gt;biblio-lookup&lt;/code&gt; function to check for open access version.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-7&#34;&gt;
Using Citar to Access Bibliographies
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;Several Emacs packages are available that link bibliography files to notes. The &lt;a href=&#34;https://joostkremers.github.io/ebib/&#34;&gt;Ebib&lt;/a&gt;, &lt;a href=&#34;https://github.com/tmalsburg/helm-bibtex&#34;&gt;Helm-BibTeX and Ivy-BibTeX&lt;/a&gt; each use their own completion system. The &lt;a href=&#34;https://github.com/emacs-citar/citar&#34;&gt;Citar&lt;/a&gt; package uses the standard &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-completion-system/&#34;&gt;minibuffer completion&lt;/a&gt; mechanism to access your bibliographies. This package provides access to hyperlinks, notes, attachments and the source bibliography file. Citar also integrates with &lt;code&gt;org-cite&lt;/code&gt;, Org mode’s citation module.&lt;/p&gt;
&lt;p&gt;
Within the Org mode system, you can have two types of bibliographies. The global bibliography is a set of BibTeX files available from anywhere within Emacs. You can also link one or more project-specific local BibTeX files to an Org mode file, discussed in the article about &lt;a href=&#34;https://lucidmanager.org/productivity/bibliographic-notes-in-emacs-with-citar-denote/&#34;&gt;bibliographic notes&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;ews-bibtex-directory&lt;/code&gt; variable stores the location of all BibTeX files and their associated attachments. This variable is defined in the article on &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;Emacs configuration&lt;/a&gt;. By default, this variable is set at &lt;code class=&#34;verbatim&#34;&gt;~/Documents/library/&lt;/code&gt;. Using this variable in combination with the &lt;code&gt;ews-bibtex-register&lt;/code&gt; command will configure Emacs to recognise all BibTeX files in the configured directory.&lt;/p&gt;
&lt;p&gt;
You store all your BibTeX files and the associated attachments in this location. BibTeX files have to reside in this directory, attachments can be in subdirectories. Any file paths for BibTeX entries start at this path. For example, when the BibTeX entry states: &lt;code class=&#34;verbatim&#34;&gt;file = {computing/stallman-1981-emacs.pdf}&lt;/code&gt;, the attachment is stored at: &lt;code class=&#34;verbatim&#34;&gt;~/Documents/library/computing/stallman-1981-emacs.pdf&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;
The EWS configuration creates a new variable named &lt;code&gt;ews-bibtex-file&lt;/code&gt; which lists the &lt;code class=&#34;verbatim&#34;&gt;.bib&lt;/code&gt; files in the &lt;code&gt;ews-bibtex-directory&lt;/code&gt; that start with a letter or a number (to exclude backup and hidden files). This code is a regular expression, which is a powerful method to find text. If you add another bibliography file, you will have to rerun the configuration code, or restart Emacs to register it.&lt;/p&gt;
&lt;p&gt;
If you add or remove any bibliography files from the bibliography directory, then use the &lt;code&gt;ews-bibtex-register&lt;/code&gt; function to register the new set of bibliographies. You don&amp;#39;t need to do this when you add new entries to a file, only when adding, renaming or removing a file.&lt;/p&gt;
&lt;p&gt;
Citations are further discussed &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;in another article&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Citar to access bibliographies&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;citar&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#007020&#34;&gt;:defer&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;citar-bibliography&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ews-bibtex-files&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w b o&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;citar-open&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Open the Citar menu with &lt;code&gt;citar-open&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c w b o&lt;/code&gt;) and select the literature you seek.&lt;/p&gt;
&lt;p&gt;
Finding literature with Citar is easy. After every keystroke in the Citar menu, the list of options is narrowed to the relevant matches. Select your candidate with the arrow keys and hit Enter. Use the Tab key to select more than one entry.&lt;/p&gt;
&lt;p&gt;
The first three columns in the menu indicate which entries include a hyperlink (&lt;code class=&#34;verbatim&#34;&gt;L&lt;/code&gt;), one or more attached files (&lt;code class=&#34;verbatim&#34;&gt;F&lt;/code&gt;) and an associated note (&lt;code class=&#34;verbatim&#34;&gt;N&lt;/code&gt;). The configuration for taking bibliographic notes is &lt;a href=&#34;https://lucidmanager.org/productivity/bibliographic-notes-in-emacs-with-citar-denote/&#34;&gt;explained in another article&lt;/a&gt;. You can filter the Citar completion menu for entries with notes using &lt;code class=&#34;verbatim&#34;&gt;:n&lt;/code&gt;, showing only entries with an attachment use &lt;code class=&#34;verbatim&#34;&gt;&amp;#34;:f&amp;#34;&lt;/code&gt; and entries that have links with &lt;code class=&#34;verbatim&#34;&gt;&amp;#34;:l&amp;#34;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
After hitting Enter, Citar provides a popup menu in the minibuffer from where you can open any attachments, create a new note or open an existing note and follow any hyperlinks listed in the BibTeX entry.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/citar-menu.png&#34; alt=&#34;Example of the Citar menu&#34; title=&#34;Example of the Citar menu&#34;/&gt;
&lt;figcaption&gt;
Example of the Citar menu.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences to undertake a task. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The next article explains how to create bibliographic notes with the &lt;a href=&#34;https://lucidmanager.org/productivity/bibliographic-notes-in-emacs-with-citar-denote/&#34;&gt;Citar-Denote package&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Bibliographic Notes with the Citar-Denote Emacs Package</title>
      <link>https://lucidmanager.org/productivity/bibliographic-notes-in-emacs-with-citar-denote/</link>
      <pubDate>Fri, 17 Feb 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/bibliographic-notes-in-emacs-with-citar-denote/</guid>
      <description>
	
&lt;p&gt;
Taking notes about the articles and books you read is an essential part of intellectual life. Many note-taking systems can connect to a bibliographic database (such as a plain text BibTeX file, or external software such as &lt;a href=&#34;http://zotero.org/&#34;&gt;Zotero&lt;/a&gt;). These databases are helpful when adding citations to your writings. Electronic bibliographies also help you to create and find notes related to your literature collection. and provide access to related materials, such as links to online sources and electronic versions of relevant books or articles. &lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;Citar-Denote&lt;/em&gt; Emacs package integrates the &lt;a href=&#34;https://github.com/emacs-citar/citar&#34;&gt;Citar&lt;/a&gt; bibliography package with the &lt;a href=&#34;https://protesilaos.com/emacs/denote&#34;&gt;Denote&lt;/a&gt; note-taking system. Citar lets you browse and act on bibliographic data in &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-bibtex-mode/&#34;&gt;BibTeX, BibLaTeX&lt;/a&gt; and &lt;a href=&#34;https://citationstyles.org/&#34;&gt;JSON-CSL&lt;/a&gt; format. Denote is a is a versatile Emacs package for taking notes. Combining these two packages enables linking any note in your Denote collection to one or more bibliographic entries, providing a complete solution for documenting literature reviews. My article about &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/&#34;&gt;taking notes with Emacs&lt;/a&gt; explains how to use Denote.&lt;/p&gt;
&lt;p&gt;
This article is part of &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt;, a book that explains how to use Emacs to undertake research and write and publish articles, books, and websites. Emacs Writing Studio is available as an e-book from your favourite retailer.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
To learn how to create and maintain a plain text bibliographic database in Emacs, read the &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-bibtex-mode/&#34;&gt;article about BibTeX mode&lt;/a&gt;. The article about &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;writing in Org mode&lt;/a&gt; explains how to add citations. This page explains how to use the Citar-Denote package, which integrates a Citar bibliography with your Denote notes.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/citar-denote/&#34; target=&#34;_blank&#34;
   title=&#34;Download citar-denote from GitHub&#34;
   alt=&#34;Download citar-denote from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;citar-denote&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/s7Mf6udiCSE?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Emacs Writing Studio (Create and manage literature notes with Citar-Denote).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Principles
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A bibliographic note is a file that refers to one or more pieces of literature in your bibliography. The note and the entry in your literature database are intrinsically linked, making it easy to move between the two. Two types of relationships exist between your notes and your bibliography:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Reference&lt;/em&gt;: Relates the whole file to one or more publication (a bibliographic note). Indicated by the reference line in the front matter and the &lt;code class=&#34;verbatim&#34;&gt;bib&lt;/code&gt; keyword.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Citation&lt;/em&gt;: A citation inside a note mentions one or more publications. A citation relates a portion of a text to a publication.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The Citar-Denote package maintains a many-to-many relationship between your notes and your bibliographies. Each bibliographic entry can have one or more notes, and each note can reference one or more pieces of literature.&lt;/p&gt;
&lt;p&gt;
You can create several atomic notes for each publication or write a complete literature review of a collection of references within one note. You could, for example, create a note about each chapter of a book, or write a single literature review note for a collection of journal articles. You can use Citar and Denote which ever way best suits your workflow.&lt;/p&gt;
&lt;p&gt;
To enable references, we need a stable link between the collection of notes and the bibliography. The most common behaviour for bibliography managers in Emacs is that the filename for the relevant note includes the citation key (e.g. &lt;code class=&#34;verbatim&#34;&gt;marcuse_1969_essay.org&lt;/code&gt;) to link it to the bibliography. However, Denote follows a strict naming convention, so we cannot use this approach to link notes and literature as it might contain characters that Denote disallows in its file names. The various citation system don&amp;#39;t have strict naming conventions on citation keys, so we need to find another way to link literature to a note.&lt;/p&gt;
&lt;p&gt;
In Citar-Denote, the citation key is part of the front matter through the &lt;code class=&#34;verbatim&#34;&gt;#+reference:&lt;/code&gt; keyword. Citar-Denote stores the relationship between citation keys and note files in a cache. The package regenerates this cache after you edit a bibliography file or call any Citar functions. Each bibliographic note uses the configurable &lt;code class=&#34;verbatim&#34;&gt;bib&lt;/code&gt; file tag. This tag reduces the number of Denote files the system needs to track. The front matter for a bibliographic note would look something like this:&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+title:      Marcuse: An Essay on Liberation
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+date:       [2022-11-12 Sat 19:23]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+filetags:   :bib:culture:marketing:philosophy:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+identifier: 20221112T192310
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+reference:  marcuse_1969_essay&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The Citar-Denote package also provides insight into citations used in the Denote directory, which uses the &lt;code class=&#34;verbatim&#34;&gt;xref&lt;/code&gt; system. You can improve the search process by installing the faster &lt;a href=&#34;https://github.com/BurntSushi/ripgrep&#34;&gt;ripgrep&lt;/a&gt; program and setting &lt;code class=&#34;verbatim&#34;&gt;xref-search-program&lt;/code&gt; to &lt;code class=&#34;verbatim&#34;&gt;ripgrep&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Create bibliographic notes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Open the Citar interface with &lt;code class=&#34;verbatim&#34;&gt;C-c w b c&lt;/code&gt; (&lt;code&gt;citar-create-note&lt;/code&gt;). The letters or icons at the start of the Citar menu indicate whether the entry has a link, note, attachment or is cited in the current buffer. Select the entry you want to create a note for, hit &lt;code class=&#34;verbatim&#34;&gt;ENTER&lt;/code&gt; and follow the prompts.&lt;/p&gt;
&lt;p&gt;
If a note already exists and you have set the &lt;code class=&#34;verbatim&#34;&gt;citar-open-always-create-notes&lt;/code&gt; variable to &lt;code class=&#34;verbatim&#34;&gt;t&lt;/code&gt;, then you can create additional notes for this entry. Otherwise, Citar will open the exiting note.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/citar-menu.png&#34; alt=&#34;Screenshot of Citar with Vertico, indicating notes and links.&#34; title=&#34;Screenshot of Citar with Vertico, indicating notes and links.&#34;/&gt;
&lt;figcaption&gt;
Screenshot of Citar with Vertico, indicating notes and links.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Various configuration options are available to fine-tune determine how Emacs creates now bibliographic notes.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Default file type
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;You can create bibliographic notes for each file type that Denote supports: Org mode, two flavours of Markdown and plain text. Citar-Denote uses the default file type set by the &lt;code class=&#34;verbatim&#34;&gt;denote-file-type&lt;/code&gt; variable, which you can override with &lt;code class=&#34;verbatim&#34;&gt;citar-denote-file-type&lt;/code&gt; to use a different file type for bibliographic notes. &lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Bibliographic note title
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The default name for a new note is the title of the bibliographic entry. You can modify this behaviour with the &lt;code class=&#34;verbatim&#34;&gt;citar-denote-title-format&lt;/code&gt; variable. Four options are available:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;title&lt;/code&gt;: Extract the title from the bibliographic item (default)&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;author-year&lt;/code&gt;: Use citation format as &amp;#34;author(s) (year)&amp;#34; (or editors when no authors are defined)&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;author-year-title&lt;/code&gt;: Concatenate the first two options&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;full&lt;/code&gt;: Full citation of the entry&lt;/li&gt;
&lt;li&gt;Fallback option or &lt;code class=&#34;verbatim&#34;&gt;nil&lt;/code&gt;: The citation key&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For example, using this citation: Coppa, Hass, Peck, Burger (2008) &lt;em&gt;Performing Magic on the Western Stage: From the Eighteenth Century to the Present&lt;/em&gt;, Palgrave Macmillan.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;title&lt;/code&gt;: &amp;#34;Performing Magic on the Western Stage: From the Eighteenth Century to the Present&amp;#34;.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;author-year&lt;/code&gt;: &amp;#34;Coppa et al. (2008)&amp;#34;. &lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;author-year-title&lt;/code&gt;: &amp;#34;Coppa et al. (2008) Performing Magic on the Western Stage: From the Eighteenth Century to the Present&amp;#34;.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;full&lt;/code&gt;: &amp;#34;Coppa, Hass, Peck, Burger (2008) &lt;em&gt;Performing Magic on the Western Stage: From the Eighteenth Century to the Present&lt;/em&gt;, Palgrave Macmillan&amp;#34;.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;nil&lt;/code&gt;: &amp;#34;coppa_2008_perf&amp;#34;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Using &lt;code class=&#34;verbatim&#34;&gt;author-year&lt;/code&gt; for entries allows for some further configuration. For entries with more than one author, you can specify the maximum number of names with &lt;code class=&#34;verbatim&#34;&gt;citar-denote-title-format-authors&lt;/code&gt;, which is one by default. When the number of defined authors is more than the number in the citation, &amp;#34;et al.&amp;#34; is added to the end. When this variable exceeds the number of defined authors, all authors are listed. The default term between authors is &amp;#34;and&amp;#34;, which can be changed by customising &lt;code class=&#34;verbatim&#34;&gt;citar-denote-title-format-andstr&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
For example, when using up to three authors and &amp;#34;&amp;amp;&amp;#34; as connecting term, the title for the example above becomes Or  &amp;#34;Coppa, Hass &amp;amp; Peck et al. (2008)&amp;#34; &lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Bibliographic keywords
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The &lt;code class=&#34;verbatim&#34;&gt;bib&lt;/code&gt; file tag is added to every new bibliographic note. This tag minimises the search space when caching notes to accelerate the process. The &lt;code class=&#34;verbatim&#34;&gt;citar-denote-keyword&lt;/code&gt; variable lets you change the tag to something else. For example, if you primay language is Welsh, you might want to change it to &lt;code class=&#34;verbatim&#34;&gt;lly&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
Changing the default requires updating all your existing bibliographic notes, because the package only recognises a single string. The change will come into effect the next time the package is loaded. The &lt;a href=&#34;https://lucidmanager.org/productivity/denote-explore/&#34;&gt;Denote-Explore&lt;/a&gt; package has a function to rename Denote keywords.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;citar-denote-use-bib-keywords&lt;/code&gt; variable lets you include keywords defined in the bibliography as Denote keywords. When set to a non-nil value, Citar-Denote extracts the available keywords from the BibTeX &lt;code class=&#34;verbatim&#34;&gt;keywords&lt;/code&gt; field.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Subdirectory
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;If you prefer storing your bibliographic notes in a subdirectory of your Denote folder, then set the &lt;code class=&#34;verbatim&#34;&gt;citar-denote-subdir&lt;/code&gt; variable to &lt;code class=&#34;verbatim&#34;&gt;t&lt;/code&gt;. When this variable is non-nil, Denote asks for a subdirectory when creating a new bibliographic note. When this variable contains a string, then any new bibliographic notes are stored in the subdirectory that matches this name.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Signature
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;When the &lt;code class=&#34;verbatim&#34;&gt;citar-denote-signature&lt;/code&gt; variable is non-nil, Denote will ask for a signature when creating a new bibliographic note. If you enter an empty line for a signature, then the citation key is used.&lt;/p&gt;
&lt;p&gt;
Please note that Denote changes or removes punctuation marks in the citation key to enforce compliance with its file naming convention. For example, when the citation key is &lt;code class=&#34;verbatim&#34;&gt;einstein_1905&lt;/code&gt;, the signature becomes &lt;code class=&#34;verbatim&#34;&gt;einstein=2005&lt;/code&gt;.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Create notes using templates
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Denote allows you to create template for various types of notes. You could, for example, have standard headings for bibliographic notes, other headings for meta notes, or whatever else you might need.&lt;/p&gt;
&lt;p&gt;
To include templates in new bibliographic notes, set the &lt;code&gt;citar-denote-template&lt;/code&gt; to non-nil and define a template.&lt;/p&gt;
&lt;p&gt;
The example below lets the user choose between a note that has two headings (Abstract and Review), or a plain note without any template content. The extensive &lt;a href=&#34;https://protesilaos.com/emacs/denote#h:f635a490-d29e-4608-9372-7bd13b34d56c&#34;&gt;Denote manual&lt;/a&gt; provides some more detailed information about using templates for all your notes.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;denote-templates&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;((&lt;span style=&#34;color:#963&#34;&gt;biblio&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;* Abstract\n\n* Review&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#963&#34;&gt;plain&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
Working with existing notes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Once you have some bibliographic notes you will want to access and modify them. You can access the attachments, links and other notes associated with the references from within via the Citar menu (&lt;code&gt;citar-open&lt;/code&gt;), &lt;code class=&#34;verbatim&#34;&gt;C-c w b o&lt;/code&gt;. Entries with a note are indicated with an &lt;code class=&#34;verbatim&#34;&gt;N&lt;/code&gt; in the third column.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-10&#34;&gt;
Open existing bibliographic notes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;There are two entry points to find notes that relate to literature, either as a reference or as a citation.&lt;/p&gt;
&lt;p&gt;
Use &lt;code&gt;citar-denote-open-note&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c w b n&lt;/code&gt;) to open the Citar menu with only entries that have one or more associated notes. Select your target and hit &lt;code class=&#34;verbatim&#34;&gt;ENTER&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
Citar provides a list of resources for the selected entry: attachments, existing notes, links and an option to create an additional note. Select the note you seek, hit &lt;code class=&#34;verbatim&#34;&gt;ENTER&lt;/code&gt; again and select the Denote file you want to open. &lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/citar-menu-resources.png&#34; alt=&#34;Screenshot of Citar and options for one of the entries&#34; title=&#34;Screenshot of Citar and options for one of the entries&#34;/&gt;
&lt;figcaption&gt;
Screenshot of Citar and options for one of the entries.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The previous function shows all literature that has one or more bibliographic note(s). The &lt;code&gt;citar-denote-find-citation&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c w c f&lt;/code&gt;) lists all bibliographic entries cited inside your Denote collection, from where you can open the relevant note. Some of these will also have their own bibliographic note, indicated in the Citar menu sidebar.&lt;/p&gt;
&lt;p&gt;
Searching through all your notes for citations can take a moment, depending on the size of your digital garden.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-11&#34;&gt;
Open attachments, links and notes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The &lt;code&gt;citar-denote-dwim&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c w b d&lt;/code&gt;) provides access to the Citar menu from where you can open attachments, other notes, and links related to the citation references associated with the current Denote buffer.&lt;/p&gt;
&lt;p&gt;
Select the required bibliographic item when there is more than one reference. You can then select the attachment, link or note you like to access and hit &lt;code class=&#34;verbatim&#34;&gt;ENTER&lt;/code&gt;, after which you select your link, note or attachment. Alternatively, you can also create a new note &lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-12&#34;&gt;
Open bibliographic entry
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The &lt;code&gt;citar-denote-open-reference-entry&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c w b e&lt;/code&gt;) opens the bibliographic entry (BibTeX, BibLaTeX or CSL file) for a selected reference from where you can edit the bibliographic data.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-13&#34;&gt;
Convert existing notes to bibliographic notes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The &lt;code&gt;citar-denote-add-citekey&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c w b k&lt;/code&gt;) adds citation keys or converts an existing Denote file to a bibliographic note. When converting a regular Denote file, the function adds the &lt;code class=&#34;verbatim&#34;&gt;bib&lt;/code&gt; keyword to the front matter and renames the file accordingly.&lt;/p&gt;
&lt;p&gt;
This function opens the Citar selection menu and adds the selected citation keys to the front matter. Use the &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; key to select multiple entries.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-14&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-14&#34;&gt;
Remove references from bibliographic notes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-14&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;You remove citation references with the &lt;code&gt;citar-denote-remove-citekey&lt;/code&gt; command (&lt;code class=&#34;verbatim&#34;&gt;C-c w b K&lt;/code&gt;). If more than one piece of literature is referenced, select the unwanted item in the minibuffer first. The bibliography keyword is also removed, and the file is renamed when removing the only reference.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-15&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-15&#34;&gt;
Citation management
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-15&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;What is the point of building a bibliography without using each entry as a citation or a reference in a bibliographic note? The last two functions let you cite literature or create a new bibliographic note for any item not used in your Denote collection.&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;citar-denote-nocite&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c w b x&lt;/code&gt;)  function opens the Citar menu and shows all items in your bibliography that are neither cited nor referenced. From there you can create a new bibliographic note, follow a link or read the file.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-16&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-16&#34;&gt;
Configuration
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-16&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration builds on the &lt;code class=&#34;verbatim&#34;&gt;C-c w&lt;/code&gt; prefix keys. Pressing &lt;code class=&#34;verbatim&#34;&gt;C-c w b&lt;/code&gt; provides access to bibliographic commands using the &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-completion-system/&#34;&gt;keystroke completion menu&lt;/a&gt; provided by the &lt;em&gt;Which Key&lt;/em&gt; package .&lt;/p&gt;
&lt;p&gt;
This configuration also sets a variable from the Citar package that allows you to create multiple notes for a bibliographic entry.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;citar-denote&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;citar-open-always-create-notes&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:init&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;citar-denote-mode&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w b c&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;citar-create-note&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w b n&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;citar-denote-open-note&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w b x&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;citar-denote-nocite&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w b k&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;citar-denote-add-citekey&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w b K&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;citar-denote-remove-citekey&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w b d&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;citar-denote-dwim&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w b e&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;citar-denote-open-reference-entry&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The source code for Citar-Denote is available on GitHub and the package is available through &lt;a href=&#34;https://melpa.org/#/citar-denote&#34;&gt;MELPA&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/citar-denote/&#34; target=&#34;_blank&#34;
   title=&#34;Download citar-denote from GitHub&#34;
   alt=&#34;Download citar-denote from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;citar-denote&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
This page is a previous version of the manual. You can read the recent manual with &lt;code class=&#34;verbatim&#34;&gt;C-h R citar-denote&lt;/code&gt; or evaluate &lt;code&gt;(info &amp;#34;citar-denote&amp;#34;)&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-17&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-17&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-17&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, and everybody has personal preferences on how to undertake a task and configure Emacs. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The next article in this series describes how to use Emacs Org mode for &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;distraction-free writing&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Emacs Org Mode for Distraction-Free Writing</title>
      <link>https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/</link>
      <pubDate>Wed, 05 May 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/</guid>
      <description>
	
&lt;p&gt;
The world is full of distractions, especially when focusing on writing. Most writing software is littered with icons and options to change the document’s design. Distraction-free writing tools remove distractions from the screen, so they become more like electronic typewriters that let the author focus on content over form. This article shows how to use Emacs Or Mode for Distraction-Free writing, using the built-in Org mode package.&lt;/p&gt;
&lt;p&gt;
This article is part of &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt;, a book that explains how to use Emacs to undertake research and write and publish articles, books, and websites. Emacs Writing Studio is also available as an e-book from your favourite retailer.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Getting started with Org mode
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Org mode is a powerful major mode that comes with Emacs by default. This software was initially developed in 2003 by Carsten Dominik, a professor of astronomy at the University of Amsterdam. Since then, countless other developers have continued to advance Org-mode.&lt;/p&gt;
&lt;p&gt;
You can use Org mode to &lt;a href=&#34;https://lucidmanager.org/productivity/create-websites-with-org-mode-and-hugo/&#34;&gt;publish websites&lt;/a&gt;, &lt;a href=&#34;https://lucidmanager.org/productivity/publishing-with-org-mode-export/&#34;&gt;articles and books&lt;/a&gt;, &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/&#34;&gt;keep a diary&lt;/a&gt;, &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-org-mode-and-org-roam/&#34;&gt;keep research notes&lt;/a&gt;, &lt;a href=&#34;https://lucidmanager.org/productivity/getting-things-done-with-emacs/&#34;&gt;manage your actions&lt;/a&gt;, and much more. And on top of all that, it is intuitive to use. This section shows you the basics of writing prose in Org mode with a screencast by Jake B. that briefly summarises the major options within Org mode.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/hnMntOQjs7Q?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Emacs Org Mode Demo by Jake B.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Creating new Org buffers
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;To start an Org file, create a file with a &lt;code class=&#34;verbatim&#34;&gt;.org&lt;/code&gt; extension and start writing, for example, &lt;code class=&#34;verbatim&#34;&gt;C-x C-f test.org &amp;lt;Enter&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
Each Org document starts with a header that contains metadata and settings relevant to the buffer. The Org mode metadata and settings start with &lt;code class=&#34;verbatim&#34;&gt;#+&lt;/code&gt; followed by a keyword and a colon. The document header can also contain metadata such as a subtitle or a date. Emacs packages can use this information when publishing the text and other functionality.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+title:   Lorem Ipsum
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+author:  Nomen Nescio
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+date:    [2021-05-08 Sat]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Org mode recognises several other types of front matter items to control exporting and other behaviours, some of which are mentioned below.&lt;/p&gt;
&lt;p&gt;
Your chosen Emacs theme will set the size and font for your document. The only purpose of these decorations is to help you navigate the document. The article about &lt;a href=&#34;https://lucidmanager.org/productivity/publishing-with-org-mode-export/&#34;&gt;publishing articles and books with Org mode&lt;/a&gt; shows how to control the output format.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Document structure
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Books have chapters, sections and paragraphs; articles have headings; poems have verses; and so on. Almost all forms of writing have a hierarchy. An excellent method to start writing is to work out your hierarchical structure and fill it with content. &lt;/p&gt;
&lt;p&gt;
Org mode is an outlining tool that helps you develop a document structure. Write an asterisk as the first character to start a new header, followed by a space. To create deeper levels, add more stars:&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;* &lt;/span&gt;Heading 1
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ** Heading 2
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  *** Heading 3&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
When you press &lt;code class=&#34;verbatim&#34;&gt;M-enter&lt;/code&gt;, the following line becomes a new heading. With &lt;code class=&#34;verbatim&#34;&gt;C-enter&lt;/code&gt;, the next line is added after the text in the current section.&lt;/p&gt;
&lt;p&gt;
Org mode makes it easy to move and promote or demote headings and associated text (which in Org mode is a subtree) with the &lt;code class=&#34;verbatim&#34;&gt;ALT&lt;/code&gt; and arrow keys.&lt;/p&gt;
&lt;p&gt;
You can collapse or expand a heading with the &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; key. Pressing &lt;code class=&#34;verbatim&#34;&gt;S-TAB&lt;/code&gt; will collapse the document, showing only the level one headings. Pressing &lt;code class=&#34;verbatim&#34;&gt;S-TAB&lt;/code&gt; once again will show the headings, and repeating it for a second time reveals the entire buffer. You can keep cycling through these modes with the &lt;code class=&#34;verbatim&#34;&gt;S-TAB&lt;/code&gt; key.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; / &lt;code class=&#34;verbatim&#34;&gt;S-TAB&lt;/code&gt;: (un)fold headings&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;M-up&lt;/code&gt; / &lt;code class=&#34;verbatim&#34;&gt;M-down&lt;/code&gt;: move a headline up or down&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;M-left&lt;/code&gt; / &lt;code class=&#34;verbatim&#34;&gt;M-right&lt;/code&gt;: promote or demote a headline&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;M-RET&lt;/code&gt;: insert a new headline&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Add numbers to the headers with the &lt;code class=&#34;verbatim&#34;&gt;num&lt;/code&gt; option in the startup line: &lt;code class=&#34;verbatim&#34;&gt;#+startup: num&lt;/code&gt;. Whether this numbering appears in any published output depends on your configuration.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Rich text
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;To change how Org Mode displays text, you surround it with special characters: &lt;code class=&#34;verbatim&#34;&gt;/italic/&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;*bold*&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;_underline_&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;+striketrough+&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;=verbatim=&lt;/code&gt;. You will see these markers in the Org mode text, but they disappear when you export the buffer. &lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Lists
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Writing lists in Org mode could not be easier. Simply start a line with a dash and complete the entry with &lt;code class=&#34;verbatim&#34;&gt;M-ENTER&lt;/code&gt; to create the next entry. Using the &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; and left or right arrow keys changes the depth of the item and, with the up and down arrows, moves the line up or down in the hierarchy. Change the list prefix with the &lt;code class=&#34;verbatim&#34;&gt;SHIFT&lt;/code&gt; and left/right arrow keys.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;- &lt;/span&gt;Item
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;+ &lt;/span&gt;next item
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;1.&lt;/span&gt; The following
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;2.&lt;/span&gt; And another
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         a. Down, down, deeper and down&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The following configuration line enables alphabetically ordered lists as well as numerals.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-list-allow-alphabetical&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Tables
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Every cell in an Org mode table is flanked by the pipe &lt;code class=&#34;verbatim&#34;&gt;|&lt;/code&gt; symbol. You don&amp;#39;t have to worry about aligning the text, as the &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; key does that for you. You create a horizontal line when you start a line with &lt;code class=&#34;verbatim&#34;&gt;|-&lt;/code&gt; and hit &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;| Column 1 | Column 2 |&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;|----------+----------|&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;| Sator    |       12 |&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;| Arepo    |       26 |&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;| Tenet    |      878 |&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;| Opera    |       89 |&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;| Rotas    |       89 |&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
You navigate forward through the cells with the &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; or arrow up/down keys. Using &lt;code class=&#34;verbatim&#34;&gt;s-TAB&lt;/code&gt; moves you back one cell. Combining Alt and Shift with the arrow keys adds and removes columns and rows.&lt;/p&gt;
&lt;p&gt;
Org mode has &lt;a href=&#34;https://orgmode.org/manual/Tables.html&#34;&gt;extensive capabilities to edit tables&lt;/a&gt;, including formulas to create spreadsheet functionality.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Images
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Although Emacs is a text editor, it can also &lt;a href=&#34;https://lucidmanager.org/productivity/using-emacs-image-dired/&#34;&gt;manage images&lt;/a&gt;. In Org mode, an image is a link to an image file. You can preview the file in your buffer or export it to your preferred format. You can also add captions and set display or export properties for each image.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+caption: Image caption.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+attr_html: :alt Alternative text
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  [[&lt;span style=&#34;color:#00c&#34;&gt;file:path/to/image&lt;/span&gt;]]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
To view the preview images in your document or remove the previews, you press &lt;code class=&#34;verbatim&#34;&gt;C-c C-x C-v&lt;/code&gt; (&lt;code&gt;org-toggle-inline-images&lt;/code&gt;). You can also add &lt;code class=&#34;verbatim&#34;&gt;#+startup: inlineimages&lt;/code&gt; to view images by default for the buffer.&lt;/p&gt;
&lt;p&gt;
To add an image, press &lt;code class=&#34;verbatim&#34;&gt;C-c C-l&lt;/code&gt; (&lt;code&gt;org-insert-link&lt;/code&gt;), which opens the link menu. Org mode understands many types of links. We want the file type, so type &lt;code class=&#34;verbatim&#34;&gt;file:&lt;/code&gt;. Press enter and select the image filename in the mini buffer. You can skip the &lt;code class=&#34;verbatim&#34;&gt;file&lt;/code&gt; part with the &lt;code class=&#34;verbatim&#34;&gt;C-u C-c C-l&lt;/code&gt; shortcut (adding &lt;code class=&#34;verbatim&#34;&gt;C-u&lt;/code&gt; before the standard shortcut.)&lt;/p&gt;
&lt;p&gt;
After adding the image, you preview it with the &lt;code&gt;org-redisplay-inline-images&lt;/code&gt; function or &lt;code class=&#34;verbatim&#34;&gt;C-c C-x C-M-v&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
You open a link in Org mode with a mouse click or by pressing &lt;code class=&#34;verbatim&#34;&gt;C-c C-o&lt;/code&gt; (&lt;code&gt;org-open-at-point&lt;/code&gt;) with your cursor on the link text. Emacs has some facilities to manage image libraries through the &lt;a href=&#34;https://lucidmanager.org/productivity/using-emacs-image-dired/&#34;&gt;image-dired package&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The images in the buffer are all shown at the same width, which you &lt;a href=&#34;https://lucidmanager.org/productivity/ricing-org-mode/&#34;&gt;can configure&lt;/a&gt; to meet your needs. The articles about &lt;a href=&#34;https://lucidmanager.org/productivity/publishing-with-org-mode-export/&#34;&gt;writing articles and books with Emacs&lt;/a&gt; and the article about &lt;a href=&#34;https://lucidmanager.org/productivity/create-websites-with-org-mode-and-hugo/&#34;&gt;creating websites with Emacs&lt;/a&gt; explains how to control image size and other image properties.&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Emacs Writing Studio&lt;/em&gt; provides a convenience function to insert images from screenshots, which is bound to the &lt;code class=&#34;verbatim&#34;&gt;Control-PrintScreen&lt;/code&gt; key. This function asks for a filename (and forces a PNG extension). The user then selects a partial screenshot and a caption. The function then inserts the image link and caption.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ews-org-insert-screenshot&lt;/span&gt; ()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Take a screenshot with ImageMagick and insert as an Org mode link.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;interactive&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;let&lt;/span&gt; ((&lt;span style=&#34;color:#963&#34;&gt;filename&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;read-file-name&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Enter filename for screenshot: &amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;default-directory&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#007020&#34;&gt;unless&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;string-equal&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;png&amp;#34;&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;file-name-extension&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;filename&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#007020&#34;&gt;setq&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;filename&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;concat&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;file-name-sans-extension&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;filename&lt;/span&gt;) &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;.png&amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#963&#34;&gt;call-process-shell-command&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;format&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;import %s&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;filename&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;insert&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;format&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#+caption: %s\n&amp;#34;&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read-from-minibuffer&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Caption: &amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;insert&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;format&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;[[file:%s]]&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;filename&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#963&#34;&gt;org-redisplay-inline-images&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;with-eval-after-load&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;org&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;define-key&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-mode-map&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;kbd&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-&amp;lt;print&amp;gt;&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;#&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#963&#34;&gt;ews-org-insert-screenshot&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Chapter numbering
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Org mode will number every heading when the &lt;code class=&#34;verbatim&#34;&gt;#+startup: num&lt;/code&gt; option is set. The numbering will appear in the Org file. How numbering is treated in the export depends on the file format you use.&lt;/p&gt;
&lt;p&gt;
In some publications, not all headers are numbered, such as in the front matter of a book. You can exclude individual sections from being numbered by setting the &lt;code class=&#34;verbatim&#34;&gt;:unnumbered:&lt;/code&gt; property as shown below. To add this property, drawer, type &lt;code class=&#34;verbatim&#34;&gt;C-c C-x p&lt;/code&gt;, select the relevant property and enter the value.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;:PROPERTIES:
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;:UNNUMBERED: t
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;:END:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
Citation Management
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Citations are the engine of academic writing. Org mode has a built-in citation management tool. You will first need to &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-bibtex-mode/&#34;&gt;create a bibliography&lt;/a&gt;. You can either create one yourself, or dynamically link a file from a bibliography management tool such as Zotero.&lt;/p&gt;
&lt;p&gt;
Bibliographies can be global or local. The global bibliography is accessible from any place in Emacs, while the local bibliography file is only available within your Org mode file.&lt;/p&gt;
&lt;p&gt;
The global bibliography is set in your configuration (&lt;code&gt;org-cite-global-bibliography&lt;/code&gt; variable) and can consist of one or more BibTeX / CSL files.&lt;/p&gt;
&lt;p&gt;
The local bibliography is linked to an Org mode file with the &lt;code class=&#34;verbatim&#34;&gt;#+bibliography: &amp;#34;bibfile.bib&amp;#34;&lt;/code&gt; in your document header.&lt;/p&gt;
&lt;p&gt;
You can insert citations with &lt;code&gt;org-cite-insert&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c C-x @&lt;/code&gt;). Within &lt;em&gt;Emacs Writing Studio&lt;/em&gt;, this command opens the Citar menu from where you can select one or more publications. A citation will look something like this: &lt;code class=&#34;verbatim&#34;&gt;[cite:@einstein_1905;@newton_1728]&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
You can access the resources related to a citation with &lt;code&gt;org-open-at-point&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c C-o&lt;/code&gt;), which opens the Citar menu for the citation under point. If the citation has no entry in your local or global bibliography, then Org mode will warn that it could not find a match and will ask you to create a new heading, which of course is not the case.&lt;/p&gt;
&lt;p&gt;
Citar indicates wether an entry is cited in your project with a &lt;code class=&#34;verbatim&#34;&gt;C&lt;/code&gt; in the list of publications.&lt;/p&gt;
&lt;p&gt;
Org mode has detailed methods to determine how citations are rendered in exported documents, which is discussed in &lt;a href=&#34;https://lucidmanager.org/productivity/publishing-with-org-mode-export/&#34;&gt;another article&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-10&#34;&gt;
Managing Your Writing Project
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A writing project is about more than just smashing words into a document. Some functionality is available to add notes to your project, manage word counts and overall progress of your writing.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/nX0-Sg90RIk?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Writing Tools in Emacs.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-11&#34;&gt;
Large Projects
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Writing a book in a single Org mode file can be laborious because you need to navigate a large file. The built-in narrowing tool can help in keeping your focus. Narrowing in Emacs means that the buffer will only show a selected part of your text so you don&amp;#39;t get distracted by the rest of the document. The hidden text is still available, just not visible on the screen.&lt;/p&gt;
&lt;p&gt;
To narrow your buffer to only show the subtree (heading and associated subheadings) you are currently working in use &lt;code&gt;org-narrow-to-subtree&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-x n s&lt;/code&gt;). This commands reduces the visible text to the section under consideration. To go back to the full document evaluate the &lt;code&gt;widen&lt;/code&gt; command (&lt;code class=&#34;verbatim&#34;&gt;C-x n w&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;
Sometimes it might be a good idea to split larger projects over multiple files. Org mode has an inclusion function that creates a link between documents.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;#+include: &amp;#34;chapter-02.org&amp;#34;&lt;/code&gt; line includes a file named Chapter 02 inside the main document. You can visit this child document with &lt;code class=&#34;verbatim&#34;&gt;C-c &amp;#39;&lt;/code&gt; (&lt;code&gt;org-edit-special&lt;/code&gt;). Org mode has some &lt;a href=&#34;https://orgmode.org/manual/Include-Files.html&#34;&gt;additional options&lt;/a&gt; to determine exactly which part of the child document is included.&lt;/p&gt;
&lt;p&gt;
This method allows you to work on a book or dissertation and store each chapter in a separate file. When you export the main file to a PDF, or ePUB file, all included files are added to the export. &lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-12&#34;&gt;
Adding notes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Sometimes, adding notes to your text that should be separate from the final version is worthwhile. You should add a checklist of what needs to be done, links to websites or notes in your Denote digital garden, or anything else of importance during the process of writing. &lt;/p&gt;
&lt;p&gt;
Any line in Org mode that starts with a hashtag or pound symbol is a comment, which Emacs ignores when exporting the text to the final output. &lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  # This is a comment&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Org mode also has handy drawers, which are bits of collapsible text that can store notes. You can keep multiple lines of text in a drawer, for example, if you need to cut out a bit of text and would like to save it for future reference. The beauty of Org mode drawers is that they are collapsible, so their contents do not distract you from the primary task. You can close or open a drawer with the &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; key when the cursor is on the drawer.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ** This is a headline
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;  :DRAWER_NAME:
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;  This is inside the drawer.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;  :END:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  After the drawer.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
You can interactively insert a drawer at point by calling the &lt;code&gt;org-insert-drawer&lt;/code&gt;, bound to &lt;code class=&#34;verbatim&#34;&gt;C-c C-x d&lt;/code&gt;. The selected text will be placed inside the drawer when a region is active. This function will add the name for your drawer, usually written in full caps. The drawer is inserted at the current location of the cursor.&lt;/p&gt;
&lt;p&gt;
An &lt;em&gt;Emacs Writing Studio&lt;/em&gt; function (&lt;code&gt;ews-org-insert-notes-drawer&lt;/code&gt;) generates notes drawers, bound to the &lt;code class=&#34;verbatim&#34;&gt;C-c C-x n&lt;/code&gt; keyboard shortcut. This function jumps just below the heading of the section you are writing and generates a notes drawer. If a drawer exists for this section, a new line is created at the end of the current note. After you finish writing the note, &lt;code class=&#34;verbatim&#34;&gt;C-u C-SPACE&lt;/code&gt; will take you back to your original position in the text.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Notes drawers&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ews-org-insert-notes-drawer&lt;/span&gt; ()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Generate or open a NOTES drawer under the current heading.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;interactive&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;push-mark&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-previous-visible-heading&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;next-line&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-beginning-of-line&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;looking-at-p&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;^[ \t]*:NOTES:&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#007020&#34;&gt;progn&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#963&#34;&gt;org-fold-hide-drawer-toggle&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;off&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;re-search-forward&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;^[ \t]*:END:&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#963&#34;&gt;previous-line&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#963&#34;&gt;org-end-of-line&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#963&#34;&gt;org-return&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#963&#34;&gt;org-insert-drawer&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;NOTES&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-unlogged-message&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Press &amp;lt;C-u C-SPACE&amp;gt; to return to the previous position.&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;with-eval-after-load&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;org&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;define-key&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-mode-map&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;kbd&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c C-x n&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;#&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#963&#34;&gt;ews-org-insert-notes-drawer&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
If you need to take any notes unrelated to the document at hand, then a fleeting note stored in your central inbox is a better choice. The &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/&#34;&gt;Org mode capture mechanism&lt;/a&gt; is the best solution for these situations.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-13&#34;&gt;
Counting words
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Emacs has a built-in functionality to count words in a region using the &lt;code&gt;count-words-region&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;M ==&lt;/code&gt;). To find out how many words each chapter or section of your work has, you will need to run this for each part of your document. Within Org mode, there is an easy way to automate this behaviour and get an almost instant overview of your word count for each document part. This method will also let you add word count targets for each section so you can monitor progress or balance your writing.&lt;/p&gt;
&lt;p&gt;
Org mode can add properties to each heading, which we can leverage to add word counts. To add a property, use &lt;code class=&#34;verbatim&#34;&gt;C-c C-x p&lt;/code&gt; and select one from the list or create a new one. The &lt;code&gt;ews-org-count-words&lt;/code&gt; function cycles through all headings in your open Org buffer and adds a word count for each heading, including the subheadings. To add a target word count, add a new property called &lt;code class=&#34;verbatim&#34;&gt;target&lt;/code&gt; and add the relevant number.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ews-org-count-words&lt;/span&gt; ()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Add word count to each heading property drawer in an Org mode buffer.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;interactive&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-map-entries&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#007020&#34;&gt;lambda&lt;/span&gt; ()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       (&lt;span style=&#34;color:#007020&#34;&gt;let*&lt;/span&gt; ((&lt;span style=&#34;color:#963&#34;&gt;start&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;point&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              (&lt;span style=&#34;color:#963&#34;&gt;end&lt;/span&gt; (&lt;span style=&#34;color:#007020&#34;&gt;save-excursion&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;org-end-of-subtree&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              (&lt;span style=&#34;color:#963&#34;&gt;word-count&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;count-words&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;start&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;end&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         (&lt;span style=&#34;color:#963&#34;&gt;org-set-property&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;wordcount&amp;#34;&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;number-to-string&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;word-count&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         (&lt;span style=&#34;color:#007020&#34;&gt;unless&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;org-entry-get&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;target&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           (&lt;span style=&#34;color:#963&#34;&gt;org-set-property&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;target&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;0&amp;#34;&lt;/span&gt;))))))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
A collapsible property drawer shows a word count and your manually added target. When no target property exists yet, this function will add one with zero as a default. This property drawer works the same way as the notes drawer discussed previously.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;  :PROPERTIES:
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;  :wordcount: 305
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;  :target: 300
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;  :END:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
You can view the word count for each heading in Org mode&amp;#39;s property column view &lt;code class=&#34;verbatim&#34;&gt;C-c C-x c&lt;/code&gt; (&lt;code&gt;org-columns&lt;/code&gt;). Ensure you evaluate this function at the highest level (beginning of the document). Org mode only shows the properties for the subtree you are currently in. This view creates an overlay. By cylcing through the document with &lt;code class=&#34;verbatim&#34;&gt;S-TAB&lt;/code&gt;, a table will appear. To include the word counts and targets, you will need to add this line at the start of the document, which defines which properties to see in each column :&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+columns: %40item %10todo %10wordcount %10target&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The columns are an overlay and not part of the text, so nothing you wrote is modified. You can keep editing your document in column view. Place the cursor on a column overlay to remove the overlay and press &lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt;.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-14&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-14&#34;&gt;
Status tracking
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-14&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;As you are working on various parts of your writing project it might be godo to know what the status of each chapter is.&lt;/p&gt;
&lt;p&gt;
Org mode also has an extensive &lt;a href=&#34;https://lucidmanager.org/productivity/getting-things-done-with-emacs/&#34;&gt;system to manage projects&lt;/a&gt;, which you can also deploy to keep track of progress in your document.&lt;/p&gt;
&lt;p&gt;
Each heading in Org mode can have a status token, such as &lt;code class=&#34;verbatim&#34;&gt;TODO&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;DONE&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;EDITED&lt;/code&gt;, or whatever workflow you like to use. You add a status token with the shift and left/right arrow keys when the cursor is on a heading. You can also use the &lt;code class=&#34;verbatim&#34;&gt;C-c C-t&lt;/code&gt; shortcut (&lt;code&gt;org-todo&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;
By default, the system only uses the &lt;code class=&#34;verbatim&#34;&gt;TODO&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;DONE&lt;/code&gt; status. You can add additional workflow states by defining them in the document header. The example below will cycle through these four status tokens. The tokens before the vertical line are in progress and usually marked in red. The vertical line are completed and marked in green. Org mode will add a timestamp when a section gets to the &lt;code class=&#34;verbatim&#34;&gt;FINAL&lt;/code&gt; status in this example.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+todo: WRITE DRAFT EDIT | FINAL&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Org mode has extensive facilities to &lt;a href=&#34;https://orgmode.org/manual/TODO-Items.html&#34;&gt;fine tune how these status tokens behave&lt;/a&gt;, including adding notes and timestamps.&lt;/p&gt;
&lt;p&gt;
This article only covered the tip of the iceberg of the writing and editing functionality in Emacs. Many specialised packages are available to enhance your writing experience. I advise keeping it simple for now and spend your tie writing instead of configuring Emacs. When you discover a new need, a few Google searches will often give you exactly what you need.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-15&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-15&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-15&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The screen still looks a bit plain, so in the next article we look at some techniques to improve the &lt;a href=&#34;https://lucidmanager.org/productivity/ricing-org-mode/&#34;&gt;look-and-feel or Emacs&lt;/a&gt; and Org mode.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Ricing Org Mode: A Beautiful Writing Environment</title>
      <link>https://lucidmanager.org/productivity/ricing-org-mode/</link>
      <pubDate>Sun, 08 Aug 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/ricing-org-mode/</guid>
      <description>
	
&lt;p&gt;
A plain text editor helps you focus on content over form. Having said this, the default Emacs experience can be harsh on the eyes. This article describes how to improve Emacs by ricing Org mode for a more pleasant writing experience.&lt;/p&gt;
&lt;p&gt;
Ricing is a term often used by hackers as the activity to make a system look nicer. The &lt;a href=&#34;https://www.urbandictionary.com/define.php?term=ricing&#34;&gt;Urban Dictionary&lt;/a&gt; defines it as: &amp;#34;To rice, or to soup up a crappy car with the mistaken idea that […] performance yellow paint makes it go faster.&amp;#34;&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Org mode as a Text Processor
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The main difference between a text editor and a Word processor is that in Emacs, the design of the text (font, colour and so on) is based on meaning and not the writer&amp;#39;s choice. The purpose of the buffer design is to help you navigate the document. This will not be the way it looks when you export the text. The articles about &lt;a href=&#34;https://lucidmanager.org/productivity/publishing-with-org-mode-export/&#34;&gt;publishing articles and books&lt;/a&gt; and the article about &lt;a href=&#34;https://lucidmanager.org/productivity/create-websites-with-org-mode-and-hugo/&#34;&gt;creating websites&lt;/a&gt; show how to export buffers.&lt;/p&gt;
&lt;p&gt;
The default design of an Org mode buffer is a bit bland, shown in the image below. This article will show you how to step-by-step improve the look-and-feel. These improvements are not  beautification for the sake of aesthetics. Removing leading stars, indentation, converting $\LaTeX$ and line spacing facilitates the writing process by giving your eyes focus on content instead of form.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/org-mode-rice-01.png&#34; alt=&#34;Before ricing org mode&#34; title=&#34;Before ricing Org mode&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Before ricing Org mode.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
All the configuration explained in this series of articles is available as an init file on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Org mode Tweaks
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Org mode needs some tweaks to remove clutter from the screen. We can change the etxt alignment, change the way fonts of rich text and special characters are displayed and preview images by default.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;;; Improve org mode looks&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;setq-default&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-startup-indented&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  &lt;span style=&#34;color:#963&#34;&gt;org-pretty-entities&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  &lt;span style=&#34;color:#963&#34;&gt;org-use-sub-superscripts&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;{}&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  &lt;span style=&#34;color:#963&#34;&gt;org-hide-emphasis-markers&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  &lt;span style=&#34;color:#963&#34;&gt;org-startup-with-inline-images&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  &lt;span style=&#34;color:#963&#34;&gt;org-image-actual-width&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;(&lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;300&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-3&#34;&gt;
Indentation
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;Org mode aligns text to the left of the buffer and all the stars of headings are visible. You can also remove leading stars and align subheadings and text below its respective heading to create a more pleasant layout. To globally turn on Org Indent mode for all files, set the variable &lt;code class=&#34;verbatim&#34;&gt;org-startup-indented&lt;/code&gt; to &lt;code class=&#34;verbatim&#34;&gt;t&lt;/code&gt;, which removes the leading stars for a nice clean view.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-4&#34;&gt;
Rich Text and Special Characters
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;The following three lines in the configuration instruct Org mode to display special characters and improve how we view rich text.&lt;/p&gt;
&lt;p&gt;
Pretty entities in Org mode relate to special symbols, such as superscript and subscript (&lt;code class=&#34;verbatim&#34;&gt;x^{2}&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;x_{2}&lt;/code&gt;) and other LaTeX special characters, such as &lt;code class=&#34;verbatim&#34;&gt;\pi&lt;/code&gt;, which display as x², x&lt;sub&gt;2&lt;/sub&gt; and π.&lt;/p&gt;
&lt;p&gt;
You can toggle this behaviour with the &lt;code class=&#34;verbatim&#34;&gt;C-c C-x \&lt;/code&gt; keystroke (&lt;code class=&#34;verbatim&#34;&gt;org-toggle-pretty-entities&lt;/code&gt;). For more complex mathematical expressions, see below.&lt;/p&gt;
&lt;p&gt;
By default, Org mode does not require curly braces for sub- and superscripts. But this can cause confusion if you like to write something using snake_case. This configuration limits applying sub- and superscripts to characters between curly braces by setting the &lt;code&gt;org-use-sub-superscripts&lt;/code&gt; variable to &lt;code class=&#34;verbatim&#34;&gt;{}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
Org mode uses various markers to indicate rich text. Emacs will adapt the text display, but the markers remain visible, which adds to the clutter on your screen. You can remove these markers by setting the &lt;code class=&#34;verbatim&#34;&gt;org-hide-emphasis-markers&lt;/code&gt; variable.&lt;/p&gt;
&lt;p&gt;
The only problem with hiding emphasis markers is that rich text becomes hard to edit because it is unclear whether your cursor is on the marker or the first or last character. The &lt;a href=&#34;https://github.com/awth13/org-appear&#34;&gt;org-appear package&lt;/a&gt; helps by displaying the markers while the cursor is on a rich text word.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-appear&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:hook&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-mode&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-appear-mode&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-5&#34;&gt;
Preview Images
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;Org mode includes images as file links, but it can also preview the image itself. The penultimate line in this configuration instructs Org mode to preview all images in a buffer. You can toggle this with &lt;code class=&#34;verbatim&#34;&gt;C-c C-x C-v&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;org-toggle-inline-images&lt;/code&gt;) for each open buffer.&lt;/p&gt;
&lt;p&gt;
You need to restrict the size of previews because they can get unwieldy when working with high-resolution images. You can set the default width of a preview in pixels, which in this example is 300. If you like to increase the size of a specific image, then place the cursor on it and use the plus and minus keys.&lt;/p&gt;
&lt;p&gt;
The code above shows the number of pixels in a list &lt;code class=&#34;verbatim&#34;&gt;&amp;#39;(300)&lt;/code&gt; instead of just the number. This method instructs Org mode to override this setting for individual images with the &lt;code class=&#34;verbatim&#34;&gt;#+attr_org: :width&lt;/code&gt; set. In this example, the image is displayed at a width of 100 pixels.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+caption: Image caption.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+attr_org: :width 100
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  [[&lt;span style=&#34;color:#00c&#34;&gt;file:path/to/image.png&lt;/span&gt;]]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-6&#34;&gt;
Prettify Special Symbols
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;When using Org mode or similar approaches, there a lot of characters that are not content but indicate semantics, such as the asterisks at the start of a header. These symbols are practical but look a bit rough. The previous configuration already removed the leading stars to reduce clutter. Now we will replace these symbols with some nicer looking bullets.&lt;/p&gt;
&lt;p&gt;
Emacs can change the way a text file is displayed by either hiding or replacing characters. The &lt;a href=&#34;https://github.com/minad/org-modern&#34;&gt;Org-Modern package&lt;/a&gt; implements a configurable package to rice your Org mode buffers. The package can style headline indicators, keywords, tables and source blocks. This configuration disables some of the functionality because hiding indicators is not always a good idea. &lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-modern&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:hook&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-mode&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;global-org-modern-mode&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-modern-keyword&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-modern-checkbox&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-modern-table&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-7&#34;&gt;
LaTeX previews
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;If you have a working LaTeX installation, then Org Mode can preview LaTeX fragments, such as formulas, as images. To preview the fragment under the cursor, press &lt;code class=&#34;verbatim&#34;&gt;C-c C-x C-l&lt;/code&gt; (&lt;code&gt;org-latex-preview&lt;/code&gt;) to, for example, convert &lt;code class=&#34;verbatim&#34;&gt;$\sum_1^\infty \frac{1}{x}$&lt;/code&gt; to $\sum_1^\infty \frac{1}{x}$. Org mode created a subdirectory named &lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://github.com/io12/org-fragtog&#34;&gt;org-fragtog&lt;/a&gt; package provides some nice functionality that toggles between the source and the preview of the formulas, which means you don&amp;#39;t have to use the &lt;code&gt;org-latex-preview&lt;/code&gt; function repeatedly. The package is loaded after the Org package has loaded.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; LaTeX previews&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-fragtog&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:after&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-startup-with-latex-preview&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:hook&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-mode&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-fragtog-mode&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-format-latex-options&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plist-put&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-format-latex-options&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;:scale&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plist-put&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-format-latex-options&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;:foreground&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;auto&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plist-put&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-format-latex-options&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;:background&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;auto&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;org-format-latex-options&lt;/code&gt; variable controls the way the Emacs presents fragments. By default, the text is a bit small. This variable is a list with properties such as colours and size. The &lt;code class=&#34;verbatim&#34;&gt;plist-put&lt;/code&gt; function lets you change one of these options in the list. The foreground and background are set to take the same colour as your text. If you change from dark to light mode or vice versa, you need to evaluate the &lt;code&gt;org-latex-preview&lt;/code&gt; function to change the way formulas are displayed.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Line Spacing
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;When the text is a bit too compact for your liking, then change the &lt;code class=&#34;verbatim&#34;&gt;line-spacing&lt;/code&gt; variable. Setting it to &lt;code class=&#34;verbatim&#34;&gt;nil&lt;/code&gt; results in a cramped reading space, so best to add some whitespace between lines. Space between paragraphs is formed by adding an empty line.&lt;/p&gt;
&lt;p&gt;
If the value is an integer, it indicates the number of pixels below each line. A decimal number is a scaling factor relative to the current window&amp;#39;s default line height. The &lt;code class=&#34;verbatim&#34;&gt;setq-default&lt;/code&gt; function sets this for all buffers. Otherwise, it only applies to the current open buffer. Try the value that best suits your preferences.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Increase line spacing&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq-default&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;line-spacing&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
A Clean Writing Interface
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Writing takes total concentration to produce creative prose. Distractions are the natural enemy of concentration. While your computer is your most important writing tool, it can also be a source of distractions.&lt;/p&gt;
&lt;p&gt;
Distraction-free writing means that your computer screen is free of clutter and, just like an old typewriter, only shows the text you are working on. In the article about &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;configuring Emacs&lt;/a&gt;, we already removed the menu bar and other on-screen distractions.&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://github.com/rnkn/olivetti&#34;&gt;Olivetti&lt;/a&gt; is a simple Emacs minor mode that facilities distraction-free writing. The name Olivetti derives from the famous typewriter brand.&lt;/p&gt;
&lt;p&gt;
You activate Olivetti mode with &lt;code class=&#34;verbatim&#34;&gt;M-x olivetti-mode&lt;/code&gt;. This minor mode reduces the width of the text to seventy characters and centres the text in the middle of the window. The width of the text is changeable with the &lt;code class=&#34;verbatim&#34;&gt;M-x olivetti-set-with&lt;/code&gt; command or &lt;code class=&#34;verbatim&#34;&gt;C-c \&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
I have written a new function that makes Olivetti mode a bit easier to use. This code stores your window configuration when you hit &lt;code class=&#34;verbatim&#34;&gt;F9&lt;/code&gt; (or whatever key you prefer) and activates Olivetti mode. It also increases the text by two steps to create a nice focussed screen. Finally, typing &lt;code class=&#34;verbatim&#34;&gt;F9&lt;/code&gt; again restores the previous window settings.&lt;/p&gt;
&lt;p&gt;
This snippet of code is a simple example of the flexibility of Emacs and how relatively easy it is to change its behaviour to suit your preferences. The &lt;code&gt;ews-distraction-free&lt;/code&gt; function checks whether Olivetti mode is currently active. If this is not the case, then it saves the current window configuration to a register and activates Olivetti mode with enlarged font size. If Olivetti mode is active, then the text is sized to its default and olivetti mode disabled. If the original window configuration had more than two open windows, then this is restored so you are back where you left off.&lt;/p&gt;
&lt;p&gt;
As a side note, all functions specifically written for the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; start with &lt;code&gt;ews-&lt;/code&gt;, which is in line with best-practice naming conventions in Emacs Lisp where all functions start with their package name.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Distraction-free writing&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ews-distraction-free&lt;/span&gt; ()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Distraction-free writing environment using Olivetti package.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;interactive&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;equal&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;olivetti-mode&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#007020&#34;&gt;progn&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#963&#34;&gt;window-configuration-to-register&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#963&#34;&gt;delete-other-windows&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#963&#34;&gt;text-scale-set&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#963&#34;&gt;olivetti-mode&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#007020&#34;&gt;progn&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#007020&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;eq&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;window-list&lt;/span&gt;)) &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            (&lt;span style=&#34;color:#963&#34;&gt;jump-to-register&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#963&#34;&gt;olivetti-mode&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#963&#34;&gt;text-scale-set&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;0&lt;/span&gt;))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;olivetti&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:demand&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;lt;f9&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ews-distraction-free&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-10&#34;&gt;
Ricing Org Mode
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;By ricing Org mode we have moved somewhere between pure plain text and a graphical interface. There is no functional need to do so other than convenience. While it might seem that we have moved away from the &lt;em&gt;What You See is What You Mean&lt;/em&gt; approach, that is not quite the case. The way the screen is presented in Emacs is different from the way it looks in your final output.&lt;/p&gt;
&lt;p&gt;
For example, if you create a website, any Org mode text surrounded by a forward slash (&lt;code class=&#34;verbatim&#34;&gt;/example/&lt;/code&gt;) is translated as &lt;code&gt;&amp;lt;i&amp;gt;example&amp;lt;/i&amp;gt;/&lt;/code&gt;. For LaTeX output, it becomes &lt;code&gt;\emph{example}&lt;/code&gt;. The HTML style sheet or LaTeX document class determines the way this code looks in the final output (the &amp;#34;what you get&amp;#34; in WYSIWYG). This example is italic by default, but it could be something different.&lt;/p&gt;
&lt;p&gt;
The results of our efforts have made a difference, as shown by the image below. Your chosen theme will change the background and text colours.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/org-mode-rice-02.png&#34; alt=&#34;After ricing org mode&#34; title=&#34;After ricing Org mode&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Enhanced Org mode screen.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-11&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media through the links in the footer.&lt;/p&gt;
&lt;p&gt;
Now that you have written a nice article or a new book, it is time to &lt;a href=&#34;https://lucidmanager.org/productivity/publishing-with-org-mode-export/&#34;&gt;publish your work as an ebook or a physical book&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Publishing Articles and Books with Org Mode Export</title>
      <link>https://lucidmanager.org/productivity/publishing-with-org-mode-export/</link>
      <pubDate>Wed, 05 May 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/publishing-with-org-mode-export/</guid>
      <description>
	
&lt;p&gt;
Emacs Org mode is an &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;ideal tool for writing without distractions&lt;/a&gt; because working with plain text allows you to focus on content instead of design. While writing articles and books in plain text is pleasant and productive, it is not ideal for sharing your work. The Org mode exports your work to PDF leveraging LaTeX, to a website, to a word processor document, an ebook and many more formats. This article explains how to export your work as a journal article, a print-ready book PDF, or an ebook.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Org mode export principles
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The basic principle of exporting Org mode files to the desired format is that the system converts the text to the relevant format and then connects it to a document class, CSS style sheet or other type of template. Your text file can also link to a &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-bibtex-mode/&#34;&gt;local or global bibliography&lt;/a&gt; to manage citations. Org mode has built-in export facilities for LaTeX (PDF), HTML and ODT (LibreOffice) and some other formats. Using external packages you can also export to other formats, such as ePub.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/org-mode-export.png&#34; alt=&#34;Org mode explort principles&#34; title=&#34;Org mode explort principles&#34; width=&#34;300&#34;/&gt;
&lt;figcaption&gt;
Org mode explort principles
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
In principle you don&amp;#39;t need to know HTML or LaTeX, but it will certainly help with fine tuning the output.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Org mode export function
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Org mode includes a powerful export module to convert your files to various formats. Start the export module with the &lt;code&gt;org-export-dispatch&lt;/code&gt; function, which you can run with the default &lt;code class=&#34;verbatim&#34;&gt;C-c C-e&lt;/code&gt; keyboard shortcut. The dispatch provides a range of options. The first letter you type determines the export format, and subsequent letters the specific options. Using &lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt; exists the export dispatcher.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://orgmode.org/manual/Exporting.html&#34;&gt;Org mode manual&lt;/a&gt; describes a myriad of configuration options to fine-tune the look and feel of the exported file. This article describes the basics of the export functionality for PDF files, word processor formats and ebooks.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Export filename
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;By default, Org mode saves the result of the export process in the same folder as the source document. The exported file has the same name as the source file but with a different extension.&lt;/p&gt;
&lt;p&gt;
Exporting &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/&#34;&gt;Denote&lt;/a&gt; Org mode files can create a filename conflict because you are effectively creating two files with the same identifier, so ideally you should change the name of the exported file. &lt;/p&gt;
&lt;p&gt;
You can change this behaviour by adding &lt;code&gt;#+export_file_name: &amp;lt;filename&amp;gt;&lt;/code&gt; to the header. The filename can be any string without file extension. You can save the exported file in another folder, but this might cause errors for certain formats.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Basic settings
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Before delving into the specific export formats, some housekeeping sets the defaults on how a document is exported. There are &lt;a href=&#34;https://orgmode.org/manual/Export-Settings.html#FOOT123&#34;&gt;various settings to control how Org mode exports your document&lt;/a&gt;, which you add to the front matter of your file, or set them as global variable for all exports. Some generic export variables are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;#+title:&lt;/code&gt; Document title.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;#+author:&lt;/code&gt; Author name (defaults to &lt;code&gt;user-full-name&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;#+date:&lt;/code&gt; Date of publication (You can set the format of the export with the &lt;code&gt;org-export-date-timestamp-format&lt;/code&gt; variable).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The snippet below ignores drawers (&lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;which can be used for writing notes and other functions&lt;/a&gt;) and &lt;a href=&#34;https://lucidmanager.org/productivity/getting-things-done-with-emacs/&#34;&gt;todo keywords&lt;/a&gt; in the export. This configuration also ignores broken links, does not produce a table of contents and turns straight quotation marks into more aesthetic curly ones.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Org Export Settings&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-export-with-drawers&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-export-with-todo-keywords&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-export-with-broken-links&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-export-with-toc&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-export-with-smart-quotes&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-export-date-timestamp-format&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%d %B %Y&amp;#34;&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
You can override these settings for specific documents with header arguments, as shown below. The &lt;code class=&#34;verbatim&#34;&gt;d&lt;/code&gt; is for drawers and the mystical looking &lt;code&gt;\\=&amp;#39;&lt;/code&gt; for smart quotes. The line below shows drawers and todo markers in the export. This configuration marks broken links, shows two levels of the table of contents and quotation marks are not converted. &lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+options: d:t todo:t broken-links:mark toc:2 \\=&amp;#39;:nil&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Section 13.2 of the &lt;a href=&#34;https://orgmode.org/manual/Export-Settings.html&#34;&gt;Org mode manual&lt;/a&gt; explains the various export settings in more detail. Each option can be set as a variable in your configuration or as a line in your Org mode header to fine tune export settings for individual files.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Excluding content from export
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Not everything you write should be exported, as suggested in the export defaults in the previous section. The article on &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;writing with Org mode&lt;/a&gt; explains how to add comments and notes drawers into your file. Comments with &lt;code class=&#34;verbatim&#34;&gt;#&lt;/code&gt; and are not exported by default. The &lt;code&gt;ews-org-insert-notes-drawer&lt;/code&gt; command inserts or appends a drawer in the current document section. The &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration does not export drawers, so your notes remain private. &lt;/p&gt;
&lt;p&gt;
Furthermore, can also exclude a section of your writing from export by adding the &lt;code class=&#34;verbatim&#34;&gt;:noexport:&lt;/code&gt; tag. You add a tag to a heading by keying &lt;code class=&#34;verbatim&#34;&gt;C-c C-q&lt;/code&gt; when the cursor is on or inside the heading. You enter the tag in the minibuffer and you can use completion to find existing tags. The tag appears on the right side of the heading name between colon markers.&lt;/p&gt;
&lt;p&gt;
Tags in Org mode provide flexible functionality to manage large files or categorise action lists. Org mode has extensive capabilities to use tags, which are not further used in &lt;em&gt;Emacs Writing Studio&lt;/em&gt;.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Bibliographic references
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Org mode has a built-in citation manager that can use BibTeX / BibLaTeX or CSL files to reference bibliographic items such as articles and books.&lt;/p&gt;
&lt;p&gt;
The article on &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-bibtex-mode/&#34;&gt;managing BibTeX files&lt;/a&gt; explains how to create a bibliography. You can create a default bibliography, that is accessible to all Org mode files and specify specific bibliography files for each Org mode file.&lt;/p&gt;
&lt;p&gt;
When exporting to LaTeX, citations are managed by  the external software. When exporting to any other format you need to specify how Org mode manages citations. The default settings in Org mode provide basic citation support.&lt;/p&gt;
&lt;p&gt;
This website by Tecosaur provides an in-depth description of how to &lt;a href=&#34;https://blog.tecosaur.com/tmio/2021-07-31-citations.html&#34;&gt;manage citations in Org mode&lt;/a&gt;, much better than I can explain it.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/NwDOKkwtJ34?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Introducing Org mode exports.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Word Processor Export
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The export function in Org Mode can export to the ODT format, which is compatible with MS Word, out of the box. The ODT export back-end relies on the &lt;code class=&#34;verbatim&#34;&gt;zip&lt;/code&gt; program to create the final output&lt;/p&gt;
&lt;p&gt;
If you have LibreOffice installed, you can also create a &lt;code class=&#34;verbatim&#34;&gt;docx&lt;/code&gt; file to make it easier for MS Word users to share in the joy of reading your writing. When you set this option, the export process will result in both an &lt;code class=&#34;verbatim&#34;&gt;odt&lt;/code&gt; and a &lt;code class=&#34;verbatim&#34;&gt;docx&lt;/code&gt; file. This behaviour is not the default in &lt;em&gt;Emacs Writing Studio&lt;/em&gt;, so you must add this yourself if you prefer exporting in the Microsoft format. Alternatively, you can also use this variable to export to PDF.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Not included in EWS&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Export ODT to MS-Word&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq-default&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-odt-preferred-output-format&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;docx&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Export ODT to PDF&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq-default&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-odt-preferred-output-format&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;pdf&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
It is possible to set this option specific to the file you are exporting by adding these three lines somewhere in your Org mode file:&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  # local variables:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  # org-odt-preferred-output-format: &amp;#34;pdf&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  # end:&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
When Org mode exports the file, these lines are evaluated but not exported as they are treated as comments.&lt;/p&gt;
&lt;p&gt;
You can use specific export settings in the front matter:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;#+subtitle:&lt;/code&gt; The document subtitle.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;#+description:&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;#+keywords&lt;/code&gt; are added to the exported file(s) metadata.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;#+odt_styles_file:&lt;/code&gt; Add the path to an LibreOffice style file (&lt;code class=&#34;verbatim&#34;&gt;ott&lt;/code&gt; format)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Creating a LibreOffice style file is straightforward:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a LibreOffice file to your liking using the Styles menu (press &lt;code class=&#34;verbatim&#34;&gt;F11&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;Modify each style to your liking.&lt;/li&gt;
&lt;li&gt;Test the document.&lt;/li&gt;
&lt;li&gt;Save as &lt;code class=&#34;verbatim&#34;&gt;ott&lt;/code&gt; file.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A LibreOffice file is essentially a &lt;code class=&#34;verbatim&#34;&gt;zip&lt;/code&gt; file with an embedded set of &lt;code class=&#34;verbatim&#34;&gt;xml&lt;/code&gt; files. Org mode extracts the &lt;code class=&#34;verbatim&#34;&gt;styles.xml&lt;/code&gt; file embedded in your template file. You cannot use this method for templates (pre-configured content).&lt;/p&gt;
&lt;p&gt;
You can fine-tune how Org exports to OpenOffice to a great extent. For a detailed discussion on &lt;code class=&#34;verbatim&#34;&gt;odt&lt;/code&gt; Export, read the online &lt;a href=&#34;https://orgmode.org/manual/OpenDocument-Text-Export.html&#34;&gt;Org mode manual&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
LaTeX export
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;LaTeX is a powerful typesetting system (pronounced “LAY-tek” or “LAH-tek”), especially for writing scientific and technical documents. LaTeX can convert your text into a beautifully designed PDF file for publishing an article, ebook or physical book. Many publishers of technical literature have LaTeX templates to comply with their style guide. &lt;/p&gt;
&lt;p&gt;
You don’t necessarily need any knowledge of LaTeX to export to PDF. Still, it will certainly help if you like to fine-tune the design of your document. The basic syntax of LaTeX is easy to explain. Let&amp;#39;s assume you have a straightforward Org mode file that looks like this:&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+title:  Example document
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+author: Peter Prevos
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+latex_class: book
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  Minimum example for a LaTeX document.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The Latex equivalent of this example is:&lt;/p&gt;
&lt;div class=&#34;src src-latex&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-latex&#34; data-lang=&#34;latex&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\documentclass&lt;/span&gt;&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;article&lt;span style=&#34;color:#007020&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\title&lt;/span&gt;&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;Example document&lt;span style=&#34;color:#007020&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\author&lt;/span&gt;&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;Peter Prevos&lt;span style=&#34;color:#007020&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\begin&lt;/span&gt;&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;document&lt;span style=&#34;color:#007020&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\maketitle&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  Minimum example for a LaTeX document.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\end&lt;/span&gt;&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;document&lt;span style=&#34;color:#007020&#34;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The LaTeX software can convert this document to a wonderfully formatted article due to the document class, which defines the typography and layout.&lt;/p&gt;
&lt;p&gt;
Writing documents directly in LaTeX can be confusing because you need to know its markup language, and your text is littered with backslashes, curly braces, and other syntactical distractions. Being productive as a writer requires focusing on the text’s content instead of how it looks. Org mode is the perfect LaTeX editor because it frees you from distractions and integrates perfectly with LaTeX.&lt;/p&gt;
&lt;p&gt;
To enable exporting Org mode files to PDF, you need to have LaTeX installed on your system. How to install LaTeX depends on your operating system, and your favourite search engine will point you in the right direction.&lt;/p&gt;
&lt;p&gt;
Keying &lt;code class=&#34;verbatim&#34;&gt;C-c C-e&lt;/code&gt; to open the export dispatch, then &lt;code class=&#34;verbatim&#34;&gt;l p&lt;/code&gt; creates and opens a PDF file. Other options are available to export the buffer to LaTeX or to save a PDF file without opening it.&lt;/p&gt;
&lt;p&gt;
To make the magic work, Org Mode converts your file to a &lt;code class=&#34;verbatim&#34;&gt;tex&lt;/code&gt; file, after which the LaTeX software converts it to PDF. The system works out of the box without any configuration. With some configuration you can produce PDF files that are perfect for producing printed books.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
Text elements
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Org mode converts headers to relevant LaTeX headers, and text becomes a paragraph. The relationship between the heading level in your Org file and LaTeX depends on the configuration, explained below. &lt;/p&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-10&#34;&gt;
Tables and images
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;Org mode converts images and tables to LaTeX floats. You can add specific attributes to these floats by using &lt;code class=&#34;verbatim&#34;&gt;#+attr_latex:&lt;/code&gt;, as shown in the image example below:&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+caption: This is an example image caption.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+attr_latex: :width 5cm :options angle=90 :placement h
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  [[&lt;span style=&#34;color:#00c&#34;&gt;directory/filename.png&lt;/span&gt;]]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Various parameters are available to determine how your table or image looks in the final output. The Org mode manual provides a detailed overview in &lt;a href=&#34;https://orgmode.org/manual/LaTeX-Export.html&#34;&gt;section 3.10&lt;/a&gt;.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-11&#34;&gt;
LaTeX snippets
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;You can write simple LaTeX commands directly into your org file. For example, &lt;code class=&#34;verbatim&#34;&gt;\newpage&lt;/code&gt; will add a page break. You can also place equations using dollar signs, for instance &lt;code class=&#34;verbatim&#34;&gt;$e^{i\pi} + 1 = 0$&lt;/code&gt; results in $e^{i\pi} + 1 = 0$.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;org-latex-preview&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c C-x C-l&lt;/code&gt;) shows a preview of any LaTeX equations within the open buffer. The chapter on &lt;a href=&#34;https://lucidmanager.org/productivity/ricing-org-mode/&#34;&gt;Ricing Org mode&lt;/a&gt; introduces the &lt;code class=&#34;verbatim&#34;&gt;org-fragtog&lt;/code&gt; package to automatically toggle between the plain text and the preview.&lt;/p&gt;
&lt;p&gt;
To create front and back matter, use the &lt;code&gt;\frontmatter&lt;/code&gt; and &lt;code&gt;\backmatter&lt;/code&gt; LaTeX commands in your Org file at the appropriate locations.&lt;/p&gt;
&lt;p&gt;
For more complex snippets, you need to use a structure template. Press &lt;code class=&#34;verbatim&#34;&gt;C-c C-, l&lt;/code&gt; to insert a LaTeX source block. This LaTeX example creates an image using the picture environment. &lt;/p&gt;
&lt;div class=&#34;src src-latex&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-latex&#34; data-lang=&#34;latex&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ,#+begin&lt;span style=&#34;color:#007020&#34;&gt;_&lt;/span&gt;export latex
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\setlength&lt;/span&gt;&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\unitlength&lt;/span&gt;&lt;span style=&#34;color:#007020&#34;&gt;}{&lt;/span&gt;1cm&lt;span style=&#34;color:#007020&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\begin&lt;/span&gt;&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;picture&lt;span style=&#34;color:#007020&#34;&gt;}&lt;/span&gt;(10,10)(-5,5)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\linethickness&lt;/span&gt;&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;1pt&lt;span style=&#34;color:#007020&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\put&lt;/span&gt;(-2.5,0)&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\vector&lt;/span&gt;(1,0)&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;5&lt;span style=&#34;color:#007020&#34;&gt;}}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\put&lt;/span&gt;(0,-2.5)&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\vector&lt;/span&gt;(0,1)&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;5&lt;span style=&#34;color:#007020&#34;&gt;}}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\put&lt;/span&gt;(0,0)&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\circle&lt;/span&gt;&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;3&lt;span style=&#34;color:#007020&#34;&gt;}}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;\end&lt;/span&gt;&lt;span style=&#34;color:#007020&#34;&gt;{&lt;/span&gt;picture&lt;span style=&#34;color:#007020&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ,#+end&lt;span style=&#34;color:#007020&#34;&gt;_&lt;/span&gt;export&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The image will not appear in Org mode as it is generated by LaTeX and will only appear when exporting.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/picture-environment-example-latex-.png&#34; alt=&#34;/images/emacs/picture-environment-example-latex-.png&#34; title=&#34;/images/emacs/picture-environment-example-latex-.png&#34; width=&#34;100&#34;/&gt;
&lt;figcaption&gt;
Example of LaTeX picture environment result.
&lt;/figcaption&gt;
&lt;/figure&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-12&#34;&gt;
LaTeX Packages and Classes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;By default, Org mode uses the article class and a set of default packages to export documents. Org mode provides three mechanisms to use LaTeX packages in your export:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In the header, using &lt;code&gt;#+latex_header:&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Configuring the &lt;code&gt;org-latex-packages-alist&lt;/code&gt; variable.&lt;/li&gt;
&lt;li&gt;Configure the &lt;code&gt;org-latex-classes&lt;/code&gt; variable.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The Org mode header can do a lot of the work. The example below specifies the book document class with A4 paper size. This example also specifies the Times fonts package. The last line tells Org mode to omit the table of contents from the export.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+latex_class: book
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+latex_class_options: [a4paper]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+latex_header: \usepackage{times}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+options: toc:nil&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The &lt;code&gt;org-latex-packages-alist&lt;/code&gt; variable defines the default packages that are used for every LaTeX export.&lt;/p&gt;
&lt;p&gt;
You can define more complex header configurations by changing the &lt;code class=&#34;verbatim&#34;&gt;org-latex-classes&lt;/code&gt; association list. &lt;/p&gt;
&lt;p&gt;
The example below adds the template for the American Psychological Association (APA) journals. This list&amp;#39;s documentation provides all the details you need to configure packages and classes for your exports. The &lt;code&gt;with-eval-after-load&lt;/code&gt; function ensures that this variable is only set once the LaTeX export function is loaded by Emacs. Note the double backslash instead of the single one in regular LaTeX syntax for compatibility with Emacs Lisp. &lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;with-eval-after-load&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;ox-latex&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;add-to-list&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;org-latex-classes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                 &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;apa6&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                   &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\documentclass[a4paper, jou, 11pt]{apa6}
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                    \\usepackage[nodoi]{apacite}
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                    \\usepackage{graphicx}
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                    \\usepackage[T1]{fontenc}
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                    \\usepackage{times}&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                   (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\section{%s}&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\section*{%s}&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                   (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\subsection{%s}&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\subsection*{%s}&amp;#34;&lt;/span&gt;))))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The last part of this association list specifies the mapping between Org mode and LaTeX headers. In this case, the highest level is associated with the section header, the second level with a subsection, and so on.&lt;/p&gt;
&lt;p&gt;
You can call this particular class by adding &lt;code class=&#34;verbatim&#34;&gt;#+latex_class: apa6&lt;/code&gt; to your file header. This mechanism empowers you to define bespoke LaTeX classes to create a library of export options.&lt;/p&gt;
&lt;p&gt;
These three mechanisms allow fine-grained control over how your Org mode document is exported to LaTeX and PDF. The &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration only uses the default settings for these variables because the possible use cases are too numerous to define a sensible default other than what is already available.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-13&#34;&gt;
PDF export configuration
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration for PDF export defines the export process to ensure that bibliographies work appropriately. This configuration also cleans all temporary files that LaTeX creates so that only the exported file remains.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; LaTeX PDF Export settings&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ox-latex&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:ensure&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:demand&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;;; Multiple LaTeX passes for bibliographies&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-latex-pdf-process&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;pdflatex -interaction nonstopmode -output-directory %o %f&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;bibtex %b&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;;; Clean temporary files after export&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-latex-logfiles-extensions&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#007020&#34;&gt;quote&lt;/span&gt; (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;lof&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;lot&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;tex~&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;aux&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;idx&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;log&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;out&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;toc&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;nav&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;snm&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;vrb&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dvi&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;fdb_latexmk&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;blg&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;brf&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;fls&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;entoc&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;ps&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;spl&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;bbl&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;tex&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;bcf&amp;#34;&lt;/span&gt;))))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-14&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-14&#34;&gt;
Publishing Ebooks
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-14&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Most ebook publishers use the ePub format for distribution. This file type is a ZIP file with your book stored as a website optimised for an e-reader. The &lt;code class=&#34;verbatim&#34;&gt;ox-epub&lt;/code&gt; package adds this functionality to the Org export dispatcher. This package uses the built-in Org to HTML export to create the ebook, so you can use any of its features to fine-tune the output.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; epub export&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ox-epub&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:demand&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
There are some &lt;a href=&#34;https://github.com/ofosos/ox-epub&#34;&gt;required export options&lt;/a&gt; that need to be set in your header:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;#+title:&lt;/code&gt; the document title.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;#+uid:&lt;/code&gt; a unique ID of the document, otherwise known as URI, could be a website or ISBN number.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;#+date&lt;/code&gt;: the date of the document.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;#+author:&lt;/code&gt; the document author or editor, the creator in the EPUB spec&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The default settings will add a postamble to the bottom of the last page with a timestamp, author and a HTML validation service. Adding &lt;code class=&#34;verbatim&#34;&gt;#+options: html-postamble:nil&lt;/code&gt; toepub the Org file header removes these from your ebook.&lt;/p&gt;
&lt;p&gt;
Any LaTeX fragments are ignored in the export, which means it is not possible to export the same source file to both PDF and ePub wit the same output.&lt;/p&gt;
&lt;p&gt;
However, LaTeX math formulas are possible with the &lt;code class=&#34;verbatim&#34;&gt;tex:dvipng&lt;/code&gt; option added to the Org header. This option converts any LaTeX formula to a PNG image, which is not ideal but readable.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;ox-epub&lt;/code&gt; package does not convert Org mode timestamps to a date format that complies with the ePub standard. You can correct this by removing the square brackets and the day and time from the timestamp.&lt;/p&gt;
&lt;p&gt;
Lastly, please note to only use open image formats such as &lt;code class=&#34;verbatim&#34;&gt;.png&lt;/code&gt; as some ebook readers cannot display JPG files and other proprietary formats. The ebook will look alright on your computer but might not pass any checks by a publisher.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-15&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-15&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-15&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences to undertake a task. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media through the links in the footer.&lt;/p&gt;
&lt;p&gt;
The next article dives into using &lt;a href=&#34;https://lucidmanager.org/productivity/create-websites-with-org-mode-and-hugo/&#34;&gt;Org mode and Hugo to create websites&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Create Websites with Emacs: Blogging with Org mode and Hugo</title>
      <link>https://lucidmanager.org/productivity/create-websites-with-org-mode-and-hugo/</link>
      <pubDate>Fri, 07 May 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/create-websites-with-org-mode-and-hugo/</guid>
      <description>
	
&lt;p&gt;
When I developed my first website in 1997, I wrote HTML in a plain text editor. When discovering WordPress when it was first released, I thought it was the best thing since sliced bread because it allowed me to create websites without managing individual HTML and CSS pages.&lt;/p&gt;
&lt;p&gt;
Unfortunately, WordPress has become bloated, and the online editor is inconvenient. Last year, I bid farewell to WordPress and now use Emacs Org mode and Hugo to develop websites.&lt;/p&gt;
&lt;p&gt;
A significant disadvantage of WordPress is that you write your text in the browser, and your content resides inside a database. You can, as such, only use WordPress to work on your website. The advantage of using Emacs and Org mode to maintain a website is that your content consists of plain text files. There are no databases or access limitations, and you get to use the incredible editing powers of Emacs.&lt;/p&gt;
&lt;p&gt;
Another reason to ditch WordPress is that static websites are faster and safer because there is no database to hack. A static website generator creates pages in plain HTML, which render faster than a database-driven website, improving the user experience and your SEO. Static websites have at least three advantages over database-driven systems, such as WordPress:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Faster website due to static content (no need to access a database)&lt;/li&gt;
&lt;li&gt;Writing web pages offline with your favourite editor&lt;/li&gt;
&lt;li&gt;Your content remains in plain text&lt;/li&gt;
&lt;li&gt;No dependence on third-party paid plugins&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This website is entirely created with Emacs Org mode and Hugo, and this post explains how you can do the same.&lt;/p&gt;
&lt;p&gt;
This article is part of the &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt;, which explains how to use Emacs to undertake research and write and publish articles, books, and websites. You can find the most recent configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Org mode
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;Org mode is a markdown language&lt;/a&gt; in plain text. This approach helps you to focus more on your writing instead of its design because it emphasises content over formatting. Text editors are not like What-You-See-Is-What-You-Get systems. You write the article in plain text, and when you publish the website, the content is merged with a style sheet that determines the design. The image below shows this article as I write it and what it looks like in the browser.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/wysiwym.jpg&#34; alt=&#34;The WYSIWYM approach with Emacs Org Mode and Hugo.&#34; title=&#34;The WYSIWYM approach with Emacs Org Mode and Hugo.&#34;/&gt;
&lt;figcaption&gt;
The WYSIWYM approach: Left, an article in Emacs. Right: The exported result.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Emacs can create simple websites with the default Org mode export function. While this function has a powerful option to use CSS templates, it is not a fully-fledged static website generator. That is why I use Hugo to generate HTML files.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Hugo static website generator
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Hugo static website generator converts a Markdown or Org mode file collection to a website using the Go language. You can use Hugo with Emacs out-of-the-box. The &lt;a href=&#34;https://github.com/niklasfasching/go-org&#34;&gt;go-org&lt;/a&gt; library by Niklas Fasching forms part of Hugo, so in principle you do not need to update your &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;init file&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;
You will need to install the Hugo software, create an empty site and download a theme before starting. The &lt;a href=&#34;https://gohugo.io/getting-started/quick-start/&#34;&gt;Quick Start guide for Hugo&lt;/a&gt; provides detailed instructions. When you get to step four, come back to this article to find out how to use Org Mode to add some content.&lt;/p&gt;
&lt;p&gt;
The video series by Mick Dane embedded below provides a comprehensive introduction to using Hugo.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/qtIqKaDlqXo?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Introduction to Hugo by Mick Dane.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
All you need to do now is start writing pages in Org mode or Markdown in the &lt;code class=&#34;verbatim&#34;&gt;content&lt;/code&gt; folder. Emacs can also help you with Markdown, but that is outside the scope of this article.&lt;/p&gt;
&lt;p&gt;
The theme for this website is optimised for working directly with Org mode files in Hugo. You can download the theme from GitHub. The &lt;a href=&#34;https://themes.gohugo.io/&#34;&gt;Hugo website&lt;/a&gt; provides access to an extensive collection of themes. Changing the look and feel of your website is as easy as changing the theme.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/hugo-thirdhemisphere/&#34; target=&#34;_blank&#34;
   title=&#34;Download hugo-thirdhemisphere from GitHub&#34;
   alt=&#34;Download hugo-thirdhemisphere from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;hugo-thirdhemisphere&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Using Org Mode and Hugo
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Hugo website does not provide much information about using Org mode. The Go-Org website has a &lt;a href=&#34;https://niklasfasching.github.io/go-org/&#34;&gt;detailed overview&lt;/a&gt; of Org mode syntax and how Hugo renders the HTML.&lt;/p&gt;
&lt;p&gt;
The Org mode module in Hugo perfectly parses your org files, but there are some special considerations and limitations.&lt;/p&gt;
&amp;nbsp;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Front matter
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Each Org mode file starts with the front matter containing your blog post&amp;#39;s title, author, date, and other metadata. You can add non-standard variables, which you can use in your Hugo shortcodes or partials, for example:&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+Title:        Create Websites with Emacs: Blogging with Org mode and Hugo
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+date:         [2021-05-07 Fri]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+lastmod:      [2023-09-09 Sat]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+categories[]: Productivity
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+tags[]:       Emacs Hugo
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+images[]:     /images/emacs/emacs-hugo.jpg
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+weight:       62
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+example:      Hello world!&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Any line that does not start with &lt;code class=&#34;verbatim&#34;&gt;#+&lt;/code&gt; ends the front matter.&lt;/p&gt;
&lt;p&gt;
Keyword values can be either strings (&lt;code class=&#34;verbatim&#34;&gt;#+key: value&lt;/code&gt;), or a whitespace-separated list of strings (&lt;code class=&#34;verbatim&#34;&gt;#+key[]: value_1 value_2&lt;/code&gt;). If you need to add a value with two words, you will need to use a hyphen.&lt;/p&gt;
&lt;p&gt;
Add single keywords to your template with, for example with &lt;code class=&#34;verbatim&#34;&gt;{{- .Params.example =-}}&lt;/code&gt;, which renders as &amp;#34;Hello world!&amp;#34;&lt;/p&gt;
&lt;p&gt;
When working with a list, spaces act as a delimiter, so you cannot use tags with two words without a workaround, for example hyphenation (&amp;#34;Hello-World&amp;#34;). &lt;/p&gt;
&lt;p&gt;
If you are handy with &lt;a href=&#34;https://lucidmanager.org/productivity/hugo-seo/&#34;&gt;Hugo templates&lt;/a&gt;, then you can easily remove the hyphens. Modify your Hugo template files that call the relevant list variables to replace any hyphens with spaces:&lt;/p&gt;
&lt;div class=&#34;src src-go&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-go&#34; data-lang=&#34;go&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{{&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#bbb&#34;&gt; &lt;/span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;range&lt;/span&gt;&lt;span style=&#34;color:#bbb&#34;&gt; &lt;/span&gt;.Params.tags&lt;span style=&#34;color:#bbb&#34;&gt; &lt;/span&gt;}}&lt;span style=&#34;color:#bbb&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{{&lt;span style=&#34;color:#bbb&#34;&gt; &lt;/span&gt;replace&lt;span style=&#34;color:#bbb&#34;&gt; &lt;/span&gt;.&lt;span style=&#34;color:#bbb&#34;&gt; &lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;-&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#bbb&#34;&gt; &lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#bbb&#34;&gt; &lt;/span&gt;}}&lt;span style=&#34;color:#bbb&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{{&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#bbb&#34;&gt; &lt;/span&gt;end&lt;span style=&#34;color:#bbb&#34;&gt; &lt;/span&gt;}}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
You can instruct Emacs to automatically add a modification timestamp by adding the following code to your init file:&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Update Org files with last modified date when #+lastmod:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;time-stamp-active&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#963&#34;&gt;time-stamp-start&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#\\+lastmod:[ \t]*&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#963&#34;&gt;time-stamp-end&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;$&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#963&#34;&gt;time-stamp-format&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;[%04Y-%02m-%02d %a]&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;add-hook&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;before-save-hook&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;time-stamp&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This hook will look for &lt;code class=&#34;verbatim&#34;&gt;#+lastmod:&lt;/code&gt; in your file and add the current date. Hugo will recognise the &lt;code class=&#34;verbatim&#34;&gt;lastmod&lt;/code&gt; variable, and if your template supports it, it will insert this date onto your page. &lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Internal Links
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Org mode includes the ability to &lt;a href=&#34;https://orgmode.org/guide/Hyperlinks.html&#34;&gt;link to other pages&lt;/a&gt;. Unfortunately, you cannot use standard Org mode or Denote links in Hugo for two reasons.&lt;/p&gt;
&lt;p&gt;
Firstly, in Hugo, the slug of a post is not necessarily the same as its relative filename. When using the &lt;code class=&#34;verbatim&#34;&gt;#+slug:&lt;/code&gt; variable in the front matter, the URL will not match the filename.&lt;/p&gt;
&lt;p&gt;
Secondly, the file&amp;#39;s location on your drive might be in a different folder than it appears on the website.&lt;/p&gt;
&lt;p&gt;
Hugo uses the &lt;code class=&#34;verbatim&#34;&gt;ref&lt;/code&gt; shortcode to manage these issues. This shortcode inserts the URL of the post into the link. When you move a post to another folder, Hugo finds it and creates the appropriate hyperlink. Hugo will throw an error when it cannot find your file during rendering.&lt;/p&gt;
&lt;p&gt;
You can create links between your pages using standard org mode syntax and the &lt;code class=&#34;verbatim&#34;&gt;ref&lt;/code&gt; Hugo shortcode, which looks like this:&lt;/p&gt;
&lt;p&gt;
&lt;code class=&#34;verbatim&#34;&gt;{{&amp;lt; ref filename.org &amp;gt;}}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;
Use the &lt;code class=&#34;verbatim&#34;&gt;C-c C-l&lt;/code&gt; shortcut (&lt;code class=&#34;verbatim&#34;&gt;org-insert-link&lt;/code&gt;) and enter the shortcode and a description. The source code of the link will look like this:&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[[&lt;span style=&#34;color:#00c&#34;&gt;{{&amp;lt; ref filename.org &amp;gt;}}&lt;/span&gt;][&lt;span style=&#34;color:#070&#34;&gt;Description&lt;/span&gt;]]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
To find the filename of the post you want to link to, open the &lt;a href=&#34;https://lucidmanager.org/productivity/manage-files-with-emacs/&#34;&gt;Dired file manager&lt;/a&gt; with &lt;code class=&#34;verbatim&#34;&gt;C-x d&lt;/code&gt; and find your post. Press &lt;code class=&#34;verbatim&#34;&gt;w&lt;/code&gt; to copy the filename and paste it into the link.&lt;/p&gt;
&lt;p&gt;
When the target is an index page, then you need to add the sub-folders starting with a forward slash and remove the &lt;code class=&#34;verbatim&#34;&gt;_index.org&lt;/code&gt; filename. Please note that paths with a non-alphanumeric symbol, such as a directory separator &lt;code class=&#34;verbatim&#34;&gt;/&lt;/code&gt;, need to be quoted.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[[&lt;span style=&#34;color:#00c&#34;&gt;{{&amp;lt; ref &amp;#34;/tags/emacs&amp;#34; &amp;gt;}}&lt;/span&gt;][&lt;span style=&#34;color:#070&#34;&gt;Index Page&lt;/span&gt;]]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Org mode has flexible options to create special types of links. We can leverage this functionality to simplify creating internal Hugo links. Creating a new Org mode link type with some Lisp makes life slightly easier. Add the code below to your &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;Emacs configuration&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;
This capability consists of three bespoke functions. The &lt;code&gt;ews-get-hugo-directory&lt;/code&gt; and &lt;code&gt;ews-hugo-list-content&lt;/code&gt; functions check whether the current open buffer is part of a Hugo project by locating the configuration file. If this is the case, then it presents a list of all articles and pages in your website. The &lt;code&gt;ews-hugo-link-complete&lt;/code&gt; function lets you select a page or post of your website to link to. This function also manages the specific requirements for index pages. &lt;/p&gt;
&lt;p&gt;
Press &lt;code class=&#34;verbatim&#34;&gt;C-l&lt;/code&gt; to create a link, and type &lt;code class=&#34;verbatim&#34;&gt;hugo:&lt;/code&gt; and enter. Pick a file, hit enter, provide a label and hit enter again.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Create Hugo links&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ews-get-hugo-directory&lt;/span&gt; ()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Lists the directory of the current Hugo website or nil.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;when&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;string-match&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\(.*\\)content&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;default-directory&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#963&#34;&gt;match-string&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;default-directory&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ews-hugo-list-content&lt;/span&gt; ()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;List the content of the Hugo website of the current buffer.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;  Return an error message when not in an apparent Hugo directory.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;if-let*&lt;/span&gt; ((&lt;span style=&#34;color:#963&#34;&gt;hugo-dir&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;ews-get-hugo-directory&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              (&lt;span style=&#34;color:#963&#34;&gt;hugo-p&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;directory-files&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;hugo-dir&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;^config\\..*&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              (&lt;span style=&#34;color:#963&#34;&gt;content-dir&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;concat&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;hugo-dir&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;content/&amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#007020&#34;&gt;let&lt;/span&gt; ((&lt;span style=&#34;color:#963&#34;&gt;org-files&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;directory-files-recursively&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;content-dir&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\.org\\&amp;#39;&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              (&lt;span style=&#34;color:#963&#34;&gt;md-files&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;directory-files-recursively&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;content-dir&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\.md\\&amp;#39;&amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;append&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-files&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;md-files&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#f00;font-weight:bold&#34;&gt;user-error&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Not in a Hugo buffer&amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ews-hugo-link-complete&lt;/span&gt; ()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Complete a Hugo weblink through the &lt;/span&gt;&lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;`org-insert-link&amp;#39;&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt; and hugo: hyperlink type.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;let*&lt;/span&gt; ((&lt;span style=&#34;color:#963&#34;&gt;posts&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;ews-hugo-list-content&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           (&lt;span style=&#34;color:#963&#34;&gt;titles&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mapcar&lt;/span&gt; (&lt;span style=&#34;color:#007020&#34;&gt;lambda&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;post&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                             (&lt;span style=&#34;color:#963&#34;&gt;string-remove-prefix&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                              (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;concat&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;ews-get-hugo-directory&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                      &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;content/&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#963&#34;&gt;post&lt;/span&gt;)) &lt;span style=&#34;color:#963&#34;&gt;posts&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           (&lt;span style=&#34;color:#963&#34;&gt;selection&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;completing-read&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Choose page:&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;titles&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           (&lt;span style=&#34;color:#963&#34;&gt;target&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;concat&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;/&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                           (&lt;span style=&#34;color:#963&#34;&gt;replace-regexp-in-string&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                            &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;_index.*&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;selection&lt;/span&gt;))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#007020&#34;&gt;when&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;titles&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;concat&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;{{&amp;lt; ref \&amp;#34;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;target&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\&amp;#34; &amp;gt;}}&amp;#34;&lt;/span&gt;))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; New link type for Org-Hugo internal links&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;org-link-set-parameters&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;hugo&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#007020&#34;&gt;:complete&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;#&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#963&#34;&gt;ews-hugo-link-complete&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This configuration only defines how to create a link. Unfortunately, this approach does not allow you to follow these links as Org mode can only recognise links that start with a string and a colon. e.g. &lt;code class=&#34;verbatim&#34;&gt;hugo:&lt;/code&gt;, while Hugo links start with curly braces. &lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Images
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The standard image syntax in Org mode works fine, but you must link the image to its published destination, not the current one. Hugo keeps images in the &lt;code class=&#34;verbatim&#34;&gt;static&lt;/code&gt; folder, so all your image paths assume this folder as the root. Hugo will convert these links to the full URL.&lt;/p&gt;
&lt;p&gt;
Unfortunately, you cannot preview images in Org mode because you are linking to the website folder, not the Org mode folder. An image stored in &lt;code class=&#34;verbatim&#34;&gt;&amp;lt;hugo-directory&amp;gt;/static/images/picture.emacs.png&lt;/code&gt; will be listed as &lt;code class=&#34;verbatim&#34;&gt;/images/picture.emacs.png&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
Hugo will parse the usual metadata, such as captions, alternative text, title and width. The example below shows how to style an image with &lt;code class=&#34;verbatim&#34;&gt;alt&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;title&lt;/code&gt; tags and set its width.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+attr_html: alt: Alternative text title: Image Title :width 800
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+caption: Caption text.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  [[&lt;span style=&#34;color:#00c&#34;&gt;/images/file-path.png&lt;/span&gt;]]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Items and drawers
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;When writing in Org mode it can be useful to &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;track progress and add notes inside drawers&lt;/a&gt;. The standard Org mode export function can be configured to ignore &lt;code class=&#34;verbatim&#34;&gt;TODO&lt;/code&gt; tags and drawers in the export. Because working with Hugo bypasses the Org Mode export functionality, &lt;code class=&#34;verbatim&#34;&gt;TODO&lt;/code&gt; tags will appear in your HTML files. Hugo ignores property drawers but includes the content of any other types of drawers.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Limitations
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Using Hugo directly with Org mode has some limitations, mentioned above. The main limitation is that it bypasses the Org mode export engine which means that some functionality is unavailable. Org mode macros cannot be used, but you can &lt;a href=&#34;https://gohugo.io/content-management/shortcodes/&#34;&gt;Hugo shortcodes&lt;/a&gt; to insert parametrised bits of text or HTML in your website. For example: &lt;code&gt;{{&amp;lt; youtube w7Ft2ymGmfc &amp;gt;}}&lt;/code&gt; embeds a YouTube video with the relevant ID in your page.&lt;/p&gt;
&lt;p&gt;
Bypassing the export engine also means that any Org mode export variables are ignored, for example to exclude &lt;code class=&#34;verbatim&#34;&gt;TODO&lt;/code&gt; tags or drawers from your website.&lt;/p&gt;
&lt;p&gt;
To insert images you either use the &lt;a href=&#34;https://gohugo.io/content-management/shortcodes/#figure&#34;&gt;figure shortcode&lt;/a&gt; or the method shown above. Unfortunately you cannot preview these images as you need to enter the image location on your website and not on your computer.&lt;/p&gt;
&lt;p&gt;
Lastly, links need to use the internal linking shortcode. The configuration shown above helps you insert links, but you cannot follow them. &lt;/p&gt;
&lt;p&gt;
These limitations have not stopped me to use Hugo and Org mode as described in this article to develop this and other websites.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
Using ox-hugo
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;https://ox-hugo.scripter.co/&#34;&gt;ox-hugo&lt;/a&gt; package in Emacs can act as an intermediary between Org mode and Hugo. This package converts the Org files in your content folder into Markdown files, which Hugo will render.&lt;/p&gt;
&lt;p&gt;
This package has some advantages over using the plain Org mode method because it relies on the standard Org mode export functionality.&lt;/p&gt;
&lt;p&gt;
However, I don’t use ox-hugo because I like the flexibility of the plain Org Mode approach. The minor limitations of the native Org mode rendering in Hugo have not prevented me from maintaining my websites. But Emacs is a matter of choice, so feel free to use &lt;code class=&#34;verbatim&#34;&gt;ox-hugo&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-10&#34;&gt;
Deploying your website
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;After adding some content, you can continue following the Hugo Quick Start Guide instructions to run the internal webserver or generate the entire website.&lt;/p&gt;
&lt;p&gt;
You don’t need to leave Emacs to run these console commands. When you execute the &lt;code class=&#34;verbatim&#34;&gt;shell&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;M-x shell &amp;lt;enter&amp;gt;&lt;/code&gt;), you can run Hugo from within Emacs. You will need to execute these files from within the folder that contains your website.&lt;/p&gt;
&lt;div class=&#34;src src-bash&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;hugo server -D &lt;span style=&#34;color:#888&#34;&gt;# Run internal web server, showing draft pages&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
All buffers in the &lt;code class=&#34;verbatim&#34;&gt;content&lt;/code&gt; folder must be saved to disk; otherwise, Hugo will throw an error.&lt;/p&gt;
&lt;p&gt;
When using the &lt;code class=&#34;verbatim&#34;&gt;server&lt;/code&gt; option in the Hugo command line, the website is available in your local browser under &lt;code class=&#34;verbatim&#34;&gt;https://localhost:1313&lt;/code&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-11&#34;&gt;
Exporting your WordPress website to Org mode
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Moving a WordPress website to Hugo can be an enormous task that can be semi-automated. You can export the content from WordPress to a CSV file to convert the content to either Org mode or Markdown. I have written some scripts to &lt;a href=&#34;https://lucidmanager.org/data-science/export-wordpress-to-hugo/&#34;&gt;export my former WordPress websites&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-12&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt; consists of a series articles and a configuration to help you publish articles, books, movie and theatre scripts and websites. You can find the most recent configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences of how to undertake a task. Any article on how to be productive with Emacs is thus opinionated. If you have a different way of doing things, please share your views and leave a comment below, or complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email.&lt;/p&gt;
&lt;p&gt;
The next article in this series discusses how to manage your projects and &lt;a href=&#34;https://lucidmanager.org/productivity/getting-things-done-with-emacs/&#34;&gt;get things done with Org mode&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Getting Things Done with Emacs: Manage your life with Org Mode</title>
      <link>https://lucidmanager.org/productivity/getting-things-done-with-emacs/</link>
      <pubDate>Sat, 08 May 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/getting-things-done-with-emacs/</guid>
      <description>
	
&lt;p&gt;
The market for productivity applications is saturated with apps and other complex systems to manage your actions. While these systems provide great functionality, the main problem is that you have to use them the way the designer intended instead of how you like to work. This article shows how to use Org mode to get things done with Emacs and configure a bespoke productivity system.&lt;/p&gt;
&lt;p&gt;
The approach in the article roughly follows the concepts of David Allen&amp;#39;s &lt;a href=&#34;https://en.wikipedia.org/wiki/Getting_Things_Done&#34;&gt;Getting Things Done&lt;/a&gt; (GTD) system. This is, however, not the only method to manage your affairs. Whatever your preferred workflow looks like, you can &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;configure Emacs&lt;/a&gt; to help you with that.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The productivity quest
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The quest to become more productive has become a popular past time. Millions of people around the world struggle with the demands of life in the twenty-first century and they constantly look for ways to cram more activities into their day. Self-proclaimed productivity gurus have published piles of popular books about methods to get more done in your limited available time.&lt;/p&gt;
&lt;p&gt;
All these methods boil down to three basic phases: set a goal, define the actions to achieve that goal and undertake these actions. These principles might sound simplistic, but it is the basic truth. The plethora of methods merely discuss different ways on how to manage these three steps effectively and efficiently. A central theme of these methods are means to process the enormous amount of information that people are exposed to every day.&lt;/p&gt;
&lt;p&gt;
In the slipstream of the productivity gurus, software developers have released many apps to manage the information stream of our daily lives. The internet contains many stories about people who moved from one application to the next, in search of the perfect way to manage their projects and tasks. I was one of those people, until I started using Emacs.&lt;/p&gt;
&lt;p&gt;
Org mode is an ideal system to help you getting things done. The Org mode package not only allows you to &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;write prose&lt;/a&gt;, it is also helps you to manage actions and projects. As with any other Emacs package, it provides virtually unlimited freedom to implement your favourite method to get stuff done.&lt;/p&gt;
&lt;p&gt;
This chapter shows how to use Org Mode to manage your projects and tasks, loosely based on David Allen&amp;#39;s &lt;em&gt;Getting Things Done&lt;/em&gt; (GTD) method. David Allen describes iterative five steps to become more productive:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;Capture&lt;/em&gt;: Empty your mind&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Clarify&lt;/em&gt;: Describe what it all means&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Organise&lt;/em&gt; Place it where it belongs&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Reflect&lt;/em&gt;: Reflect on your progress&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Engage&lt;/em&gt;: Take action&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Capture: empty your head
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;One of the reasons we are often not as productive as we like is because our minds are filled with issues. When our brain is full of thoughts about what we should be doing, we start to worry about how busy we are instead of doing the thing we need to do. David Allen says that &amp;#34;Our minds are for having ideas, not for holding them&amp;#34;.&lt;/p&gt;
&lt;p&gt;
The first step to getting things done is to &lt;a href=&#34;https://lucidmanager.org/productivity/clear-your-head/&#34;&gt;empty your mind&lt;/a&gt;. This is not a Buddhism-inspired quest for enlightenment, but a simple technique to help you focus. A brain only has a limited capacity as we can only have one thought at a time. When your brain is full of thoughts about what you should be doing, creative and productive thoughts are suppressed.&lt;/p&gt;
&lt;p&gt;
The other problem with keeping ideas in your head is the risk that they will disappear in the fog of your brain. I am sure you all recognise the experience of having the most wonderful idea when enjoying your morning shower, but half an hour later you are unable to recall your gem.&lt;/p&gt;
&lt;p&gt;
Open a new Org Mode file with the &lt;code&gt;find-file&lt;/code&gt; command (&lt;code class=&#34;verbatim&#34;&gt;C-x c-f&lt;/code&gt;). You can call it something like &lt;code class=&#34;verbatim&#34;&gt;inbox.org&lt;/code&gt;, or whatever you fancy. For the next fifteen minutes, write down everything that is floating around in your head. Dump the contents of your brain into this virgin Org Mode file. Try not to &lt;a href=&#34;https://lucidmanager.org/management/myth-of-multitasking/&#34;&gt;multitask&lt;/a&gt; when you empty your mind, but fully focus your attention on the list.&lt;/p&gt;
&lt;p&gt;
Start every new idea with an asterisk so that they become headlines. Your list will contain a jumble of random things. From minor household tasks to big future projects you want to do one day. Don&amp;#39;t filter your thoughts. Just write them down. &lt;/p&gt;
&lt;p&gt;
For the next twenty-five minutes, focus only on this task and write down everything that is in your head. Don&amp;#39;t multitask and give this activity your undivided attention. &lt;a href=&#34;https://lucidmanager.org/management/myth-of-multitasking/&#34;&gt;Multitasking is the enemy of productivity&lt;/a&gt; because our brains can only focus on one intellectual activity at a time. The fact that magicians can so easily fool people illustrates why multitasking is a fool&amp;#39;s errand. Perhaps &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emms/&#34;&gt;listen to some music&lt;/a&gt; with the Emacs EMMS package to keep you focused.&lt;/p&gt;
&lt;p&gt;
Don&amp;#39;t spend any time thinking about these tasks. Don&amp;#39;t worry about when you&amp;#39;ll need to do it or in what order they need to be done just yet. Ensure that your mind is empty by the time you complete your list. If the list only has about a dozen items, then your list is not complete. For most people, fifty actionable items, projects and fuzzy goals are not unusual. If you are overwhelmed by the list then don&amp;#39;t shoot the messenger as it merely reflects your life. If it takes you longer than twenty five minutes to empty your mind, then take a five minute break and start again.&lt;/p&gt;
&lt;p&gt;
You now have a long list of all the stuff you need to get done. But that is only the starting point. Org mode also has functions that can capture tasks as they come up in random moments of the day.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#000080;font-weight:bold&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;font-weight:bold&#34;&gt; Mow the lawn&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#000080;font-weight:bold&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;font-weight:bold&#34;&gt; Clean up the backyard&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#000080;font-weight:bold&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;font-weight:bold&#34;&gt; Improve my job skills&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#000080;font-weight:bold&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;font-weight:bold&#34;&gt; Learn how to use Emacs&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#000080;font-weight:bold&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;font-weight:bold&#34;&gt; Write an ebook about ... (fill in your speciality)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#000080;font-weight:bold&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;font-weight:bold&#34;&gt; Empty your e-mail inbox&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#000080;font-weight:bold&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;font-weight:bold&#34;&gt; Prepare presentation for the quarterly meeting next week&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#000080;font-weight:bold&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;font-weight:bold&#34;&gt; And so on, and so on ...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Clarify: Describe what it all means
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Did you notice that most things on the list above, apart from items 6 and 7, are more work than just one action?&lt;/p&gt;
&lt;p&gt;
In GTD-speak, they are projects, which are desired outcomes that take more than one action to complete.&lt;/p&gt;
&lt;p&gt;
Your list will be a mess of tasks, projects, goals and vague ideas. Your next task is to organise them. Firstly you can add some order and hierarchy to the list with the &lt;code class=&#34;verbatim&#34;&gt;ALT&lt;/code&gt; and arrow keys. &lt;code class=&#34;verbatim&#34;&gt;M-up&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;M-down&lt;/code&gt; will move a heading up or down, while &lt;code class=&#34;verbatim&#34;&gt;M-right&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;M-left&lt;/code&gt; will promote or demote your entry.&lt;/p&gt;
&lt;p&gt;
With these four keystrokes, you can organise your list so that projects and tasks go together and create some order in the chaos that came from your mind. So the garden becomes a project with two tasks:&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#000080;font-weight:bold&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;font-weight:bold&#34;&gt; Gardening&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#800080;font-weight:bold&#34;&gt;**&lt;/span&gt; Clean up the backyard
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#800080;font-weight:bold&#34;&gt;**&lt;/span&gt; Mow the lawn&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
If you like a bit more clarity on your list, you can collapse a heading with the &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; key. Using &lt;code class=&#34;verbatim&#34;&gt;S-TAB&lt;/code&gt; will collapse the whole document to only the first-level headlines. Repeatedly using &lt;code class=&#34;verbatim&#34;&gt;S-TAB&lt;/code&gt; will cycle through the full content, only the first headlines and all headlines.&lt;/p&gt;
&lt;p&gt;
You can also add notes or link images below any heading to provide some context to the task by hitting enter at the end of the headline and typing.&lt;/p&gt;
&lt;p&gt;
Your list is starting to take shape now. The following steps will add more context to your tasks. If you like do some more finessing, then read my article on &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;writing prose with Org mode&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Organise: Place it where it belongs
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;After a week or so, your inbox will start filling with stuff. Your inbox is not just one location, but a collection of places where you gather information. &lt;em&gt;Emacs Writing Studio&lt;/em&gt; uses the Org mode capture mechanism as an inbox, but it can also be a physical inbox to collect papers. A digital notebook on your phone or a physical diary to collect notes are also viable options.&lt;/p&gt;
&lt;p&gt;
My personal inbox consists of my Org mode inbox file, my email inbox, a cloud-based notes application in my phone a physical inbox and my physical diary. As part of my weekly review I promise myself to empty these locations and process them into my system using this flowchart, which is based on the classic GTD model.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/todo-workflow.png&#34; alt=&#34;Example of a productivity workflow using Org mode&#34; title=&#34;Example of a productivity workflow using Org mode&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Example of a productivity workflow using Org mode.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
During your regular review, you assess each bit of information you collected. If it is not actionable, the you either ditch it, otherwise capture it in  &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/&#34;&gt;Denote&lt;/a&gt; as a permanent note.&lt;/p&gt;
&lt;p&gt;
If the new item is actionable and it only takes a few minutes to do, then just go ahead and do it; don&amp;#39;t waste your time formally registering the action.&lt;/p&gt;
&lt;p&gt;
Lastly, if the inbox item is actionable, bur requires some time, you can add it as an action to your agenda file. The status of each action depends on external circumstances. &lt;/p&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Action Status
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The problem with most todo-lists is that you get overwhelmed by the amount of stuff to be done. But in reality, most actions don&amp;#39;t need or can&amp;#39;t be progressed. You can be more precise in your records and mark items as the next action to be undertaken, or mark the ones where you are waiting for somebody else.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Next&lt;/em&gt;: The next action to be taken.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Todo&lt;/em&gt;: Something to be done in the future (either scheduled or as yet undetermined)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Waiting&lt;/em&gt;: If you are waiting for somebody to do something, then mark it as such.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Org mode can associate each headline in a document with a workflow state. By default, there are only two states, &lt;code class=&#34;verbatim&#34;&gt;TODO&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;DONE&lt;/code&gt;. You can change the state of a heading with the shift and arrow keys. Org mode will cycle between the two states. The keywords are commonly written in all caps, but that is not necessary.&lt;/p&gt;
&lt;p&gt;
You can define workflow states any way you like. Adding the following Lisp lines to your init file will set your workflow states. The states after the vertical bar will be marked as completed, usually coloured green.&lt;/p&gt;
&lt;p&gt;
If you have many states, cycling through them can be tedious. The &lt;code class=&#34;verbatim&#34;&gt;C-c C-t&lt;/code&gt; command provides a popup menu to quickly select your option. You add the menu letter between parentheses after the keyword like this:&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;setq-defualt&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-todo-keywords&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;((&lt;span style=&#34;color:#963&#34;&gt;sequence&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;TODO(t)&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;NEXT(n)&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;WAITING(w)&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;|&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;DONE(d)&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;CANCELLED(c)&amp;#34;&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;em&gt;Emacs Writing Studio&lt;/em&gt; roughly follows the GTD approach and have a status for next actions, waiting for others or future actions. When an action is completed, it is either done or cancelled. There are, in principle, no limitations to how you use this functionality.&lt;/p&gt;
&lt;p&gt;
The basic principle of the GTD approach is not to have massive lists of items that you like to do one day but that you define the next action that needs to be done to achieve your goal, or schedule activities in your diary. This method ensures that only a subset of activities is in your consciousness and  you don&amp;#39;t get overwhelmed by your inactivity as action lists tend to be long list of promises to our future selves.&lt;/p&gt;
&lt;p&gt;
You can set different keywords can for each Org file. When, for example, you are writing a book, you could set specific keywords for each heading with the following line in your header:&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;#+TODO&lt;/span&gt;&lt;span style=&#34;color:#888&#34;&gt;: TODO(t) DRAFT(d) | DONE(c) EDITED(e)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Adding dates and deadlines
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Now that your list is nicely organised in the stuff you need to do, add dates to some of the tasks. Scheduling a task to a specific date is to commit your recalcitrant future self to the action.&lt;/p&gt;
&lt;p&gt;
You can add the date that the task is scheduled or a deadline by which is should be completed. A scheduled date indicates the date or period you plan to work on the task. A deadline is the time the task needs to be completed.&lt;/p&gt;
&lt;p&gt;
To add a scheduled date, use &lt;code class=&#34;verbatim&#34;&gt;C-c C-s&lt;/code&gt; when on a headline. Emacs will pop up a calendar that you can use to select a date. The shift and arrow buttons move the timestamp by day or week. The &lt;code class=&#34;verbatim&#34;&gt;&amp;lt;&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;&amp;gt;&lt;/code&gt; symbols move you a month in time. Press enter when done, and the date appears below the headline. You can add a deadline in a similar way but with the &lt;code class=&#34;verbatim&#34;&gt;C-c C-a&lt;/code&gt; keystroke.&lt;/p&gt;
&lt;p&gt;
Timestamps use the ISO 8601 format: year, month, day. This format avoids any confusion between American formats and the rest of the world. Editing a timestamp is easy. Place your cursor on either the year, month or date and use the arrow keys to move it up or down.&lt;/p&gt;
&lt;p&gt;
Scheduled dates can also set a regular schedule. For example, suppose you add, for instance, &lt;code class=&#34;verbatim&#34;&gt;+7d&lt;/code&gt; at the end of the date. In that case, Org mode recalculates the date every time you complete the task and resets the status to &lt;code class=&#34;verbatim&#34;&gt;TODO&lt;/code&gt;. You can also use the letters &lt;code class=&#34;verbatim&#34;&gt;w&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;m&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;y&lt;/code&gt; for scheduling a job weekly, monthly or yearly. Some actions have to be undertaken weekly on the same day, but in some instances it is better to restart the clock every time it is completed.&lt;/p&gt;
&lt;p&gt;
In the example below, I have planned to complete the Org mode article on 8 May. My tax return has a deadline of 30 September and appears annually on that date. It is a deadline instead of a schedule because the date is enforced on me externally. The last action is my weekly review of the inboxes. In this case, the seven days are recalculated every time I complete the action. So if I complete the review on 13 May instead of 11 May, the new date will become 20 May.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;* &lt;/span&gt;TODO Complete Org-Mode article
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;  SCHEDULED: &lt;/span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;&amp;lt;2021-05-08 Sat&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;* &lt;/span&gt;TODO Submit tax return
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;  DEADLINE: &lt;/span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;&amp;lt;2021-09-30 Mon +1y&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;* &lt;/span&gt;TODO Weekly review
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;  SCHEDULED: &lt;/span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;&amp;lt;2021-05-11 Sun ++7d&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Only add a scheduled date if this is the time that you plan to do the action. Try not to add too many self-imposed schedules because you will over commit your day. A deadline is only helpful if there is an external expectation that you need to complete something by a specific day, for example, get travel insurance before your flight leaves.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Checklists
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Not every action needs to be a headline todo item. Org mode allows you to add checkbox items anywhere in your document by adding &lt;code class=&#34;verbatim&#34;&gt;[ ]&lt;/code&gt; after the list indicator. Using &lt;code class=&#34;verbatim&#34;&gt;M-S enter&lt;/code&gt; after a tick box item will create a new box. You could use this functionality as a checklist for a larger action.&lt;/p&gt;
&lt;p&gt;
The snippet below is an example of a todo item with a deadline, some notes and a checklist.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;* &lt;/span&gt;TODO Submit tax return
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;  DEADLINE: &lt;/span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;&amp;lt;2021-09-30 Mon +1y&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  Tax accountant: 0407 555 283
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;- [X]&lt;/span&gt; Collect records
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;- [ ]&lt;/span&gt; Prepare overview
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;- [ ]&lt;/span&gt; Set appointment with accountant&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Ticking and unticking any items is as simple as hitting &lt;code class=&#34;verbatim&#34;&gt;C-c C-c&lt;/code&gt;.  You can convert a plain list item to a todo item, or vice versa, with &lt;code class=&#34;verbatim&#34;&gt;C-u C-c c&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
You can also convert list items to headings and back again. The &lt;code&gt;org-ctrl-c-star&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c C-*&lt;/code&gt;) converts a paragraph to a heading. If the line contains a tick box, it becomes a TODO item. Using &lt;code class=&#34;verbatim&#34;&gt;C-c C--&lt;/code&gt; (&lt;code&gt;org-ctrl-c-minus&lt;/code&gt;) converts a paragraph to a list item.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Reflect: Review your progress
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The key of any productivity workflow is to regularly review your list of actions, your priorities and goals. The central tool in Org mode to look at your list of registered actions is the agenda.&lt;/p&gt;
&lt;p&gt;
The agenda provides a summary of all your headings with an action status.  Firstly, it is common practice to bind &lt;code class=&#34;verbatim&#34;&gt;C-c a&lt;/code&gt; to the agenda menu. You can assign one or more Org mode files that contain your actions. Org mode will read these files and present the todo items as an agenda.&lt;/p&gt;
&lt;p&gt;
The Org files used to construct the agenda are stored in &lt;code&gt;org-agenda-files&lt;/code&gt;. You can figure this variable with some keystrokes.To add a file with actions to the agenda use &lt;code&gt;org-agenda-file-to-front&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c [&lt;/code&gt;) and remove it with &lt;code class=&#34;verbatim&#34;&gt;C-c ]&lt;/code&gt; (&lt;code&gt;org-remove-file&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;
When you evaluate the &lt;code&gt;org-agenda&lt;/code&gt; function with &lt;code class=&#34;verbatim&#34;&gt;C-c a&lt;/code&gt;, Org mode reads all agenda files and constructs an agenda, listing actions by date.&lt;/p&gt;
&lt;p&gt;
You can change the status of items from within the agenda or jump to the file that contains the action, so you can ready any context or maintain checklist items.&lt;/p&gt;
&lt;p&gt;
The agenda starts with a self-explanatory menu screen which you can explore. Org mode has extensive capabilities to configure how the agenda is presented, which are outside the scope of this article (See &lt;a href=&#34;https://orgmode.org/manual/Agenda-Views.html&#34;&gt;chapter 11 of the Org mode manual&lt;/a&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
Engage: Take action
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Unfortunately, Emacs cannot help you with mowing the lawn, go shopping or other physical tasks on your lists. Emacs can help you with any task that involves creating written content, but it can&amp;#39;t mow the lawn for you.&lt;/p&gt;
&lt;p&gt;
In the end, there is no productivity system in the world that does the tasks for you, no matter what the gurus promise. However, bringing order into your tasks keeps you focussed on your goals.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-10&#34;&gt;
Org mode configuration
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This code snippet provides a basic configuration for managing actions and projects in Org mode. You can of course modify the sequence of your action statuses to whatever you please.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-todo-keywords&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;((&lt;span style=&#34;color:#963&#34;&gt;sequence&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;TODO(t)&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;NEXT(n)&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;WAITING(w)&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;|&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;DONE(d)&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;CANCELLED(c)&amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c a&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-agenda&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-11&#34;&gt;
Learning More
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Getting Things Done is just one of many methods to manage your busy life. This article shows how to implement the principles of David Allan&amp;#39;s method with Org mode. The beauty of Emacs is that you have the freedom to implement whatever method you prefer.&lt;/p&gt;
&lt;p&gt;
You can find the &lt;a href=&#34;https://orgmode.org/manual/TODO-Items.html&#34;&gt;Org manual on TODO items&lt;/a&gt; with &lt;code class=&#34;verbatim&#34;&gt;C-h R org RET g todo RET&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
Bavarian Org mode guru Rainer König has developed a comprehensive series of YouTube videos that explain using Org for managing actions and projects in great detail. I also recommend following his &lt;a href=&#34;https://www.udemy.com/course/getting-yourself-organized-with-org-mode/&#34;&gt;Getting Yourself Organized with Org mode&lt;/a&gt; course on Udemy.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/sQS06Qjnkcc?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Org mode Tutorial by Rainer König.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-12&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences. Any article on how to use Emacs is thus opinionated. If you have a different way of doing things, please complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email or contact me on social media.&lt;/p&gt;
&lt;p&gt;
The next article discusses how to &lt;a href=&#34;https://lucidmanager.org/productivity/manage-files-with-emacs/&#34;&gt;manage your files with Emacs dired&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Manage Files with Emacs: Organise your drive with Dired</title>
      <link>https://lucidmanager.org/productivity/manage-files-with-emacs/</link>
      <pubDate>Sun, 25 Apr 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/manage-files-with-emacs/</guid>
      <description>
	
&lt;p&gt;
Working with Emacs means that you will need to access, create files and manage files on your drives. Emacs comes shipped with &lt;code class=&#34;verbatim&#34;&gt;dired&lt;/code&gt; (pronounced &lt;em&gt;dir-ed&lt;/em&gt;), a potent file manager. This article explains the basic principles of using dired and shows how to manage files with Emacs to organise your hard drive.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Accessing directories and files with dired
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Dired is short for “&lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/emacs/Dired.html&#34;&gt;directory editor&lt;/a&gt;”, but it can do much more than just that. This software has an illustrious history. The first version of dired was a stand-alone program written circa 1974, so its origins are even further back in time than Emacs. The software comes packaged with Emacs and it provides a front end to various &lt;a href=&#34;https://www.gnu.org/software/coreutils/&#34;&gt;GNU core utilities&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
You activate the file manager with the &lt;code&gt;dired&lt;/code&gt; function or the &lt;code class=&#34;verbatim&#34;&gt;C-x C-d&lt;/code&gt; shortcut. When you hit &lt;code class=&#34;verbatim&#34;&gt;enter&lt;/code&gt;, Emacs will create a buffer with the content of the directory of your open buffer. You can also enter another directory in the minibuffer before you hit the &lt;code class=&#34;verbatim&#34;&gt;enter&lt;/code&gt; key. Another useful function is &lt;code class=&#34;verbatim&#34;&gt;dired-jump&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-x C-j&lt;/code&gt;) which opens dired and jumps to the file linked to the current buffer. The &lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt; button closes the dired window but does not kill (remove) it. &lt;/p&gt;
&lt;p&gt;
You can navigate the content with the arrow keys and press &lt;code class=&#34;verbatim&#34;&gt;j&lt;/code&gt; to jump to a specific file by entering part of its name. &lt;/p&gt;
&lt;p&gt;
The enter key opens the respective file or directory. To open a file or directory in another window, press &lt;code class=&#34;verbatim&#34;&gt;o&lt;/code&gt; (Using &lt;code class=&#34;verbatim&#34;&gt;C-o&lt;/code&gt; open the file in another window, but the cursor stays in Dired). The carat key &lt;code class=&#34;verbatim&#34;&gt;^&lt;/code&gt; takes you to the parent folder.&lt;/p&gt;
&lt;p&gt;
Note that every time you open a new directory, Emacs will open a new dired buffer. After a while, you can litter your Emacs session with unused dired buffers. Pressing the &lt;code class=&#34;verbatim&#34;&gt;a&lt;/code&gt; key opens a directory in the same buffer. This functionality is disabled by default because the Emacs developers strangely believe that new users find it confusing. &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configures this behaviour by default.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Copying and Moving Files
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To copy a file, press the &lt;code class=&#34;verbatim&#34;&gt;C&lt;/code&gt; button. Dired will ask for a new name and location in the minibuffer. To move a file, you press &lt;code class=&#34;verbatim&#34;&gt;R&lt;/code&gt; because moving a file is the same as renaming it with a new directory.&lt;/p&gt;
&lt;p&gt;
There is no need to close the buffer before you rename an open file. Emacs will link the open buffer to the new filename. &lt;/p&gt;
&lt;p&gt;
If you have two open dired buffers, &lt;em&gt;Emacs Writing Studio&lt;/em&gt; copies and moves from the folder in the active window to the other dired buffer.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Renaming files
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Renaming the file is the same as moving it. So press &lt;code class=&#34;verbatim&#34;&gt;R&lt;/code&gt; and type a new filename.&lt;/p&gt;
&lt;p&gt;
It is sometimes useful to copy the name of a file to the kill ring with the &lt;code class=&#34;verbatim&#34;&gt;w&lt;/code&gt; key, so you can use it to rename the file. So to rename a file, copy the name with &lt;code class=&#34;verbatim&#34;&gt;w&lt;/code&gt;, rename the file with &lt;code class=&#34;verbatim&#34;&gt;R&lt;/code&gt; and paste the existing name with &lt;code class=&#34;verbatim&#34;&gt;C-y&lt;/code&gt; and edit the name to your new version.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Removing files
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;You can select and deselect files for deletion (killed) with the &lt;code class=&#34;verbatim&#34;&gt;d&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;u&lt;/code&gt; buttons. After you selected the files you like to delete, press &lt;code class=&#34;verbatim&#34;&gt;x&lt;/code&gt; to execute the deletion. Press capital &lt;code class=&#34;verbatim&#34;&gt;D&lt;/code&gt; if you like to remove a single file.&lt;/p&gt;
&lt;p&gt;
By default, Emacs permanently removes files. The &lt;em&gt;Emacs Writing Studio&lt;/em&gt; is configured so that files are moved to the recycle bin.&lt;/p&gt;
&lt;p&gt;
When you delete or trash a currently open file, Emacs will also ask you to close the appropriate buffer.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Working on Multiple Files
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;You can select multiple files to work on at the same time by marking them. The &lt;code class=&#34;verbatim&#34;&gt;m&lt;/code&gt; button marks a file, and the &lt;code class=&#34;verbatim&#34;&gt;u&lt;/code&gt; removes the mark. The capital &lt;code class=&#34;verbatim&#34;&gt;U&lt;/code&gt; removes all marks in the buffer. The &lt;code class=&#34;verbatim&#34;&gt;t&lt;/code&gt; key reverses your markings, which is helpful when you want to select everything but one or two files.&lt;/p&gt;
&lt;p&gt;
This method requires you to manually select each file. You can also use &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/emacs/Regexps.html&#34;&gt;regular expressions&lt;/a&gt; to select files. Regular expressions are a powerful set of logical rules to select sections of text. Simply put, regex is wildcards on steroids—press &lt;code class=&#34;verbatim&#34;&gt;% m&lt;/code&gt; to open the regular expression selection prompt.&lt;/p&gt;
&lt;p&gt;
For example, &lt;code class=&#34;verbatim&#34;&gt;^2023.*_journal*&lt;/code&gt; selects all &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/&#34;&gt;Denote files&lt;/a&gt; that start with the &lt;code class=&#34;verbatim&#34;&gt;2023&lt;/code&gt; and that have the &lt;code class=&#34;verbatim&#34;&gt;journal&lt;/code&gt; file tag.  Now press &lt;code class=&#34;verbatim&#34;&gt;t&lt;/code&gt; to invert the selection and &lt;code class=&#34;verbatim&#34;&gt;k&lt;/code&gt; to remove the selected files from view. This sequence is a useful method to find related files.&lt;/p&gt;
&lt;p&gt;
After you selected multiple files in this manner, you can use all file commands to act on the selected targets, for example moving all 2023 files with the &lt;code class=&#34;verbatim&#34;&gt;_journal&lt;/code&gt; tag to another folder.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Opening a file with another program
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs is a Swiss-Army chainsaw, but it cannot do everything. Sometimes you might like to open a file in other software, such as your image editor or video player.&lt;/p&gt;
&lt;p&gt;
You can open files with external software by pressing &lt;code class=&#34;verbatim&#34;&gt;&amp;amp;&lt;/code&gt; after which dired will ask for the appropriate software. You need to type the name of the executable file of the software you like to use, e.g. &lt;code class=&#34;verbatim&#34;&gt;gimp&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Manage files with Emacs dired
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If your head is buzzing with all the different key bindings, the table lists the functionality described in this article. These are only a small snapshot of the functions of the directory editor in Emacs. You can press the &lt;code class=&#34;verbatim&#34;&gt;h&lt;/code&gt; key while in a dired buffer to view all functionality and related keybindings.&lt;/p&gt;
&lt;figure&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Key&lt;/th&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;a&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;dired-find-alternate-file&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Open folder in same buffer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;C&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;dired-do-copy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Copy a file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;j&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;dired-goto-file&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Jump to a file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;g&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;revert-buffer&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Refresh the dired buffer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;m&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;dired-mark&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Mark file under cursor&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;% m&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;dired-mark-files=regexp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Mark by regular expression&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;o&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;dired-find-file-other-window&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Open file in other window&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;quit-window&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Close the buffer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;R&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;dired-do-rename&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Rename (move) a file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;t&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;dired-toggle-marks&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Inverse marked files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;u&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;dired-unmark&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Unmark file under cursor&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;U&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;dired-unmark-all-marks&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Unmark all files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;&amp;amp;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;dired-do-async-shell-command&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Open file with other program&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;enter&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;dired-find-file&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Open file&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;figcaption&gt;
Dired key bindings.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The dired package is a convenient and powerful tool to keep your drives organised and access your information. Developers have published an extensive collection of extensions to dired to add functionality, which you can find in the package manager.&lt;/p&gt;
&lt;p&gt;
Dired lists files and directories in alphabetical order. I prefer a different view, which shows directories on top and files below them. The parameters determine the order of the entries in the folder.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Removing hidden files from view
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Your Dired view might be littered with hidden files and folders that start with a dot. You can remove these by marking them with a regular expression and removing these lines from view, but that is a bit awkward to do every time you open a Dired buffer. The Dired-X package provides functionality to hide files that meet a certain condition. The &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration for Dired omits all files staring with a dot.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Hide hidden files&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;dired-hide-dotfiles&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:hook&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;dired-mode&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;dired-hide-dotfiles-mode&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;:map&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;dired-mode-map&lt;/span&gt; (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;.&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;dired-hide-dotfiles-mode&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
Dired Configuration
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;em&gt;Emacs Writing Studio&lt;/em&gt; uses the following configuration for Dired:&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;dired&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:ensure&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:commands&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;dired&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;dired-jump&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:init&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;with-eval-after-load&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;dired&lt;/span&gt; (&lt;span style=&#34;color:#007020&#34;&gt;require&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;dired-x&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;put&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;dired-find-alternate-file&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;disabled&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;dired-listing-switches&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;-goah --group-directories-first --time-style=long-iso&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;dired-dwim-target&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;delete-by-moving-to-trash&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;dired-omit-files&lt;/span&gt; (&lt;span style=&#34;color:#007020&#34;&gt;rx&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;seq&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;bol&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;.&amp;#34;&lt;/span&gt;))) &lt;span style=&#34;color:#888&#34;&gt;;; Omit dot files&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;:map&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;dired-mode-map&lt;/span&gt; (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;.&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;dired-omit-mode&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:hook&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;dired-mode&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;dired-omit-mode&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-10&#34;&gt;
Backup files
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This last bit of configuration code defines how Emacs deals with automated backups. The default setting is that the system stores these files in the folder where the original files lives, clutterin/g your drive with copies of your stuff. The setting below modifies the &lt;code class=&#34;verbatim&#34;&gt;backup-directory-alist&lt;/code&gt; variable so that Emacs saves all backups in your configuration folder. This configuration also eliminates lock files, which are only useful when working in shared folders.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Backup files&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq-default&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;backup-directory-alist&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#333&#34;&gt;`&lt;/span&gt;((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;.&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;,&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;expand-file-name&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;backups/&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;user-emacs-directory&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#963&#34;&gt;create-lockfiles&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt;)  &lt;span style=&#34;color:#888&#34;&gt;; No lock files&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Alternatively, you could instruct Emacs to not save backups at all with &lt;code&gt;(setq-default make-backup-files nil)&lt;/code&gt;. I prefer keeping backups as they have saved my bacon a few times in the past.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-11&#34;&gt;
Recent Files and Bookmarks
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Whenever you return to Emacs you might want to open a file you were working on recently. The recent files minor mode (&lt;code&gt;recentf-mode&lt;/code&gt;) provides a transient list of the files you most recently opened. &lt;/p&gt;
&lt;p&gt;
This minor mode saves the most recent opened files when you exit Emacs to a file in your configuration folder. However, it might be more useful to save the recent files regularly to ensure it is saved. The &lt;code&gt;run-at-time&lt;/code&gt; function runs a function at a regular interval, in this case every five minutes. The &lt;code&gt;recentf-edit-list&lt;/code&gt; function opens the file with your recent acquisitions and lets you delete selected files.&lt;/p&gt;
&lt;p&gt;
By default, the recent files mode stores the last twenty opened files, which you can change by modifying the &lt;code&gt;recentf-max-saved-items&lt;/code&gt; variable. &lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Recent files&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;recentf&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;recentf-mode&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;run-at-time&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;nil&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;5&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;60&lt;/span&gt;) &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;recentf-save-list&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;recentf-max-saved-items&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;50&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Recent files are transient as they are continuously updated as you open new files. For a more permanent list of files you like to open, use &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/emacs/Bookmarks.html&#34;&gt;bookmarks&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
You can store a file as a bookmark with &lt;code class=&#34;verbatim&#34;&gt;C-x r m&lt;/code&gt; (&lt;code&gt;bookmark-set&lt;/code&gt;). The bookmark will also store the location of the cursor, so you can maintain multiple bookmarks for a file. The default name for the bookmark is the name of the file. You can also enter a bespoke name in the minibuffer before hitting &lt;code class=&#34;verbatim&#34;&gt;ENTER&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
To view a list of all bookmarks in the minibuffer and select the one you like to open, use &lt;code class=&#34;verbatim&#34;&gt;C-x r b&lt;/code&gt; (&lt;code&gt;bookmark-jump&lt;/code&gt;). &lt;/p&gt;
&lt;p&gt;
Bookmarks are saved in the &lt;code class=&#34;verbatim&#34;&gt;bookmarks&lt;/code&gt; file in your configuration folder every time a new bookmark is created. The &lt;code&gt;bookmark-save-flag&lt;/code&gt; is set to one so that the bookmarks file is saved every time you add a new one. The default value only saves it when you exit Emacs, which mean you could loose bookmarks in the unlikely event of an Emacs or system crash.&lt;/p&gt;
&lt;p&gt;
If you like to remove  bookmark no longer required then use the &lt;code&gt;bookmark-delete&lt;/code&gt; function, which has no default keybinding but is bound to &lt;code class=&#34;verbatim&#34;&gt;C-x r D&lt;/code&gt; in the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; configuration.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Bookmarks&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;bookmark&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;bookmark-save-flag&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-x r D&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;bookmark-delete&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-12&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences to undertake a task. Any article on how to be productive with Emacs is thus opinionated. If you have a different way of doing things, please share your views and leave a comment below, or complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email.&lt;/p&gt;
&lt;p&gt;
The next article in this series discusses how to use &lt;a href=&#34;https://lucidmanager.org/productivity/using-emacs-image-dired/&#34;&gt;dired to view images&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Viewing Images with Emacs and the image-dired package</title>
      <link>https://lucidmanager.org/productivity/using-emacs-image-dired/</link>
      <pubDate>Sun, 25 Apr 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/using-emacs-image-dired/</guid>
      <description>
	
&lt;p&gt;
Emacs is a powerful text editor that lets you manage your life and be creative and productive with text. This focus on text does mean that Emacs cannot help you managing and editing images. This article shows how to view and manage images with Emacs using the image-mode and the built-in image-dired package by Mathias Dahl and Stefan Kangas.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Prerequisites
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Image-mode and the image-dired package are bundled with Emacs, so there is no need to install packages, but you might need some additional software.&lt;/p&gt;
&lt;p&gt;
You can view images without external software, but you cannot manipulate them. The &lt;a href=&#34;https://imagemagick.org/&#34;&gt;ImageMagick software suite&lt;/a&gt; provides functionality for editing and manipulating images.&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Emacs Writing Studio&lt;/em&gt; checks whether the required software is available when it starts. Check the &lt;code class=&#34;verbatim&#34;&gt;*Messages*&lt;/code&gt; buffer to see of there are any warnings. &lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Viewing images
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs can display various popular image formats out-of-the-box with image mode. You can open an image file directly with &lt;code&gt;find-file&lt;/code&gt; or through the &lt;a href=&#34;https://lucidmanager.org/productivity/manage-files-with-emacs/&#34;&gt;directory editor&lt;/a&gt; (dired). You can also open an image from within an Org file with &lt;code class=&#34;verbatim&#34;&gt;C-c C-o&lt;/code&gt; (&lt;code&gt;org-open-at-point&lt;/code&gt;) with the cursor on the image. Emacs automatically scales the image to snugly fit inside the display window.&lt;/p&gt;
&lt;p&gt;
A range of keyboard shortcuts are available to view images. The &lt;code class=&#34;verbatim&#34;&gt;n&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;p&lt;/code&gt; keys (next and previous) or the left and right arrows flick though the images in the current directory.&lt;/p&gt;
&lt;p&gt;
Image mode also provides several commands to change the display size of images (I am unsure why the prefix key is &lt;code class=&#34;verbatim&#34;&gt;s&lt;/code&gt; for some commands, but &lt;code class=&#34;verbatim&#34;&gt;i&lt;/code&gt; for others, but alas):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;s o&lt;/code&gt;: Show image at original size (when it doesn&amp;#39;t fit in the window, scroll through the image with the arrow keys).&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;s w&lt;/code&gt;: Fit the current image to the height and width of the window.  &lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;i +&lt;/code&gt;: Increase the image size by 20%&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;i -&lt;/code&gt;: Decrease the image size by 20%.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Furthermore, image mode can manipulate images:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;i r&lt;/code&gt;: Rotate the image by 90 degrees clockwise.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;i h&lt;/code&gt;: Flip the image horizontally.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;i v&lt;/code&gt;: Flip the image vertically.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;i c&lt;/code&gt;: Crop the image.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;i x&lt;/code&gt;: Cut a rectangle from the image and replace with black.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The crop and cut commands display a rectangular frame superimposed on the image. Use the mouse to move and resize the frame. Type &lt;code class=&#34;verbatim&#34;&gt;m&lt;/code&gt; to move the frame instead of resizing it and type &lt;code class=&#34;verbatim&#34;&gt;s&lt;/code&gt; to convert the frame to a square. When you are satisfied with the result, type &lt;code class=&#34;verbatim&#34;&gt;enter&lt;/code&gt; to crop or cut the image. You can exit the crop and cutting menu with &lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt; without changing the source file. Please note that these commands are only available when &lt;em&gt;ImageMagick&lt;/em&gt; is installed.&lt;/p&gt;
&lt;p&gt;
If you like to retain the result of the transformation, press &lt;code class=&#34;verbatim&#34;&gt;i o&lt;/code&gt; to save the image under a new name. &lt;/p&gt;
&lt;p&gt;
When you are done with watching images, use &lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt; to quit the image buffer, or &lt;code class=&#34;verbatim&#34;&gt;k&lt;/code&gt; to kill the image buffer altogether.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
The image-dired package
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Viewing images individually is great, but wouldn&amp;#39;t it be nice if you cold see thumbnails before delving into your collection? The image-dired package provides a thumbnail buffer to view and maintain images from within a &lt;a href=&#34;https://lucidmanager.org/productivity/manage-files-with-emacs/&#34;&gt;dired buffer&lt;/a&gt; using thumbnails.&lt;/p&gt;
&lt;p&gt;
Evaluate the &lt;code&gt;image-dired&lt;/code&gt; function (bound to &lt;code class=&#34;verbatim&#34;&gt;C-c w I&lt;/code&gt; in &lt;em&gt;Emacs Writing Studio&lt;/em&gt;) and select the directory you like to use. Emacs splits the screen and presents a thumbnail screen (of up to a thousand entries) to explore your collection. Emacs stores the thumbnails in the configuration directory for future reference.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/image-dired-screenshot.jpg&#34; alt=&#34;Viewing images with image-dired&#34; title=&#34;Viewing images with image-dired&#34;/&gt;
&lt;figcaption&gt;
Viewing some travel photos in Emacs with image-dired.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Alternatively, when you are inside a Dired buffer that contains images, mark the images you like to view and generate the thumbnails with &lt;code class=&#34;verbatim&#34;&gt;C-t d&lt;/code&gt; (&lt;code&gt;image-dired-display-thumbs&lt;/code&gt;). If you don&amp;#39;t mark any files, the program uses the image under the cursor.&lt;/p&gt;
&lt;p&gt;
Yet another method of previewing your images is by marking the ones you need and generate inline thumbnails inside the Dired buffer with &lt;code class=&#34;verbatim&#34;&gt;C-t C-t&lt;/code&gt; (&lt;code&gt;image-dired-dired-toggle-marked-thumbs&lt;/code&gt;). The same shortcut also removes the thumbnails.&lt;/p&gt;
&lt;p&gt;
The active image is marked with a flashing border around the thumbnail and its filename is displayed on the top of the thumbnail window.&lt;/p&gt;
&lt;p&gt;
You can navigate the thumbnails with the arrow keys. The &lt;code class=&#34;verbatim&#34;&gt;&amp;lt;&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;&amp;gt;&lt;/code&gt; keys take you to the start or end of the collection. You can remove a thumbnail from the collection with &lt;code class=&#34;verbatim&#34;&gt;C-d&lt;/code&gt;. If you have selected more images than thumbnails that can fit on page, then image-dired tracks your movement, so as your cursor moves up or down, the thumbnails refresh.&lt;/p&gt;
&lt;p&gt;
To view an image, hit &lt;code class=&#34;verbatim&#34;&gt;enter&lt;/code&gt; when the thumbnail is marked. You cycle through the marked images in your collection with the &lt;code class=&#34;verbatim&#34;&gt;space&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;backspace&lt;/code&gt; buttons, or &lt;code class=&#34;verbatim&#34;&gt;C-&amp;lt;left&amp;gt;&lt;/code&gt; /  &lt;code class=&#34;verbatim&#34;&gt;C-&amp;lt;right&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
But why manually flick through your album if you can let Emacs do this for you? The &lt;code class=&#34;verbatim&#34;&gt;S&lt;/code&gt; key starts a slideshow with each image shown five seconds by default. You can configure the delay with the &lt;code&gt;image-dired-slideshow-delay&lt;/code&gt; variable, or drive the slideshow manually with the &lt;code class=&#34;verbatim&#34;&gt;space&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;backspace&lt;/code&gt; keys, or &lt;code class=&#34;verbatim&#34;&gt;C-&amp;lt;left&amp;gt;&lt;/code&gt; /  &lt;code class=&#34;verbatim&#34;&gt;C-&amp;lt;right&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
The main image display is in image mode, so all the actions described in the previous section apply.&lt;/p&gt;
&lt;p&gt;
As usual, &lt;code class=&#34;verbatim&#34;&gt;q&lt;/code&gt; quits the image or thumbnail window.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Tagging images
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The image-dired software can also create a plain text database of images with searchable tags and thumbnail descriptions. &lt;/p&gt;
&lt;p&gt;
You tag images directly from a dired buffer. The &lt;code class=&#34;verbatim&#34;&gt;C-t t&lt;/code&gt; keystrokes lets you tag the selected files. You can retrieve the tags in a future session using &lt;code class=&#34;verbatim&#34;&gt;C-t f&lt;/code&gt; and view the image thumbnails with &lt;code class=&#34;verbatim&#34;&gt;C-t d&lt;/code&gt;, as described above. You can tag images from within a thumbnail buffer with the &lt;code class=&#34;verbatim&#34;&gt;t t&lt;/code&gt; shortcut. You can also add a comment to the image by pressing &lt;code class=&#34;verbatim&#34;&gt;c&lt;/code&gt; in the thumbnail viewer.&lt;/p&gt;
&lt;p&gt;
The file name, tags and comments show in the mini buffer as you move through the image thumbnails: &lt;code class=&#34;verbatim&#34;&gt;directory: filename (tags): comment&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
Emacs stores the metadata in the &lt;code class=&#34;verbatim&#34;&gt;image-dired&lt;/code&gt; directory in your configuration folder in the &lt;code class=&#34;verbatim&#34;&gt;.image-dired_db&lt;/code&gt; file. This is a plain text file that lists each file name and the tags an comment.&lt;/p&gt;
&lt;p&gt;
Retrieving tagged files only selects images with tags in the directory of the current dired buffer. It does not work across multiple folders. &lt;/p&gt;
&lt;p&gt;
This tagging system is nice, but it creates an integrity vulnerability in that it separates tags and files. When you accidentally remove the database, all metadata is lost. You will also loose access to the metadata when you rename an image.&lt;/p&gt;
&lt;p&gt;
An alternative method to tag files is to use the Denote file naming convention, which encodes metadata into the name of the file.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Using Denote to manage images
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Denote is a package to produce and maintain plain text notes, but it can also be used to maintain a collection of binary (non-text) files. When using the &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/&#34;&gt;Denote file naming convention&lt;/a&gt; for your images, you can mark parts of you collection using regular expressions. The Denote file naming convention encodes four bits of metadata about a file into the filename. Only the timestamp is compulsory and serves as a unique identifier:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Timestamp in ISO 8601 format&lt;/li&gt;
&lt;li&gt;An alphanumeric signature (starting with double equality sign (&lt;code&gt;==&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;The title in &lt;a href=&#34;https://www.freecodecamp.org/news/snake-case-vs-camel-case-vs-pascal-case-vs-kebab-case-whats-the-difference/&#34;&gt;kebab-case&lt;/a&gt; (starting with double dash &lt;code&gt;==&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Keywords in &lt;a href=&#34;https://www.freecodecamp.org/news/snake-case-vs-camel-case-vs-pascal-case-vs-kebab-case-whats-the-difference/&#34;&gt;snake_case&lt;/a&gt; (starting with double underscore &lt;code class=&#34;verbatim&#34;&gt;__&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, one photo in my collection is: &lt;code class=&#34;verbatim&#34;&gt;19930825T132000--forbidden-city-throne-palace-of-heavenly-purity__china.jpg&lt;/code&gt;. So this photo was taken on 25 August 1993, the title describes the topic of the photograph and &lt;/p&gt;
&lt;p&gt;
I can now go into Dired and mark files with regular expressions, searching for each of these fields. For example, using &lt;code class=&#34;verbatim&#34;&gt;%m _china&lt;/code&gt; marks photos taken in China, or &lt;code class=&#34;verbatim&#34;&gt;%m -city&lt;/code&gt; all images with the word &amp;#34;city&amp;#34; in their title. Using the Dired convention for naming files is not only great for notes, it also helps you manage your photo collection.&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;denote-rename-file&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c w R&lt;/code&gt;) lets you construct a Denote-compliant file name for existing images or other binary files. This function uses the last modified date as the identifier by default. But when you are sorting old collections you might want to add a date that is different to the last modified one. Adding the universal argument (&lt;code class=&#34;verbatim&#34;&gt;C-u&lt;/code&gt;) will also ask you to provide a date and time, i.e. (&lt;code class=&#34;verbatim&#34;&gt;C-u C-c w R&lt;/code&gt;).&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Editing Images
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Emacs is a powerful piece of software but it is mostly limited to editing text. To meaningfully work with images, you will need another package. Image-dired lets you open images in external viewers or editors by setting one variable.&lt;/p&gt;
&lt;p&gt;
Pressing &lt;code class=&#34;verbatim&#34;&gt;C-enter&lt;/code&gt; opens the file in an external viewer or editor. You can tell Emacs which external viewer to user by configuring the &lt;code class=&#34;verbatim&#34;&gt;image-dired-external-viewer&lt;/code&gt; variable. I linked it to the GIMP (&lt;a href=&#34;https://www.gimp.org/&#34;&gt;GNU Image Manipulation Program&lt;/a&gt;). The content of this variable obviously depends on your system and preferred viewer.&lt;/p&gt;
&lt;p&gt;
When you are in an image-dired buffer, you open the external viewer with &lt;code class=&#34;verbatim&#34;&gt;C-enter&lt;/code&gt;. Confusingly, when you are in a normal dired buffer, this function is bound to &lt;code class=&#34;verbatim&#34;&gt;C-t x&lt;/code&gt;. &lt;em&gt;Emacs Writing Studio&lt;/em&gt; remaps the keys so that you can use &lt;code class=&#34;verbatim&#34;&gt;C-enter&lt;/code&gt; in dired and in image-dired to open an image in your favourite external editor.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Configuration
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs image-mode and image-dired work out-of-the-box, but some configuration helps to add some convenience.&lt;/p&gt;
&lt;p&gt;
This configuration adds keyboard shortcuts to kill an image buffer, so your Emacs session is not littered with open pictures. It also lets you view your image gallery with the arrow keys instead of the non-intuitive &lt;code class=&#34;verbatim&#34;&gt;space&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;backspace&lt;/code&gt; combination.&lt;/p&gt;
&lt;p&gt;
If you like reading more details about image-mode and its configuration options, type &lt;code class=&#34;verbatim&#34;&gt;C-h r&lt;/code&gt; to open the Emacs manual, followed by &lt;code class=&#34;verbatim&#34;&gt;g image-mode return&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Image viewer&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;emacs&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ((&lt;span style=&#34;color:#007020&#34;&gt;:map&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;image-mode-map&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;k&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;image-kill-buffer&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;lt;right&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;image-next-file&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;lt;left&amp;gt;&amp;#34;&lt;/span&gt;  &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;image-previous-file&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#007020&#34;&gt;:map&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;dired-mode-map&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-&amp;lt;return&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;image-dired-dired-display-external&lt;/span&gt;))))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The configuration for the image-dired package defines the external viewer and defines some convenience keybindings to flick through your albums.&lt;/p&gt;
&lt;p&gt;
To find out about further customisation options, type &lt;code class=&#34;verbatim&#34;&gt;C-h r&lt;/code&gt; to open the Emacs manual, followed by &lt;code class=&#34;verbatim&#34;&gt;g Image-Dired return&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;image-dired&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;image-dired-external-viewer&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;gimp&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;image-dired-thumb-margin&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c w I&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;image-dired&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#007020&#34;&gt;:map&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;image-dired-thumbnail-mode-map&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-&amp;lt;right&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;image-dired-display-next&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-&amp;lt;left&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;image-dired-display-previous&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Emacs Writing Studio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to support my work, then please purchase the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; book.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
You can find the source files for the book and the latest configuration files on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences to undertake a task. Any article on how to be productive with Emacs is thus opinionated. If you have a different way of doing things, please share your views and leave a comment below, or complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email.&lt;/p&gt;
&lt;p&gt;
This is the last article in the &lt;em&gt;Emacs Writing Studio&lt;/em&gt; series.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Establish and Maintain a Gemini Capsule with Emacs</title>
      <link>https://lucidmanager.org/productivity/create-and-maintain-a-gemini-capsule-with-emacs/</link>
      <pubDate>Tue, 30 Jun 2026 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/create-and-maintain-a-gemini-capsule-with-emacs/</guid>
      <description>
	
&lt;p&gt;
This article introduces the Gemini internet protocol and shows how to access and create your own ‘capsules’ (the equivalent of a website) using Emacs. This plain text replacement for the bloated World Wide Web is a perfect companion for Emacs users.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Introduction
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;It has been suggested that the internet is dead. Bots dominate a significant share of web traffic, and companies lock users into algorithmic feeds to drive doomscrolling. And when you do finally find an interesting website, your eyeballs are attacked with advertising after every paragraph.&lt;/p&gt;
&lt;p&gt;
But there is still hope. Paraphrasing the words of punk legend Johnny Rotten, “The internet is not dead, it just smells funny”.&lt;/p&gt;
&lt;p&gt;
Cultural expression always finds new places as yet untouched by commercialisation. Several alternative web protocols are available. I am not talking about the dark web, where unspoken things happen, but about alternative protocols for exchanging information.&lt;/p&gt;
&lt;p&gt;
When people say &amp;#34;the internet,&amp;#34; they really mean the World Wide Web (fun fact: &amp;#34;WWW&amp;#34; is the only abbreviation with more syllables than the full term).&lt;/p&gt;
&lt;p&gt;
The oldest of these is &lt;a href=&#34;https://en.wikipedia.org/wiki/Gopher_(protocol)&#34;&gt;Gopher&lt;/a&gt;, which is a plain text protocol designed to exchange files through decentralised servers. The protocol was &lt;a href=&#34;https://www.youtube.com/watch?v=Flo9kn_nhbg&#34;&gt;born at the University of Minnesota&lt;/a&gt; by a group of developers after a frustrating meeting. Gopher (named after the university mascot) is still around, and thousands of Gopher ‘holes’ as the vernacular goes, are still actively maintained. But Gopher is perhaps a bit too minimalist for the modern age.&lt;/p&gt;
&lt;p&gt;
Gemini (named after the Gemini space program) also supports an electronic library of interconnected text documents, with some improvements compared to Gopher but without the complexity of webpages. As &lt;a href=&#34;https://geminiprotocol.net/&#34;&gt;Project Gemini&lt;/a&gt; put it:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Gemini isn’t about innovation or disruption; it’s about providing some respite for those who feel the internet has been disrupted enough already. We’re not out to change the world or destroy other technologies. We are out to build a lightweight online space where documents are just documents, in the interests of every reader’s privacy, attention and bandwidth.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Accessing Gemini Capsules in Emacs
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In the Gemini protocol, what we know as a Gopher hole or a WWW site is called a capsule.&lt;/p&gt;
&lt;p&gt;
You can access Gemini capsules using the &lt;a href=&#34;https://thelambdalab.xyz/elpher/&#34;&gt;Elpher Emacs package&lt;/a&gt;, which renders both Gopher and Gemini pages. The package has a detailed manual, available through &lt;code class=&#34;verbatim&#34;&gt;C-h R elpher &amp;lt;RET&amp;gt;&lt;/code&gt;.    Elpher&amp;#39;s navigation interface is inspired by the Emacs Info mode. Short form manual:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Start with &lt;code class=&#34;verbatim&#34;&gt;M-x elpher&lt;/code&gt; (Use the universal argument &lt;code class=&#34;verbatim&#34;&gt;C-u&lt;/code&gt; to start additional Elpher sessions)&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;g&lt;/code&gt;: Read a Gemini capsule (enter either &lt;code class=&#34;verbatim&#34;&gt;gopher://url&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;gemini://url&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;= and =S-&lt;/code&gt;: Move between links&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;&amp;lt;RET&amp;gt;&lt;/code&gt;: Follow a link&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;u&lt;/code&gt;: Return to the previous page&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;A&lt;/code&gt;: Bookmark the current page&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;B&lt;/code&gt;: Open bookmarks&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;?&lt;/code&gt;: for keybindings&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Several customisation options are available, for example setting the default URL type to Gemini so that you don&amp;#39;t have to type &lt;code class=&#34;verbatim&#34;&gt;gemini://&lt;/code&gt; for every capsule. &lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;elpher&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;elpher-default-url-type&lt;/span&gt; &lt;span style=&#34;color:#f00;background-color:#faa&#34;&gt;“&lt;/span&gt;&lt;span style=&#34;color:#963&#34;&gt;gemini&lt;/span&gt;&lt;span style=&#34;color:#f00;background-color:#faa&#34;&gt;”&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Finding Gemini Capsules
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A good place to start exploring Gemini capsules is gemini://geminiquickst.art/. To get there use &lt;code class=&#34;verbatim&#34;&gt;M-x elpher g geminiquickst.art &amp;lt;RET&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Gemtext, the Gemini file format
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Reading published Capsules is great fun, but what about publishing your own content? This section explains how to create a Gemini capsule in Emacs.&lt;/p&gt;
&lt;p&gt;
The files that make up a Gemini capsule have the &lt;code class=&#34;verbatim&#34;&gt;.gmi&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;.gemini&lt;/code&gt; extension, also called the Gemtext format. The basic unit of the Gemini text format is a line, and the first 1 to 3 characters determine how it is rendered. Formatting is only permitted by line, so there is no inline bold text or emphasis and hyperlinks exist on separate lines, not embedded in a sentence. There is no CSS equivalent in Gemini; all rendering is undertaken client-side.&lt;/p&gt;
&lt;p&gt;
The basic syntax for a Gemtext file is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Heading: three levels, starting with &lt;code class=&#34;verbatim&#34;&gt;#&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;##&lt;/code&gt;, or &lt;code class=&#34;verbatim&#34;&gt;###&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Paragraph: starts with any non-prescribed character&lt;/li&gt;
&lt;li&gt;Quotation: start with &lt;code class=&#34;verbatim&#34;&gt;&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;List item: start with &lt;code class=&#34;verbatim&#34;&gt;*&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Link: starts with &lt;code&gt;=&amp;gt;&lt;/code&gt; followed by the URL and optional label&lt;/li&gt;
&lt;li&gt;Monospace toggle: three backticks &lt;code class=&#34;verbatim&#34;&gt;```&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The Gemtext format only allows text, so many capsules are adored with ASCII art. Some browsers allow inline images by linking directly to an image in the Gemini space. A relative link to a file recognised as an image file can be displaced by the Gemini browser by clicking on it. It goes against the minimalist philosophy of the Gemini philosophy to show all images by default.&lt;/p&gt;
&lt;p&gt;
This example Gemtext file demonstrates the available formats:&lt;/p&gt;
&lt;div class=&#34;src src-gmi&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-gmi&#34; data-lang=&#34;gmi&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#000080;font-weight:bold&#34;&gt;# Header 1
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Each line is a paragraph. Gemini clients wrap the text as in Emacs visual-line-mode.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;List example:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;,* List item 1
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;,* List Item 2
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#800080;font-weight:bold&#34;&gt;## Header 2
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&#34;font-style:italic&#34;&gt; Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away (Antoine de Saint-Exupéry)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#800080;font-weight:bold&#34;&gt;### Header 3
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Gemtext format cheatsheet:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#00c&#34;&gt;gemini://geminiprotocol.net/docs/cheatsheet.gmi&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Toggle monospace to view ASCII art or source code:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;```
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       _________
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      /___   ___\
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     //@@@\ /@@@\\
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     \\@@@/ \@@@//
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      \___ &amp;#34; ___/
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;jrjc     | - |
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          \_/
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;```&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Use a link as an embedded image (depending on browser):
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#00c&#34;&gt;image-filename.png&lt;/span&gt; &lt;span style=&#34;color:#070&#34;&gt;Image header&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Write Gemtext in Emacs
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;You can write Gemtext in Emacs with the &lt;a href=&#34;https://git.carcosa.net/jmcbray/gemini.el&#34;&gt;gemini-mode package&lt;/a&gt;. Support is currently incomplete, but it is certainly usable.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;gemini-insert-link&lt;/code&gt;: Insert a Gemini Link (&lt;code class=&#34;verbatim&#34;&gt;C-c C-l&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;gemini-insert-list-item&lt;/code&gt;: Start a new list item (&lt;code class=&#34;verbatim&#34;&gt;C-c RET&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;gemini-insert-time-stamp&lt;/code&gt;: Insert a timestamp (&lt;code class=&#34;verbatim&#34;&gt;C-c C-t&lt;/code&gt;) in accordance with the  &lt;code&gt;gemini-timestamp-format&lt;/code&gt; template&lt;/li&gt;
&lt;li&gt;&lt;code&gt;gemini-open-link-at-point&lt;/code&gt;: Open a link in Elpher (&lt;code class=&#34;verbatim&#34;&gt;C-c C-o&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I have remapped the insert list item function to &lt;code class=&#34;verbatim&#34;&gt;C-c -&lt;/code&gt; for Org mode similarity.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;gemini-mode&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt; (&lt;span style=&#34;color:#007020&#34;&gt;:map&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;gemini-mode-map&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  	      (&lt;span style=&#34;color:#f00;background-color:#faa&#34;&gt;“&lt;/span&gt;&lt;span style=&#34;color:#963&#34;&gt;C-c&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#f00;background-color:#faa&#34;&gt;”&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;gemini-insert-list-item&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
The Gemini Server
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;You can create your own server with the &lt;a href=&#34;https://github.com/mbrubeck/agate&#34;&gt;Agate program&lt;/a&gt; by Matt Brubeck. This software provides a simple Gemini network protocol server built with Rust. All you need to run your own Gemini capsule is to run this program and open port 1965 on your server.&lt;/p&gt;
&lt;p&gt;
If you are unable to run your own servr then you can still participate by joining a Tilde community, names after the &lt;code class=&#34;verbatim&#34;&gt;~&lt;/code&gt; symbol in front of user names. The Tildeverse is a constellation of Tilde server instances, which are public servers that allow public accounts.&lt;/p&gt;
&lt;p&gt;
To create a capsule, place at least a file named &lt;code class=&#34;verbatim&#34;&gt;index.gmi&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;index.gemini&lt;/code&gt; in each directory in your server configuration.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Conclusion
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Gemini protocol is ideal for Emacs users because they both value the power of plain text.&lt;/p&gt;
&lt;p&gt;
Main disadvantage of Gemini is that the content is not discoverable through the usual means by which people find information. But the obscurity of Gemini is also it&amp;#39;s strength.  &lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Using Emacs on a Chromebook: An Installation Guide</title>
      <link>https://lucidmanager.org/productivity/emacs-chromebook/</link>
      <pubDate>Sat, 29 Aug 2020 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/emacs-chromebook/</guid>
      <description>
	
&lt;p&gt;
One of the main advantages of free software is that it runs on almost any platform. Google&amp;#39;s Chromebooks are somewhat of an exception because of its restricted application access. Emacs is not available as an application within the app store. However, the foundations of Google&amp;#39;s Chromebook are Linux, which makes it an ideal platform to use Emacs. Although Emacs does not run natively on a Chromebook, there is an elegant solution to this problem.&lt;/p&gt;
&lt;p&gt;
Installing Emacs on a Chromebook is like a three-course meal. You start with a Crouton or some Crostini as an appetiser, install Emacs as the main course, and some configuration as the desert. This article explains how to install Emacs on your Chromebook laptop.&lt;/p&gt;
&lt;p&gt;
This article is part of &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt;, a book that explains how to use Emacs to undertake research and write and publish articles, books, and websites. Emacs Writing Studio is also available as an e-book from your favourite retailer.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Linux on a Chromebook
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Several open-source projects developed over the years enable running Linux on a Chromebook. &lt;a href=&#34;https://chromebook.guide/crouton/&#34;&gt;Crouton&lt;/a&gt; (not to be confused with the bread sticks) installs a GNU/Linux operating system, such as Ubuntu, on your Chromebook. Linux will live side-by-side with Chrome OS and you can switch between the two with a keyboard shortcut without rebooting.&lt;/p&gt;
&lt;p&gt;
More recently, Google introduced a new Linux subsystem called  &lt;a href=&#34;https://chromeos.dev/en/linux&#34;&gt;Crostini&lt;/a&gt;, for its Chrome OS  so that you can use all the great software it offers, including the venerable Emacs. Crostini is a play on words as it is a fancy version of a crouton. With Crostini, your Linux terminal is an application within the Chrome OS. &lt;/p&gt;
&lt;p&gt;
Click on the clock and select the settings icon. Scroll down to the Linux section and follow the prompts. Not all Chromebooks support this method yet. If your Chromebook does not include Crostini, then you&amp;#39;ll have to use Crouton instead. Crostini is still beta software and some functionality, such as USB, might not be fully functional.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Install Emacs
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Once you have access to either Crouton or Crostini, you can install Emacs in the usual way. Crostini uses a stable version of Debian, with Emacs 25 as the most recent version. Start the Linux terminal and type:&lt;/p&gt;
&lt;div class=&#34;src src-shell&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-shell&#34; data-lang=&#34;shell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;sudo apt-get install emacs25&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Emacs will now be accessible from Chrome OS, without needing the terminal. You can start it just like any other Chrome software.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/emacs-chromebook-screen.jpg&#34; alt=&#34;/images/emacs/emacs-chromebook-screen.jpg&#34; title=&#34;Writing this acticle with Emacs on the Chromebook&#34;/&gt;
&lt;figcaption&gt;
Writing this acticle with Emacs on the Chromebook.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Using Emacs with Crouton
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Linux system is a virtual machine within Chrome and has a separate file system. Files within the Linux container are available by default from the file browser. The user&amp;#39;s Linux home folder is a folder within the Chromebook&amp;#39;s file system.&lt;/p&gt;
&lt;p&gt;
If you want to access the Chrome file system within Emacs, you will need to share the Chrome folder with Linux. Right-click on any folder in the Chrome file browser and select &amp;#34;Share with Linux&amp;#34;. The shared folders are available in &lt;code class=&#34;verbatim&#34;&gt;/mnt/chromeos/MyFiles/&lt;/code&gt; in the Linux container.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Chromebook keybindings
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The keyboard on Chromebooks is a bit different from the normal PC or Apple. The top-row arrow keys are by default bound to &lt;code class=&#34;verbatim&#34;&gt;next-buffer&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;previous-buffer&lt;/code&gt; functions. The &lt;code class=&#34;verbatim&#34;&gt;ALT&lt;/code&gt; and up/down arrow keys map to page-up and page-down, which is annoying when you use Org mode.&lt;/p&gt;
&lt;p&gt;
The code below restores the behaviour of &lt;code class=&#34;verbatim&#34;&gt;M-up&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;M-down&lt;/code&gt; in Org mode. When you use this keybinding, you will have to use &lt;code class=&#34;verbatim&#34;&gt;M-v&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;C-v&lt;/code&gt; for scrolling while in Org mode. &lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Chromebook shortcuts&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;define-key&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-mode-map&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;kbd&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;lt;prior&amp;gt;&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;org-metaup&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;define-key&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-mode-map&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;kbd&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;lt;next&amp;gt;&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;org-metadown&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Edit in 2026: For a more recent view of installing Emacs on a Chromebook, watch this video by Timothy W. Ukert.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/jPqvbyZqqF0?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
How to Install Emacs on a Chromebook in 2025.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Chromebook Emacs as a writing companion
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs is the ideal software for a Chromebook. They are cheap lightweight computers that are perfect for writing on the go. Emacs provides the perfect &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;distraction-free writing environment&lt;/a&gt; for anyone who writes as a professional activity or creative outlet.&lt;/p&gt;
&lt;p&gt;
You can download a configuration file focused on content creators from my GitHub page.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences. Any article on how to be productive with Emacs is thus opinionated. If you have a different way of doing things, please share your views and leave a comment below, or complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Using Emacs on Windows 11: An Installation Guide</title>
      <link>https://lucidmanager.org/productivity/emacs-windows/</link>
      <pubDate>Fri, 20 Aug 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/emacs-windows/</guid>
      <description>
	
&lt;p&gt;
This article describes how to install Emacs on Windows 10, including supporting packages. This article is part of the &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt; which explains how to use Emacs to undertake research and write and publish articles, books, and websites.&lt;/p&gt;
&lt;p&gt;
This article is part of &lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs Writing Studio&lt;/a&gt;, a book that explains how to use Emacs to undertake research and write and publish articles, books, and websites. Emacs Writing Studio is also available as an e-book from your favourite retailer.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2024-ews.jpg&#34; alt = &#34;Emacs Writing Studio&#34; title = &#34;Emacs Writing Studio&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Emacs Writing Studio&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;A comprehensive guide for writers seeking to streamline their workflow using Emacs. The book covers everything from organising ideas and writing distraction-free to publishing in multiple formats. It’s perfect for both beginners and experienced Emacs users, offering practical tips and a tailored configuration to enhance your writing process.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://payhip.com/b/alhIJ&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Payhip&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=ebook&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;e-readers&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://books2read.com/u/4NpgQ9?format=print&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Paperback&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://leanpub.com/emacswritingstudio&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;LeanPub&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The source files of the book and EWS configuration are also freely available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Installing Emacs on Windows 11
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The first step is to download Emacs for Windows directly from its makers on the &lt;a href=&#34;http://ftp.gnu.org/gnu/emacs/windows/emacs-29/&#34;&gt;GNU website&lt;/a&gt;. You need the &lt;code class=&#34;verbatim&#34;&gt;emacs-$VERSION-x86_64-installer.exe&lt;/code&gt;, where version is currently 29.4. This file contains a 64-bit build of Emacs with dependencies as an installer package.&lt;/p&gt;
&lt;p&gt;
Download this file and run the program to install Emacs on your system. You can now run Emacs like any other Windows software.&lt;/p&gt;
&lt;p&gt;
To upgrade Emacs in future, simply repeat this process.&lt;/p&gt;
&lt;p&gt;
But wait there is more. Emacs is neatly integrated with Linux systems, but to make it function properly on Windows some additional configuration steps and additional software is required.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Directories
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Home Directory
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The next step is to set the default folder for Emacs by setting the &lt;code class=&#34;verbatim&#34;&gt;HOME&lt;/code&gt; variable. This variable instructs Emacs to use the &lt;code class=&#34;verbatim&#34;&gt;C:\users\username\&lt;/code&gt; folder as your home location. Open Powershell in administrator mode and enter this line:&lt;/p&gt;
&lt;div class=&#34;src src-shell&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-shell&#34; data-lang=&#34;shell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  setx HOME %USERPROFILE%&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
You can also set this variable through the Windows Control Panel. Search for &amp;#34;environment&amp;#34; and click &lt;em&gt;Edit System Variables&lt;/em&gt; and select &lt;em&gt;Environment variables&lt;/em&gt;. Create a new variable called &lt;code class=&#34;verbatim&#34;&gt;HOME&lt;/code&gt; and select your home folder and click &lt;em&gt;OK&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;
In Emacs, your home folder is indicated with a tilde symbol. So lets say that your home folder is &lt;code class=&#34;verbatim&#34;&gt;C:\Users\peter\&lt;/code&gt; and you need the &lt;code class=&#34;verbatim&#34;&gt;Downloads&lt;/code&gt; folder, then in Emacs refers to this location as &lt;code class=&#34;verbatim&#34;&gt;~/Downloads&lt;/code&gt;.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Emacs configuration folder
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The location of the configuration folder depends on your operating system and Emacs version. If you are unsure where to store the &lt;code class=&#34;verbatim&#34;&gt;init.el&lt;/code&gt; file, then you can use the Emacs help functionality. In most cases it will be something like &lt;code class=&#34;verbatim&#34;&gt;~/.emacs.d/&lt;/code&gt;. The dot at the start of the folder name means that it is hidden from view. To view the content of this folder in Windows you need to enable &amp;#34;Show hidden items&amp;#34; in the file explorer.&lt;/p&gt;
&lt;p&gt;
Type &lt;code class=&#34;verbatim&#34;&gt;C-h v&lt;/code&gt; for help on variables and type &lt;code&gt;user-emacs-directory&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;enter&lt;/code&gt;. The help buffer that now appears provides the correct folder name. &lt;/p&gt;
&lt;p&gt;
Read my article on &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;configuring Emacs&lt;/a&gt; for more information.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
External Software
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Emacs is not a text editor, it is a computing platform with a built-in text editor. Emacs can also act as an interface to other Open Source free software. Most of these packages are included in common Linux distributions. Windows users need to use a bit more effort to install these.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Reading documents and ebooks
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Emacs is great at displaying plain text but needs some assistance with reading other formats. The basic emacs package to view documents other than plain text is Doc-View. The image below explains the external packages required to read ebooks and articles.&lt;/p&gt;
&lt;p&gt;
For PDF documents you need to install &lt;a href=&#34;https://www.ghostscript.com/&#34;&gt;Ghostscript&lt;/a&gt; or &lt;a href=&#34;https://mupdf.com/&#34;&gt;MuPDF&lt;/a&gt;. The &lt;code&gt;pdftotext&lt;/code&gt; program from the &lt;a href=&#34;https://poppler.freedesktop.org/&#34;&gt;Poppler software&lt;/a&gt; helps with finding and copying text in a PDF.&lt;/p&gt;
&lt;p&gt;
To read and export to office documents (MS Office and LibreOffice), Emacs needs to have acces to the &lt;a href=&#34;https://www.libreoffice.org/download/download-libreoffice/&#34;&gt;LibreOffice software&lt;/a&gt;. Emacs uses this software to convert office documents to PDF and display them with the DocView package. LibreOffice can also assist with exporting Org mode files to office formats or to PDF.&lt;/p&gt;
&lt;p&gt;
To view EPub files you need a version of the &lt;code class=&#34;verbatim&#34;&gt;zip&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;unzip&lt;/code&gt; programs. You can find these programs, and many others, in the &lt;a href=&#34;https://gnuwin32.sourceforge.net/&#34;&gt;GnuWin32&lt;/a&gt; project.&lt;/p&gt;
&lt;p&gt;
You also need to tell Emacs where these tools live, so you need to customise the &lt;code&gt;exec-path&lt;/code&gt; variable.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/doc-view.png&#34; alt=&#34;Document conversion in Doc-View&#34; title=&#34;Document conversion in Doc-View&#34; width=&#34;300&#34;/&gt;
&lt;figcaption&gt;
Document conversion in Doc-View.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
For more information on reading non-text files in Emacs see my article on &lt;a href=&#34;https://lucidmanager.org/productivity/reading-ebooks-with-emacs/&#34;&gt;reading ebooks&lt;/a&gt;.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Spellcheck
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The Flyspell package performs spell checking on Emacs. Read the &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;distraction-free writing&lt;/a&gt; for more information on how to configure spell-checking.&lt;/p&gt;
&lt;p&gt;
The ezwinports project maintains a large collection of useful open source software compiled for Windows computers, including Hunspell.&lt;/p&gt;
&lt;p&gt;
To install Hunspell on Windows, download the software from &lt;a href=&#34;https://sourceforge.net/projects/ezwinports/files/&#34;&gt;ezwinports&lt;/a&gt;. Extract the files in a folder on your drive, for example: &lt;code class=&#34;verbatim&#34;&gt;C:\ProgramData\ezwinports\&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;
You need to add the &lt;code class=&#34;verbatim&#34;&gt;bin&lt;/code&gt; folder to your path environment variable. A simple workaround is to add the full path of the Hunspell variable to your configuration, as such:&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#007020&#34;&gt;setq-default&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;ispell-program-name&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C:/ProgramData/ezwinports/bin/hunspell&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Note that Emacs uses a forward slash &lt;code class=&#34;verbatim&#34;&gt;/&lt;/code&gt;, not the Windows backslash &lt;code class=&#34;verbatim&#34;&gt;\&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
The binary distribution includes dictionaries for US English and UK English. You can find the dictionaries for other languages on the Internet; install them into &lt;code class=&#34;verbatim&#34;&gt;share/hunspell&lt;/code&gt; directory in your Hunspell installation directory.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Using Emacs on Windows 11
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This article only discussed how to install Emacs on Windows 11. The other articles on this website show you how to &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;configure Emacs&lt;/a&gt; and how to use Emacs to research, write and publish articles, books and websites.&lt;/p&gt;
&lt;p&gt;
The EWS GitHub repository contains the latest information about the required external software.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences to undertake a task. Any article on how to be productive with Emacs is thus opinionated. If you have a different way of doing things, please share your views and leave a comment below, or complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Taking Notes with Emacs Org Mode and Org-Roam</title>
      <link>https://lucidmanager.org/productivity/taking-notes-with-emacs-org-mode-and-org-roam/</link>
      <pubDate>Sat, 08 May 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/taking-notes-with-emacs-org-mode-and-org-roam/</guid>
      <description>
	
&lt;p&gt;
Taking notes is an important activity for all creative work. Recording your thoughts and ideas or somebody else’s ideas is 2a foundational activity whether you write scientific articles, novels or whatever else. Emacs Org mode has some useful functionality to take notes, which can be further extended with the &lt;a href=&#34;https://www.orgroam.com/&#34;&gt;Org-Roam package&lt;/a&gt;. This article explains how to take notes in Emacs and configure the Org-roam note-taking system for Emacs.&lt;/p&gt;
&lt;p&gt;
Org Roam is a popular note-taking package that uses Org mode as its central repository. The disadvantage of this package is that it relies on a database and can only manage Org mode files. This page assumes that you are using the latest version of Emacs, which at the time of writing is 29.1, which has a built-in database. This page is no longer maintained as &lt;em&gt;Emacs Writing Studio&lt;/em&gt; uses &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/&#34;&gt;Denote for notetaking&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Single File or Personal Wiki
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Taking notes in Org mode can be as easy as maintaining one or more files with many headers. Org mode has some functionality to &lt;a href=&#34;https://orgmode.org/guide/Tags.html&#34;&gt;tag each heading&lt;/a&gt; to help you categorise notes. &lt;/p&gt;
&lt;p&gt;
While this is a great start, keeping topical notes in separate files is a more productive method because you can easily link Org mode files to each other, creating a personal Wiki. To create a hyperlink between two files, press &lt;code class=&#34;verbatim&#34;&gt;C-c C-l&lt;/code&gt; (&lt;code&gt;org-insert-link&lt;/code&gt;) and type &lt;code class=&#34;verbatim&#34;&gt;file:&lt;/code&gt; (Or add the universal argument &lt;code class=&#34;verbatim&#34;&gt;C-u C-c C-l&lt;/code&gt; to choose file links by default). You can then select the file with your &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-completion-system/&#34;&gt;completion system&lt;/a&gt; and type a description, which creates a hyperlink. You follow these links by pressing &lt;code class=&#34;verbatim&#34;&gt;C-c C-o&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
This method allows you to navigate from one file to the next, but Org mode does not know which other files link to your current buffer. There is no database in vanilla Emacs that allows you to review the structure of your linked files.&lt;/p&gt;
&lt;p&gt;
The Org-Roam package extends the Org mode functionality by saving all the links between files and headings in a database. This method allows you to also view the backlinks. The database stores a list of nodes, which are files or registered headings. This additional functionality allows you to navigate through your network of notes like you would in a personal wiki.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Zettelkasten: Structured collection of notes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Org-Roam implements the principles of the Zettelkasten method as a digital slip box full of cards. German sociologist Niklas Luhmann maintained a collection of tens of thousands notes, each written on an index card. These cards were linked through a series of keywords. This method allowed Luhmann to connect disparate ideas and writes his extensive oeuvre of books and articles.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/rOSZOCoqOo8?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Zettelkasten Note-Taking Method: Simply Explained.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The Org-Roam package in Emacs creates a network of links between your notes and manages your digital knowledge garden. Basically, the package extends Org mode functionality by storing all nodes (files and registered headings) in a database, including which between nodes. Furthermore, Org-roam provides each node in your knowledge network with a unique identifier consisting of a long string of numbers and letters, e.g. &lt;code class=&#34;verbatim&#34;&gt;711a7cac-e46b-4e64-b1e6-2940fa431e55&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
The Org-Roam database provides excellent opportunities to analyse your network and discover patterns in your research that were perhaps previously invisible. You can examine this database and visualise its structure. The graph below is created with the &lt;a href=&#34;https://lucidmanager.org/data-science/visualise-org-roam/&#34;&gt;igraph package in R&lt;/a&gt;.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/org-roam-network.png&#34; alt=&#34;My personal Org-roam notes network&#34; title=&#34;My personal Org-roam notes network&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
My personal Org-roam notes network.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The package provides a lot of freedom to structure your personal Wiki, and this article describes the basic functionality. However, before we can get started, we need to configure the system.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Configuring Org-roam
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Install database
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The Org-roam package stores a summary of all nodes in your network in a database. In Emacs version 29.1, this functionality comes out of the box and no further configuration is required.&lt;/p&gt;
&lt;p&gt;
If you are using an older version of Emacs, then Org-Roam depends on the EmacSQL package to connect with the database. During package installation EmacSQL needs to compile a custom native binary for communicating with the SQLite database.&lt;/p&gt;
&lt;p&gt;
To enable this task, you will need to install a compiler on your system. On GNU/Linux systems, including &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-chromebook/&#34;&gt;Chromebook&lt;/a&gt;, you need to instal the GCC compiler through your favourite package manager.&lt;/p&gt;
&lt;p&gt;
On &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-windows/&#34;&gt;Windows&lt;/a&gt; you need to install Chocolatey. Open PowerShell as administrator and follow he instructions on the &lt;a href=&#34;https://chocolatey.org/install&#34;&gt;Chocolatey website&lt;/a&gt;. After Chocolatey is available, you can install the compiler in Powershell as administrator with:&lt;/p&gt;
&lt;div class=&#34;src src-bash&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;choco install mingw&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
When Emacs configures the Org-Roam package, it will try to compile the database connector. This might take a little while, but is only done once.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Configure Org-Roam
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The Org-roam package requires some configuration to get it to work. At a minimum, we need to activate the package, bind some keys, define the folder where your notes and database will live and set a template for new notes.&lt;/p&gt;
&lt;p&gt;
You will also need to install the &lt;code class=&#34;verbatim&#34;&gt;use-package&lt;/code&gt; package, which the &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;configure Emacs&lt;/a&gt; article discusses. Alternatively, you can download the complete init file for this series of articles from GitHub and store it in your configuration folder. &lt;/p&gt;
&lt;p&gt;
You will also need to install use-package, which is explained article on how to &lt;a href=&#34;https://lucidmanager.org/productivity/configure-emacs/&#34;&gt;configure Emacs&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Org-Roam basic configuration&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-directory&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;concat&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;getenv&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;HOME&amp;#34;&lt;/span&gt;) &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;/Documents/org-roam/&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-roam&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:after&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:custom&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-roam-directory&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;file-truename&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-directory&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:init&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-roam-setup&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt; ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c n f&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-roam-node-find&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c n r&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-roam-node-random&lt;/span&gt;)		    
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           (&lt;span style=&#34;color:#007020&#34;&gt;:map&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-mode-map&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                 ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c n i&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-roam-node-insert&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c n o&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-id-get-create&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c n t&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-roam-tag-add&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c n a&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-roam-alias-add&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c n l&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-roam-buffer-toggle&lt;/span&gt;)))))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The first line defines the default file for Org mode files. I store my Org-Roam notes in &lt;code class=&#34;verbatim&#34;&gt;/Documents/notes/&lt;/code&gt; in my home folder. You need to change the name of the folder to your personal preference. The &lt;code class=&#34;verbatim&#34;&gt;(getenv ““HOME””)&lt;/code&gt; part of this configuration is your home folder, so you only need to modify the relative path between quotation marks.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;org-roam-setup&lt;/code&gt; function initiates the database, which can take a while the first time round if you have many existing notes.&lt;/p&gt;
&lt;p&gt;
Lastly, the configuration defines the keyboard shortcuts. The first three shortcuts are added to the overall keyboard map, so you can activate it from anywhere in Emacs. The last five lines are only valid when you are in an open Org mode buffer. Note that all shortcuts start with &lt;code class=&#34;verbatim&#34;&gt;C-c n&lt;/code&gt; to provide consistency.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Creating and Taking Notes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;We are finally ready to write notes. You add a new note with the &lt;code class=&#34;verbatim&#34;&gt;org-roam-node-find&lt;/code&gt; function (&lt;code class=&#34;verbatim&#34;&gt;C-c n f&lt;/code&gt;). You can type the name of an existing note or of a new note. The minibuffer &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-completion-system/&#34;&gt;completion system&lt;/a&gt;, which we configured earlier, shows a list of available nodes and filters options as you type. &lt;/p&gt;
&lt;p&gt;
When you create a new node, it will open in an Org mode capture screen. You complete the node with &lt;code class=&#34;verbatim&#34;&gt;C-c C-c&lt;/code&gt; and cancel it with &lt;code class=&#34;verbatim&#34;&gt;C-c C-k&lt;/code&gt;. You can read these instructions in the top of the popup screen. When you complete the node, Org-Roam will construct a filename and save it to disk. The filename starts with a timestamp, followed by the name of the note, separated by dashes. There is need to worry too much about the filename because you will be retrieving nodes through their title and tags, rather than a filename. &lt;/p&gt;
&lt;p&gt;
An Org-Roam file (called a node) is just another Org mode file with some minor differences. The file starts with a properties drawer that defines the file ID. Using an ID instead of a file name makes it easier to maintain link integrity when you change file names or titles. A node can also contain one or more aliases, so you can search on multiple names. &lt;/p&gt;
&lt;p&gt;
The remainder of the file contains the header and content. Note the &lt;code class=&#34;verbatim&#34;&gt;#+filetags:&lt;/code&gt; property. A file tag is a way to add tags to files so you can easily group entries. The tags are displayed after the title or alias when you find a new or existing file.&lt;/p&gt;
&lt;p&gt;
When you first create a new file, a capture screen appears where you can write your note. To save the note to your system, press &lt;code class=&#34;verbatim&#34;&gt;C-c C-c&lt;/code&gt;, to cancel creating a new note, press &lt;code class=&#34;verbatim&#34;&gt;C-c C-k&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;  :PROPERTIES:
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;  :ID: f1bdb099-2184-46cf-a952-4808baa00b09
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;  :ROAM_ALIASES: &amp;#34;Note taking with Org-roam&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;  :END:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+title: Zettelkasten method with Org-roam
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  #+filetags: :notes::emacs:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;* &lt;/span&gt;First headline&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
If this file exists in your database, you will be able to find it through its title, alias or tag. An alias is useful for registering synonyms of words or definitions of abbreviations (AI / Artificial Intelligence). File tags help you cluster notes by topic.&lt;/p&gt;
&lt;p&gt;
Your note starts below your header. If you are new to Org-mode, then read the article on &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-for-distraction-free-writing/&#34;&gt;distraction-free writing&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Org-Roam Nodes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;In Org-roam terminology, a file or a registered heading is a node in a network. You can promote a heading inside a file to a node by pressing &lt;code class=&#34;verbatim&#34;&gt;C-c n o&lt;/code&gt; (&lt;code&gt;org-id-get-create&lt;/code&gt;). This will create a property drawer below the heading with an id tag. Use the &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; key to open or close the drawer. &lt;a href=&#34;https://orgmode.org/manual/Drawers.html&#34;&gt;Drawers are an Org mode functionality&lt;/a&gt; to store metadata about files or headings.&lt;/p&gt;
&lt;p&gt;
Org-roam indexes every node (file or heading with an id) that resides in its designated folder and subfolders in a database. This database contains metadata about the node, such as its title and any links from and to the node.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Tags and Aliases
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;To make it easier to group and find nodes, you can give it one or more alias titles with the &lt;code class=&#34;verbatim&#34;&gt;C-c n a&lt;/code&gt; shortcut (&lt;code&gt;org-roam-alias-add&lt;/code&gt;). The main and the alias titles are searchable when finding a node. The name of the alias stored in the drawer at the start of the file.&lt;/p&gt;
&lt;p&gt;
To add one or more tags to a Org-Roam file, use &lt;code&gt;org-roam-tag-add&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c n t&lt;/code&gt;). Note that tags have completion using the &lt;code class=&#34;verbatim&#34;&gt;TAB&lt;/code&gt; key. Tags are also searchable when visiting a node. Tags are a way to add structure to your nodes by adding them to a group. Adding a tag to a heading is as easy as hitting &lt;code class=&#34;verbatim&#34;&gt;C-c C-c&lt;/code&gt;, which is a standard Org mode function.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
Linking Nodes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The second method to add structure is by linking nodes. You can start writing your note as per usual. Links to existing files are easy to insert with the &lt;code class=&#34;verbatim&#34;&gt;C-c n i&lt;/code&gt; shortcut (&lt;code&gt;org-roam-node-insert&lt;/code&gt;). Search for the file you want to link to and hit enter.&lt;/p&gt;
&lt;p&gt;
As your nodes grow in number, you slowly build a personal knowledge network. Org-Roam has graphing capabilities, provided you have the Graphviz package installed, which is outside the scope of this article. The &lt;a href=&#34;https://github.com/org-roam/org-roam-ui&#34;&gt;org-roam-ui&lt;/a&gt; package provides an interactive graphical interface to your node network through your browser. &lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-10&#34;&gt;
Discovering Nodes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;If you like to know which files link to the buffer you are currently editing, then use &lt;code&gt;org-rosm-buffer-toggle&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c n l&lt;/code&gt;). A new window appears with a list of all files that link to the current buffer. Move to the window with &lt;code&gt;org-open-at-point&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;C-c o&lt;/code&gt;), select your node, and hit &lt;code class=&#34;verbatim&#34;&gt;ENTER&lt;/code&gt; to open the note. To close the backlinks window, use  &lt;code class=&#34;verbatim&#34;&gt;C-c n l&lt;/code&gt; again.&lt;/p&gt;
&lt;p&gt;
My favourite function is to open a random note. Pressing &lt;code class=&#34;verbatim&#34;&gt;C-c n r&lt;/code&gt; (&lt;code&gt;org-roam-node-random&lt;/code&gt;) opens a note and invite you to take a random walk through your knowledge garden.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-11&#34;&gt;
Note Templates
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The default new node only has a property drawer and a title and the filename starts with a timestamp. You can of course change this default behaviour by setting the &lt;code class=&#34;verbatim&#34;&gt;org-roam-capture-templates&lt;/code&gt; variable.&lt;/p&gt;
&lt;p&gt;
For example, this configuration creates a new default node with a filename and a template head (&lt;code class=&#34;verbatim&#34;&gt;file+head&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;
The file name is based on the title slug (&lt;code class=&#34;verbatim&#34;&gt;${slug}.org&lt;/code&gt;), which is basically the node title in lower case, with spaces replaced by dashes.&lt;/p&gt;
&lt;p&gt;
The first lines of the head of this node contain the title, the creation date and a &lt;code class=&#34;verbatim&#34;&gt;#+lastmod:&lt;/code&gt; entry, which you can use to store the date it was last saved. To make this happen, you also set the &lt;code class=&#34;verbatim&#34;&gt;time-stamp-start&lt;/code&gt; variable.&lt;/p&gt;
&lt;p&gt;
The immediate-finish option bypasses the capture system and creates a new file without .&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-roam-capture-templates&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;d&amp;#34;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;default&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;plain&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%?&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           &lt;span style=&#34;color:#007020&#34;&gt;:if-new&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           (&lt;span style=&#34;color:#963&#34;&gt;file+head&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;${slug}.org&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                      &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#+title: ${title}\n#+date: %u\n#+lastmod: \n\n&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           &lt;span style=&#34;color:#007020&#34;&gt;:immediate-finish&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#963&#34;&gt;time-stamp-start&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#\\+lastmod: [\t]*&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The template functionality in Org-Roam is extensive, so I will leave it at this example. You can add additional lines to your node template after the title or lastmod entry in this example. The &lt;code class=&#34;verbatim&#34;&gt;\n&lt;/code&gt; indicator denotes a new line.!&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-12&#34;&gt;
Bibliographic notes with Org-Roam
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Managing a large collection of literature, electronic files and associated notes is one thing, but if you can’t quickly find them then you might as well not have them at all.&lt;/p&gt;
&lt;p&gt;
The Helm completion system provides a useful window to your bibliographies. The Helm BibTeX menu lets you search entries and act on the results. The &lt;code class=&#34;verbatim&#34;&gt;C-z&lt;/code&gt; key provides a menu for further actions, such as viewing pdf files or adding and editing notes.&lt;/p&gt;
&lt;p&gt;
Emacs will open any associated PDF files. When you select to take notes, Emacs will create a separate Org mode file for the selected reference. When you also use Org-Roam for taking notes in Emacs, then you have a complete research management system that creates hyperlinked and tagged bibliographical notes.&lt;/p&gt;
&lt;p&gt;
The setup below provides a minimal configuration that uses the folder names defined above. Use &lt;code class=&#34;verbatim&#34;&gt;C-c n B&lt;/code&gt; to start Helm BibTeX.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;helm-bibtex&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;setq&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;bibtex-completion-bibliography&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;bib-files-directory&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#963&#34;&gt;bibtex-completion-library-path&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;pdf-files-directory&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#963&#34;&gt;bibtex-completion-pdf-field&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;File&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#963&#34;&gt;bibtex-completion-notes-path&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-directory&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#963&#34;&gt;bibtex-completion-additional-search-fields&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;#39;&lt;/span&gt;(&lt;span style=&#34;color:#963&#34;&gt;keywords&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ((&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c n B&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;helm-bibtex&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The paths in the &lt;code class=&#34;verbatim&#34;&gt;file&lt;/code&gt; field in a BibTeX file can contain one or more filenames, separated by a semi-colon. When you start the filename with a colon, you can use a relative path, e.g.: &lt;code class=&#34;verbatim&#34;&gt;file = {:/path/to/article.pdf}&lt;/code&gt; is the same as &lt;code class=&#34;verbatim&#34;&gt;~/Documents/bibliography/pdf/path/to/article.pdf&lt;/code&gt;, i.e. the colon symbol stands for the content of the &lt;code class=&#34;verbatim&#34;&gt;pdf-files-directory&lt;/code&gt; variable we defined in the previous section.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;bibtex-completion-additional-search-fields&lt;/code&gt; includes the keyword as a search field, which makes it a bit easier to find stuff.&lt;/p&gt;
&lt;p&gt;
The first time you start Helm BibTeX might take a few seconds as it parses all entries in the collection of files, depending on the size of your bibliography. Just like all Helm applications, the interface uses incremental search, so just start typing and the bibliography will narrow. &lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://github.com/tmalsburg/helm-bibtex&#34;&gt;helm-bibtex website&lt;/a&gt; provides detailed information about further functionality.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-13&#34;&gt;
Org-Roam BibTex Package
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The org Roam database can also connect to a bibliography in the form of a collection of &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-bibtex-mode/&#34;&gt;BibTeX files&lt;/a&gt;. This last configuration connects your bibliography to the Org-Roam database. The Org-Roam BibTeX package allows you to create notes directly from your bibliography. The only difference between a regular note and a bibliographic one is that the properties drawer contains a citation link in the &lt;code class=&#34;verbatim&#34;&gt;ROAM_REFS&lt;/code&gt; property, as shown in the example below.&lt;/p&gt;
&lt;div class=&#34;src src-org&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-org&#34; data-lang=&#34;org&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;:PROPERTIES:
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;:ID:       c037d9f7-1aad-4774-8f8e-d5974de23b8c
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;:ROAM_REFS: cite:harris_customer_2001
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;:END:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#c00;font-weight:bold&#34;&gt;#+title&lt;/span&gt;&lt;span style=&#34;color:#888&#34;&gt;: Customer participation in retail service: Lessons from Brecht&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
You can view the associated PDF file from anywhere in the document with the &lt;code class=&#34;verbatim&#34;&gt;C-c n b&lt;/code&gt; shortcut, which will open a menu with options.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;use-package&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-roam-bibtex&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:after&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;org-roam&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;helm-bibtex&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:bind&lt;/span&gt; (&lt;span style=&#34;color:#007020&#34;&gt;:map&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;org-mode-map&lt;/span&gt; (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;C-c n b&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;.&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;orb-note-actions&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;:config&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;require&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;org-ref&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;org-roam-bibtex-mode&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-14&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-14&#34;&gt;
Taking Notes with Org Roam
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-14&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This is a short introduction to getting you started with Org-roam. There are lots of opinions on how to structure your personal knowledge network. My approach is organic, and I have imported all text files stored in various places in the Org-roam folder. I now have my third brain hemisphere available at my fingertips, thanks to the great work of the Emacs, Org mode, Org-Roam and Deft developers.&lt;/p&gt;
&lt;p&gt;
The following article in this series outlines how to manage &lt;a href=&#34;https://lucidmanager.org/productivity/emacs-bibtex-mode/&#34;&gt;bibliographies in Emacs&lt;/a&gt; and link these to Org-roam.&lt;/p&gt;
&lt;p&gt;
All the configuration explained in this series of articles is available as an init file on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-writing-studio/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-writing-studio from GitHub&#34;
   alt=&#34;Download emacs-writing-studio from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-writing-studio&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Emacs is a malleable system, so everybody will have their personal preferences for undertaking a task. Any article on how to be productive with Emacs is thus opinionated. If you have a different way of doing things, please share your views and leave a comment below, or complete the &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact form&lt;/a&gt; to send me an email.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Simulating Text Files with R to Test the Emacs Denote Package</title>
      <link>https://lucidmanager.org/productivity/testing-denote-package/</link>
      <pubDate>Thu, 28 Jul 2022 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/testing-denote-package/</guid>
      <description>
	
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/tags/emacs/&#34;&gt;Emacs&lt;/a&gt; is the most user friendly piece of software ever invented by humanity. I use it for 90% of my computing tasks, including keeping my digital knowledge garden with notes. Several notes packages exist in the Emacs ecosystem, with &lt;a href=&#34;https://www.orgroam.com/&#34;&gt;Org Roam&lt;/a&gt; as the most popular and fully-featured. I have used this package for a while now, but it relies on a database and has grown a feature set far beyond my needs.&lt;/p&gt;
&lt;p&gt;
Protesilaos (Prot) Stavrou developed the &lt;a href=&#34;https://protesilaos.com/emacs/denote&#34;&gt;Denote package&lt;/a&gt; that goes back to the basics of Emacs. The defining feature of this package is a file-naming convention that acts as metadata to find your notes. The basic structure is:&lt;/p&gt;
&lt;p&gt;
&lt;code class=&#34;verbatim&#34;&gt;YYYMMDDTHHMMSS==signature--file-name__keyword1_keyword2.extension&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
The filename starts with a timestamp at one second resolution to ensure unique file names (unless you create more than one per second). This timestamp also acts as the unique identifier to link notes.&lt;/p&gt;
&lt;p&gt;
The timestamp is followed by two dashes and the sluggified file name. Two underscores after the file name indicate the start of the keywords, separated by one underscore. Users can also add a signature, which is denoted with two equals signs.&lt;/p&gt;
&lt;p&gt;
This convention provides a convenient heuristics to find notes based on dates, title and keywords. Denote supports either Org mode, plain text or Markdown files.&lt;/p&gt;
&lt;p&gt;
The simplicity of Denote allows for it to be easily integrated with other Emacs packages and it can be easily extended with some Emacs Lisp code. My &lt;a href=&#34;https://github.com/pprevos/denote-explore&#34;&gt;Denote Explore package&lt;/a&gt; is an example of a set of auxiliary functions to help find notes.&lt;/p&gt;
&lt;p&gt;
I considered moving away from Org Roam to the monastic simplicity of Denote. But before converting my existing knowledge base, I wanted to see how it behaves with thousands of files in a single folder. Rather then converting my existing files, I decided to generate some random files to see how it performs.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Generating Random Text Files for Emacs Denote
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;My coding chops in R are much better than Emacs Lisp, so I decided to write some R code to generate random text files and take Denote through its paces.&lt;/p&gt;
&lt;p&gt;
This code uses the &lt;a href=&#34;https://boardgames.stackexchange.com/questions/38366/latest-collins-scrabble-words-list-in-text-file&#34;&gt;Collins Scrabble Word list&lt;/a&gt; to generate random file names and keywords. Download this file to your working directory before using this code. The code reads the file and generates a set of 50 keywords. Random timestamps are set somewhere in the distant future. Each file has a template for the front matter.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Simulate n files in denote folder&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Initiation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(stringr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  k &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;50&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  wordlist &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;collins-scrabble-words-2019.txt&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  wordlist &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tolower&lt;/span&gt;(words)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  tag_words &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(words&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[nchar&lt;/span&gt;(wordlist) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;], k)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  timestamps &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;Sys.time&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;600E6&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;666E6&lt;/span&gt;, n)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  template &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#+title:      &amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#+date:       &amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#+filetags:   &amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#+identifier: &amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  denote_directory &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;~/denote-sim/&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dir.create&lt;/span&gt;(denote_directory)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This next code snippet generates $n$ Org mode files in the &lt;code class=&#34;verbatim&#34;&gt;denote_directory&lt;/code&gt; folder. Titles are extracted by sampling the word list and the tags (keywords) are sampled from the $k$ defined tags. The front matter includes the tile, the creation date, keywords (called filetags in Org mode) and the identifier.&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;Lorem Ipsum&lt;/em&gt; generator in the stringr package generates some paragraphs of text. The last part of the code generates some links to random posts.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;## Generate n random posts&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt;(i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      title &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(wordlist, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)), collapse &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;-&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      tags &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(tag_words, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)), collapse &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;_&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      identifier &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;format&lt;/span&gt;(timestamps[i], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%Y%m%dT%H%M%S&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      front_matter &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(template[1],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                               &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_to_title&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(title,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                                            &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;-&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;))),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(template[2],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                               &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;[&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;format&lt;/span&gt;(timestamps[i],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                                  &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%F %a %H:%M&amp;#34;&lt;/span&gt;), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;]&amp;#34;&lt;/span&gt;)),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(template[3],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                               &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;:&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(tags,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                                           &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;_&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;:&amp;#34;&lt;/span&gt;), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;:&amp;#34;&lt;/span&gt;)),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(template[4], identifier))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      links_list &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (j &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;))) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        links_list[j] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;- &amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;[[denote:&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;format&lt;/span&gt;(timestamps, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%Y%m%dT%H%M%S&amp;#34;&lt;/span&gt;), &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;]]&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      content &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(front_matter,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                   &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                   stringi&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;stri_rand_lipsum&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                   &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                   &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;*&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_to_title&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(wordlist,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                                        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                                 collapse &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;))),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                   links_list)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      filename &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(denote_directory, identifier, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;--&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                         title, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;__&amp;#34;&lt;/span&gt;, tags, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;.org&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;writeLines&lt;/span&gt;(content, filename)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Generating thousands of files will take a few minutes …&lt;/p&gt;
&lt;p&gt;
This codes generates ten thousand notes to test the Denote package to review it if works at a large scale. This tests shows that Prot&amp;#39;s approach is perfectly capable of working with thousands of notes. Just for kicks, I also synchronised these files with an Org Roam setup. My laptop struggled with the computational load. I was unable to properly access the files as with the large number of files and struggled accessing files. So case, closed - &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-denote/&#34;&gt;I am moving to Denote&lt;/a&gt; and teach myself more Emacs Lisp to build my ideal Zettelkasten.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Postscriptum
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Since I wrote this post a few months ago I have migrated all my Org Roam notes to Denote. I migrated my 2,000 notes manually as I wanted to reread all my material and immerse myself in my old ideas to generate new ones. Paraphrasing Scocrates: gaining knowledge is the art of remembering.&lt;/p&gt;
&lt;p&gt;
Denote plays a central role in my &lt;a href=&#34;https://lucidmanager.org/tags/emacs&#34;&gt;Emacs Writing Studio&lt;/a&gt; configuration. This starter kit is specially designed for authors who have no need to develop software.&lt;/p&gt;
&lt;p&gt;
If you don&amp;#39;t feel like spending the time to migrate manually, then other Emacs enthusiasts have developed automated methods:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Jeremy Friesen, &lt;a href=&#34;https://takeonrules.com/2022/10/01/exploring-the-denote-emacs-package/&#34;&gt;Exploring the Denote Emacs Package&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Jeremy Friesen, &lt;a href=&#34;https://takeonrules.com/2022/10/02/migration-plan-for-org-roam-notes-to-denote/&#34;&gt;Migration Plan for Org-Roam Notes to Denote&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Charanjit Singh, &lt;a href=&#34;https://github.com/bitspook/notes-migrator&#34;&gt;Notes Migrator&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Plain Text Visualisation: The Emacs User Survey Results</title>
      <link>https://lucidmanager.org/productivity/emacs-user-survey-results/</link>
      <pubDate>Sat, 14 Jan 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/emacs-user-survey-results/</guid>
      <description>
	
&lt;p&gt;
The Emacs User Survey was held in &lt;a href=&#34;https://emacs-survey.netlify.app/&#34;&gt;2020&lt;/a&gt; and &lt;a href=&#34;https://emacssurvey.org/&#34;&gt;2022&lt;/a&gt;. It is a bit ironic that the data was &lt;a href=&#34;https://project-mage.org/emacs-is-not-enough&#34;&gt;neither collected nor analysed with Emacs&lt;/a&gt;. This article shows how to visualise the Emacs user survey results with plain text inside of Emacs. First, we download the CSV file and then parse it into an association list. With some bespoke functions and the quirky &lt;code class=&#34;verbatim&#34;&gt;chart&lt;/code&gt; package that forms part of core Emacs.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/emacs-survey/&#34; target=&#34;_blank&#34;
   title=&#34;Download emacs-survey from GitHub&#34;
   alt=&#34;Download emacs-survey from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;emacs-survey&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Read the cleaned CSV file
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Before visualising the data, let&amp;#39;s declare some required packages and download the 2020 Emacs user survey data.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;require&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;csv&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;require&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;f&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;require&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;dash&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;require&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;chart&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;url-copy-file&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;https://emacs-survey.netlify.app/2020/Emacs-User-Survey-2020-clean.csv&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;emacs-survey.csv&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Define some functions
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;https://gitlab.com/u11/csv.el/tree/aa1dfa1263565d5fac3879c21d8ddf5f8915e411&#34;&gt;CSV package&lt;/a&gt; by Ulf jasper provides functionality to parse a CSV file buffer into a list of alists. Unfortunately, this package has no functionality to read CSV files or extract data, so I wrote a few additional functions. Thanks to &lt;a href=&#34;https://www.reddit.com/r/emacs/comments/10bibet/comment/j4b1gcc/?context=3&#34;&gt;u/deaddyfreddy&lt;/a&gt; for helping with wrangling association lists. I initially tried chatGPT to write some elisp code, but that was a disaster. Glad to see that human intelligence still trumps the silicon variant.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;csv-parse-file&lt;/code&gt; function parses a CSV file into a list of alists. The &lt;code class=&#34;verbatim&#34;&gt;csv-extract-column-*&lt;/code&gt; functions extract the values from a column by number or header. The result of these functions is a simple list that can be visualised.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;csv-parse-file&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;file&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Read CSV FILE and parse its contents.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;with-temp-buffer&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;insert-file-contents&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;file&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#963&#34;&gt;csv-parse-buffer&lt;/span&gt; &lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;csv-extract-column-number&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;n&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;csv&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Extract values in column N from parsed CSV file into an alist.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mapcar&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;#&amp;#39;cdr&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            (&lt;span style=&#34;color:#963&#34;&gt;seq-map&lt;/span&gt; (&lt;span style=&#34;color:#007020&#34;&gt;lambda&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;list&lt;/span&gt;) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nth&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;n&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;list&lt;/span&gt;)) &lt;span style=&#34;color:#963&#34;&gt;csv&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;csv-extract-column-name&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;name&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;csv&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Extract the values in a column with NAME from parsed CSV into a list.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mapcar&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;#&amp;#39;cdr&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            (&lt;span style=&#34;color:#963&#34;&gt;seq-map&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;apply-partially&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;#&amp;#39;assoc&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;name&lt;/span&gt;) &lt;span style=&#34;color:#963&#34;&gt;csv&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Visualise the Emacs User Survey Results
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Visualising data with in plain text is a lost art. The famous &lt;a href=&#34;http://www.bigear.org/Wow30th/wow30th.htm&#34;&gt;WOW signal&lt;/a&gt; is our best candidate for a signal from an extraterrestrial civilisation. No fancy visualisations like we are used from radio astronomy, but a simple plain text data stream printed on chain paper. Computer users were creative with plain text and there is still a cult following of &lt;a href=&#34;https://www.asciiart.eu/&#34;&gt;ASCII art&lt;/a&gt;, images that only use plain text characters.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;http://www.bigear.org/Wow30th/wowcl.jpg&#34; alt=&#34;Wow signal.&#34; title=&#34;Wow signal.&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Wow Signal (North American Astrophysical Observatory).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
We are now spoilt with graphical displays, but there are still some packages that can visualise data with plain text, including Eric Ludlam&amp;#39;s &lt;a href=&#34;https://francismurillo.github.io/2017-04-15-Exploring-Emacs-chart-Library/&#34;&gt;chart package&lt;/a&gt;. This code can draw coloured bar charts in plain text. The &lt;code class=&#34;verbatim&#34;&gt;chart-bar-quicky&lt;/code&gt; function takes several arguments, most notably the &lt;em&gt;x&lt;/em&gt; and &lt;em&gt;y&lt;/em&gt; variables for the chart. The &lt;em&gt;n&lt;/em&gt; variable declares the number of bars to draw. We need some more helper functions to visualise the CSV data.&lt;/p&gt;
&lt;p&gt;
We want the bar height to count each unique item, so we also need a function to create a ordered frequency table. The &lt;code class=&#34;verbatim&#34;&gt;visualose-frequency-table&lt;/code&gt; mashes everything together to create a bar chart.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;create-frequency-table&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;data&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Generate an ordered frequency table from DATA.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sort&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;-frequencies&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;data&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#007020&#34;&gt;lambda&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;gt;&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cdr&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt;) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cdr&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;)))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;visualise-frequency-table&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;table&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;n&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;title&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Create a bar chart from a frequency TABLE with top N entries.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;  VAR and TITLE used for display.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;chart-bar-quickie&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;horizontal&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#963&#34;&gt;title&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mapcar&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;#&amp;#39;car&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;table&lt;/span&gt;) &lt;span style=&#34;color:#963&#34;&gt;var&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mapcar&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;#&amp;#39;cdr&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;table&lt;/span&gt;) &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Frequency&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;n&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Now we are ready to visualise the data. Parsing the data can take a few moments as it contains thousands of results. The bar chart will pop up in a new buffer.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;emacs-survey&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#963&#34;&gt;csv-parse-file&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;emacs-survey.csv&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;visualise-frequency-table&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   (&lt;span style=&#34;color:#963&#34;&gt;create-frequency-table&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;csv-extract-column-number&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;6&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;emacs-survey&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Responses&amp;#34;&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Which version of Emacs do you primarily use?&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/emacs-survey-2020-question-5.png&#34; alt=&#34;/images/emacs/emacs-survey-2020-question-5.png&#34; title=&#34;/images/emacs/emacs-survey-2020-question-5.png&#34; /&gt;&lt;figcaption&gt;
Results of question six of the 2020 Emacs user Survey.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Conclusion
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Visualising data with plain text is less aesthetic than using graphics, but it does the job of telling the story, which is the purpose of visualisation. There are other methods to create graphics inside an Emacs buffer. For example, one could use a &lt;a href=&#34;https://irreal.org/blog/?p=10199&#34;&gt;literate programming approach&lt;/a&gt; and write an Org Mode file and run R, Python, MATLAB or GNUPLot code to create graphics. The latter also has an option to create graphics in plain text.&lt;/p&gt;
&lt;p&gt;
Let&amp;#39;s hope the following Emacs user survey will be more Emacs-centric in its&amp;#39;s data collection and presenting the results.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Emacs LISP exercises in Structure and Interpretation of Computer Programs: Section 1.1</title>
      <link>https://lucidmanager.org/productivity/elisp-scip-1-1/</link>
      <pubDate>Tue, 12 Jan 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/elisp-scip-1-1/</guid>
      <description>
	
&lt;p&gt;
This article contains proposed solutions to the exercises in section 1.1 of  &lt;em&gt;Structure and Interpretation of Computer Programs&lt;/em&gt; (SICP) by Abelson, Sussman and Sussman. MIT hosts video lectures to accompany the book on &lt;a href=&#34;https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/&#34;&gt;MIT OpenCourseWare&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The textbook uses the Scheme dialect of Lisp. I have written these solutions to help me learn Emacs Lisp (Elisp). Some of the solutions are derived from the work by &lt;a href=&#34;https://github.com/sarabander/p2pu-sicp&#34;&gt;Andres Raba&lt;/a&gt;. Most of the solutions include links to the online version of the &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/elisp.html&#34;&gt;GNU Emacs Lisp Reference Manual&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Chapter 1: The Elements of Programming
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The first chapter of the textbook introduces the elements of the Lisp language. Harold Abelson starts the lecture with the interesting statement that computer science is neither a science, nor is it about computers, just like physics is not about particle accelerators. &lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/-J_xL4IGhJA?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Lecture 1A: Overview and Introduction to Lisp.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The first 28 minutes are an introduction to computer programming, after which the LISP lecture starts.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Exercise 1.1
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Below is a sequence of expressions. What is the result printed by the interpreter in response to each expression? Assume that the sequence is to be evaluated in the order in which it is presented.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Answer
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;In Emacs, you can type this code in the scratch buffer and evaluate an expression with the &lt;code class=&#34;verbatim&#34;&gt;eval-last-sexp&lt;/code&gt; function or the &lt;code class=&#34;verbatim&#34;&gt;C-x C-e&lt;/code&gt; keyboard shortcut, placing the cursor after the end of the expression. The &lt;code class=&#34;verbatim&#34;&gt;eval-last-sexp&lt;/code&gt; function evaluates the last expression before the cursor (point). The results will appear in the minibuffer at the bottom of the screen.&lt;/p&gt;
&lt;p&gt;
Emacs also has a REPL (Read-Eval-Print Loop), which you can access with &lt;code class=&#34;verbatim&#34;&gt;M-x ielm&lt;/code&gt;. In REPL mode, the results appear below the expression after you hit enter.&lt;/p&gt;
&lt;p&gt;
Emacs provides the result in decimal numbers. The output between parenthesis is the result in octal (&lt;code class=&#34;verbatim&#34;&gt;#o&lt;/code&gt;) and hexadecimal (&lt;code class=&#34;verbatim&#34;&gt;#x&lt;/code&gt;) numeral system, e.g.: &lt;code class=&#34;verbatim&#34;&gt;1969 (#o3661, #x7b1)&lt;/code&gt;. For values below 128, the output also includes an associated character, e.g. &lt;code class=&#34;verbatim&#34;&gt;26 (#o32 #x1a ?\C-z)&lt;/code&gt;, where z is the character 26 in &lt;a href=&#34;https://en.wikipedia.org/wiki/ASCII&#34;&gt;ASCII&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The code below shows the solutions in the comments after the expressions. The first lines demonstrate &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/elisp/Arithmetic-Operations.html&#34;&gt;Arithmetic Operations&lt;/a&gt; in Emacs Lisp. Lisp uses &lt;a href=&#34;https://en.wikipedia.org/wiki/Polish_notation&#34;&gt;Polish notation&lt;/a&gt; to resolve mathematical expressions. In this system, the operatore precede the operands, e.g. &lt;code class=&#34;verbatim&#34;&gt;+ 3 4&lt;/code&gt; is the same as $3+4$ in &lt;a href=&#34;https://en.wikipedia.org/wiki/Infix_notation&#34;&gt;infix notation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The second set of expressions demonstrates &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/elisp/Setting-Variables.html&#34;&gt;setting variable values&lt;/a&gt;. The &lt;code class=&#34;verbatim&#34;&gt;setq&lt;/code&gt; function sets universal variables. The q relates to the fact that the variable name is quoted. Without quoting the variable (the &lt;code class=&#34;verbatim&#34;&gt;set&lt;/code&gt; function), Emacs will evaluate the name of the variable as a function and cause an error. You can also add a quotation mark to prevent Emacs from evaluating an expression. The following two expressions have the same result:&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Equivalent expressions&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;set&lt;/span&gt; &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;a&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;10&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Emacs is a self-documenting editor and you can document your programming on the fly. The &lt;code class=&#34;verbatim&#34;&gt;defvar&lt;/code&gt; function allows you to define a new variable plus a documentation string. This function is helpful when the variable will be available to other users. The help string that you define is available through the help function with the &lt;code class=&#34;verbatim&#34;&gt;C-h v&lt;/code&gt; shortcut.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Arithmetic operations&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;; =&amp;gt; 10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;5&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;4&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;; =&amp;gt; 12&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;9&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;; =&amp;gt; 8&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;6&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;; =&amp;gt; 3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;4&lt;/span&gt;) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;4&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;6&lt;/span&gt;)) &lt;span style=&#34;color:#888&#34;&gt;; =&amp;gt; 10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Seting variable names&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;3&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;setq&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defvar&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;example&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;An example of a documented variable.&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;)) &lt;span style=&#34;color:#888&#34;&gt;; =&amp;gt; 19&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;; =&amp;gt; nil&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
These last lines of code look provide an example of basic &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/elisp/Conditionals.html&#34;&gt;conditionals&lt;/a&gt;. The first expression is a an if-then-else statement. The second expression is a conditional. The last clause is executed when none of the other conditions is true. The &lt;code class=&#34;verbatim&#34;&gt;t&lt;/code&gt; parameter ensures that this expression is always evaluated.&lt;/p&gt;
&lt;div class=&#34;src src-emacs-lisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;;; Conditionals&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#007020&#34;&gt;and&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt;) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;;; =&amp;gt; 4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;cond&lt;/span&gt; ((&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;4&lt;/span&gt;) &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;6&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          ((&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;4&lt;/span&gt;) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;6&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;7&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;25&lt;/span&gt;)) &lt;span style=&#34;color:#888&#34;&gt;;;=&amp;gt; 16&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; (&lt;span style=&#34;color:#007020&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt;) &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt;)) &lt;span style=&#34;color:#888&#34;&gt;; =&amp;gt; 6&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#007020&#34;&gt;cond&lt;/span&gt; ((&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;) &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             ((&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;) &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             (&lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;-1&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;)) &lt;span style=&#34;color:#888&#34;&gt;;; =&amp;gt; 16&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Exercise 1.2
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Translate the following expression into prefix form:&lt;/p&gt;
&lt;p&gt;
$$\frac{5 + 4 + (2 - (3 - (6 + \frac{5}{4})))}{3(6 - 2)(2 - 7)}$$&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Answer
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;When Emacs Lisp divides two integers, the outcome will also be integer, e.g. &lt;code class=&#34;verbatim&#34;&gt;(/ 22 7)&lt;/code&gt; results in 3 instead of 3.142… To force a floating point output, add a decimal to one of the parameters: &lt;code class=&#34;verbatim&#34;&gt;(/ 22 7.0)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
Elisp can evaluate this expression in a single line, but it becomes hard to read.  This example demonstrates the multitude of parenthesis in Lisp expressions. Some people jokingly suggest that Lisp means “Lots of Irritating Superfluous Parentheses”. The &lt;a href=&#34;https://github.com/Fuco1/smartparens&#34;&gt;smartparens&lt;/a&gt; package can help you write code.&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://en.wikipedia.org/wiki/Prettyprint&#34;&gt;Prettyprinting&lt;/a&gt; is a way to format source code to make it easier for human readers to understand. In Emacs, you can convert a convoluted expression to prettyprinting with the &lt;code class=&#34;verbatim&#34;&gt;pp-macroexpand-last-sexp&lt;/code&gt; function. Run this function at the end of an expression, and the &lt;code class=&#34;verbatim&#34;&gt;pp&lt;/code&gt; package, the pretty printer for Emacs Lisp, will provide a better formatted version.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;/&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;5&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;4&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;3&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;6&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4.0&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;5&lt;/span&gt;))))) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;3&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;6&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; ) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;7&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Pretty printing (pp-macroexpand-last-sexp)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;/&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;5&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;6&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4.0&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;5&lt;/span&gt;)))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;6&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; )
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;7&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Exercise 1.3
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Answer
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;code class=&#34;verbatim&#34;&gt;defun&lt;/code&gt; declares a new &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/elisp/Functions.html&#34;&gt;function in Emacs Lisp&lt;/a&gt;. The name of the function appears after &lt;code class=&#34;verbatim&#34;&gt;defun&lt;/code&gt; and its parameters are listed between parentheses. The quoted string on the next line is the documentation. The doc string will be accessible via the Emacs help functions.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;square&lt;/code&gt; function returns the square of a number and the &lt;code class=&#34;verbatim&#34;&gt;sum-of-squares&lt;/code&gt; helper function produces the sum of squares. The main function determines the two largest numbers of three and provides the sum of their squares..&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Exercise 1.3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;square&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Squaring a number&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;sum-of-squares&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Sum the squares of two numbers&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#963&#34;&gt;square&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#963&#34;&gt;square&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;largest-sum-of-squares&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;c&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Find the largest sum of squares for two out of three numbers&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;cond&lt;/span&gt; ((&lt;span style=&#34;color:#007020&#34;&gt;and&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;c&lt;/span&gt;)) (&lt;span style=&#34;color:#963&#34;&gt;sum-of-squares&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;c&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          ((&lt;span style=&#34;color:#007020&#34;&gt;and&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt;) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;c&lt;/span&gt;)) (&lt;span style=&#34;color:#963&#34;&gt;sum-of-squares&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;c&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;sum-of-squares&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;largest-sum-of-squares&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;5&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;largest-sum-of-squares&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;5&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;largest-sum-of-squares&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;5&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;3&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The three functions are bow available through the whole Emacs session. The variables are only available within each function (&lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/elisp/Variable-Scoping.html&#34;&gt;scoping rules&lt;/a&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Exercise 1.4
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Observe that our model of evaluation allows for combinations whose operators are compound expressions. Use this observation to describe the behavior of the following procedure:&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a-plus-abs-b&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;funcall&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (&lt;span style=&#34;color:#007020&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       &lt;span style=&#34;color:#a60;background-color:#fff0f0&#34;&gt;&amp;#39;-&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;a-plus-abs-b&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;-20&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
Answer
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The function evaluates as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If &lt;code class=&#34;verbatim&#34;&gt;b&lt;/code&gt; is positive, the function evaluates &lt;code class=&#34;verbatim&#34;&gt;(+ a b)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;If &lt;code class=&#34;verbatim&#34;&gt;b&lt;/code&gt; is negative, the function evaluates &lt;code class=&#34;verbatim&#34;&gt;(- a b)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code class=&#34;verbatim&#34;&gt;funcall&lt;/code&gt; evaluates the expression &lt;code class=&#34;verbatim&#34;&gt;(if (&amp;gt; b 0) &amp;#39;+ &amp;#39;-))&lt;/code&gt; and uses the result (either + or -) as a function. The quote is needed to ensure the &lt;code class=&#34;verbatim&#34;&gt;+&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;-&lt;/code&gt; are not evaluated in the conditional.&lt;/p&gt;
&lt;p&gt;
The original Scheme implementation used in the book and lectures did not use a function call. Scheme is a Lisp-1 and Emacs Lisp is Lisp-2. In scheme names and procedures are located in the same namespace, so it is possible to return a procedure name from a condition and evaluate it. In Lisp-2, procedures have their own namespace, so in order to call procedure from name you have to use &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/elisp/Calling-Functions.html&#34;&gt;funcal&lt;/a&gt; (Source: &lt;a href=&#34;https://www.reddit.com/r/emacs/comments/g89q2y/learning_elisp_need_some_help/&#34;&gt;/u/andreyorst&lt;/a&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-10&#34;&gt;
Exercise 1.5
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Ben Bitdiddle has invented a test to determine whether the interpreter he is faced with is using &lt;a href=&#34;https://en.wikipedia.org/wiki/Evaluation_strategy#Comparison_of_applicative_order_and_normal_order_evaluation&#34;&gt;applicative-order evaluation or normal-order evaluation&lt;/a&gt;. He defines the following two procedures:&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;p&lt;/span&gt; () (&lt;span style=&#34;color:#963&#34;&gt;p&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;test&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;y&lt;/span&gt;) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;0&lt;/span&gt;) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;0&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#963&#34;&gt;y&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Then he evaluates the expression:&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#963&#34;&gt;test&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;0&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;p&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
What behavior will Ben observe with an interpreter that uses applicative-order evaluation? What behavior will he observe with an interpreter that uses normal-order evaluation? Explain your answer. (Assume that the evaluation rule for the special form if is the same whether the interpreter is using normal or applicative order: The predicate expression is evaluated first, and the result determines whether to evaluate the consequent or the alternative expression.)&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-11&#34;&gt;
Answer
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-3&#34;&gt;
&lt;ul&gt;
&lt;li&gt;Applicative order: The function call results in an infinite loop, as the function &lt;code class=&#34;verbatim&#34;&gt;p&lt;/code&gt; calls itself (Emacs&amp;#39; behaviour).&lt;/li&gt;
&lt;li&gt;Normal order: The function never reaches &lt;code class=&#34;verbatim&#34;&gt;p&lt;/code&gt; because it exits with 0 as a result.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-12&#34;&gt;
Exercise 1.6
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Alyssa P. Hacker doesn&amp;#39;t see why &lt;code class=&#34;verbatim&#34;&gt;if&lt;/code&gt; needs to be provided as a special form. “Why can’t I just define it as an ordinary procedure in terms of &lt;code class=&#34;verbatim&#34;&gt;cond&lt;/code&gt;?” she asks. Alyssa’s friend Eva Lu Ator claims this can indeed be done, and she defines a new version of if:&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;new-if&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;predicate&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;then-clause&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;else-clause&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;cond&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;predicate&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;then-clause&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#036;font-weight:bold&#34;&gt;t&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;else-clause&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Eva demonstrates the program for Alyssa:&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#963&#34;&gt;new-if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;3&lt;/span&gt;) &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;5&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#963&#34;&gt;new-if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;5&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Delighted, Alyssa uses new-if to rewrite the square-root program:&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;sqrt-iter&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;new-if&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;good-enough?&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#963&#34;&gt;sqrt-iter&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;improve&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;) &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
What happens when Alyssa attempts to use this to compute square roots? Explain.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-13&#34;&gt;
Answer
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-3&#34;&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;square&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;good-enough?&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;lt;&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;square&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;) &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;)) &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.001&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;average&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;/&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;b&lt;/span&gt;) &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2.0&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;improve&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#963&#34;&gt;average&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;sqrt-iter&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#963&#34;&gt;new-if&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;good-enough?&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              (&lt;span style=&#34;color:#963&#34;&gt;sqrt-iter&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;improve&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;sqrt-iter&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.0&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#963&#34;&gt;average&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;12&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;13&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The version with &lt;code class=&#34;verbatim&#34;&gt;new-if&lt;/code&gt; function crashes because of a nesting error (&lt;code class=&#34;verbatim&#34;&gt;Lisp nesting exceeds ‘max-lisp-eval-depth&lt;/code&gt;). The &lt;code class=&#34;verbatim&#34;&gt;sqrt&lt;/code&gt; function works fine with the regular &lt;code class=&#34;verbatim&#34;&gt;if&lt;/code&gt; function.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-14&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-14&#34;&gt;
Exercise 1.7
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-14&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;code class=&#34;verbatim&#34;&gt;good-enough?&lt;/code&gt; test used in computing square roots will not be effective for finding the square roots of very small numbers. Also, in real computers, arithmetic operations are almost always performed with limited precision. This makes our test inadequate for huge numbers.&lt;/p&gt;
&lt;p&gt;
Explain these statements, with examples showing how the test fails for small and large numbers. An alternative strategy for implementing &lt;code class=&#34;verbatim&#34;&gt;good-enough?&lt;/code&gt;,is to watch how guess changes from one iteration to the next and to stop when the change is a very small fraction of the guess.&lt;/p&gt;
&lt;p&gt;
Design a square-root procedure that uses this kind of end test. Does this work better for small and large numbers?&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-15&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-15&#34;&gt;
Answer
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-15&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The &lt;code class=&#34;verbatim&#34;&gt;float&lt;/code&gt; function forces floating point answers. See Elisp manual about &lt;a href=&#34;https://www.gnu.org/software/emacs/manual/html_node/elisp/Numeric-Conversions.html&#34;&gt;Numeric Conversions&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Exercise 1.7&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;sqrt-heron&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Determine a square root using Heron’s method.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;avg&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;y&lt;/span&gt;) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;/&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;float&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;) &lt;span style=&#34;color:#963&#34;&gt;y&lt;/span&gt;) &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;) (&lt;span style=&#34;color:#007020&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;0&lt;/span&gt;) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;) &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt; ))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;improve&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#963&#34;&gt;avg&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;good-enough?&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;next-guess&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;lt;&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;next-guess&lt;/span&gt;)) &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1e-20&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;try&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#007020&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;good-enough?&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;improve&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#963&#34;&gt;try&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;improve&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#963&#34;&gt;try&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.0&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;sqrt-heron&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;1234567890&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;sqrt-heron&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1e-5&lt;/span&gt;) (&lt;span style=&#34;color:#963&#34;&gt;sqrt-heron&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1e-5&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-16&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-16&#34;&gt;
Exercise 1.8
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-16&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Newton’s method for cube roots is based on the fact that if $y$ is an approximation to the cube root of $x$, then a better approximation is given by the value:&lt;/p&gt;
&lt;p&gt;
$$\frac{x/y^2 +2y}{3}$$&lt;/p&gt;
&lt;p&gt;
Use this formula to implement a cube-root procedure analogous to the square-root procedure.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-17&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-17&#34;&gt;
Answer
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-17&#34; class=&#34;outline-text-3&#34;&gt;
&lt;div class=&#34;src src-elisp&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;;; Exercise 1.8&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;cube-root-newton&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Newton’s method for cube roots&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;) (&lt;span style=&#34;color:#007020&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;0&lt;/span&gt;) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt;) &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt; ))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;improve&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;/&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;+&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;x&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;)) (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;)) &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3.0&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;good-enough?&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;next-guess&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;&amp;lt;&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;next-guess&lt;/span&gt;)) &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1e-20&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#007020&#34;&gt;defun&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;try&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          (&lt;span style=&#34;color:#007020&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;good-enough?&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;improve&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              (&lt;span style=&#34;color:#963&#34;&gt;try&lt;/span&gt; (&lt;span style=&#34;color:#963&#34;&gt;improve&lt;/span&gt; &lt;span style=&#34;color:#963&#34;&gt;guess&lt;/span&gt;))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#963&#34;&gt;try&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.0&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;cube-root-newton&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;4&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;4&lt;/span&gt; &lt;span style=&#34;color:#00d;font-weight:bold&#34;&gt;4&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#963&#34;&gt;cube-root-newton&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1e-5&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Visualise and Analyse Bathymetric Survey Data with R</title>
      <link>https://lucidmanager.org/data-science/analyse-bathymetric-survey/</link>
      <pubDate>Sun, 14 Dec 2025 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/analyse-bathymetric-survey/</guid>
      <description>
	
&lt;p&gt;
The first step in the value chain for water utilities is extracting water from natural sources, such as rivers, groundwater, oceans, or reservoirs. Water managers and the public alike are interested in knowing how much water a reservoir currently holds. This is not an easy problem to solve, as it requires some analysis to move from survey to volume measurement. This article shows how to visualise and analyse bathymetric survey data using the R language and data from the Prettyboy Reservoir in Maryland, USA.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Prettyboy reservoir
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;While searching the web for a publicly available bathymetric survey, I stumbled across the Maryland Geological Survey (MGS) website. This organisation investigates the geology and water resources of the American state of Maryland. The Prettyboy Reservoir helps provide water for nearly two million residents in Baltimore City and parts of five neighbouring Maryland counties.&lt;/p&gt;
&lt;p&gt;
The MGS publishes bathymetric data for their reservoirs, including the &lt;a href=&#34;http://www.mgs.md.gov/coastal_geology/prettyboy.html&#34;&gt;Prettyboy reservoir&lt;/a&gt; in the county of Baltimore.&lt;/p&gt;
&lt;figure&gt;
&lt;iframe width=&#34;600&#34; height=&#34;400&#34; style=&#34;height:400px !important; border:0;&#34; frameborder=&#34;0&#34; scrolling=&#34;no&#34; marginheight=&#34;0&#34; marginwidth=&#34;0&#34; src=&#34;https://www.openstreetmap.org/export/embed.html?bbox=-76.79778099%2C39.60%2C-76.684%2C39.66709406770333&amp;amp;layer=mapnik&amp;amp;marker=39.6371580705754%2C-76.74113273620605&#34; style=&#34;border: 0px solid black&#34;&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;small&gt;&lt;a href=&#34;https://www.openstreetmap.org/?mlat=39.6372&amp;amp;mlon=-76.7411#map=14/39.6372/-76.7411&#34; target=&#34;_blank&#34;&gt;View Larger Map&lt;/a&gt;&lt;/small&gt;
&lt;figcaption&gt;
Pretty Boy reservoir in Maryland.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Extract, Transfer and Load
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;http://www.mgs.md.gov/publications/data_pages/reservoir_bathymetry.html&#34;&gt;Maryland Geological Survey website&lt;/a&gt; hosts the raw data as a zipped CSV file with a double header. The file has a double header, the first row contains the field names and the second row the units. The data has three columns:&lt;/p&gt;
&lt;figure&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th class=&#34;align-right&#34;&gt;Easting&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;Northing&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;Depth&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;th class=&#34;align-right&#34;&gt;UTM-NAD83-Meters&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;UTM-NAD83-Meters&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;Feet&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&#34;align-right&#34;&gt;352606.8&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;4386507&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;9.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;align-right&#34;&gt;352606.8&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;4386507&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;8.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&#34;align-right&#34;&gt;352606.5&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;4386507&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;11.4&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;figcaption&gt;
Prettyboy reservoir bathymetry data structure.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The Easting and Northing are in the Universal Transverse Mercator projection. As a demonstration of unit confusion, the reservoir&amp;#39;s depth in feet. As usual in bathymetry surveys, depth is measured from the datum as a positive number. The zero datum is the reservoir&amp;#39;s Full Supply Level.&lt;/p&gt;
&lt;p&gt;
The script below extracts, transforms and loads (ETL) the data. The file contains duplicates and a zero point at each of the four corners, which are removed from the data. This leaves us a clean file to work from.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Bathymetry visualisation and analysis&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# libraries&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(RColorBrewer)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rm&lt;/span&gt;(list &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ls&lt;/span&gt;())
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Data source&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# http://www.mgs.md.gov/publications/data_pages/reservoir_bathymetry.html&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;file.exists&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/PrettyBoy1998.dat&amp;#34;&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;download.file&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;http://www.mgs.md.gov/output/reservoir_bathy/PrettyBoy1998.zip&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  destfile &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/prettyboy-1998.zip&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unzip&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/prettyboy-1998.zip&amp;#34;&lt;/span&gt;, exdir &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;file.remove&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/prettyboy-1998.zip&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Read data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  rawdata &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read.csv&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/PrettyBoy1998.dat&amp;#34;&lt;/span&gt;, skip &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  fsl &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;145&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Full Supply Level&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Data cleaning&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  prettyboy &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; rawdata &lt;span style=&#34;color:#333&#34;&gt;|&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rename&lt;/span&gt;(easting &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, northing &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;, depth_ft &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;|&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;duplicated&lt;/span&gt;(rawdata) &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;(easting &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;range&lt;/span&gt;(easting))) &lt;span style=&#34;color:#333&#34;&gt;|&amp;gt;&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(depth_m &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; depth_ft &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.304&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Visualise the Data
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This visualisation shows the lines that the survey vessel sailed to capture the sonar soundings. The edge of the reservoir was measured with a terrestrial survey and has a depth of zero.&lt;/p&gt;
&lt;p&gt;
The code defines a colour palette for this data using green and blue. The colours combine two palettes from the green and blue palettes so that only zero values are green and positive values are blue.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Basic Visualisation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  bathymetry_colours &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rev&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;brewer.pal&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Greens&amp;#34;&lt;/span&gt;))[&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-3&lt;/span&gt;], 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;brewer.pal&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Blues&amp;#34;&lt;/span&gt;)[&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-3&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(prettyboy) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(easting, northing, colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; depth_m) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_x_continuous&lt;/span&gt;(labels &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; scales&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;label_comma&lt;/span&gt;()) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_y_continuous&lt;/span&gt;(labels &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; scales&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;label_comma&lt;/span&gt;()) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_equal&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Depth [m]&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_colour_gradientn&lt;/span&gt;(colors &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; bathymetry_colours) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Prettyboy Reservoir Bathymetry (1988)&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         caption &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Source: Maryland Geological Survey&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Easting (UTM NAD83)&amp;#34;&lt;/span&gt;, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Northing (UTM NAD83)&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_minimal&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/prettyboy-bathymetry.png&#34; alt=&#34;Prettyboy Reservoir bathymetry&#34; title=&#34;Prettyboy Reservoir bathymetry&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Prettyboy Reservoir bathymetry.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Mapping the data
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The coordinates are provided in the North American UTM / NAD83 projection. To map this survey data onto a map tile, we need to convert these to longitude and latitudes for the WGS84 spheroid.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://r-spatial.github.io/sf/&#34;&gt;SF (Simple Features) package&lt;/a&gt; converts the coordinates for use in Google maps. To achieve this we need the CRS (Coordinate Reference System) with number 26918, as Maryland is in zone 18N: &lt;a href=&#34;https://spatialreference.org/ref/epsg/26918/&#34;&gt;EPSG:26918 NAD83 / UTM zone 18N&lt;/a&gt;. The second CRS (4326) is the system used by Google maps: &lt;a href=&#34;https://spatialreference.org/ref/epsg/4326/&#34;&gt;EPSG:4326 WGS 84&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
We can now plot the data on a Google Maps tile using the &lt;a href=&#34;https://cran.r-project.org/web/packages/ggmap/index.html&#34;&gt;ggmap package&lt;/a&gt;. This functionality requires a Google API key, which I am not sharing here. You can also use this data in other spatial systems, such as the interactive tooling in &lt;a href=&#34;https://r-charts.com/spatial/interactive-maps-leaflet/&#34;&gt;the Leaflet package&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Spatial mapping&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(sf)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Convert prettyboy tibble to an sf object&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  prettyboy_sf &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;st_as_sf&lt;/span&gt;(prettyboy,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                           coords &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;easting&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;northing&amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                           crs &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;26918&lt;/span&gt;)   &lt;span style=&#34;color:#888&#34;&gt;# NAD83 / UTM zone 18N&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Transform to latitude/longitude (WGS84)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  prettyboy_wgs &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;st_transform&lt;/span&gt;(prettyboy_sf, crs &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4326&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Convert back to tibble with lat/lon columns&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  coords &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;st_coordinates&lt;/span&gt;(prettyboy_wgs)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  prettyboy_wgs &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cbind&lt;/span&gt;(prettyboy_wgs, coords) &lt;span style=&#34;color:#333&#34;&gt;|&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rename&lt;/span&gt;(lon &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; X, lat &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; Y) &lt;span style=&#34;color:#333&#34;&gt;|&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;st_drop_geometry&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggmap)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Register Google Maps API&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  api &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/google-maps.api&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;register_google&lt;/span&gt;(key &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; api)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  prettyboy_map &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;get_map&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mean&lt;/span&gt;(prettyboy_wgs&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon), 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                             &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mean&lt;/span&gt;(prettyboy_wgs&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lat)),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                           zoom &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;14&lt;/span&gt;, color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;bw&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggmap&lt;/span&gt;(prettyboy_map, extent &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;device&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as_tibble&lt;/span&gt;(prettyboy_wgs), 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(lon, lat, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; depth_m), size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_colour_gradientn&lt;/span&gt;(colors &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; bathymetry_colours, name &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Depth [m]&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Prettyboy Reservoir Bathymetry (1988)&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         caption &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Source: Maryland Geological Survey&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/prettyboy-bathymetry-map.png&#34; alt=&#34;Prettyboy bathymetry on Google map tile&#34; title=&#34;Prettyboy bathymetry on Google map tile&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Prettyboy bathymetry on Google map tile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Analyse Bathymetric Survey: Full Supply Volume
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Two methods are available to estimate the total volume of a reservoir using bathymetric data. The analogue method uses contour lines to draw cross-sections on graph paper at regular intervals. Then use a &lt;a href=&#34;https://en.wikipedia.org/wiki/Planimeter&#34;&gt;planimeter&lt;/a&gt; or the &lt;a href=&#34;https://en.wikipedia.org/wiki/Shoelace_formula&#34;&gt;shoelace formula&lt;/a&gt; to measure the surface area of each section and calculate the total volume by multiplying the surface area by the spacing between sections. I used this method more than thirty years ago when working on dredging projects. But technology has moved on.&lt;/p&gt;
&lt;p&gt;
The second method is more numeric, and there are two methods: interpolate a grid or build a Triangular Irregular Network.&lt;/p&gt;
&lt;p&gt;
The bathymetry provides data only for the lines on the map, as visualised above. To estimate the full supply analytically, we can overlay the reservoir with a grid and interpolate the depth for each cell. We can then estimate the Full Supply Volume by summing the product of each cell area and depth for each grid item. When we have a grid with &lt;em&gt;n&lt;/em&gt; elements, and &lt;em&gt;x&lt;/em&gt; and &lt;em&gt;y&lt;/em&gt; indicate the element size and &lt;em&gt;d&lt;sub&gt;i&lt;/sub&gt;&lt;/em&gt; the depth of an element, the volume is calculated with:&lt;/p&gt;
&lt;p&gt;
$$V = \sum_{i=1}^{n} {x \times y \times d_i}$$&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://cran.r-project.org/web/packages/akima/index.html&#34;&gt;akima package&lt;/a&gt; provides functionality for interpolation of irregularly and regularly spaced data, making it ideal for our problem. First, we set the spacing to 10 meters. The smaller the interval, the more accurate the estimation. But small spacing comes at a cost, as the interpolation will take some time to finalise.&lt;/p&gt;
&lt;p&gt;
Once we have a grid with a depth for each location, we can estimate the Full Supply Volume by multiplying each location&amp;#39;s depth by its grid area and summing across all grids.&lt;/p&gt;
&lt;p&gt;
This analysis provides a volume of  71.50 × 10&lt;sup&gt;6&lt;/sup&gt; m&lt;sup&gt;3&lt;/sup&gt;, which is close to the 19 billion US gallons (71.92 × 10&lt;sup&gt;6&lt;/sup&gt; m&lt;sup&gt;3&lt;/sup&gt;) reported by the Maryland Geological Survey.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Extrapolate gridded version&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(akima)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Grid size [m]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  dx &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  dy &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Regular grid coordinates&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  x_seq &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;min&lt;/span&gt;(prettyboy&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;easting), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(prettyboy&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;easting), by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; dx)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  y_seq &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;min&lt;/span&gt;(prettyboy&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;northing), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(prettyboy&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;northing), by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; dy)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Interpolate scattered (x, y, depth) -&amp;gt; regular grid&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# no extrapolation outside convex hull&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  interp_res &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;with&lt;/span&gt;(prettyboy,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                     &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;interp&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; easting,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                            y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; northing,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                            z &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; depth_m,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                            xo &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; x_seq,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                            yo &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; y_seq,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                            duplicate &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;strip&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                            linear &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                            extrap &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Volume&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  prettyboy_grid &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;interp2xyz&lt;/span&gt;(interp_res, data.frame &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;|&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as_tibble&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;|&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rename&lt;/span&gt;(easting &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; x, northing &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; y, depth_m &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; z)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  grid_volume_m3 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(prettyboy_grid&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;depth_m &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; dx &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; dy, na.rm &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  grid_volume_m3 &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;^6&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
We can use the interpolated values to create a nice map of the reservoir with contour lines and cross-sections. The cross sections are taken at four random points in the grid.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Visualise Cross sections&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;set.seed&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1234&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;northing_sections &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(prettyboy_grid&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;northing, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;prettyboy_sections &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(prettyboy_grid, northing &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; northing_sections)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;max_depth &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;round&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(prettyboy_sections&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;depth_m, na.rm &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;map &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(prettyboy_grid)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(easting, northing) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_raster&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; depth_m), interpolate &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_contour&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(z &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; depth_m), colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;, alpha &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.4&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_hline&lt;/span&gt;(yintercept &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; northing_sections, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;orange&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_equal&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_x_continuous&lt;/span&gt;(labels &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; scales&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;label_comma&lt;/span&gt;()) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_y_continuous&lt;/span&gt;(labels &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; scales&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;label_comma&lt;/span&gt;()) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_fill_gradientn&lt;/span&gt;(
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    colours &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;, bathymetry_colours[&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;]),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    na.value &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;transparent&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    guide &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;guide_colourbar&lt;/span&gt;(reverse &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    name &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Depth [m]&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_minimal&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;28&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Prettyboy Reservoir&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       caption &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Source: Maryland Geological Survey&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Easting [m]&amp;#34;&lt;/span&gt;, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Northing [m]&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme&lt;/span&gt;(legend.position &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;bottom&amp;#34;&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        legend.key.width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unit&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#39;cm&amp;#39;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;sections &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(prettyboy_sections) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(easting, (fsl &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; depth_m)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_area&lt;/span&gt;(fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; bathymetry_colours[1], alpha &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.5&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_x_continuous&lt;/span&gt;(labels &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; scales&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;label_comma&lt;/span&gt;()) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;facet_wrap&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rev&lt;/span&gt;(northing), ncol &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_cartesian&lt;/span&gt;(ylim &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(fsl &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(prettyboy_sections&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;depth_m, na.rm &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;), fsl)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_minimal&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;28&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Easting [m]&amp;#34;&lt;/span&gt;, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Elevation [m]&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(gridExtra)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grid.arrange&lt;/span&gt;(map, sections, ncol &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/prettyboy-sections.png&#34; alt=&#34;Prettyboy Reservoir bathemetry and cross sections&#34; title=&#34;Prettyboy Reservoir cross sections&#34; width=&#34;800&#34;/&gt;
&lt;figcaption&gt;
Prettyboy Reservoir cross sections.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The second method for calculating the total volume is to use a &lt;a href=&#34;https://en.wikipedia.org/wiki/Triangulated_irregular_network&#34;&gt;Triangulated Irregular Network&lt;/a&gt; (TIN). A TIN is a representation of a surface consisting of triangular facets. The main difference with the interpolated values is that this model is irregular, so each triangle has a different projected area.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://cran.r-project.org/web/packages/geometry/index.html&#34;&gt;geometry package&lt;/a&gt; implements Delaunay triangulation, where each row contains the indices of three points forming a triangle. In the next step, we use the &lt;code&gt;map_dfr()&lt;/code&gt; function to create a data frame with the index number of each triangle, the three coordinates and the associated depths.&lt;/p&gt;
&lt;p&gt;
To measure the volume, we can use the shoelace formula to calculate the area of each triangle:&lt;/p&gt;
&lt;p&gt;
$$A_i = \frac{1}{2}| x_{i_1} (y_{1_2} - y_{i_3}) + x_{i_2} (y_{1_3} - y_{i_1}) + x_{i_3} (y_{1_1} - y_{i_2})|$$&lt;/p&gt;
&lt;p&gt;
The volume of the element is the area multiplied by the average depth:&lt;/p&gt;
&lt;p&gt;
$$V = \sum{A_i \frac{\sum d_i}{3}}$$&lt;/p&gt;
&lt;p&gt;
This method provides the same volume but is a bit faster to process because we are not creating new data.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Triangulated Irregular Network&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(geometry) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(purrr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# 2D coordinates&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  coords2d &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.matrix&lt;/span&gt;(prettyboy[, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;easting&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;northing&amp;#34;&lt;/span&gt;)])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Delaunay triangulation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  tri &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;delaunayn&lt;/span&gt;(coords2d)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Convert the triangles into a long data frame for ggplot&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  tin_df &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;map_dfr&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq_len&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(tri)), &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(i) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    idx &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; tri[i, ]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      tri_id   &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; i,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      easting  &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; prettyboy&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;easting[idx],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      northing &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; prettyboy&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;northing[idx],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      depth_m  &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; prettyboy&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;depth_m[idx])})
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle_area_shoelace &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x, y) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt;(x[1] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (y[2] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; y[3]) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        x[2] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (y[3] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; y[1]) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        x[3] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (y[1] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; y[2])) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  tin_volume &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; tin_df &lt;span style=&#34;color:#333&#34;&gt;|&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    dplyr&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;group_by&lt;/span&gt;(tri_id) &lt;span style=&#34;color:#333&#34;&gt;|&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    dplyr&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;summarise&lt;/span&gt;(
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             area       &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;triangle_area_shoelace&lt;/span&gt;(easting, northing),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             mean_depth &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mean&lt;/span&gt;(depth_m),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             volume     &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; area &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; mean_depth,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             .groups    &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;drop&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  tin_volume_m3 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(tin_volume&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;volume)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  tin_volume_m3 &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1e6&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Generate Capacity Charts
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Last but not least, we need a chart that converts the measured reservoir level to a volume. The easiest method to develop this curve is to use the grid. The TIN becomes mathematically problematic when not all three triangle points are underwater.&lt;/p&gt;
&lt;p&gt;
While bathymetry measures depth from the top down, with higher numbers indicating greater depth, reservoir levels are expressed in elevation. I could not find the official elevation of the Full Supply Level. Google Maps provides an elevation of 145 meters for the dam, so let&amp;#39;s use this.&lt;/p&gt;
&lt;p&gt;
The measured values closely matched a cubic regression as shown in the graph below, so we can also calculate the volume of the reservoir using the level with this formula:&lt;/p&gt;
&lt;p&gt;
$$V(\ell) =-3.463 \times 10^{9} + 8.883 \times 10^{7}\,\ell - 7.640 \times 10^{5}\,\ell^{2} + 2.203 \times 10^{3}\,\ell^{3}$$&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Capacity Curve&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# levels to evaluate&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  levels &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(fsl &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;round&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(prettyboy&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;depth_m) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;, fsl, by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  grid_capacity &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(level &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; levels) &lt;span style=&#34;color:#333&#34;&gt;|&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(volume_m3 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;map_dbl&lt;/span&gt;(level, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;\&lt;/span&gt;(L) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      bed &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; fsl &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; prettyboy_grid&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;depth_m
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      depth_L &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;pmax&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, L &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; bed)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(depth_L &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; dx &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; dy, na.rm &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)}))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Cubic regression&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  cubic &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lm&lt;/span&gt;(volume_m3 &lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;poly&lt;/span&gt;(level, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, raw &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;), data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; grid_capacity)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  grid_capacity&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;cubic &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;predict&lt;/span&gt;(cubic)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(grid_capacity) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(level, volume_m3 &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1E6&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;grey&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_line&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(level, cubic &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1E6&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_hline&lt;/span&gt;(yintercept &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; grid_volume_m3 &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1E6&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               linetype &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_y_continuous&lt;/span&gt;(labels &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; scales&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;label_comma&lt;/span&gt;()) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_minimal&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Prettyboy Reservoir Capacity Curve&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Water level&amp;#34;&lt;/span&gt;, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;expression&lt;/span&gt;(Volume&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;m^3))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/prettyboy-capacity-curve.png&#34; alt=&#34;Prettyboy Reservoir capacity curve&#34; title=&#34;Prettyboy capacity curve&#34; width=&#34;800&#34;/&gt;
&lt;figcaption&gt;
Prettyboy Capacity Curve.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
After all that maths and code, perhaps watch a nice video about the Pretty Boy Dam.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/Dj92uYurwqM?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Zack Ventures, Exploring Prettyboy Dam and Reservoir in Maryland
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>A Brief Guide to Providing Insights as a Service</title>
      <link>https://lucidmanager.org/data-science/insights-as-a-service/</link>
      <pubDate>Sat, 21 Jun 2025 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/insights-as-a-service/</guid>
      <description>
	
&lt;p&gt;
Analysing data requires a high level of technical skill, which Drew Conway summarised in his often-cited &lt;a href=&#34;http://drewconway.com/zia/2013/3/26/the-data-science-venn-diagram&#34;&gt;Venn diagram&lt;/a&gt;. Following this model, data scientists, individually or as a team, require competencies in computer science, statistics, and knowledge of the domain they are analysing. There is, however, more to providing value from data than these three technical skills. This article introduces the concept of &lt;em&gt;Insights as a Service&lt;/em&gt; (IaaS), a framework to assist data science teams with maximising the value they deliver to their internal or external customers.&lt;/p&gt;
&lt;p&gt;
With the ongoing improvement of AI capabilities, the technical skills of data professionals are becoming increasingly automated. This development requires data engineers, analysts, and scientists to embrace the elusive softer skills and use insights from &lt;a href=&#34;https://lucidmanager.org/categories/marketing/&#34;&gt;marketing&lt;/a&gt; and the &lt;a href=&#34;https://lucidmanager.org/tags/humanities/&#34;&gt;humanities&lt;/a&gt;. The &lt;em&gt;insights as a Service Framework&lt;/em&gt; enables data professionals to plan and execute their projects, creating greater value for their clients.&lt;/p&gt;
&lt;p&gt;
This model incorporates lessons I learned while managing a data team for over ten years, as well as my research into &lt;a href=&#34;https://lucidmanager.org/tags/invisible-water-utility/&#34;&gt;applying Service-Dominant Logic&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The content of this article was recently discussed in the &lt;a href=&#34;https://valuedrivendatascience.com/68&#34;&gt;Value Driven Data Science podcast&lt;/a&gt; by Genevieve Hayes.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Introducing the Insights as a Service Framework
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Technology managers regularly apply the acronym &amp;#34;PPT&amp;#34; (People, Process, and Technology) as a mnemonic. The &lt;a href=&#34;https://www.forbes.com/councils/forbestechcouncil/2022/12/29/is-the-60-year-old-people-process-technology-framework-still-useful/&#34;&gt;golden triangle of technology management&lt;/a&gt; dates back to the early 1960s when Harold Leavitt developed his Diamond Model. Bruce Schneier modified and popularised the tool in the 1990s.&lt;/p&gt;
&lt;p&gt;
From a service delivery perspective, we need to add some more dimensions. The &lt;a href=&#34;https://www.marketing91.com/service-marketing-mix/&#34;&gt;Services Marketing Mix&lt;/a&gt;, first developed by Bernard Booms and Mary Bitner in 1981, employs seven dimensions as a model for delivering services. A marketing mix is not a model that guarantees success. You need to use it as a heuristic device to think more deeply about the service your team provides.&lt;/p&gt;
&lt;p&gt;
These two models conceptually overlap, which leads to the IaaS framework. Insights as a Service recognises the importance of the core elements of PPT and adds elements from the services marketing mix. This combination leads to six dimensions: Product, Price, Promotion, People, Process, and Platform (technology is renamed for a lovely alliteration of six Ps).&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/six-ps-of-insights-as-a-service.jpg&#34; alt=&#34;Six Ps of delivering Insights as a Service&#34; title=&#34;Six Ps of delivering Insights as a Service&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Six Ps of delivering Insights as a Service.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Insights as a Service (IaaS) is in most cases used exclusively in a B2B (&lt;a href=&#34;https://en.wikipedia.org/wiki/Business-to-business&#34;&gt;Business-to-Business&lt;/a&gt;) context. In this scenario a commercial service provider generates insights for a client using a cloud-based platform. This article reinterprets the IaaS model to include contexts where an internal data team provides electronic services to colleges (&lt;a href=&#34;https://en.wikipedia.org/wiki/Business-to-employee&#34;&gt;B2E, Business-to-Employee&lt;/a&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Insights as a Service Framework
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The remainder of this article briefly discusses the significance of each of these framework dimensions and their practical relevance.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Product
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The data product, which is, in most cases, a report, either static or interactive, is the vehicle that delivers value to the end-user. We can use an analogy from architecture by following the Vitruvian rules for buildings and translating them to our context:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Sound&lt;/em&gt;: Is the analysis mathematically and statistically correct?&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Useful&lt;/em&gt;: Can the client generate insights from it?&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Aesthetic&lt;/em&gt;: Is the data product well-designed and, as such, easy to understand? &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This previous article about &lt;a href=&#34;https://lucidmanager.org/data-science/strategic-data-science/&#34;&gt;strategic data science&lt;/a&gt; discusses this model of good data science in more depth, which is also explained in detail in my book on the topic.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2019_sds.jpg&#34; alt = &#34;Principles of Strategic Data Science&#34; title = &#34;Principles of Strategic Data Science&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Principles of Strategic Data Science&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Principles of Strategic Data Science helps you join the dots between mathematics, programming, and business analysis. With a unique approach that bridges the gap between mathematics and computer science, this book takes you through the entire data science pipeline.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.packtpub.com/en-us/product/principles-of-strategic-data-science-9781838985509&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Packt Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&amp;nbsp;
&lt;p&gt;
The value of a service product, in simplest terms, is the difference between the benefits and the cost. The product provides the benefits of the value equation, visualised below. While the product delivers value to the customer, there is also a cost, which is the next dimension in the framework.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/value-equation.png&#34; alt=&#34;The value equation, balancing benefits and cost&#34; title=&#34;The value equation, balancing benefits and cost&#34; width=&#34;300&#34;/&gt;
&lt;figcaption&gt;
The value equation, balancing benefits and cost.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Price
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Whether you are an internal data science team or a commercial service provider that assists other organisations with creating value from data, all development has a price. However, the monetary cost of a data product is only one dimension of the total Price equation.&lt;/p&gt;
&lt;p&gt;
Firstly, consumers of services incur a time cost. The time cost of a service is the amount of time a consumer (in our case, the user of a data product) spends using the tool. The time we spend using a service is an opportunity cost because we could be doing something else.&lt;/p&gt;
&lt;p&gt;
The time cost also extends to the development phase as the input from end users is essential. A data professional relies on the detailed, contextual knowledge of the end-user to create insights. &lt;/p&gt;
&lt;p&gt;
An extension of the time cost to use a service is the mental cost. How much mental effort does an end-user need to use to understand the output of your data product? The cognitive cost of consuming insights can be minimised in two ways. Firstly, the design of the report needs to be aesthetic. Not in the sense of beatification, but in making the end product easy to understand.&lt;/p&gt;
&lt;p&gt;
The mental cost to users of a report depends a lot on their data literacy. The advanced specialisation of data science has created a knowledge gap between subject-matter experts who use the report and the advanced statistical methods used by analysts. Reducing this knowledge gap requires the service provider to educate their customers, which falls under the next dimension of the IaaS framework.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Promotion
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;When working in a B2B environment, the necessity for promotion is easily understood. However, promotion is also essential for internal teams working in B2E.&lt;/p&gt;
&lt;p&gt;
A data science service provider is often &lt;a href=&#34;https://lucidmanager.org/tags/invisible-water-utility/&#34;&gt;invisible to the consumer&lt;/a&gt; of its services. Being invisible is a good thing because it means our data products are working flawlessly, but this great uptime also comes at a cost, as your services might be taken for granted. The most effective way to combat invisibility is promotion.&lt;/p&gt;
&lt;p&gt;
For teams providing services to external entities (B2B), promotion is an essential business activity. However, this also applies to internal data teams. In my workplace, we ensure that our colleagues have regular visibility of the tools we develop through intranet articles and other internal communication means. These promotional activities ensure that management understands the relevance of the team and improves data literacy across the organisation.&lt;/p&gt;
&lt;p&gt;
To promote data science skills in my industry, I wrote a textbook for water professionals who want to &lt;a href=&#34;https://lucidmanager.org/data-science/spreadsheets-for-data-science/&#34;&gt;move away from their spreadsheets&lt;/a&gt;, the content of which I also deliver as a course. One objective of this course is to equip water professionals with the skills to communicate effectively with data scientists. Increasing data literacy among those who work with data scientists is essential to ensure the full value of our services is realised.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
Another important aspect of providing valuable data services is that your client knows the team. Don&amp;#39;t hide your experts behind the veil of technology. This thought segways nicely onto the next dimension of the framework.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
People
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Enough has been said and written about the technical requirements of being a data scientist. The &lt;a href=&#34;http://drewconway.com/&#34;&gt;Conway Venn diagram&lt;/a&gt; is a widely cited model of the technical skills required for data science. In this model, a data scientist is somebody who understands the subject matter under consideration in mathematical terms and writes computer code to solve problems.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/autodesk-water-unicorns.jpg&#34; alt=&#34;The Data Science Venn Diagram&#34; title=&#34;The Data Science Venn Diagram&#34; width=&#34;300&#34;/&gt;
&lt;figcaption&gt;
The Data Science Venn Diagram.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Many alternatives have been proposed that incorporate soft skills into this diagram, and the Insights as a Service Framework also does so. Especially with the steady advancement of AI developments, non-technical skills will become increasingly crucial for a data scientist to thrive in this industry.&lt;/p&gt;
&lt;p&gt;
The importance of domain knowledge cannot be underestimated. The time price of a service suggests that the client needs to invest time in explaining the context of the data problem to the developer. However, the development team also needs to have sufficient domain knowledge to advise the client. I have been in many situations where an end-user knows what problem to solve but is unable to articulate what they want clearly. It is then the task of the service provider to understand their customer and provide them with what they need.&lt;/p&gt;
&lt;p&gt;
The well-worn &amp;#34;faster horses&amp;#34; marketing cliché also applies to providing &lt;em&gt;Insights as a service&lt;/em&gt;. A data service provider needs to be able to provide the client with a vision (in this analogy, a car) that solves or prevents problems.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Process
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The process of service delivery relates to your pipeline from ideation to production. Each organisation will have a governance model to decide which projects are executed and how they are implemented. &lt;/p&gt;
&lt;p&gt;
From a service perspective, your process needs to be seamless and easy to understand while also minimising the time the client has to invest in development and testing. Service Blueprinting is a commonly used technique to map a service. The primary difference between this approach and standard process maps is that a service blueprint also considers the customer&amp;#39;s perspective. A good service blueprint adds equal weight to the inputs of both the service provider and the service beneficiary.&lt;/p&gt;
&lt;p&gt;
Another important consideration in the service provision process is the method for measuring service quality. Service Quality goes beyond customer satisfaction and seeks to provide deep insight into which aspects of a service need improving. At a basic level, it consists of four dimensions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Reliability&lt;/em&gt;: The ability to provide the service(s) accurately and dependably.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Assurance&lt;/em&gt;: The ability to project trust and confidence.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Tangibles&lt;/em&gt;: The physical or digital proof of the service provider&amp;#39;s status.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Empathy&lt;/em&gt;: The ability to provide empathetic attention to customers.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Responsiveness&lt;/em&gt;: The ability to provide timely services.&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Platform
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Last but not least is the technology platform that you use for developing the data product. Data scientists use a complex web of applications to transform raw data into the final product. The data consumption platform is the interface between this technology stack and the end-user. &lt;/p&gt;
&lt;p&gt;
When choosing a data consumption platform, two factors are essential to consider: complexity and degrees of freedom.&lt;/p&gt;
&lt;p&gt;
Firstly, complexity relates to the level of coding required to create data products, ranging from no-code to high-code. No-code means that everything can be done with a mouse and a few keystrokes. High code implies that the developer needs to use scripting languages. For example, the R Shiny platform provides interactive web applications using R and Python. This package is a high-code solution that requires a substantial amount of training to utilise effectively. &lt;a href=&#34;https://www.knime.com/&#34;&gt;KNIME&lt;/a&gt; is a no-code solution with a node-based  graphical interface to build analytical &lt;/p&gt;
&lt;p&gt;
The less coding is involved, the more democratised access to the tool is, as more people can use it. A no or low-code platform can provide a self-service interface for subject-matter experts to analyse data without needing data science skills. Low-code platforms, such as &lt;a href=&#34;https://lucidmanager.org/data-science/spreadsheets-for-data-science/&#34;&gt;spreadsheets&lt;/a&gt; also have disadvantages, most importantly that they are often not reproducible and hard to reverse-engineer when updates are required.&lt;/p&gt;
&lt;p&gt;
The second dimension is the degree of freedom available to the end user. Tools such as Power BI offer a high degree of freedom, whereas a report in MS Word provides little to no freedom for the user. While Power BI or Tableau provide a &amp;#39;create-your-own-adventure&amp;#39; interface, other systems are more limited and provide &lt;/p&gt;
&lt;p&gt;
The choice of platform should align with the end-user&amp;#39;s needs. A no-code solution with a high level of freedom is not always best.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
Conclusion
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This article summarises the &lt;em&gt;Insights-as-a-Service Framework&lt;/em&gt;. I am currently working on a book on the topic that will dive much deeper into the model, including practical examples.&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://www.linkedin.com/in/peterprevos/&#34;&gt;Follow or connect with me on LinkedIn&lt;/a&gt; if you&amp;#39;d like to stay informed about my progress and learn how this concept develops.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 35: Circular Primes below One Million</title>
      <link>https://lucidmanager.org/data-science/project-euler-35/</link>
      <pubDate>Thu, 12 Jun 2025 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-35/</guid>
      <description>
	
&lt;p&gt;
Euler Problem 35 takes us back to the world of prime numbers, in particular &lt;a href=&#34;https://en.wikipedia.org/wiki/Circular_prime&#34;&gt;circular primes&lt;/a&gt;. The Online Encyclopedia of Integers (&lt;a href=&#34;https://oeis.org/A068652&#34;&gt;A068652&lt;/a&gt;) lists the first 46 decimal numbers for which every cyclic permutation is a prime.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 35 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The number 197 is a decimal circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.&lt;/p&gt;
&lt;p&gt;
There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://projecteuler.net/problem=35&#34;&gt;How many circular primes are there below one million&lt;/a&gt;?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution in R
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This code reuses the function that strips all digits for a number, presented in &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-30/&#34;&gt;Euler Problem 30&lt;/a&gt;. The solution for this problem also use the &lt;code class=&#34;verbatim&#34;&gt;is_prime&lt;/code&gt; function to test whether a number is a prime, developed for &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-7/&#34;&gt;Euler Problem 7&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;
The following auxiliary functions help to solve the problem:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;prime_sieve&lt;/code&gt;: Generate primes&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is_prime&lt;/code&gt;: Checks whether a number is prime&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rotate_left&lt;/code&gt;: Rotates the a number&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;is_circular_prime&lt;/code&gt; function first removes any numbers greater than 9 that contains either a 0, 2, 4, 5, 6 or 8, as at least one rotation will be &lt;a href=&#34;https://t5k.org/glossary/page.php?sort=CircularPrime&#34;&gt;divisible by either 2 or 5&lt;/a&gt;, which drastically reduces the search space.&lt;/p&gt;
&lt;p&gt;
The main program tests each of the 78,498 primes below one million and counts the number of circular ones.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  prime_sieve &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(n)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;x
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    p &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (p^2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l[l &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; p &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; l &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; p&lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      p &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l[i]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(l)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  is_prime &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; x &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    primes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;prime_sieve&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ceiling&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(x)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;all&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; primes &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;101&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  rotate_left &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(x)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;log10&lt;/span&gt;(x)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    first_digit &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; x &lt;span style=&#34;color:#333&#34;&gt;%/%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;^&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    rest &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; x &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;^&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    rotated &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; rest &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; first_digit
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(rotated)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  is_circular_prime &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;any&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;[024568]&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(x)))) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;log10&lt;/span&gt;(x)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    p &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;(length &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; n)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (r &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      p[r] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;is_prime&lt;/span&gt;(x)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;p[r] ) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rotate_left&lt;/span&gt;(x)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  primes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;prime_sieve&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1E6&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;system.time&lt;/span&gt;({
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    circular_primes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; primes&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[sapply&lt;/span&gt;(primes, is_circular_prime)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(circular_primes))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  })&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Mapping the Ancient World: A Digital Odyssey through Ptolemy&#39;s Geography</title>
      <link>https://lucidmanager.org/data-science/mapping-ptolemy-geography/</link>
      <pubDate>Fri, 17 Nov 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/mapping-ptolemy-geography/</guid>
      <description>
	
&lt;p&gt;
In the chronicles of cartographic history, few works have captivated the imagination, such as Claudius Ptolemy&amp;#39;s &amp;#34;&lt;a href=&#34;https://en.wikipedia.org/wiki/Geography_(Ptolemy)&#34;&gt;Geography&lt;/a&gt;&amp;#34;. This monumental second-century creation is the oldest fully preserved theoretical treatise on cartography, written almost 2000 years ago. This article discusses Mapping Ptolemy&amp;#39;s Geography with &lt;em&gt;ggplot2&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;
His cartography is not just a collection of maps of the known world in Hellenic times. Ptolemy also provides latitudes and longitudes with fantastic accuracy. Interestingly, he wrote that the best way to store geographic information is as a collection of numbers because copying maps leads to distortions over time. Thus, he created one of the world&amp;#39;s first geographic information systems. His book contains the locations of thousands of towns, rivers, mountains and other points of interest.&lt;/p&gt;
&lt;p&gt;
Unfortunately, no freely available database of these coordinates exists in electronic format, but there are some &lt;a href=&#34;https://babel.hathitrust.org/cgi/pt?id=mdp.39015022717592&amp;amp;seq=7&#34;&gt;textual versions&lt;/a&gt;, such as the example below.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/geography/ptolemy-extract.jpg&#34; alt=&#34;Extract from Ptolemy&amp;#39;s Geography (Nobbe edition, 1843)&#34; title=&#34;Extract from Ptolemy&amp;#39;s Geography (Nobbe edition, 1843)&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Extract from Ptolemy&amp;#39;s Geography (Nobbe edition, 1843).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
I thus set forth to scrape these sources and create a Ptolemaic geographic database. The code and data for this project are available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/geography/&#34; target=&#34;_blank&#34;
   title=&#34;Download geography from GitHub&#34;
   alt=&#34;Download geography from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;geography&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Obtaining the Data
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The process begins with the scraping of Ptolemy’s text from &lt;a href=&#34;https://topostext.org/work/209&#34;&gt;ToposText&lt;/a&gt;, which is a treasure trove of classical literature. This website contains an almost complete transcription of Ptolemy&amp;#39;s tome. I saved the webpage to disk to prevent hitting the ToposText server too often. The source data is available on the Github repo in RDS format.&lt;/p&gt;
&lt;p&gt;
The website provides an accurate transcription of a large portion of Ptolemy&amp;#39;s work. Some typographical quirks and curious coordinates were standardised using regular expressions.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(stringr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(dplyr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# library(rvest)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Scrape the website and save it to disk&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;#&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# url &amp;lt;- &amp;#34;https://topostext.org/work/209&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;#&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# raw_html &amp;lt;- read_html(url) %&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;#     html_nodes(&amp;#34;p&amp;#34;) %&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;#     html_text()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# saveRDS(raw_html, &amp;#34;topostext.org-work-209.rds&amp;#34;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readRDS&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;topostext.org-work-209.rds&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Fix issues and typos&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(raw, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\. equator&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;0°0&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Equator&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(raw, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;0°0 and&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;0°0&amp;#39;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(raw, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(\\d+.\\d+&amp;#39;) S &amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;-\\1&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Southern hemisphere&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(raw, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(\\d) c&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\1&amp;#39;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(raw, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(\\d) d&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\1&amp;#39; \\.&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(raw, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(\\d) e&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\1&amp;#39; \\.&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(raw, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;5°00&amp;#39; . 3°00&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;45°15&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Estimated lat&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(raw, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;4°00&amp;#39; . 3°00&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;43°00&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Estimated lat&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(raw, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(\\d+)&amp;#39;(\\d+)&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\1°\\2&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(raw, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(Elateia . 51°38&amp;#39; )&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\1. 38°15&amp;#39;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(raw, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(Kambyses)&amp;#39;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\1&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(raw, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(Libison)&amp;#39;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\1&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The script then loops through all paragraphs that include coordinates and extracts the place names, longitude and latitude in degrees and minutes.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Detect place names and coordinates&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  locs &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_split&lt;/span&gt;(raw&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[str_detect&lt;/span&gt;(raw, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;°|º&amp;#34;&lt;/span&gt;)], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#39;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  p_regex &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\b[A-Za-z ,:\\-]+\\b&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  c_regex &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(-?[0-9]{1,3}[°|º][0-9]{1,3})&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  place &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  lon_raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  lat_raw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (j &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq_along&lt;/span&gt;(locs)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    t &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(locs[j])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ceiling&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_detect&lt;/span&gt;(t,  &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;°|º&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    k &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    place[i&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;k] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_extract&lt;/span&gt;(t, p_regex)&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;n) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    lon_txt &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_extract_all&lt;/span&gt;(t&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;n) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;], c_regex))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    lat_txt &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_extract_all&lt;/span&gt;(t&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;n) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;], c_regex))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(lat_txt) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) lat_txt &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(lon_txt) &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; n) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;stop&lt;/span&gt;(j)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    lon_raw[i&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;k] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; lon_txt
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    lat_raw[i&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;k] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; lat_txt
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; n
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    j &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; j &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The next phase creates a table of coordinates by converting the coordinates into numeric values and cleaning the place names. The degrees and minutes of longitude and latitude are stored in separate variables. Regular expressions split the geographic coordinates (e.g. 14°20&amp;#39; . 54°30&amp;#39;) into four numbers (14, 20, 54, 30).&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Generate data frame&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  extract_nums &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x, regex) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_extract_all&lt;/span&gt;(x, regex)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  d_regex &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(-?[0-9]+)(?=°|º)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  m_regex &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(?&amp;lt;=°|º)([0-9]+)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  locations &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(place, lon_raw, lat_raw) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(lon &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;extract_nums&lt;/span&gt;(lon_raw, d_regex),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           lon_min &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;extract_nums&lt;/span&gt;(lon_raw, m_regex),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           lat &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;extract_nums&lt;/span&gt;(lat_raw, d_regex),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           lat_min &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;extract_nums&lt;/span&gt;(lat_raw, m_regex),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           place &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_squish&lt;/span&gt;(place),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           place &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_to_sentence&lt;/span&gt;(place)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(placename &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; place, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;7&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The table of place names and their coordinates is available on the GitHub repository.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Mapping Ptolemy&amp;#39;s Geography
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The visualisation was realised through the &lt;a href=&#34;https://ggplot2.tidyverse.org/reference/geom_map.html&#34;&gt;ggplot2 mapping geometry&lt;/a&gt;. Ptolemy&amp;#39;s ancient world is reborn; its cities and landmarks emerge from the mists of time on this digital canvas.&lt;/p&gt;
&lt;p&gt;
This map uses the Conic projection, similar to one of the projections used by Ptolemy himself. This projection distorts the southern part of Africa slightly.&lt;/p&gt;
&lt;p&gt;
The longitudes are corrected to better match them with modern coordinates. Ptolemy used the Canary Islands as the zero meridian of his coordinate system, which is 18 degrees west of the Greenwich meridian. Research also shows that Ptolemy&amp;#39;s longitudes are stretched by a factor of 1.428.&lt;/p&gt;
&lt;p&gt;
Ptolemy&amp;#39;s work might seem full of mistakes from our modern perspective, but in fact, &lt;a href=&#34;https://www.openculture.com/2021/03/why-every-world-map-is-wrong.html&#34;&gt;every world map we have ever produced is essentially wrong&lt;/a&gt;. Turning a globe into a two-dimensional object always results in distortions, no matter how hard you try.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/geography/ptolemaeus-geography-ii-vi.png&#34; alt=&#34;Mapping Ptolemaic coordinates on a modern map&#34; title=&#34;Mapping Ptolemaic coordinates on a modern map&#34;/&gt;
&lt;figcaption&gt;
Mapping Ptolemaic coordinates on a modern map.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;# Visualise&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;world &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;map_data&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;world&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_map&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; world, map &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; world,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(long, lat, map_id &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; region),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;darkgreen&amp;#34;&lt;/span&gt;, colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;lightgrey&amp;#34;&lt;/span&gt;, linewidth &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; locations,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; (lon &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; lon_min &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;18&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.428&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                   y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; (lat &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; lat_min &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;)),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;orange&amp;#34;&lt;/span&gt;, alpha &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.7&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_x_continuous&lt;/span&gt;(limits &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-15&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;70&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_y_continuous&lt;/span&gt;(limits &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-10&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_map&lt;/span&gt;(projection &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;conic&amp;#34;&lt;/span&gt;, lat0 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;37&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Ptolemaeus, Geography (II-VI)&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Longitude correction: 0.7(lon - 18)&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         caption &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Source: topostext.org/work/209&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_minimal&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme&lt;/span&gt;(panel.background &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;element_rect&lt;/span&gt;(fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;lightblue&amp;#34;&lt;/span&gt;, colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Ptolemy knew the Earth was spherical – a fact established by Greek philosophers well before his time. In his &lt;em&gt;Geographic&lt;/em&gt;, Ptolemy provides a cornucopia of coordinates, illustrating the known world from Britain to Southeast Asia and from the northern reaches of Scandinavia to below the equator. But their knowledge only covered a small part of the whole globe. &lt;/p&gt;
&lt;p&gt;
The Greeks blended mythology, philosophy, and early scientific speculation to theorise what lies beyond the world they mapped. They imagined a vast, unending ocean encircling the world. Beyond Oceanus, some thought, might be other worlds or unknown lands. The concept of &amp;#34;&lt;a href=&#34;https://lucidmanager.org/data-science/mapping-antipodes/&#34;&gt;antipodes&lt;/a&gt;&amp;#34; was also bandied about - these are  places where people&amp;#39;s feet are directly opposite to ours. Though the existence of such lands or peoples was often debated or outright denied.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>About The Lucid Manager</title>
      <link>https://lucidmanager.org/about/</link>
      <pubDate>Sun, 05 Nov 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/about/</guid>
      <description>
	
&lt;p&gt;
The Lucid Manager is a website with the collected works of civil engineer, social scientist and reality disruptor, &lt;a href=&#34;https://peterprevos.com/&#34;&gt;Dr Peter Prevos&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Biography
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Peter is a Dutch civil engineer, business scholar and magician. He has thirty years experience in managing water infrastructure projects and water utility management. He currently manages the data science team at a water utility in regional Victoria, Australia.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The Lucid Manager is the business anti-guru&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
&lt;img src=&#34;https://peterprevos.com/images/presentation.jpg&#34; alt=&#34;https://peterprevos.com/images/presentation.jpg&#34; title=&#34;https://peterprevos.com/images/presentation.jpg&#34; /&gt;&lt;/p&gt;
&lt;p&gt;

&lt;div class=&#34;container&#34;&gt;
  &lt;div class=&#34;columns is-multiline&#34;&gt;
    
    &lt;div class=&#34;column is-half&#34;&gt;
      &lt;article class=&#34;media notification has-background-white&#34;&gt;
	&lt;figure class=&#34;media-left&#34;&gt;
	  &lt;a href=&#34;https://lucidmanager.org/categories/data-science/&#34; title=&#34;The Devil is in the Data&#34;&gt;
	    &lt;span class=&#34;icon&#34;&gt;
	      &lt;i class=&#34;fas fa-2x fa fa-chart-bar has-text-info&#34;&gt;&lt;/i&gt;
	    &lt;/span&gt;
	  &lt;/a&gt;
	&lt;/figure&gt;
	&lt;div class=&#34;media-content&#34;&gt;
	  &lt;div class=&#34;content&#34;&gt;
	    &lt;h2 class=&#34;title is-size-4&#34;&gt;
	      &lt;a href=&#34;https://lucidmanager.org/categories/data-science/&#34; title=&#34;The Devil is in the Data&#34; style=&#34;text-decoration: none;&#34;&gt;The Devil is in the Data&lt;/a&gt;
	    &lt;/h2&gt;
	    &lt;p class=&#34;subtitle is-size-5&#34;&gt;The Devil is in the Data is about practical data science and fun games with the R language. Analyse water problems, digital humanities and play games.&lt;/p&gt;
	    
	    &lt;p class=&#34;has-text-grey is-size-6&#34;&gt;&lt;/p&gt;
	  &lt;/div&gt;
	&lt;/div&gt;
      &lt;/article&gt;
    &lt;/div&gt;
    
    &lt;div class=&#34;column is-half&#34;&gt;
      &lt;article class=&#34;media notification has-background-white&#34;&gt;
	&lt;figure class=&#34;media-left&#34;&gt;
	  &lt;a href=&#34;https://lucidmanager.org/categories/management/&#34; title=&#34;Perspectives on Management&#34;&gt;
	    &lt;span class=&#34;icon&#34;&gt;
	      &lt;i class=&#34;fas fa-2x fa fa-briefcase has-text-info&#34;&gt;&lt;/i&gt;
	    &lt;/span&gt;
	  &lt;/a&gt;
	&lt;/figure&gt;
	&lt;div class=&#34;media-content&#34;&gt;
	  &lt;div class=&#34;content&#34;&gt;
	    &lt;h2 class=&#34;title is-size-4&#34;&gt;
	      &lt;a href=&#34;https://lucidmanager.org/categories/management/&#34; title=&#34;Perspectives on Management&#34; style=&#34;text-decoration: none;&#34;&gt;Perspectives on Management&lt;/a&gt;
	    &lt;/h2&gt;
	    &lt;p class=&#34;subtitle is-size-5&#34;&gt;Creative reflections on contemporary management practices. Celebrating deviance from the norm, magic and the humanities.&lt;/p&gt;
	    
	    &lt;p class=&#34;has-text-grey is-size-6&#34;&gt;&lt;/p&gt;
	  &lt;/div&gt;
	&lt;/div&gt;
      &lt;/article&gt;
    &lt;/div&gt;
    
    &lt;div class=&#34;column is-half&#34;&gt;
      &lt;article class=&#34;media notification has-background-white&#34;&gt;
	&lt;figure class=&#34;media-left&#34;&gt;
	  &lt;a href=&#34;https://lucidmanager.org/categories/marketing/&#34; title=&#34;Marketing for Engineers&#34;&gt;
	    &lt;span class=&#34;icon&#34;&gt;
	      &lt;i class=&#34;fas fa-2x fas fa-users-cog has-text-info&#34;&gt;&lt;/i&gt;
	    &lt;/span&gt;
	  &lt;/a&gt;
	&lt;/figure&gt;
	&lt;div class=&#34;media-content&#34;&gt;
	  &lt;div class=&#34;content&#34;&gt;
	    &lt;h2 class=&#34;title is-size-4&#34;&gt;
	      &lt;a href=&#34;https://lucidmanager.org/categories/marketing/&#34; title=&#34;Marketing for Engineers&#34; style=&#34;text-decoration: none;&#34;&gt;Marketing for Engineers&lt;/a&gt;
	    &lt;/h2&gt;
	    &lt;p class=&#34;subtitle is-size-5&#34;&gt;Collected essays and perspectives on marketing for engineers. How can engineers embrace the social sciences to deliver technology?&lt;/p&gt;
	    
	    &lt;p class=&#34;has-text-grey is-size-6&#34;&gt;&lt;/p&gt;
	  &lt;/div&gt;
	&lt;/div&gt;
      &lt;/article&gt;
    &lt;/div&gt;
    
    &lt;div class=&#34;column is-half&#34;&gt;
      &lt;article class=&#34;media notification has-background-white&#34;&gt;
	&lt;figure class=&#34;media-left&#34;&gt;
	  &lt;a href=&#34;https://lucidmanager.org/categories/productivity/&#34; title=&#34;Musings About Productivity&#34;&gt;
	    &lt;span class=&#34;icon&#34;&gt;
	      &lt;i class=&#34;fas fa-2x fa fa-keyboard has-text-info&#34;&gt;&lt;/i&gt;
	    &lt;/span&gt;
	  &lt;/a&gt;
	&lt;/figure&gt;
	&lt;div class=&#34;media-content&#34;&gt;
	  &lt;div class=&#34;content&#34;&gt;
	    &lt;h2 class=&#34;title is-size-4&#34;&gt;
	      &lt;a href=&#34;https://lucidmanager.org/categories/productivity/&#34; title=&#34;Musings About Productivity&#34; style=&#34;text-decoration: none;&#34;&gt;Musings About Productivity&lt;/a&gt;
	    &lt;/h2&gt;
	    &lt;p class=&#34;subtitle is-size-5&#34;&gt;Become more productive with Emacs, the Swiss Army chainsaw of productivity tools. Use Emacs Writing Studio to write articles, websites and books.&lt;/p&gt;
	    
	    &lt;p class=&#34;has-text-grey is-size-6&#34;&gt;&lt;/p&gt;
	  &lt;/div&gt;
	&lt;/div&gt;
      &lt;/article&gt;
    &lt;/div&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Analysing the Customer Experience</title>
      <link>https://lucidmanager.org/data-science/analysing-the-customer-experience/</link>
      <pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/analysing-the-customer-experience/</guid>
      <description>
	
&lt;p&gt;
Summarising data through descriptive statistics such as averages, percentiles or variances does not add new knowledge but merely summarises what you already know. &lt;a href=&#34;https://dx.doi.org/10.1201/9781003326977-8&#34;&gt;This chapter&lt;/a&gt; of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; introduces basic inferential statistics, a set of methods for finding patterns in data to create new knowledge. Technical professionals often focus on the tangible aspects of services and measure performance in physical units. Technical data does, however, only tell part of the story of the customer experience. Analysing the customer experience requires different techniques to analyse data compared to physical processes. This chapter discusses how to use surveys to learn how customers experience services and demonstrates some techniques to explore this type of data using the R language. The learning objectives for this chapter are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Understand the principles of measuring the customer experience with surveys&lt;/li&gt;
&lt;li&gt;Assess the reliability of surveys with a correlation matrix&lt;/li&gt;
&lt;li&gt;Assess the validity of surveys using factor analysis&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Measuring Mental States
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Suppose we like to know how somebody feels or what they think about something, such as the quality of service their water utility provides. In that case, we need to measure their mental state. There is currently no direct method to measure mental states, so we use indirect methods such as &lt;a href=&#34;https://en.wikipedia.org/wiki/Survey_methodology&#34;&gt;customer surveys&lt;/a&gt;. The basic idea is the way somebody completes a survey is causally related to their state of mind.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/mental-state.png&#34; alt=&#34;/images/r4h2o/mental-state.png&#34; title=&#34;/images/r4h2o/mental-state.png&#34; /&gt;&lt;/p&gt;
&lt;p&gt;
This chapter analysis a scale for consumer involvement where customers answered the following question bank of ten items:&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/involvement-pii-scale.jpg&#34; alt=&#34;Personal Involvement Inventory semantic-differential scale&#34; title=&#34;Personal Involvement Inventory semantic-differential scale&#34;/&gt;
&lt;figcaption&gt;
Personal Involvement Inventory semantic-differential scale (Zaichowsky 1994).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Reliability and Validity
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The basic principle of measuring a mental state using a survey is that we have a group of questions that relate to the same underlying mental construct. We need to evaluate reliability and validity to assess whether the survey items measure the underlying latent variable.&lt;/p&gt;
&lt;p&gt;
The reliability of a survey relates to the extent to which the answers to the survey items are internally consistent. The internal reliability of a survey can be informally assessed by reviewing the extent to which each of the items in the survey correlates with each other. The &lt;a href=&#34;https://personality-project.org/r/psych/&#34;&gt;psych package&lt;/a&gt; provides more advanced methods, such as Cronbach Alpha, to assess reliability.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/involvement-correlation.png&#34; alt=&#34;Correlation matrix for the Personal Involvement Index&#34; title=&#34;Correlation matrix for the Personal Involvement Index&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Correlation matrix for the Personal Involvement Index.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The validity of a survey is broadly the extent to which it measures the underlying mental states. One of the methods to assess validity is factor analysis.&lt;/p&gt;
&lt;p&gt;
This previous article about using factor analysis to &lt;a href=&#34;https://lucidmanager.org/data-science/measuring-consumer-involvement/&#34;&gt;measure consumer involvement&lt;/a&gt; summarises how to undertake exploratory factor analysis.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Analysing the Customer Experience Screencast
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Chapter eight of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains the theory of measuring the customer experience and how to implement it in R in more detail. This screencast runs through the code in the customer experience chapter.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/6PVaIf5T8Qw?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Analysing the Customer Experience screencast.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Additional Resources
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Surveys are a useful tool to analyse what customers think about tap water. Still, it can be better to move outside the formalities of the survey and use the customer&amp;#39;s own words. &lt;a href=&#34;https://lucidmanager.org/data-science/tap-water-sentiment-analysis/&#34;&gt;Sentiment analysis using tweets about tap water&lt;/a&gt; can provide illuminating insights.&lt;/p&gt;
&lt;p&gt;
My other book &lt;em&gt;Customer Experience Management for Water Utilities&lt;/em&gt; by IWA publishing delves deeper into using marketing theory for urban water supplies.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Other Chapters
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/managing-dirty-data/&#34;&gt;Previous Chapter&lt;/a&gt;: &lt;em&gt;Managing Dirty Data&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/basic-linear-regression/&#34;&gt;Next Chapter&lt;/a&gt;: &lt;em&gt;Basic Linear Regression&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;
Feel free to &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt; if you have any comments, suggestions or questions about this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Basic Linear Regression</title>
      <link>https://lucidmanager.org/data-science/basic-linear-regression/</link>
      <pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/basic-linear-regression/</guid>
      <description>
	
&lt;p&gt;
Regression analysis is one of the most common methods to investigate relationships between variables. Understanding basic linear regression is the first step toward predictive analysis and machine learning. &lt;a href=&#34;https://dx.doi.org/10.1201/9781003326977-9&#34;&gt;This chapter&lt;/a&gt; of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explores possible linear relationships between the responses in the customer survey and uses these results to explain the theory and practice of building and assessing linear models. The learning objectives for this chapter are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Understand the principles of linear regression&lt;/li&gt;
&lt;li&gt;Perform a linear regression of the customer survey data&lt;/li&gt;
&lt;li&gt;Assess the significance of a linear regression&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Principles of Linear Regression
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The purpose of a regression model is to predict one variable by measuring one or more other variables through a linear relationship. For example, predict water consumption based on the forecast temperature or investigate how customer complaints relate to the pressure level.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/regression-principles.png&#34; alt=&#34;/images/r4h2o/regression-principles.png&#34; title=&#34;Principles of linear regression&#34; alyt=&#34;Principles of linear regression&#34;/&gt;
&lt;figcaption&gt;
Principles of linear regression.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The task of linear regression analysis is to find the line that minimises the difference between the observed values $(y)$ and the predicted values $(\hat{y})$.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Linear Regressions in R
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;code&gt;lm()&lt;/code&gt; function is the regression workhorse that provides detailed output to assess the hypothesised relationship stored in a list.&lt;/p&gt;
&lt;p&gt;
Plotting the output of the linear model provides a detailed graphical assessment of the model.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The first plot reviews the residuals versus the fitter (predicted) values. Ideally, the red line overlaps perfectly with the &lt;em&gt;x&lt;/em&gt;-axis.&lt;/li&gt;
&lt;li&gt;The QQ-Residuals Plot tests whether the distribution of the residuals is normal, which is the case when the observations are all on the diagonal line.&lt;/li&gt;
&lt;li&gt;The scale location plot tests for the assumption of homoscedasticity, which is the case when the red line is horizontal.&lt;/li&gt;
&lt;li&gt;Lastly, the leverage plot tests the data for outliers. The numbers relate to the rows with outliers. Leverage is the extent to which coefficients would change of these values are removed.&lt;/li&gt;
&lt;/ol&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/linear-regression-review.png&#34; alt=&#34;Linear regression graphical review&#34; title=&#34;Linear regression graphical review&#34;/&gt;
&lt;figcaption&gt;
Linear regression graphical review.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Basic Linear Regression Screencast
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Chapter nine of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains the theory of linear regression and how to implement it in R in more detail. This screencast runs through the code in the basic linear regression chapter.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/X0SRaZu9lp0?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Basic Linear Regression Screencast.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Additional Resources
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/introduction-to-machine-learning/&#34;&gt;Chapter 13&lt;/a&gt; discusses multiple linear regression.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Other Chapters
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/analysing-the-customer-experience/&#34;&gt;Previos Chapter&lt;/a&gt;: &lt;em&gt;Analysing the Customer Experience&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/cluster-analysis-to-segment-customers/&#34;&gt;Next Chapter&lt;/a&gt;: &lt;em&gt;Clustering customers to define segments&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
Feel free to &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt; if you have any comments, suggestions or questions about this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Basics of the R Language</title>
      <link>https://lucidmanager.org/data-science/basics-of-the-r-language/</link>
      <pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/basics-of-the-r-language/</guid>
      <description>
	
&lt;p&gt;
&lt;a href=&#34;https://dx.doi.org/10.1201/9781003326977-2&#34;&gt;The second chapter&lt;/a&gt; of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; introduces the basic principles of the R language and RStudio to analyse and visualise data. Writing code is not only about using the correct syntax and the appropriate functions; this chapter also covers some issues regarding styling your code, making it easy to understand. This chapter concludes with a case study to measure water flow in an open channel using the Kindsvater-Carter formula. The learning objectives for this chapter are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Install R and RStudio and identify the different parts of the RStudio screen.&lt;/li&gt;
&lt;li&gt;Understand the principles of writing code to analyse data.&lt;/li&gt;
&lt;li&gt;Apply R code to solve a simple water problem.


   &lt;div class=&#34;box&#34;&gt;
     &lt;div class=&#34;media&#34;&gt;
       &lt;figure class=&#34;media-left&#34;&gt;
         &lt;p class=&#34;image is-128x128&#34;&gt;
           &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
         &lt;/p&gt;
       &lt;/figure&gt;
       &lt;div class=&#34;media-content&#34;&gt;
         &lt;div class=&#34;content&#34;&gt;
           &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
           &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
           &lt;div class=&#34;buttons&#34;&gt;
             &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
               &lt;span class=&#34;icon&#34;&gt;
                 &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
               &lt;/span&gt;
               &lt;span&gt;Routledge&lt;/span&gt;
             &lt;/a&gt;
             &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
               &lt;span class=&#34;icon&#34;&gt;
                 &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
               &lt;/span&gt;
               &lt;span&gt;Amazon&lt;/span&gt;
             &lt;/a&gt;
           &lt;/div&gt;
         &lt;/div&gt;
       &lt;/div&gt;
     &lt;/div&gt;
   &lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Installing R and Rstudio
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The best way to use R is through an &lt;em&gt;Integrated Development Environment&lt;/em&gt; (IDE). This type of software helps you to write and manage code. An IDE typically comprises a source code editor, automation tools, and functionality to simplify crafting and running code. Of course, you can use R without the IDE, but it will be less user-friendly.&lt;/p&gt;
&lt;p&gt;
Several IDEs are available to help you write R code. RStudio by Posit is the most popular option.&lt;/p&gt;
&lt;p&gt;
This software is also an open-source project, with free and paid versions for companies that want to use advanced features and support services. RStudio can also work with other languages, such as SQL and Python. Follow these steps to install the required software:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go to the R Project website: &lt;a href=&#34;https://cran.r-project.org/&#34;&gt;cran.r-project.org&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Download the base version for your operating system and install the software&lt;/li&gt;
&lt;li&gt;Go to the download page on the RStudio website: &lt;a href=&#34;https://posit.co/download/rstudio-desktop/&#34;&gt;posit.co&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Download the installer for the free desktop version and install the software&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Alternatively, you can sign up for a free and fully featured account to access RStudio’s cloud version (&lt;a href=&#34;https://posit.cloud/&#34;&gt;posit.cloud&lt;/a&gt;). This service gives you full access to R and RStudio in your browser without installing software. The free version provides enough hours of computing time to work through this book. You’ll have to pay for a subscription or install the desktop version if you need more time.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/rstudio.jpg&#34; alt=&#34;The RStudio IDE interface&#34; title=&#34;The RStudio IDE interface&#34;/&gt;
&lt;figcaption&gt;
The RStudio IDE interface.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Other R IDEs
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://microsoft.github.io/RTVS-docs/installation.html&#34;&gt;R Tools for Visual Studio&lt;/a&gt;: Microsoft’s development environment.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://rattle.togaware.com/&#34;&gt;Rattle&lt;/a&gt; is a popular graphical user interface for data mining in the R programming language.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://ess.r-project.org/&#34;&gt;Emacs Speaks Statistics&lt;/a&gt;: For advanced computer users.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Principles of Writing Code
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Writing code has a steep learning curve and can be both frustrating and rewarding at the same time. Here are some principles that will help you write good code that is easy to understand:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Use descriptive variable names. Don’t, for example, use &lt;code class=&#34;verbatim&#34;&gt;d&lt;/code&gt;, but &lt;code class=&#34;verbatim&#34;&gt;pipe-diameter&lt;/code&gt; or another descriptive name.&lt;/li&gt;
&lt;li&gt;Add plenty of whitespace in your code.&lt;/li&gt;
&lt;li&gt;Use comments starting with a hashtag: &lt;code class=&#34;verbatim&#34;&gt;#&lt;/code&gt; (comments are not evaluated)&lt;/li&gt;
&lt;li&gt;Follow a coding style guide, for example, the &lt;a href=&#34;https://style.tidyverse.org/&#34;&gt;Tidyverse Style Guide&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/r-learning-curve.jpg&#34; alt=&#34;The R Learning Curve can be steep and full of surprises&#34; title=&#34;The R Learning Curve can be steep and full of surprises&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
The R Learning Curve can be steep and full of surprises.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
R is Meme Proof
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The basic arithmetic in the R language follows the BODMAS rules (Brackets, Order, Division, Multiplication, Addition, and Subtraction). R is thus meme-proof and can solve the silly mathematical ‘challenges’ spread on social media.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/memes.jpg&#34; alt=&#34;R is meme-proof and can solve arithmetic challenges&#34; title=&#34;R is meme-proof and can solve arithmetic challenges&#34; width=&#34;200&#34;/&gt;
&lt;figcaption&gt;
R is meme-proof and can solve arithmetic challenges.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Channel Flow Case Study
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Determining the flow in an open channel is usually achieved by measuring the water depth through a section with a known shape. Forcing the water through a given shape over a sharp weir creates a boundary condition that allows us to calculate the flow. A mathematical relationship determines the volume of water that passes through the channel. This case study uses a rectangular weir. A simplified version of the Kindsvater-Carter formula:&lt;/p&gt;
&lt;p&gt;
$$Q = \frac{2}{3} C_d \sqrt{2g} \\ bh^{\frac{3}{2}}$$&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;$Q$: Flow rate ($m^3/s$)&lt;/li&gt;
&lt;li&gt;$C_d$ : Discharge coefficient&lt;/li&gt;
&lt;li&gt;$g$: Gravitational acceleration (9.81 $m/s^2$ )&lt;/li&gt;
&lt;li&gt;$b$: Measured width of the notch [$m$]&lt;/li&gt;
&lt;li&gt;$h$: Upstream head above crest level [$m$]&lt;/li&gt;
&lt;/ul&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/rectangular-weir.png&#34; alt=&#34;Rectangular weir&#34; title=&#34;Rectangular weir&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Rectangular weir.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What is the flow in $m^3/s$ when $h=100$&lt;/li&gt;
&lt;li&gt;What is the average flow when the level above the weir is 150, 136 and 75mm? &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Cheat Sheet
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To help you remember the various functions discussed in the first five chapters of the book, a &lt;a href=&#34;https://lucidmanager.org/pdf/r4h2o-cheat-sheet.pdf&#34;&gt;cheat sheet&lt;/a&gt; is available.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/r4h2o-cheat-sheet.jpg&#34; alt=&#34;R4H2O Cheat Sheet&#34; title=&#34;R4H2O Cheat Sheet&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Data Science for Water Utilities Cheat Sheet.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Basics of the R Language Screencast 
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Chapter two of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains the principles of writing code to analyse data in more detail. This screencast runs through the code in this chapter.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/iYO7rbAeatU?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Basics of the R Language.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
 The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Additional Resources
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To help you remember the various functions discussed in the first five chapters of the book, a &lt;a href=&#34;https://lucidmanager.org/pdf/r4h2o-cheat-sheet.pdf&#34;&gt;cheat sheet&lt;/a&gt; is available.&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/tags/project-euler/&#34;&gt;Project Euler&lt;/a&gt; provides an excellent way to practice solving basic mathematical methods in the R language.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
Other Chapters
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/r-for-water-utilities/&#34;&gt;Previous Chapter&lt;/a&gt;: &lt;em&gt;Introduction to Data Science for Water Utilities&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/loading-and-exploring-water-quality-data/&#34;&gt;Next Chapter&lt;/a&gt;: &lt;em&gt;Loading and Exploring Water Quality Data&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
Feel free to &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt; if you have any comments, suggestions or questions about this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Clustering Customers to Define Segments</title>
      <link>https://lucidmanager.org/data-science/cluster-analysis-to-segment-customers/</link>
      <pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/cluster-analysis-to-segment-customers/</guid>
      <description>
	
&lt;p&gt;
The ideal form of customer service is personal attention, where the needs of each individual are met. Unfortunately, this level of service is more often than not impossible or too costly to achieve. Service providers, therefore, segment their customers into groups with similar characteristics. Cluster analysis to segment customers is a commonly used technique, which analyses and divides an unlabeled dataset into groups of observations with similar properties. &lt;a href=&#34;https://dx.doi.org/10.1201/9781003326977-10&#34;&gt;This chapter&lt;/a&gt; of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; shows how to detect patterns and define segments in customer data. The learning objectives for this chapter are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Understand the principles of customer segmentation&lt;/li&gt;
&lt;li&gt;Apply and interpret hierarchical cluster analysis&lt;/li&gt;
&lt;li&gt;Apply and interpret k-means clustering&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Principles of Customer Segmentation
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The ideal situation for customer-centric services is that each customer receives individual attention. For large organisations, giving each customer individual attention is very costly and treating everybody the same is not very good either. Customer segmentation helps service providers group customers into segments with similar needs.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Demographic&lt;/em&gt;: Age, gender, income, education, ethnicity.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Behavioural&lt;/em&gt;: Purchasing habits, spending habits, water consumption.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Psychographic&lt;/em&gt;: Interests, lifestyle, motivations, and water-related priorities.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Geographic&lt;/em&gt;: Town, postal code, water system.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Hierarchical Cluster Analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This example contains data from ten hypothetical customers (A–J). The first data dimension in the test data is the average annual water consumption, and the second is the size of the land on which the house resides. The clusters should be easily visible by viewing the image.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/cluster-analysis-example.png&#34; alt=&#34;Cluster analysis example&#34; title=&#34;Cluster analysis example&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Cluster analysis example.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Hierarchical cluster analysis is a deterministic method to find the relevant clusters. This method reviews all possible combinations of data points and can thus be problematic when analysing large amounts of data. This tree diagram shows how all the points in the chart relate to each other.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/cluster-analysis-hierarchical.png&#34; alt=&#34;Hierarchical clustering example&#34; title=&#34;Hierarchical clustering example&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Hierarchical clustering example.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
k-means clustering
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;em&gt;k&lt;/em&gt;-means method uses a stochastic approach, which means that the outcome is not always the same when some clusters are in doubt. But, this method can digest much larger data sets than the hierarchical method. Another difference with the first method is that in &lt;em&gt;k&lt;/em&gt;-means, you need to specify the number of clusters before the analysis starts.&lt;/p&gt;
&lt;p&gt;
The elbow method visualises the Within-Clusters Sum of Squares for the number of clusters. The location where the graph has the smallest angle is most likely the ideal number of clusters.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/cluster-analysis-elbow.png&#34; alt=&#34;k-Means cluster analysis elbow method&#34; title=&#34;k-Means cluster analysis elbow method&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
k-Means cluster analysis elbow method.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Interpreting cluster analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Clustering analysis methods are a form of unsupervised machine learning. The computer detects patterns in the data but cannot relate them to meaning. The results of a cluster analysis require human interpretation to link it to the context of the data. &lt;/p&gt;
&lt;p&gt;
In this simple example, we could name the two clusters of households with and those without a garden.&lt;/p&gt;
&lt;p&gt;
In reality, cluster analysis occurs with many more variables, as in these simplified examples. The book provides a small case study that also uses categorical data.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Cluster Analysis to Segment Customers Screencast
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Chapter ten of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains the principles of cluster analysis for customer segmentation in more detail. This screencast demonstrates how to undertake cluster analysis to segment customers using the code explained in the book.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/4PwcB2NZX9M?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Clustering Customers to Define Segments.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Additional Resources
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;My book &lt;em&gt;Customer Experience Management for Water Utilities&lt;/em&gt; by IWA publishing delves deeper into using marketing theory for urban water supplies.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Other Chapters
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/basic-linear-regression/&#34;&gt;Previous Chapter&lt;/a&gt;: &lt;em&gt;Basic Linear Regression&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/working-with-dates-and-times-in-r/&#34;&gt;Next Chapter&lt;/a&gt;: &lt;em&gt;Working with Dates and Times&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
Feel free to &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt; if you have any comments, suggestions or questions about this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Descriptive Statistics in Water Quality</title>
      <link>https://lucidmanager.org/data-science/descriptive-statistics-in-water-quality/</link>
      <pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/descriptive-statistics-in-water-quality/</guid>
      <description>
	
&lt;p&gt;
The first step in telling data stories is summarising the available data. Descriptive statistics are tools that use a single number to describe a distribution. Analysts calculate averages, medians, percentiles and other statistical summaries to represent a data set&amp;#39;s tendency, spread, positions and shape. Statisticians have defined five types of descriptive statistics: frequency, central tendency, position, dispersion and shape. &lt;a href=&#34;https://dx.doi.org/10.1201/9781003326977-4&#34;&gt;This chapter&lt;/a&gt; of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; shows how to calculate descriptive statistics using synthetic water quality data from an imaginary city. The learning objectives for this chapter are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Summarise water quality data using various descriptive statistics&lt;/li&gt;
&lt;li&gt;Evaluate compliance of water quality data with relevant regulations.&lt;/li&gt;
&lt;li&gt;Perform grouped data analysis&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Descriptive Statistics
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;We have already seen &lt;em&gt;measures of frequency&lt;/em&gt; in Chapter 3, which count the number of times each observation occurs in a data sample. The remaining four descriptive statistics are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;Central tendency&lt;/em&gt; summarises a distribution with a single number&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Position&lt;/em&gt; describes how an observation relates to the others&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Dispersion&lt;/em&gt; describes how far the data deviates from the central tendency&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Shape&lt;/em&gt; summarises the shape of a distribution&lt;/li&gt;
&lt;/ol&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Measure of Central Tendency
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;A central tendency summarises a distribution with a single number, such as the mean, median or mode.&lt;/p&gt;
&lt;p&gt;
R has the &lt;code class=&#34;verbatim&#34;&gt;mean()&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;median()&lt;/code&gt; functions, but no basic function to &lt;a href=&#34;https://www.statology.org/mode-in-r/&#34;&gt;calculate the mode&lt;/a&gt; is available but can easily be added. Water quality data tends to be heavily skewed, so care needs to be taken when using the mean to describe a sample of water quality samples.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/measures-of-central-tendency.png&#34; alt=&#34;Descriptive statistics: Measures of Central Tendency&#34; title=&#34;Descriptive statistics: Measures of Central Tendency&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Measures of central tendency.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Measures of Position
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;A measure of position is a number’s relative position within the sample. Examples of measures of position are quartiles, deciles, and percentiles, generically known as a quantile. A percentile is a quantile multiplied by 100. Percentiles are a standard method to describe water quality data. For example, if we state that the 95th percentile of turbidity was 4 NTU, 95% of results were lower than or equal to 4 NTU, allowing the occasional spike. An earlier article on the website describes how R undertakes &lt;a href=&#34;https://lucidmanager.org/data-science/percentile-calculations/&#34;&gt;percentile calculations&lt;/a&gt; in more detail.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Measures of Dispersion
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Dispersion is the extent to which the measurements are spread. Several measures are available, such as the range and Inter-Quartile-Range, variance and standard deviation. The base R package has built-in functions for each of these measures. Please note that R uses &lt;a href=&#34;https://en.wikipedia.org/wiki/Bessel%27s_correction&#34;&gt;Bessel’s Correction&lt;/a&gt; to calculate variances to correct the bias in the estimated population variance.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Measures of Shape
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Lastly, we also need to know something about the shape of the distribution. The skewness of a distribution measure the eccentricity of the distribution curve. The kurtosis measures the ‘fatness’ of the tails of the distribution. A high skewness and kurtosis are, therefore, a sign of outliers in the data.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/measures-of-shape.png&#34; alt=&#34;Descriptive statistics: measures of shape (skewness and kurtosis)&#34; title=&#34;Descriptive statistics: measures of shape (skewness and kurtosis)&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Measures of shape (skewness and kurtosis)
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The &lt;a href=&#34;https://cran.r-project.org/web/packages/moments/index.html&#34;&gt;moments&lt;/a&gt; and &lt;a href=&#34;https://cran.r-project.org/web/packages/e1071/index.html&#34;&gt;e1071&lt;/a&gt; packages provide functions to calculate skewness and kurtosis. These packages use slightly different approaches, so the results can differ. Refer to the book or the package documentation for details.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Grouping Data
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Most data sets contain observations from various groups of data. In this case, we can analyse data by analyte, suburb or sample point. The &lt;code class=&#34;verbatim&#34;&gt;group_by()&lt;/code&gt; function in the dplyr package creates a grouped data frame which means you can calculate descriptive statistics by group. The example below shows a subset of the water quality data, and the two tables on the right are grouped by measure (analyte). The &lt;code class=&#34;verbatim&#34;&gt;summarise&lt;/code&gt; function is the workhorse that lets us analyse the data frame for each group.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/grouping.png&#34; alt=&#34;Grouped data frames (tibbles) in Tidyverse&#34; title=&#34;Grouped data frames (tibbles) in Tidyverse&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Grouped data frames (tibbles) in Tidyverse.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Descriptive Statistics in R Screencast
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Chapter four of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains descriptive statistics and how to calculate them in R in more detail. This screencast below reviews the code for this chapter.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/-HGwANDwxjc?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Descriptive Statistics in Water Quality screencast.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Additional Resources
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To help you remember the various functions discussed in the first five chapters of the book, a &lt;a href=&#34;https://lucidmanager.org/pdf/r4h2o-cheat-sheet.pdf&#34;&gt;cheat sheet&lt;/a&gt; is available.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
Other Chapters
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/loading-and-exploring-water-quality-data/&#34;&gt;Previous Chapter&lt;/a&gt;: &lt;em&gt;Loading and Exploring Data&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/visualising-data-with-ggplot2/&#34;&gt;Next Chapter&lt;/a&gt;: &lt;em&gt;Visualing Water Quality Data with ggplot2&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;
Feel free to &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt; if you have any comments, suggestions or questions about this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Detecting Outliers and Anomalies in Time Series Data</title>
      <link>https://lucidmanager.org/data-science/detecting-outliers-and-anomalies/</link>
      <pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/detecting-outliers-and-anomalies/</guid>
      <description>
	
&lt;p&gt;
Reporting all available data has little value because it overwhelms the organisation with information that is not actionable. A more productive approach to processing the data deluge is to show those processes where something interesting has occurred. A range of techniques is available to detect anomalies in the data. Reporting outliers and anomalies focuses the organisation&amp;#39;s attention by raising questions and motivating action. &lt;a href=&#34;https://dx.doi.org/10.1201/9781003326977-12&#34;&gt;This chapter&lt;/a&gt; of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; discusses finding the most exciting points in your data to create actionable reports. This chapter also shows how to streamline code with functions and develop a leak detection tool to use with digital metering data. The learning objectives for this session are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Apply statistical methods to detect outliers&lt;/li&gt;
&lt;li&gt;Find anomalies in a time series&lt;/li&gt;
&lt;li&gt;Develop R functions to streamline your code&lt;/li&gt;
&lt;li&gt;Write a function to detect leaks from digital metering data&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Anomaly Detection Methods
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Several methods are available to detect anomalies:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Visual inspection of graphs (such as boxplots, see &lt;a href=&#34;https://lucidmanager.org/data-science/visualising-data-with-ggplot2/&#34;&gt;chapter 6&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Static thresholds, such as physical constraints or a regulatory limit &lt;/li&gt;
&lt;li&gt;Statistical criteria (such as &lt;a href=&#34;https://en.wikipedia.org/wiki/Standard_score&#34;&gt;Z-scores&lt;/a&gt; and &lt;a href=&#34;https://en.wikipedia.org/wiki/Median_absolute_deviation&#34;&gt;Median Absolute Deviation&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Domain knowledge&lt;/li&gt;
&lt;/ul&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/boxplot-with-outliers.png&#34; alt=&#34;Visually detecting outliers with a boxplot of chlorine data&#34; title=&#34;Visually detecting outliers with a boxplot of chlorine data&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Visually detecting outliers with a boxplot of chlorine data.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Leak Detection
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Domain knowledge also helps to detect anomalies. For example, reservoir levels cannot extend much above the Full Supply Level, and a pH probe cannot measure values of zero and so on. Domain knowledge helps to define typical situations.&lt;/p&gt;
&lt;p&gt;
Detecting leaks downstream of a meter is easy when we can make some assumptions about the consumption pattern. For any residential connection, we can safely assume there is no flow for at least a few hours daily. This assumption can easily be transformed into code.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/diurnal-curve.png&#34; alt=&#34;Visually detecting outliers with a boxplot of chlorine data&#34; title=&#34;Visually detecting outliers with a boxplot of chlorine data&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Visually detecting outliers with a boxplot of chlorine data.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The data for this case study was &lt;a href=&#34;https://lucidmanager.org/data-science/simulating-water-consumption/&#34;&gt;simulated using R scripts&lt;/a&gt;. A previous blog post about &lt;a href=&#34;https://lucidmanager.org/data-science/analyse-digital-water-meter-data/&#34;&gt;analysing digital meter data&lt;/a&gt; contains more details.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Detecting Outliers and Anomalies Screencast
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Chapter twelve of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains the theory and application of anomaly detection in more detail. This screencast below reviews the code for this chapter.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/U4w9-OdYc3A?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Detecting Outliers and Anomalies Screencast.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Additional Resources
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The video below provides an excellent introduction to the principles of anomaly detection.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/mhSFyXbCaPM?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Anomaly Detection 101.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Other Chapters
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/working-with-dates-and-times-in-r/&#34;&gt;Previous Chapter&lt;/a&gt;: &lt;em&gt;Working with Dates and Times&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/introduction-to-machine-learning/&#34;&gt;Next Chapter&lt;/a&gt;: &lt;em&gt;Introduction to Machine Learning&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
Feel free to &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt; if you have any comments, suggestions or questions about this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Introduction to Machine Learning</title>
      <link>https://lucidmanager.org/data-science/introduction-to-machine-learning/</link>
      <pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/introduction-to-machine-learning/</guid>
      <description>
	
&lt;p&gt;
Machine learning is an approach to statistical analysis whereby a computer detects and then uses the results to predict outcomes from new data. The combination of large amounts of available data becoming cheaply available and open source machine learning algorithms is causing a revolution in many industries, including water management. For example, water utilities can apply machine learning to predict which water or sewer main is likely to fail soon. &lt;a href=&#34;https://dx.doi.org/10.1201/9781003326977-13&#34;&gt;This chapter&lt;/a&gt; of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; introduces the principles of machine learning and the basic modelling process. The learning objectives for this chapter are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Understand the principles of machine learning&lt;/li&gt;
&lt;li&gt;Apply cross-validation to linear regression&lt;/li&gt;
&lt;li&gt;Implement a decision tree prediction&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Principles of Machine Learning
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Machine learning is an area of study in computer science and statistics that involves developing algorithms that can automatically learn patterns from data and make predictions or decisions, without being explicitly programmed to do so.&lt;/p&gt;
&lt;p&gt;
We have already seen &lt;a href=&#34;https://lucidmanager.org/data-science/basic-linear-regression/&#34;&gt;linear regression&lt;/a&gt;, which is a form of supervised learning. In this type of machine learning, The model is trained on a dataset that contains both input and output variables. &lt;a href=&#34;https://lucidmanager.org/data-science/cluster-analysis-to-segment-customers/&#34;&gt;Cluster analysis&lt;/a&gt; belongs to the unsupervised leanring category. In these types of problems, the computer seeks dor structure in the data without independent variable.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/machine-learning-tree.png&#34; alt=&#34;Family tree of machine learning&#34; title=&#34;Family tree of machine learning&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Family tree of machine learning.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This chapter introduces multiple linear regression and decision trees.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Cross Validation and Fitting
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/machine-learning-fitting.png&#34; alt=&#34;Fitting a machine-learning model&#34; title=&#34;Fitting a machine-learning model&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Fitting a machine-learning model.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Multiple Linear Regression
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/concrete-linear-regression.png&#34; alt=&#34;Concrete mixture decision tree&#34; title=&#34;Concrete mixture decision tree&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Concrete mixture decision tree.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Comparing models
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;RMSE&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Decision Tree
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/concrete-decision-tree.png&#34; alt=&#34;Concrete mixture decision tree&#34; title=&#34;Concrete mixture decision tree&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Concrete mixture decision tree.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Comparing models
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Confusion matrix&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Introduction to Machine Learning Screencast
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Chapter thirteen of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains the theory and application of machine learning in more detail. This screencast below reviews the code for this chapter.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/ZGJ77YexLyA?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Introduction to Machine Learning Screencast.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Additional Resources
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
Other Chapters
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/detecting-outliers-and-anomalies/&#34;&gt;Previous Chapter&lt;/a&gt;: &lt;em&gt;Detecting Outliers and Anomalies&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
Feel free to &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt; if you have any comments, suggestions or questions about this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Introduction to R for Utilities</title>
      <link>https://lucidmanager.org/data-science/r-for-water-utilities/</link>
      <pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/r-for-water-utilities/</guid>
      <description>
	
&lt;p&gt;
Data science is the activity of creating value from data. While the mechanics of developing data products by writing code is an essential skill, data science as an activity needs to be strategic to deliver business value. This chapter develops a framework for a strategic approach to data science by creating useful, sound and aesthetic data products. Usefulness relates to a data product&amp;#39;s ability to achieve business outcomes. A sound data product is developed using valid and reliable models, is reproducible, and, when using data about people, is ethical. Lastly, data products need to be aesthetic, not to beautify but to ensure that the outcomes of analyses are easily understood so that benefits can be realised. The book &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; introduces using R for water utilities through realistic case studies. &lt;a href=&#34;https://dx.doi.org/10.1201/9781003326977-1&#34;&gt;The first chapter&lt;/a&gt; introduces the principles of data science and how they relate to water management.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
What is Data Science?
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Data science involves analyzing data in a systematic way to create value for businesses. This field combines mathematics, computer science, and domain knowledge. Some professionals in the industry believe that individuals with expertise in all three areas are rare and often referred to as &amp;#34;data science unicorns.&amp;#34;&lt;/p&gt;
&lt;p&gt;
As part of my Data Science Unicorn Breeding Program, I have written a book aimed at water professionals who already possess mathematical skills and domain knowledge. I want to create the elusive data science unicorns by teaching them computer science.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/conway-venn-diagram.png&#34; alt=&#34;Conway Venn Diagram&#34; title=&#34;Conway Venn Diagram&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Data science competencies (Based on Conway, 2009).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
See my article about &lt;a href=&#34;https://lucidmanager.org/data-science/strategic-data-science/&#34;&gt;strategic data science&lt;/a&gt;, which develops a systematic approach to creating value from data.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2019_sds.jpg&#34; alt = &#34;Principles of Strategic Data Science&#34; title = &#34;Principles of Strategic Data Science&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Principles of Strategic Data Science&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Principles of Strategic Data Science helps you join the dots between mathematics, programming, and business analysis. With a unique approach that bridges the gap between mathematics and computer science, this book takes you through the entire data science pipeline.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.packtpub.com/en-us/product/principles-of-strategic-data-science-9781838985509&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Packt Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Learning how to code
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This book uses the &lt;a href=&#34;https://www.r-project.org/&#34;&gt;R language for Statistical Computing&lt;/a&gt;. This language is specifically designed for statistical analysis. Data science often uses other languages, such as Python, SQL, and Julia. The fact is that all data scientists need to be multi-lingual. &lt;/p&gt;
&lt;p&gt;
These seven steps will help you in your journey of becoming fluent in any programming language:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/basics-of-the-r-language/&#34;&gt;Understand the basics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Code by hand&lt;/li&gt;
&lt;li&gt;Create simple programs&lt;/li&gt;
&lt;li&gt;Practice&lt;/li&gt;
&lt;li&gt;Ask for help&lt;/li&gt;
&lt;li&gt;Build projects&lt;/li&gt;
&lt;li&gt;Help others&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This book introduces the basics of coding with R. Coding by hand is essential to thoroughly learning the language. Although generative AI, such as GPT or GitHub CoPilot, can write code, it will not teach you how to write code. Generative AI can assist you with finding solutions, but make sure you reverse-engineer the output so you understand the code.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
R for Water Utilities
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The following twelve chapters in this book introduce the R language by developing case studies:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Water quality data: Chapters 3–6 and 12&lt;/li&gt;
&lt;li&gt;Customer survey: Chapters 7–10&lt;/li&gt;
&lt;li&gt;Digital metering: Chapters 11–12&lt;/li&gt;
&lt;li&gt;Concrete curing: Chapter 13&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Additional Resources
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The water industry produces a lot of resources on how to implement smart water networks.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;a href=&#34;https://swan-forum.com/&#34;&gt;Smart Water Networks Forum&lt;/a&gt; (SWAN) is the leading, global voice for the smart water sector. They have detailed resources on how to implement a smart water network.&lt;/li&gt;
&lt;li&gt;Fee &lt;a href=&#34;https://iwa-network.org/publications/digital-water-book-a-strategic-digital-transformation-for-the-water-industry/&#34;&gt;Digital Water Book&lt;/a&gt;: A Strategic Digital Transformation for the Water Industry.&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Other Chapters
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/basics-of-the-r-language/&#34;&gt;Next Chapter&lt;/a&gt;: &lt;em&gt;Basics of the R Language&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
Feel free to &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt; if you have any comments, suggestions or questions about this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Loading and Exploring Water Quality Data from Spreadsheets</title>
      <link>https://lucidmanager.org/data-science/loading-and-exploring-water-quality-data/</link>
      <pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/loading-and-exploring-water-quality-data/</guid>
      <description>
	
&lt;p&gt;
The first action in any analysis project is to obtain and load data. This data is often available in a database, the internet, or a file on your computer. One of the essential skills is thus to load this data into memory and view its content. This chapter introduces how to read CSV files and spreadsheets into R and explore their content using the Tidyverse suite of libraries. &lt;a href=&#34;https://dx.doi.org/10.1201/9781003326977-3&#34;&gt;This chapter&lt;/a&gt; of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; also presents a case study about water quality using synthetic data from an imaginary water supply network. This chapter has the following learning objectives:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Download and install R packages&lt;/li&gt;
&lt;li&gt;Load and describe CSV files and spreadsheet&lt;/li&gt;
&lt;li&gt;Explore the content of rectangular data (data frames)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Tidyverse
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The R language has a lot of capabilities out of the box. But its strongest feature is that it can be easily extended. Thousands of packages are available for almost every imaginable specialised task. Packages are available in public repositories, such as &lt;a href=&#34;https://cran.r-project.org/web/packages/index.html&#34;&gt;CRAN&lt;/a&gt; (The Comprehensive R Archive Network).&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://www.tidyverse.org/&#34;&gt;Tidyverse&lt;/a&gt; is a collection of packages that makes working with R a bit easier. The remainder of this book will rely heavily on the Tidyverse way of analysing data.&lt;/p&gt;
&lt;p&gt;
A package provides additional functions for specialised tasks. You install packages with the &lt;code class=&#34;verbatim&#34;&gt;install.packages(&amp;#34;package-name&amp;#34;)&lt;/code&gt; function. To use the functions in a package, you must evaluate &lt;code class=&#34;verbatim&#34;&gt;library(package-name)&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Loading Data into R
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Using specialised packages, R can read almost every common data format, such as REST APIs, SQL databases and GIS shape files.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://readr.tidyverse.org/&#34;&gt;Tidyverse readr&lt;/a&gt; package reads rectangular data from text files, such as the standard CSV format. Of course, R can also do this with base functions. Still, the Tidyverse version is faster and better at recognising data types. The &lt;a href=&#34;https://readxl.tidyverse.org/&#34;&gt;Tidyverse readxl&lt;/a&gt; package reads data from Excel files.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Water Quality Case Study
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This case study uses synthetic data from an imaginary water system named Gormsey. This data contains four analytes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Escherichia coli (E. coli): A harmful bacterium.&lt;/li&gt;
&lt;li&gt;Total chlorine [mg/l]. Chlorine is dosed to prevent bacteria from multiplying.&lt;/li&gt;
&lt;li&gt;THM: Trihalomethanes. A byproduct of disinfection with chlorine that can cause a negative health impact.&lt;/li&gt;
&lt;li&gt;Turbidity [NTU]: A measure of cloudiness.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The data is available in the &lt;a href=&#34;https://github.com/pprevos/r4h2o&#34;&gt;GitHub repository&lt;/a&gt; for this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Variable Types and Classes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The previous chapter introduced scalar and vector variables. However, most data used in practice is stored in a rectangular format as a table. In the R language, a data frame is a rectangular data set where each column is a variable and each row an observation. The Tidyverse data frame is a Tibble, but these names are used interchangeably.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/variable-types.png&#34; alt=&#34;Scalar, vector and data frame variables in R&#34; title=&#34;Scalar, vector and data frame variables in R&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Scalar, vector and data frame variables in R.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Exploring Water Quality Data Screencast
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Chapter three of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains loading and exploring CSV and Excel files in more detail. This screencast below reviews the code for this chapter.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/KTQYBvD5DT4?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Loading and exploring spreadsheet data in R.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Additional Resources
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To help you remember the various functions discussed in the first five chapters of the book, a &lt;a href=&#34;https://lucidmanager.org/pdf/r4h2o-cheat-sheet.pdf&#34;&gt;cheat sheet&lt;/a&gt; is available.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Other Chapters
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/basics-of-the-r-language/&#34;&gt;Previous Chapter&lt;/a&gt;: &lt;em&gt;Basics of the R Language&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/descriptive-statistics-in-water-quality/&#34;&gt;Next Chapter&lt;/a&gt;: &lt;em&gt;Descriptive Statistics in Water Quality&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
Feel free to &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt; if you have any comments, suggestions or questions about this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Managing and Cleaning Dirty Data</title>
      <link>https://lucidmanager.org/data-science/managing-dirty-data/</link>
      <pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/managing-dirty-data/</guid>
      <description>
	
&lt;p&gt;
Data is almost always produced to manage operations and rarely collected to analyse it in the future. The available data is thus never in an ideal format and needs to be converted to be suitable for analysis. We need, at minimum, a clear data structure, the correct variable types, and readable variables names. Preparing data for analysis, sometimes called data munging or wrangling, is an essential part of the data science workflow. &lt;a href=&#34;https://dx.doi.org/10.1201/9781003326977-7&#34;&gt;This chapter&lt;/a&gt; of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; introduces some techniques to clean data with R and the Tidyverse to create reproducible code. This chapter introduces a case study about customer perceptions about tap water. The learning objectives for this session are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use the dplyr package to transform data.&lt;/li&gt;
&lt;li&gt;Apply the principles of tidy data.&lt;/li&gt;
&lt;li&gt;Develop a script to automate data cleaning.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Case Study 2: Understanding the Customer Experience
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The data for this case study is a survey to measure the customer experience of the customers of a water utility. This data is generated with online survey software and contains information about:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/measuring-consumer-involvement/&#34;&gt;Consumer Involvement&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Customer contact frequency&lt;/li&gt;
&lt;li&gt;Level of financial hardship&lt;/li&gt;
&lt;li&gt;Service Quality&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Data Cleaning
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Data cleaning, or data jujitsu as some call it, consists of three steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Load and explore the data&lt;/li&gt;
&lt;li&gt;Convert the data structure&lt;/li&gt;
&lt;li&gt;Remove invalid data&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A basic principle of good data science is never to manually clean data. Using a script to clean your data means that it is reproducible for other data sets with the same structure and issues and you can always go back to the raw data in case something went wrong.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Tidy Data
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Tidyverse uses the principles of &lt;a href=&#34;https://www.jstatsoft.org/article/view/v059i10/&#34;&gt;Tidy Data&lt;/a&gt;, which means that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Each variable forms a column&lt;/li&gt;
&lt;li&gt;Each observation forms a row&lt;/li&gt;
&lt;li&gt;Each type of observational unit forms a table&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The data on the left is untidy because the variable is spread over multiple columns. We can fix this by pivoting the data so  that the locations are no longer column names, but they become data.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/tidy-data.png&#34; alt=&#34;Untidy and tidy version of laboratory data&#34; title=&#34;Untidy and tidy version of laboratory data&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Untidy and tidy version of laboratory data.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Managing Dirty Data Screencast
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Chapter seven of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains using the dplyr package to clean data in more detail. This screencast below reviews the code for this chapter.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/BV8L94b1Y3s?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Managing Dirty Data Screencast.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Additional Resources
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Other Chapters
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/sharing-the-results-of-data-analysis/&#34;&gt;Previous Chapter&lt;/a&gt;: &lt;em&gt;Sharing Results of Data Analysis&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/analysing-the-customer-experience/&#34;&gt;Next Chapter&lt;/a&gt;: &lt;em&gt;Analysing the Customer Experience&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;
Feel free to &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt; if you have any comments, suggestions or questions about this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Sharing the Results of Data Analysis with R Markdown</title>
      <link>https://lucidmanager.org/data-science/sharing-the-results-of-data-analysis/</link>
      <pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/sharing-the-results-of-data-analysis/</guid>
      <description>
	
&lt;p&gt;
Data science aims to create value from data by creating useful, sound and aesthetic data products. Analysing data is rewarding, but creating value requires you to communicate the results. Analysing data in RStudio is fun but hard to share with anyone who does not understand the language. Of course, you could copy and paste results into a document, but that is neither efficient nor reproducible. This chapter explains how to communicate the fruits of your labour with colleagues and other interested parties by generating reports that combine text and analysis through literate programming. &lt;a href=&#34;https://dx.doi.org/10.1201/9781003326977-6&#34;&gt;This chapter&lt;/a&gt; of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt;  a workflow for data science products and how to create data products using the R Markdown method. The learning objectives for this chapter are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implement the workflow for data science projects&lt;/li&gt;
&lt;li&gt;Apply the principles of reproducible and replicable research&lt;/li&gt;
&lt;li&gt;Use basic R Markdown to create a Powerpoint presentation from data&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Data Science Workflow
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The data science workflow starts with &lt;em&gt;preparation&lt;/em&gt; and data cleaning, which can take most of the time in some projects. All projects should begin with a concise problem statement to prevent open-ended data dredging. Programmatic data cleaning is the topic of the next chapter.&lt;/p&gt;
&lt;p&gt;
Once the data has been tidied, we can try to &lt;em&gt;understand&lt;/em&gt; the data through exploratory analysis using &lt;a href=&#34;https://lucidmanager.org/data-science/descriptive-statistics-in-water-quality/&#34;&gt;descriptive statistics&lt;/a&gt; and &lt;a href=&#34;https://lucidmanager.org/data-science/visualising-data-with-ggplot2/&#34;&gt;visualisation&lt;/a&gt;. That insight allows us to model and reflect, an iterative process known as the &amp;#39;data vortex&amp;#39;.&lt;/p&gt;
&lt;p&gt;
Once we have created the model that best answers the problem statement, we can &lt;em&gt;communicate&lt;/em&gt; these results to the consumers of our data products. One method is through literate programming with tools such as R Markdown or Org Mode.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/workflow.png&#34; alt=&#34;Data science workflow&#34; title=&#34;Data science workflow&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Data science workflow.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Literate Programming Reproducible Analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Literate programming means integrating the text, the data and the code. This approach ensures that the analysis is reproducible, which means you can repeat the same process with new data in the same way.&lt;/p&gt;
&lt;p&gt;
A data science project consists of at least three sets of code:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Cleaning code to get from raw data to a tidy state&lt;/li&gt;
&lt;li&gt;Analytical code to analyse the data&lt;/li&gt;
&lt;li&gt;Presentation code to create summaries, tables and figures.&lt;/li&gt;
&lt;/ol&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/literate-programming.png&#34; alt=&#34;Reproducible research pipeline&#34; title=&#34;Reproducible research pipeline&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Reproducible research pipeline.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
With literate programming, you can combine text and code in one script. The most popular method with R is to use a Markdown file. This is the WYSIWYM (What You See is What You Mean) approach instead of the more popular WYSIWYG (What You See Is What You Get) approach in word processors.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/wysiwym.png&#34; alt=&#34;What You See Is What You Mean (WYSIWYM)&#34; title=&#34;What You See Is What You Mean (WYSIWYM)&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
What You See Is What You Mean (WYSIWYM)
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The left part of the screen shows what it looks like when I write a book, and the right part shows the end result when exported as a PDF file.&lt;/p&gt;
&lt;p&gt;
The screencast below introduces the principles of this approach.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Sharing the Results of Data Analysis Screencast
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Chapter six of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains using literate programming with R Markdown in more detail. This screencast below reviews the code for this chapter.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/c_No60g-mi0?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Sharing the Results of Data Analysis with RMarkdown.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Additional Resources
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;code class=&#34;verbatim&#34;&gt;consumer-involvement.Rmd&lt;/code&gt; in the &lt;code class=&#34;verbatim&#34;&gt;case-studies&lt;/code&gt; folder of the GitHub repository shows how to write a journal article, including references using a BibTeX file. The concept of Consumer Involvement is explained in &lt;a href=&#34;https://lucidmanager.org/data-science/analysing-the-customer-experience/&#34;&gt;Chapter 8&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://bookdown.org/yihui/rmarkdown/&#34;&gt;R Markdown: The Definitive Guide&lt;/a&gt; by Yihui Xie and others explains the how to use literate programming in R in great detail.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Other Chapters
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/visualising-data-with-ggplot2/&#34;&gt;Previous Chapter&lt;/a&gt;: &lt;em&gt;Visualising Data with ggplot2&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/managing-dirty-data/&#34;&gt;Next Chapter&lt;/a&gt;: &lt;em&gt;Managing Dirty Data&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
Feel free to &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt; if you have any comments, suggestions or questions about this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Visualising Data with ggplot2</title>
      <link>https://lucidmanager.org/data-science/visualising-data-with-ggplot2/</link>
      <pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/visualising-data-with-ggplot2/</guid>
      <description>
	
&lt;p&gt;
Visualisation is essential for data scientists who want to explore and understand data and communicate their results. Scientists have studied how the mind perceives graphics in great depth and devised a comprehensive body of knowledge that helps us create sound, useful and aesthetic visualisations. The first part of &lt;a href=&#34;https://dx.doi.org/10.1201/9781003326977-5&#34;&gt;this chapter&lt;/a&gt; of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; introduces some principles of best practices in data visualisation. The second part presents the ggplot2 library and the principles of the Grammar of Graphics to create basic visualisations. The learning objectives for this chapter are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Evaluate data visualisations using basic principles.&lt;/li&gt;
&lt;li&gt;Apply the principles of the Grammar of Graphics.&lt;/li&gt;
&lt;li&gt;Visualise water quality data with the ggplot2 package.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Principles of Visualisation
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Data visualisation needs to tell a story, which means that when somebody looks at the image, they need to draw a conclusion. A visualisation should not be a case of &amp;#34;create your own adventure&amp;#34;. Achieving this objective requires simplicity and graphic austerity.&lt;/p&gt;
&lt;p&gt;
The data-to-pixel ratio is a rule of thumb that helps to focus your visualisation on the story. This ratio expresses the number of pixels in the image (excluding the neutral background) versus those representing data.&lt;/p&gt;
&lt;p&gt;
The example below illustrates the idea. The image on the left might be interesting, but the background is distracting, and the colours don&amp;#39;t express data. The version on the right is a lot clearer on the story. We can immediately see which imaginary suburb has the best taste scores for tap water.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/data-pixel-ratio.png&#34; alt=&#34;Data to Pixel Ratio low and high&#34; title=&#34;Data to Pixel Ratio low and high&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Data to Pixel Ratio.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Grammar of Graphics and ggplot2
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;https://ggplot2.tidyverse.org/&#34;&gt;ggplot2 package&lt;/a&gt; is part of the Tidyverse. It implements the &lt;em&gt;Grammar of Graphics&lt;/em&gt;, a systematic approach to visualising data using layers. The various functions in ggplot2 are chained with a &lt;code class=&#34;verbatim&#34;&gt;+&lt;/code&gt; sign, forming the individual layers, as shown below. You can combine as many layers as you like.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/grammar-of-graphics.png&#34; alt=&#34;Grammar of Graphics and ggplot2 layers&#34; title=&#34;Grammar of Graphics and ggplot2 layers&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Grammar of Graphics and ggplot2 layers.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Using Colour in Visualisations
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Most graphs overuse colour to visualise data. Colours should only be used to comply with a style guide or to visualise data.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://colorbrewer2.org&#34;&gt;Color Brewer website&lt;/a&gt; provides a great interface to explore various colour palates.&lt;/p&gt;
&lt;p&gt;
Since writing this book, the latest R version has received an upgraded colour palette. &lt;a href=&#34;https://arxiv.org/abs/2303.04918&#34;&gt;This article&lt;/a&gt; explains the new built-in colour palettes.&lt;/p&gt;
&lt;p&gt;
Emil Hvitfeld has gathered a large collection of &lt;a href=&#34;https://github.com/EmilHvitfeldt/r-color-palettes&#34;&gt;colour palettes in R&lt;/a&gt;. &lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Visualising Data with ggplot2 Screencast
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Chapter five of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains visualising data with ggplot2 in more detail. This screencast below reviews the code for this chapter.&lt;/p&gt;
&lt;p&gt;
To help you remember the various functions discussed in the first five chapters of the book, a &lt;a href=&#34;https://lucidmanager.org/pdf/r4h2o-cheat-sheet.pdf&#34;&gt;cheat sheet&lt;/a&gt; is available.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/rzsh2uLtBTU?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Visualising Water Quality Data with ggplot2.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Additional Resources
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To help you remember the various functions discussed in the first five chapters of the book, a &lt;a href=&#34;https://lucidmanager.org/pdf/r4h2o-cheat-sheet.pdf&#34;&gt;cheat sheet&lt;/a&gt; is available.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Addendum
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The &lt;code&gt;width&lt;/code&gt; parameter in ggplot2 geometries that use lines has been deprecated and is replaced with &lt;code&gt;linewidth&lt;/code&gt;.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Other Sources
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.slideserve.com/lenore-holder/designing-great-visualizations&#34;&gt;PPT - Designing Great Visualizations PowerPoint Presentation, free download - ID:6574423&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://guides.lib.berkeley.edu/data-visualization/about&#34;&gt;About - Data Visualization - Library Guides at UC Berkeley&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://r-graph-gallery.com/&#34;&gt;The R Graph Gallery – Help and inspiration for R charts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://flowingdata.com/category/tutorials/&#34;&gt;Tutorials | FlowingData&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Other Chapters
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/descriptive-statistics-in-water-quality/&#34;&gt;Previous Chapter&lt;/a&gt;: &lt;em&gt;Descriptive Statistics&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/sharing-the-results-of-data-analysis/&#34;&gt;Next Chapter&lt;/a&gt;: &lt;em&gt;Sharing the Results&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
Feel free to &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt; if you have any comments, suggestions or questions about this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Working with Dates and Times in R</title>
      <link>https://lucidmanager.org/data-science/working-with-dates-and-times-in-r/</link>
      <pubDate>Wed, 10 May 2023 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/working-with-dates-and-times-in-r/</guid>
      <description>
	
&lt;p&gt;
Most data collected in operational processes are time series. These are data sets where each measurement is associated with the time of the measurement or observation. This chapter introduces a study which looks at synthetic data collected from water meters from individual houses. Meter reads collected at a high frequency provide valuable insights into water consumption, such as leak detection. &lt;a href=&#34;https://dx.doi.org/10.1201/9781003326977-11&#34;&gt;This chapter&lt;/a&gt; of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains how the R language manages dates and times and uses this knowledge to explore time series data. The learning objectives for this chapter are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Understand the principles of how the R language processes date and time variables.&lt;/li&gt;
&lt;li&gt;Apply the functionality of the Lubridate package to manipulate dates and times.&lt;/li&gt;
&lt;li&gt;Use date and time variables in calculations and visualisations.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Date and Time Variables
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;All date and time variables in R use integer numbers starting at the Unix Epoch (1 January 1970). Spreadsheets tend to use 31 December 1899 as their datum.&lt;/p&gt;
&lt;p&gt;
The basic time string uses the ISO &lt;a href=&#34;https://en.wikipedia.org/wiki/ISO_8601&#34;&gt;8601 convention&lt;/a&gt;, i.e. &amp;#34;2023-06-15 18:23:45 AEST&amp;#34;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Lubridate Package
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Working with dates and times in base R can be challenging. The &lt;a href=&#34;https://lubridate.tidyverse.org/&#34;&gt;lubridate package&lt;/a&gt; in the Tidyverse lubricates dates and times with some convenient functions.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Digital Metering Leak Detection
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The case study for this chapter uses synthetic digital metering data. The data for this case study was &lt;a href=&#34;https://lucidmanager.org/data-science/simulating-water-consumption/&#34;&gt;simulated using R scripts&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The article on &lt;a href=&#34;https://lucidmanager.org/data-science/analyse-digital-water-meter-data/&#34;&gt;analysing digital metering data&lt;/a&gt; explains some of the principles and creates a diurnal curve.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/r4h2o/diurnal-curve.png&#34; alt=&#34;Example of a diurnal curve for domestic water consumption&#34; title=&#34;Example of a diurnal curve for domestic water consumption&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Example of a diurnal curve for domestic water consumption.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Working with Dates and Times in R Screencast
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Chapter eleven of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains working with dates and times and leak detection in more detail. This screencast below reviews the code for this chapter.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/bjcBbZXbO8A?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Working with Dates and Times in R.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The data and code used in this chapter are available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Additional Resources
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Addendum
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The code on page 150 uses the &lt;code class=&#34;verbatim&#34;&gt;summarise()&lt;/code&gt; function to calculate daily flows. This function has been deprecated for this particular case. While &lt;code&gt;summarise()&lt;/code&gt; requires that each argument returns a single value, and &lt;code&gt;mutate()&lt;/code&gt; requires that each argument returns the same number of rows as the input, &lt;a href=&#34;https://dplyr.tidyverse.org/reference/reframe.html&#34;&gt;reframe()&lt;/a&gt; is a more general workhorse with no requirements on the number of rows returned per group.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Other Chapters
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://lucidmanager.org/data-science/cluster-analysis-to-segment-customers/&#34;&gt;Previous Chapter&lt;/a&gt;: &lt;em&gt;Clustering Customers to Define Segments&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/detecting-outliers-and-anomalies/&#34;&gt;Next Chapter&lt;/a&gt;: &lt;em&gt;Detecting Anomalies and Outliers in Water Data&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;
Feel free to &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt; if you have any comments, suggestions or questions about this book.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Create Bibliographies in Hugo with a shortcode</title>
      <link>https://lucidmanager.org/productivity/hugo-bibliography/</link>
      <pubDate>Sat, 09 Oct 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/hugo-bibliography/</guid>
      <description>
	
&lt;p&gt;
All writers stand on the shoulders of giants. To recognise that fact, academic writing uses a comprehensive system of citations and bibliographies to acknowledge the authors whose ideas you have based your work. Unfortunately, there is no standardised method in Hugo to manage citations and bibliographies. This article shows how to manage a Hugo bibliography using a &lt;a href=&#34;https://citeproc-js.readthedocs.io/&#34;&gt;CSL-JSON&lt;/a&gt; file and shortcodes.&lt;/p&gt;
&lt;p&gt;
The code for these shortcodes forms part of the &lt;em&gt;Third Hemisphere&lt;/em&gt; Hugo theme, which is used for this website. You can download the code from GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/hugo-thirdhemisphere/&#34; target=&#34;_blank&#34;
   title=&#34;Download hugo-thirdhemisphere from GitHub&#34;
   alt=&#34;Download hugo-thirdhemisphere from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;hugo-thirdhemisphere&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
CSL JSON Bibliography files
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Hugo can generate HTML content from JSON files, so all we need is a bibliography in this format. The &lt;a href=&#34;https://citationstyles.org/&#34;&gt;Citation Style Language&lt;/a&gt; (CSL) is a modern bibliography format that is perfect for developing Hugo shortcodes.&lt;/p&gt;
&lt;p&gt;
You can create CSL JSON with your favourite bibliography manager, such as &lt;a href=&#34;https://www.zotero.org/&#34;&gt;Zotero&lt;/a&gt; or &lt;a href=&#34;https://www.mendeley.com/&#34;&gt;Mendeley&lt;/a&gt;. In Zotero you can use the &lt;a href=&#34;https://retorque.re/zotero-better-bibtex/&#34;&gt;Better BibTeX package&lt;/a&gt; to synchronise your Zotero database to a JSON file. You can also export BibTeX files to JSON with &lt;a href=&#34;https://pandoc.org/&#34;&gt;Pandoc&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;pandoc filename.bib -t csljson -o filename.json&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;
The bibliography lives in the data folder of your website. for example &lt;code class=&#34;verbatim&#34;&gt;data/example.json&lt;/code&gt;. These shortcodes don&amp;#39;t work for data files stored in the theme&amp;#39;s data folder.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Hugo Bibliography Shortcodes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;em&gt;Third hemisphere&lt;/em&gt; Hugo theme contains three shortcodes to display information from the bibliography file:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Citation (&lt;code class=&#34;verbatim&#34;&gt;cite&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Bibliography (&lt;code class=&#34;verbatim&#34;&gt;bibliography&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Bibliography length (&lt;code class=&#34;verbatim&#34;&gt;bib-length&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You need to set a default JSON bibliography file by defining the &lt;code class=&#34;verbatim&#34;&gt;bib&lt;/code&gt; page variable in the front matter of the each page that uses this data to the relevant JSON filename, without extension, which Emacs org mode is &lt;code class=&#34;verbatim&#34;&gt;#+bib: example&lt;/code&gt; and in YAML:&lt;/p&gt;
&lt;pre class=&#34;example&#34;&gt;
---
params:
  bib: example
---
&lt;/pre&gt;
&lt;p&gt;
The Citation Style Language specifies over thirty &lt;a href=&#34;https://docs.citationstyles.org/en/stable/specification.html#appendix-iii-types&#34;&gt;reference types&lt;/a&gt;. These Hugo shortcodes only parse the most common types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Books&lt;/li&gt;
&lt;li&gt;Book chapters&lt;/li&gt;
&lt;li&gt;Conference papers&lt;/li&gt;
&lt;li&gt;Journal articles&lt;/li&gt;
&lt;li&gt;Reports&lt;/li&gt;
&lt;li&gt;Theses&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Citations
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The citations shortcode can create three types of citations. Two types of author-year citations and a full bibliographical citation. The &lt;code class=&#34;verbatim&#34;&gt;cite&lt;/code&gt; shortcode takes two variables, the citation type (&lt;code class=&#34;verbatim&#34;&gt;p&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;t&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;f&lt;/code&gt;) and the citation key. These shortcodes can only cite a single entry.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-4&#34;&gt;
Textual citations
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;Textual citations follow the author-year system. When there are more than one author or editor, the names are combined with &amp;#34;and&amp;#34;. If there are more than two authors or editors, the first two are named, followed by &amp;#34;et al.&amp;#34;. When no author or editor is defined, it displays &amp;#34;Anonymous&amp;#34;. In the next part, the code displays the year of the publication between parentheses. &lt;/p&gt;
&lt;p&gt;
The letter &lt;code class=&#34;verbatim&#34;&gt;p&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;t&lt;/code&gt; are used to indicate parenthetical or textual citations, for example:&lt;/p&gt;
&lt;p&gt;
&lt;code class=&#34;verbatim&#34;&gt;The taste of tap water influences perceptions of quality {{&amp;lt; cite p teillet-2010 *&amp;gt;}} and {{&amp;lt; cite t burns-2011 &amp;gt;}} suggested that …&lt;/code&gt; results in:&lt;/p&gt;
&lt;p&gt;
&amp;#34;The taste of tap water influences perceptions of quality (Teillet et al.
2010) and Burns et al.
(2011) suggested that …&amp;#34;&lt;/p&gt;
&lt;p&gt;
Using a file or cite key that does not exist causes an error: &lt;span class=&#34;has-background-danger has-text-white&#34;&gt;Entry not found&lt;/span&gt;.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-5&#34;&gt;
Full citations
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;The &lt;code class=&#34;verbatim&#34;&gt;{{&amp;lt; cite f zoeteman-1980 &amp;gt;}}&lt;/code&gt; gives the full citation in APA style, for example: &amp;#34;Zoeteman
(1980).
    &lt;em&gt;Sensory Assessment of Water Quality&lt;/em&gt;.
    Pergamon Press.&amp;#34;&lt;/p&gt;
&lt;p&gt;
The first part is the same as a textual citation. The remainder of the citation depends on the type as shown in the table below:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Citation field names&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Article&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;title&lt;/code&gt;. &lt;code class=&#34;verbatim&#34;&gt;container-title&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;volume&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;issue&lt;/code&gt;), &lt;code class=&#34;verbatim&#34;&gt;page&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Book&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;title&lt;/code&gt;. &lt;code class=&#34;verbatim&#34;&gt;publisher&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Chapter&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;title&lt;/code&gt;. In: &lt;code class=&#34;verbatim&#34;&gt;editor&lt;/code&gt; (Ed.), &lt;code class=&#34;verbatim&#34;&gt;container-title&lt;/code&gt;. &lt;code class=&#34;verbatim&#34;&gt;publisher&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Conference&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;title&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;event-name&lt;/code&gt; (&lt;code class=&#34;verbatim&#34;&gt;event-location&lt;/code&gt;).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Report&lt;/td&gt;
&lt;td&gt;&lt;code class=&#34;verbatim&#34;&gt;title&lt;/code&gt;, (&lt;code class=&#34;verbatim&#34;&gt;number&lt;/code&gt;). &lt;code class=&#34;verbatim&#34;&gt;publisher&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
If the DOI field is available, it will be added to the end of the citation as a hyperlink. The URL field is used when the DOI is not defined.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
List of references
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The &lt;code class=&#34;verbatim&#34;&gt;{{&amp;lt; bibliography &amp;gt;}}&lt;/code&gt; shortcode lists the literature stored in the referenced JSON file. The entries are displayed in the order in which they appear in the JSON file.&lt;/p&gt;
&lt;p&gt;
The example bibliography contains 5 entries, one of each of the supported reference types.&lt;/p&gt;
&lt;p&gt;
&lt;div class =&#34;box&#34;&gt;
  &lt;p&gt;
    Burns, Ann V. et al. (2011).
    Victorian Water Customer: Water Services Needs &amp;amp; Values Summary Report.
    Victorian Water Customer: Water Services Needs &amp;amp; Values Summary Report, (Report 1).Accenture.&lt;/p&gt;
  &lt;p&gt;
    Mays, Larry W. and Angelakis, Andreas Nikolaos (2012).
    Ancient gods and godesses of water.
    In: 
    Angelakis et al.
    (Eds.),
    &lt;i&gt;Evolution of Water Supply Throughout the Millennia&lt;/i&gt; (IWA, London).&lt;/p&gt;
  &lt;p&gt;
    Teillet, Eric et al. (2010).
    Sensory methodologies and the taste of water.
    &lt;i&gt;Food Quality and Preference&lt;/i&gt;, 21(8), 967–976.doi: &lt;a href=&#34;https://doi.org/10.1016/j.foodqual.2010.04.012&#34; title=&#34;Sensory methodologies and the taste of water&#34; target=&#34;_blank&#34;&gt;10.1016/j.foodqual.2010.04.012&lt;/a&gt;.&lt;/p&gt;
  &lt;p&gt;
    Webber, Michael A. et al. (2014).
    When does the taste of water become offensive?
    In: &lt;em&gt;OzWater&lt;/em&gt;, Brisbane.&lt;/p&gt;
  &lt;p&gt;
    Zoeteman, B. C. J. (1980).
    &lt;em&gt;Sensory Assessment of Water Quality&lt;/em&gt;.
    Pergamon Press.&lt;/p&gt;
  &lt;/div&gt;&lt;/p&gt;
&lt;p&gt;
You can filter the bibliography by adding a keyword, for example: &lt;code class=&#34;verbatim&#34;&gt;{{&amp;lt; bibliography tast &amp;gt;}}&lt;/code&gt;. Any entry where the keyword appears in the keyword field is displayed (normalised to lowercase). The query matches on the start of the keyword, so this example shows any entry where the keyword field includes &lt;code class=&#34;verbatim&#34;&gt;taste&lt;/code&gt; or &lt;code class=&#34;verbatim&#34;&gt;tasting&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;
Lastly, the &lt;code class=&#34;verbatim&#34;&gt;{{&amp;lt; bib-length &amp;gt;}}&lt;/code&gt; shortcode counts the number of entries in the bibliography file and displays it as a number.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Hugo Bibliography Shortcodes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;These shortcodes are not yet fully optimised, but good enough to share with the world. I use them on my website about &lt;a href=&#34;https://horizonofreason.com/magic/magic-bibliography/&#34;&gt;scientific research into theatrical magic&lt;/a&gt;. These are some of the improvements I like to make:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Cite multiple entries in one shortcode call&lt;/li&gt;
&lt;li&gt;Add prefix and suffix numbers to citations&lt;/li&gt;
&lt;li&gt;Reference multiple bibliography files&lt;/li&gt;
&lt;li&gt;Add more literature types&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The source code for these shortcodes is available on GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/hugo-thirdhemisphere/&#34; target=&#34;_blank&#34;
   title=&#34;Download hugo-thirdhemisphere from GitHub&#34;
   alt=&#34;Download hugo-thirdhemisphere from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;hugo-thirdhemisphere&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    
    
    <item>
      <title>Hugo SEO plugin: A Search-Engine Optimisation partial template</title>
      <link>https://lucidmanager.org/productivity/hugo-seo/</link>
      <pubDate>Thu, 30 Sep 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/hugo-seo/</guid>
      <description>
	
&lt;p&gt;
Writing articles for a website is fun, but it is even more fun when readers can find your content through their favourite search engine. This article shows how to improve the likelihood that your page will rank highly in search engine results with on-site Search Engine Optimisation (SEO). The Third Hemisphere plugin has several Hugo SEO features to help you optimise the content and architecture of your website. &lt;/p&gt;
&lt;p&gt;
People are lazy searchers and will rarely go beyond the first page of search results. To improve your chances of a high ranking, your website needs to have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Quality content&lt;/li&gt;
&lt;li&gt;Good user experience and user interface&lt;/li&gt;
&lt;li&gt;Flawless security&lt;/li&gt;
&lt;li&gt;Effective publicity and social media&lt;/li&gt;
&lt;li&gt;Technical excellence&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The last point relates to the architecture of your website and how articles are structured and written. The recommendations in this article are implemented in the &lt;em&gt;Third Hemisphere&lt;/em&gt; template, which is used for this website. You can get the source code from GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/hugo-thirdhemisphere/&#34; target=&#34;_blank&#34;
   title=&#34;Download hugo-thirdhemisphere from GitHub&#34;
   alt=&#34;Download hugo-thirdhemisphere from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;hugo-thirdhemisphere&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
Please note that this approach has no guarantees because your ranking on the search results depends on factors you have less control over, such as backlinks. But technical SEO is in your control, so there is no reason to leave your search engine ranking entirely to chance.&lt;/p&gt;
&lt;p&gt;
This article shows how to optimise Hugo websites to make it easier for search engine bots to crawl your website and analyse your content.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Crawlability
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Website bots crawl the internet to analyse websites so that they appear in search results. Crawlability refers to how easy it is for a search engine to find its way around your website. Naturally, you want all your pages to be easily found and index. However, sometimes it is helpful to exclude pages, such as contact forms, from being crawled. There are three locations where your website instructs the search engine bot on what to index.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
robots.txt
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Search engines that crawl your website first analyse the &lt;code class=&#34;verbatim&#34;&gt;robots.txt&lt;/code&gt; file. This file instructs the search engine which files to include and exclude in its analysis.&lt;/p&gt;
&lt;p&gt;
Hugo creates a &lt;a href=&#34;https://gohugo.io/templates/robots/&#34;&gt;default robots file&lt;/a&gt; that allows all pages to be crawled. The &lt;em&gt;Third Hemisphere&lt;/em&gt; template enhances this behaviour by adding an exclusion to the &lt;code class=&#34;verbatim&#34;&gt;robots.txt&lt;/code&gt; file for every page where the &lt;code class=&#34;verbatim&#34;&gt;private&lt;/code&gt; variable is set to &lt;code class=&#34;verbatim&#34;&gt;true&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
To generate a custom robots file, set &lt;code class=&#34;verbatim&#34;&gt;enableRobotsTXT&lt;/code&gt; to true in your site configuration.&lt;/p&gt;
&lt;p&gt;
The robots file also points to the sitemap, which is an index of all your crawlable pages.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Sitemap
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Search engines discover new pages by following links. However, a more efficient way for them to find content is by following a &lt;a href=&#34;https://gohugo.io/templates/sitemap-template/&#34;&gt;sitemap&lt;/a&gt;. You can submit your sitemap URL to search engines to assist with crawling.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;sitemap.xml&lt;/code&gt; template of the &lt;em&gt;Third Hemisphere&lt;/em&gt; theme excludes any pages for which the &lt;code class=&#34;verbatim&#34;&gt;private&lt;/code&gt; variable is set to &lt;code class=&#34;verbatim&#34;&gt;true&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Canonical URL
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;A &lt;a href=&#34;https://yoast.com/rel-canonical/&#34;&gt;canonical URL&lt;/a&gt; lets search engines know that some pages are the same. Duplicate content can hurt your ranking, so you need to tell which page version is canonical.&lt;/p&gt;
&lt;p&gt;
Each page in the template contains a self-referencing canonical link to indicate that this is the page to be indexed.&lt;/p&gt;
&lt;div class=&#34;src src-html&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&amp;lt;&lt;span style=&#34;color:#070&#34;&gt;link&lt;/span&gt; &lt;span style=&#34;color:#00c&#34;&gt;rel&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;canonical&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#00c&#34;&gt;href&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;{{ .Permalink }}&amp;#34;&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Individual pages also can have a robots reference which indicates whether a crawler should index the page and/or follow its links. The head template contains the following line to enable excluding private pages.&lt;/p&gt;
&lt;div class=&#34;src src-html&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&amp;lt;&lt;span style=&#34;color:#070&#34;&gt;meta&lt;/span&gt; &lt;span style=&#34;color:#00c&#34;&gt;name&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;robots&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#00c&#34;&gt;content&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;{{if&lt;/span&gt; &lt;span style=&#34;color:#00c&#34;&gt;eq&lt;/span&gt; &lt;span style=&#34;color:#f00;background-color:#faa&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#00c&#34;&gt;Params&lt;/span&gt;&lt;span style=&#34;color:#f00;background-color:#faa&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#00c&#34;&gt;private&lt;/span&gt; &lt;span style=&#34;color:#00c&#34;&gt;true&lt;/span&gt; &lt;span style=&#34;color:#f00;background-color:#faa&#34;&gt;}}&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#00c&#34;&gt;noindex&lt;/span&gt;&lt;span style=&#34;color:#f00;background-color:#faa&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color:#00c&#34;&gt;nofollow&lt;/span&gt;&lt;span style=&#34;color:#f00;background-color:#faa&#34;&gt;&amp;#34;{{&lt;/span&gt; &lt;span style=&#34;color:#00c&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#f00;background-color:#faa&#34;&gt;}}&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#00c&#34;&gt;index&lt;/span&gt;&lt;span style=&#34;color:#f00;background-color:#faa&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color:#00c&#34;&gt;follow&lt;/span&gt;&lt;span style=&#34;color:#f00;background-color:#faa&#34;&gt;&amp;#34;{{&lt;/span&gt; &lt;span style=&#34;color:#00c&#34;&gt;end&lt;/span&gt; &lt;span style=&#34;color:#f00;background-color:#faa&#34;&gt;}}&lt;/span&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Structured Data
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Structured data helps search engines to classify the webpage it is indexing. It is a bit of JSON in your web page&amp;#39;s header that provides metadata to the search engine. The benefit of using correctly formatted structured data is that search engines will better present your page in the search results.&lt;/p&gt;
&lt;p&gt;
Search engines accept different &lt;a href=&#34;https://developers.google.com/search/docs/advanced/structured-data/article&#34;&gt;structured data schemas&lt;/a&gt;. The most relevant one for a blog is the article schema. The &lt;code class=&#34;verbatim&#34;&gt;schema.article.html&lt;/code&gt; file in the theme partials contains a schema for website articles, using the metadata for your website and page.&lt;/p&gt;
&lt;p&gt;
The template uses the following page variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Page description in the &lt;code class=&#34;verbatim&#34;&gt;description&lt;/code&gt; page variable&lt;/li&gt;
&lt;li&gt;Page image as the first image defined in the &lt;code class=&#34;verbatim&#34;&gt;images&lt;/code&gt; page variable&lt;/li&gt;
&lt;li&gt;Published date of the page, or if unavailable, the date that the website is generated&lt;/li&gt;
&lt;li&gt;The date the page was last modified using the &lt;code class=&#34;verbatim&#34;&gt;lastmod&lt;/code&gt; variable.&lt;/li&gt;
&lt;li&gt;The name of the author. When not defined in the page, it uses the author defined in the site configuration&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Lastly, the template inserts the following site variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Name of the website (site title)&lt;/li&gt;
&lt;li&gt;Publisher&lt;/li&gt;
&lt;li&gt;Logo, as defined in the &lt;code class=&#34;verbatim&#34;&gt;logo&lt;/code&gt; variable (URL to the image)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To optimise the use of structured data, make sure that you define all these site and page variables for all pages.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Content optimisation
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Search engines analyse the content of your page using complex algorithms. Unfortunately, there are no formulas to optimise your text, but there are some best-practice rules.&lt;/p&gt;
&lt;p&gt;
The basic premise of the game is that the text makes frequent references to the search keyword you want the page to rank for. Of course, you cannot outsmart search engines by simply repeating the phrase, but some good practices help to optimise your content.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
The Keyword
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The keyword (or perhaps better keyphrase) is the term that people enter into their search engine. The central idea of on-site SEO is to optimise the text and structure of your page so that the search engine relates it to that particular phrase.&lt;/p&gt;
&lt;p&gt;
Several tools are available to research what phrases people commonly use to search for stuff on the internet. Your keyphrase should not be just one word because millions of websites will discuss general topics. A good keyphrase is not too common but is also not too obscure. For example, this page is optimised for the keyword &amp;#34;Hugo SEO&amp;#34;.&lt;/p&gt;
&lt;p&gt;
The keyphrase should be &lt;a href=&#34;https://yoast.com/difference-between-keyword-and-keyphrase/&#34;&gt;between one and six words&lt;/a&gt;. Note that you should only use &lt;a href=&#34;https://yoa.st/33x&#34;&gt;each keyphrase once&lt;/a&gt; on your site so that your pages don&amp;#39;t compete with each other.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Slug
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;In Hugo, the website slug is the same as the filename of your article. You can also set it with the &lt;code class=&#34;verbatim&#34;&gt;slug&lt;/code&gt; &lt;a href=&#34;https://gohugo.io/content-management/organization#slug-1&#34;&gt;page variable&lt;/a&gt;. The slug of your page should ideally contain the keyphrase.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
Meta description
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The meta description is an HTML tag that describes what your page is about. You set the description for each page with the &lt;code class=&#34;verbatim&#34;&gt;description&lt;/code&gt; site variable. The meta description should contain the keyphrase and be between 120 and 155 characters long.&lt;/p&gt;
&lt;p&gt;
The meta description will also appear in a meta tag in the HTML. If no page description is available, the template either uses the &lt;a href=&#34;https://gohugo.io/content-management/summaries/&#34;&gt;content summary&lt;/a&gt;, and if that is unavailable, then the site description.&lt;/p&gt;
&lt;p&gt;
Ideally, you should also only use unique descriptions for each page on your website.&lt;/p&gt;
&lt;div class=&#34;src src-html&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&amp;lt;&lt;span style=&#34;color:#070&#34;&gt;meta&lt;/span&gt; &lt;span style=&#34;color:#00c&#34;&gt;name&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;description&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#00c&#34;&gt;content&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;{{ with .Description }}{{ . }}{{ else }}{{ with .Summary }}{{ . }}{{ else }}{{ .Site.Params.description }}{{end }}{{ end }} &amp;#34;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-10&#34;&gt;
Page Title
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Each page can have two titles, the one displayed on the page in the &lt;code class=&#34;verbatim&#34;&gt;H1&lt;/code&gt; header and one for the &lt;code class=&#34;verbatim&#34;&gt;title&lt;/code&gt; tag. The &lt;em&gt;Third Hemisphere&lt;/em&gt; template allows defining a separate title for the &lt;code class=&#34;verbatim&#34;&gt;title&lt;/code&gt; tag. This is the one that search engines tend to display, while the &lt;code class=&#34;verbatim&#34;&gt;H1&lt;/code&gt; is what readers see. Use the &lt;code class=&#34;verbatim&#34;&gt;seotitle&lt;/code&gt; variable to create separate titles.&lt;/p&gt;
&lt;p&gt;
The title needs to be long enough to make sense but short enough to fit into the search engine snippet. The ideal title is between 50 and 60 characters, and it should contain the keyphrase.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-11&#34;&gt;
Headings
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Your content should have headings to guide the reader through your text. At least one header, besides the title, needs to contain the keyphrase.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-12&#34;&gt;
Text
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The content needs to be at least 300 words and contain the keyphrase in the first paragraph. Ideally, the key phrase should be mentioned a few times throughout the text.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-13&#34;&gt;
Images
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;All images on your page should all have alt and title tags, one of which should contain the keyphrase.&lt;/p&gt;
&lt;p&gt;
In the &lt;em&gt;Third Hemisphere&lt;/em&gt; template, you can define a featured image with the &lt;code class=&#34;verbatim&#34;&gt;images&lt;/code&gt; parameter. This image should be at least 800 pixels wide with an aspect ratio of 3:2. The image is used in the structured data page summary on list pages. In addition, this image is automatically provided with relevant alt and title tags, using the content of the &lt;code class=&#34;verbatim&#34;&gt;description&lt;/code&gt; page variable.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-14&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-14&#34;&gt;
Hugo SEO Partial Template
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-14&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;em&gt;Third Hemisphere&lt;/em&gt; Hugo theme contains a partial template that checks the content of each article.&lt;/p&gt;
&lt;p&gt;
The SEO dashboard only appears when running the site on localhost and when the &lt;code class=&#34;verbatim&#34;&gt;draft&lt;/code&gt; page parameter is &lt;code class=&#34;verbatim&#34;&gt;true&lt;/code&gt;.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hugo/hugo-seo-summary.png&#34; alt=&#34;Hugo SEO summary for this page&#34; title=&#34;Hugo SEO summary for this page&#34;/&gt;
&lt;figcaption&gt;
Hugo SEO summary for this page.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
You can find the code for this template on the GitHub repository for this theme.&lt;/p&gt;
&lt;p&gt;
This assessment is pretty crude due to the limited text analysis capabilities in Hugo. Search engines can ignore stopwords, so &amp;#34;SEO for Hugo&amp;#34; is the same as &amp;#34;Hugo SEO&amp;#34;. The dashboard is just an aide to guide you when optimising your content.&lt;/p&gt;
&lt;p&gt;
While all these techniques are considered best practices, there is no substitution for content that readers want to read and share.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Monte Carlo Cost Estimates: Engineers Throwing Dice</title>
      <link>https://lucidmanager.org/data-science/monte-carlo-cost-estimates/</link>
      <pubDate>Mon, 23 Aug 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/monte-carlo-cost-estimates/</guid>
      <description>
	
&lt;p&gt;
Estimating the cost of a complex project is not a trivial task. Traditional cost estimates are full of assumptions about the future state of the market and the final deliverable. Monte Carlo cost estimates are a tool for better understanding your project&amp;#39;s risks and enabling better cost control. Monte Carlo simulations are a technique to control your “known unknowns”.&lt;/p&gt;
&lt;p&gt;
Albert Einstein famously said that “God does not play dice”. While this might or might not be the case, engineers play dice and embrace the stochastic nature of reality to predict the future. Monte Carlo Simulations are a method for estimating the cost of your project across thousands of parallel universes to assess financial risk. &lt;/p&gt;
&lt;p&gt;
While I have a pet hate against using &lt;a href=&#34;https://lucidmanager.org/management/alternative-risk-matrix-template/&#34;&gt;matrices to manage risk&lt;/a&gt;, Monte Carlo simulations are an analytical method for dealing with uncertainty and risk. This article explains the principles of Monte Carlo cost estimates and how to implement them in the R language for statistical computing.&lt;/p&gt;
&lt;p&gt;
You can download the code from GitHub in the &lt;code class=&#34;verbatim&#34;&gt;case-studies&lt;/code&gt; folder.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The principles of cost estimates
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The basic principle of cost estimation is deceptively simple. To estimate the cost for each item in a project, multiply the quantity of work $Q_i$ times the rate $R_i$ you will pay for each unit of work. Sum the cost of each item, and you have the total project cost $P$ for a project with $j$ items:&lt;/p&gt;
&lt;p&gt;
$$P = \sum_{i=1}^j Q_i R_i$$&lt;/p&gt;
&lt;p&gt;
The reality is, unfortunately, more inconsistent than this equation can express. Determining the correct quantity and rate for each item is a fine art requiring knowledge of engineering and economics.&lt;/p&gt;
&lt;p&gt;
Cost estimates reflect the state of knowledge at the time of developing them. Many aspects of the project have yet to be discovered and might only surface once we start digging. As the late &lt;a href=&#34;https://medium.com/the-philosophers-stone/rumsfelds-logic-of-known-knowns-known-unknowns-and-unknown-unknowns-f506db31ac74&#34;&gt;Donald Rumsfeld philosophically said&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;… there are known knowns; there are things we know we know. We also know there are known unknowns; that is, we know there are things we do not know. But there are also unknown unknowns — the ones we don’t know, we don’t know.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/REWeBzGuzCc?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Donald Rumsfeld.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Deterministic
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The basic method is helpful, but it assumes we know the amount of work or the unit rate accurately. Both parameters are subject to uncertainty and risk because the project has yet to be realised. Only at the end of the project do we know precisely how much it costs.&lt;/p&gt;
&lt;p&gt;
In deterministic cost estimation, this uncertainty is accounted for by adding a contingency to the estimate. This contingency is simply a percentage of the total. The less information about the project (usually at the early stages of development), the higher the rate.&lt;/p&gt;
&lt;p&gt;
In the planning phases, 20% or even higher might be suitable, while uncertainty can be much lower after tender award. This uncertainty covers any risk that quantities or rates are higher, as well as unforeseen activities that were not costed. The table below shows a typical deterministic cost estimate.&lt;/p&gt;
&lt;figure&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;Quantity&lt;/th&gt;
&lt;th&gt;Unit&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;Rate&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;Cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Materials&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;12,000&lt;/td&gt;
&lt;td&gt;$m^1$&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;75&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;$900,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Excavation&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;2,200&lt;/td&gt;
&lt;td&gt;$m^3$&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;15&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;$33,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pipe laying&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;12,000&lt;/td&gt;
&lt;td&gt;$m^1$&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;13&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;$156,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;SUBTOTAL&lt;/em&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;em&gt;$1,089,000&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Contingency&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;20%&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;$217,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TOTAL&lt;/strong&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;strong&gt;$1,306,000&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;figcaption&gt;
Example of a simple pipeline project estimate.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
A deterministic method is a blunt tool. Uncertainties are not estimated; they are based on rules of thumb. In this example, we cannot know which part of the project contributes most to the uncertainty or the likelihood of staying within budget. Is the project manager simply inflating the budget to reduce the risk of spending more? What is the probability that the project will cost more than the estimated amount? We cannot answer these questions with the deterministic method.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Probabilistic
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;A better understanding of the financial risk in a project leads to better decisions. Probabilistic cost estimation methods assess the uncertainty of each item rather than applying a percentage to the total. Breaking the uncertainty into smaller chunks allows project managers to better understand the financial risk in their projects and reduces the risk of significant estimating errors.&lt;/p&gt;
&lt;p&gt;
The quantity of work and the rate we pay vary with local conditions, external factors, market rates, and other conditions. We thus need to introduce an error rate $\epsilon_i$ for each item to account for the uncertainty in the estimate. Uncertainty relates to the inaccuracy of each cost item due to a lack of information. Thus, our formula for a project with $j$ items and $k$ events cost now becomes:&lt;/p&gt;
&lt;p&gt;
$$P = \sum_{i=1}^j (Q_i R_i)+ \epsilon_i$$&lt;/p&gt;
&lt;p&gt;
The most basic way to implement this concept is to assign a contingency to each item in the estimate and nominate the risk events in something like this:&lt;/p&gt;
&lt;figure&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;Quantity&lt;/th&gt;
&lt;th&gt;Unit&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;Rate&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;Cost&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;Uncertainty&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Materials&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;12,000&lt;/td&gt;
&lt;td&gt;$m^1$&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;75&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;$900,000&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;$9,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Excavation&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;2,200&lt;/td&gt;
&lt;td&gt;$m^3$&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;15&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;$33,000&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;$16,500&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pipe laying&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;12,000&lt;/td&gt;
&lt;td&gt;$m^1$&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;13&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;$156,000&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;$30,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;SUBTOTAL&lt;/em&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;em&gt;$1,089,000&lt;/em&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;em&gt;$55,500&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TOTAL&lt;/strong&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;strong&gt;$1,144,500&lt;/strong&gt;&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;figcaption&gt;
Example of a simple pipeline project estimate.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Note that we now call it &amp;#39;uncertainty&amp;#39; rather than &amp;#39;contingency&amp;#39;. This terminology is more than a semantic difference, as we have estimated our uncertainty at the item level in the Work-Breakdown-Structure.&lt;/p&gt;
&lt;p&gt;
This approach provides additional intelligence about where the project&amp;#39;s risks lie, which can help the team allocate efforts where they are most needed. The fact that the estimate is lower than before is less interesting than what we can gather from the details. If this were my project, I would gather more information about the events with the highest relative uncertainty to reduce risk.&lt;/p&gt;
&lt;p&gt;
A probabilistic cost estimate produces higher accuracy because the error rate for some items will be more controllable than for others. In the traditional method, the amount of contingency is anyone&amp;#39;s best guess. Estimates often hide contingencies in cost items to reduce the risk of requesting more budget. While this approach is pragmatic, looking at each item is more transparent.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Monte Carlo Cost Estimate
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The probabilistic approach in the table above is an acceptable way to assign uncertainties and risks. Still, it does not give us insight into how likely this estimate will eventuate.&lt;/p&gt;
&lt;p&gt;
Experience shows that the final project outcome rarely matches the estimate. It is, after all, an estimate, not a prediction. In other words, if you do the same project thousands of times in parallel universes, you will have thousands of different outcomes. This science-fiction concept is the basis for Monte Carlo simulations. With some statistics, we can recreate this hypothetical situation by repeating the same estimate thousands of times and analysing the distribution of possible outcomes.&lt;/p&gt;
&lt;p&gt;
Monte Carlo simulations model reality using large volumes of randomised numbers drawn from known distributions. They can be used for any situation where deterministic methods are too complex, such as &lt;a href=&#34;https://lucidmanager.org/data-science/call-centre-workforce-planning-erlang-c-in-r/&#34;&gt;modelling contact centre call traffic&lt;/a&gt;, or in this case, a cost estimate.&lt;/p&gt;
&lt;p&gt;
To add more information to the estimate, we assign each item a low, likely and high cost. The low cost ($a$) is rarely achieved and is your ‘bargain-basement’ price. The likely cost ($c$) is what you would typically use in your estimate. Finally, the high cost ($b$) is what you will pay when everything you can think of goes wrong. Statistically, each cost item now has a &lt;a href=&#34;https://en.wikipedia.org/wiki/Triangular_distribution&#34;&gt;triangular probability distribution&lt;/a&gt;, visualised below.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://upload.wikimedia.org/wikipedia/commons/4/45/Triangular_distribution_PMF.png&#34; alt=&#34;Triangular probability density distribution&#34; title=&#34;Triangular probability density function&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Triangular probability density function.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Our cost estimate would now look something like this:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;Low&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;Medium&lt;/th&gt;
&lt;th class=&#34;align-right&#34;&gt;High&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Materials&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;900000&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;909000&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;950000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Excavation&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;33000&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;49500&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;50000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pipe laying&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;156000&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;186000&lt;/td&gt;
&lt;td class=&#34;align-right&#34;&gt;200000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
For each item, we can calculate the average or any other percentile. The average cost of an item is $\frac{a+b+c}{3}$. The expected cost $x$ with likelihood $p$ is defined by the &lt;a href=&#34;https://lucidmanager.org/data-science/percentile-calculations/&#34;&gt;quantiles&lt;/a&gt; for each item, given by:&lt;/p&gt;
&lt;p&gt;
$$x_p = \begin{cases}
a + \sqrt{(b-a)(c-a)p} &amp;amp; 0 \leq p \leq p_c \\
b - \sqrt{(b-a)(b-c)(1-p)} &amp;amp; p_c &amp;lt; p \leq 1
\end{cases}$$&lt;/p&gt;
&lt;p&gt;
Where $p_c$ is the probability of the likely estimate ($c$): $p_c=\frac{c-a}{b-a}$, and $a \leq c$ and $b \geq c$.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://upload.wikimedia.org/wikipedia/commons/thumb/e/e5/Triangular_distribution_CMF.png/800px-Triangular_distribution_CMF.png&#34; alt=&#34;Triangular cumulative distribution function&#34; title=&#34;cumulative distribution function&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Triangular cumulative distribution function.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
While the triangular distribution is the most common method for assessing uncertainty, other distributions are possible; the principles remain the same. Be mindful, however, that most probability distributions range from minus to plus infinity, which is not a realistic assumption for cost estimates.&lt;/p&gt;
&lt;p&gt;
If your cost estimate contains only one item, you are done, as you can calculate the project cost by plugging in a percentile $p$ into the formulas. The final project cost will be lower than this number at probability $p$. The chosen percentile depends on your risk appetite. A percentile of .95 provides much more confidence that the actual cost will be lower than the budget.&lt;/p&gt;
&lt;p&gt;
But when the estimate includes multiple items, doing so analytically will be too complex for mere mortals. This situation is where the Monte Carlo technique comes in. The Monte Carlo method simulates reality by calculating thousands of possible outcomes. The result is not a singular number but a distribution of $n$ possible outcomes.&lt;/p&gt;
&lt;p&gt;
The outcome of a Monte Carlo simulation is a cost estimate for thousands of parallel universes. If you were to undertake the project $n$ times, the distribution of the final cost is expected to resemble the simulation outcome.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Monte Carlo Simulation in R
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Several R libraries can calculate triangular distributions. The &lt;code class=&#34;verbatim&#34;&gt;triangle&lt;/code&gt; package provides a set of functions to work with &lt;a href=&#34;https://bertcarnell.github.io/triangle/&#34;&gt;triangular distributions&lt;/a&gt;. The &lt;code class=&#34;verbatim&#34;&gt;rtriangle()&lt;/code&gt; function provides a vector of random quantiles for the chosen distribution, as shown below:&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Monte Carlo Simulation in R&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(triangle)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Triangular distribution&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;hist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rtriangle&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10000&lt;/span&gt;, a &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;12000&lt;/span&gt;, b &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15000&lt;/span&gt;, c &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;14000&lt;/span&gt;), 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       breaks &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       main &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Triangular distribution simulation&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
When plotting the histogram of these results, the triangular shape becomes evident, albeit a bit rough around the edges. Notice that a Monte Carlo simulation is only ever an estimate. The higher the number of simulations (in this diagram, 10,000), the higher the resolution of the result. To test this proposition, change the &lt;code class=&#34;verbatim&#34;&gt;n&lt;/code&gt; parameter in the &lt;code class=&#34;verbatim&#34;&gt;rtriangle()&lt;/code&gt; function.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/triangular-distribution.png&#34; alt=&#34;Simulated triangular distribution&#34; title=&#34;Simulated triangular distribution&#34;/&gt;
&lt;figcaption&gt;
Simulated triangular distribution.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
To add the probability distribution of all your cost items, store all simulations in a matrix with &lt;code class=&#34;verbatim&#34;&gt;n&lt;/code&gt; columns (number of simulations) and &lt;code class=&#34;verbatim&#34;&gt;j&lt;/code&gt; (number of cost items) rows. Then, in the next step, you add all the simulated values and create a histogram or calculate percentiles.&lt;/p&gt;
&lt;p&gt;
The example below reads a CSV file with the same content as the table above. It then creates a results matrix, runs the simulations and calculates and visualises the results.&lt;/p&gt;
&lt;p&gt;
The &lt;code&gt;set.seed(1234)&lt;/code&gt; function fixes the pseudo-random number generator to always use the same &amp;#39;random&amp;#39; numbers. This way we always have the same result instead of introducing stochastic noise. If you need true randomness, then use a &lt;a href=&#34;https://cran.r-project.org/web/packages/random/index.html&#34;&gt;specialised random generator package&lt;/a&gt; that obtains numbers form the &lt;a href=&#34;https://random.org/&#34;&gt;random.org&lt;/a&gt; website.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Read Data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  estimate &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read.csv&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/cost-estimate.csv&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Simulation settings&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10000&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;## Simulations&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  j &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(estimate)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  mc_sims &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;matrix&lt;/span&gt;(ncol &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; n,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    nrow &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; j)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Simulation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;set.seed&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1234&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;j){
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mc_sims[i,] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rtriangle&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; n,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                             a &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; estimate&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Low[i],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                             b &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; estimate&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;High[i],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                             c &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; estimate&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Medium[i])}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Determine estimates and 95th percentile&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  mc_results &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;colSums&lt;/span&gt;(mc_sims)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  p95 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;quantile&lt;/span&gt;(mc_results, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.95&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Visualise&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;hist&lt;/span&gt;(mc_results, breaks &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abline&lt;/span&gt;(v &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; p95, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, lwd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
A Monte Carlo simulation outcome is thus never one number but a vector of numbers from which you can analyse. The example below uses the 95&lt;sup&gt;th&lt;/sup&gt; percentile as the budget figure.&lt;/p&gt;
&lt;p&gt;
Adding triangular distributions will create a new distribution specific to this project. The &lt;code class=&#34;verbatim&#34;&gt;mc_results&lt;/code&gt; vector holds the estimated possible total cost.&lt;/p&gt;
&lt;p&gt;
To set a budget figure, you need to nominate a percentile. The 50&lt;sup&gt;th&lt;/sup&gt; percentile has an equal chance of being higher or lower than the actual. You should choose the 95&lt;sup&gt;th&lt;/sup&gt; percentile or whatever percentile matches your risk appetite to have more certainty that a sufficient budget is available.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/monte-carlo-estimate.png&#34; alt=&#34;Monte Carlo cost estimate&#34; title=&#34;Monte Carlo cost estimate&#34;/&gt;
&lt;figcaption&gt;
Monte Carlo cost estimate and 95&lt;sup&gt;th&lt;/sup&gt; percentile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Monte Carlo cost estimates are not only for projects. You can also undertake these calculations at the program level and assess the level of financial risk you hold within the program. &lt;/p&gt;
&lt;p&gt;
Monte Carlo cost estimates are a powerful tool for better understanding your project. They are, however, like any modelling, subject to the GiGo principle (Garbage-in-Garbage-out). Therefore, determining the low, likely and high costs will require domain knowledge. While these three estimates have their level of uncertainty, they will provide better insights than relying only on a monolithic amount for contingency.&lt;/p&gt;
&lt;p&gt;
Probabilistic cost estimates do not guarantee that your project will remain under budget, but they help you achieve this elusive goal.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Visualise Org-Roam Networks With igraph and R</title>
      <link>https://lucidmanager.org/data-science/visualise-org-roam/</link>
      <pubDate>Sat, 14 Aug 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/visualise-org-roam/</guid>
      <description>
	
&lt;p&gt;
The &lt;a href=&#34;https://lucidmanager.org/productivity/taking-notes-with-emacs-org-mode-and-org-roam/&#34;&gt;Emacs package Org-Roam&lt;/a&gt; provides a powerful tool to take notes following the idea of the Zettelkasten method. You can write notes with all the power that Emacs provides while linking your thoughts to each other and with your bibliography. This article shows how to analyse and visualise Org-Roam knowledge networks with the &lt;a href=&#34;https://igraph.org/&#34;&gt;iGraph package&lt;/a&gt; and the R language.&lt;/p&gt;
&lt;p&gt;
The image below shows the current state of my personal knowledge network as visualised by iGraph. The Org-Roam community is working hard to create a &lt;a href=&#34;https://github.com/org-roam/org-roam-ui&#34;&gt;visual user interface&lt;/a&gt; for Org-Roam with network diagrams. While this user interface is a great tool to explore your network, Emacs users tend to prefer writing code instead of clicking buttons. This article adds to this concept by showing how to apply some mathematical analysis and delve deep into your Zettelkasten. The beauty of iGraph is that it is available in R, Python, Mathematica and C/C++.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/org-roam-network.png&#34; alt=&#34;My personal Org-roam notes network&#34; title=&#34;My personal Org-roam notes network&#34;/&gt;
&lt;figcaption&gt;
My personal Org-roam notes network.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
You can download the code in this article from GitHub.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/digital-humanities/&#34; target=&#34;_blank&#34;
   title=&#34;Download digital-humanities from GitHub&#34;
   alt=&#34;Download digital-humanities from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;digital-humanities&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Loading the Database
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Org-Roam stores information about the notes in your system in an SQLite database. This database holds information about the nodes (registered files and headings) and links. The &lt;a href=&#34;https://db.rstudio.com/r-packages/dbi/&#34;&gt;DBI package&lt;/a&gt; enables connecting to these databases.&lt;/p&gt;
&lt;p&gt;
The first lines open the connection. You will have to change the path of the database location to your preferences for this to work. The two queries extract the unique ID and the title for all nodes. The second query extracts the links between nodes. The Org-Roam database also stores external links, which are excluded from this analysis.&lt;/p&gt;
&lt;p&gt;
The next part cleans the titles by removing quotation marks and joins the tables. I could have done this in the query, but I know Tidyverse better than SQL.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Visualise Org-Roam databse&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Connect to database and extract nodes and links&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(DBI)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  roam &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dbConnect&lt;/span&gt;(RSQLite&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;SQLite&lt;/span&gt;(), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;~/.config/emacs/org-roam.db&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  nodes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dbGetQuery&lt;/span&gt;(roam, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;SELECT id, title FROM nodes&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  links &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dbGetQuery&lt;/span&gt;(roam, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;SELECT source, dest FROM links WHERE type = &amp;#39;\&amp;#34;id\&amp;#34;&amp;#39;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dbDisconnect&lt;/span&gt;(roam)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Clean node names and create network table&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  nodes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; nodes &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_remove_all&lt;/span&gt;(title, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\&amp;#34;&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  network &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;left_join&lt;/span&gt;(links, nodes, by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;source&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;id&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;left_join&lt;/span&gt;(nodes, by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dest&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;id&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(from &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; title.x, to &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; title.y)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The result of this code is a data frame with two names of the nodes at each vertex in the network. Any unconnected nodes are ignored due to the left join. The next step is to convert this data to iGraph format and start visualising and analysing.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Create iGraph network
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The iGraph package uses a specific data format. The &lt;code class=&#34;verbatim&#34;&gt;graph.data.frame()&lt;/code&gt; function converts a data frame to an iGraph network. The &lt;code class=&#34;verbatim&#34;&gt;simplify()&lt;/code&gt; function removes any multiple links and self-references. &lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Create network diagram&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(igraph)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  g &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;graph.data.frame&lt;/span&gt;(network)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  g &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;simplify&lt;/span&gt;(g)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Analyse the Network
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The iGraph package has an extensive library of functions to analyse networks. In this section, we look at a measure for centrality and clustering. &lt;/p&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Centrality
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Not all nodes in the network are of equal importance. &lt;a href=&#34;https://en.wikipedia.org/wiki/Centrality&#34;&gt;Centrality&lt;/a&gt; is a concept in graph theory that describes the importance of a node in a network. The most straightforward method of calculating the centrality of a node is to count the number of vertices (connections) that it has with other nodes. The example below shows a simple undirected graph and the degree of each node.&lt;/p&gt;
&lt;figure&gt;
&lt;a title=&#34;Melchoir (source); pan BMP, CC BY-SA 4.0 &amp;lt;https://creativecommons.org/licenses/by-sa/4.0&amp;gt;, via Wikimedia Commons&#34; href=&#34;https://commons.wikimedia.org/wiki/File:UndirectedDegrees_(Loop).svg&#34;&gt;&lt;img width=&#34;330&#34; alt=&#34;UndirectedDegrees (Loop)&#34; src=&#34;https://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/UndirectedDegrees_%28Loop%29.svg/330px-UndirectedDegrees_%28Loop%29.svg.png?utm_source=commons.wikimedia.org&amp;utm_campaign=index&amp;utm_content=thumbnail&#34;&gt;&lt;/a&gt;
&lt;figcaption&gt;
Example of the degree centrality of an undirected graph.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
In a directed graph, like with Org-Roam, we can calculate the in-degree and out-degree, the number of vertices point &lt;em&gt;to&lt;/em&gt; the node, or the number of vertices pointing &lt;em&gt;from&lt;/em&gt; the node (the number of backlinks and the number of links). The &lt;code class=&#34;verbatim&#34;&gt;degree()&lt;/code&gt; function of the iGraph package calculates degree centrality. The code below generates a table with the top ten most connected nodes.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Centrality&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  centrality &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(Node &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;names&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;degree&lt;/span&gt;(g)),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                       Degree &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;degree&lt;/span&gt;(g, mode &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;total&amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                       Links &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;degree&lt;/span&gt;(g, mode &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;out&amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                       Backlinks &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;degree&lt;/span&gt;(g, mode &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;in&amp;#34;&lt;/span&gt;)) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  centrality &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;top_n&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;arrange&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;desc&lt;/span&gt;(Degree))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Communities
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;While some nodes might be more connected than others, it would also be good to know which nodes are closest to each other. In other words, can we find clusters of nodes (communities) to find meta-structure in the network? A community is a sub-network with densely connected nodes, but less so with nodes outside the community. Expressed probabilistically, two random nodes are more
likely to be associated when they form part of the same community than when they don&amp;#39;t. Thus, community detection increases the parsimony of the network by identifying those groups of nodes that are most closely related to each other.&lt;/p&gt;
&lt;p&gt;
Using the example network, two communities can be visually distinguished: nodes 1–4 and nodes 5–7. Texts A, B and C belong to the first community, while texts C and D belong to the second community. Text C (nodes 2 and 5) spans the two communities of discourse. This solution is valid because each node has more connections to nodes within its own community than nodes outside it.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/mix_example.communities.png&#34; alt=&#34;Example of a network with two communities&#34; title=&#34;Example of a network with two communities&#34; width=&#34;320&#34;/&gt;
&lt;figcaption&gt;
Example of a network with two communities.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The examples&amp;#39; communities are easily detected visually, but community detection becomes more difficult as the network grows. Community detection is a mathematical process to cluster nodes into cohesive sub-networks. &lt;/p&gt;
&lt;p&gt;
Several algorithms for community detection have been developed based on a range of mathematical principles. However, the numerical validation of community structure has not yet been satisfactorily solved, and no agreed single method exists to assess the quality of communities. In my research into &lt;a href=&#34;https://lucidmanager.org/data-science/discourse-network-analysis-literature-review/&#34;&gt;knowledge networks&lt;/a&gt;, the Spinglass algorithm provided the most interpretable results.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Community-detection&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  c &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cluster_spinglass&lt;/span&gt;(g)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Note that clustering algorithms only work with complete graph, which means that all nodes are connected to each other by one or more steps. If you have multiple clusters and one or more single nodes, you can decompose the graph into its connected components and analyse each of these.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  g.comp &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;decompose&lt;/span&gt;(g)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  largest &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which.max&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(g.comp, diameter))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  g &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; g.comp[[largest]]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  c &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cluster_spinglass&lt;/span&gt;(g)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This algorithm results in a named vector that assigns a number of each community to each node. Making sense of community structure requires some human interpretation because the algorithm does not analyse the texts, only the connections between them. Please note that clustering algorithms are computationally intensive and can take a while.&lt;/p&gt;
&lt;p&gt;
We can assign a name to each community by using the node&amp;#39;s name with the most backlinks within each community. The code below creates a table of the community memberships and joins it with the centrality table. The last part assigns a name to each community by selecting the node&amp;#39;s name with the most backlinks, counts the number of members and arranges the table by community size.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  communities &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(Node &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; c&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;names,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                        Community &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; c&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;membership) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;left_join&lt;/span&gt;(centrality) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;group_by&lt;/span&gt;(Community) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;summarise&lt;/span&gt;(Name &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; Node&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[which.max&lt;/span&gt;(Backlinks)],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              Nodes &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;n&lt;/span&gt;()) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;arrange&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;desc&lt;/span&gt;(Nodes))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Visualise Org-Roam
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Now that we have analysed the graph, it is time to visualise the results. iGraph has extensive &lt;a href=&#34;https://igraph.org/r/doc/plot.common.html&#34;&gt;plotting functionality&lt;/a&gt; that gives full control over every aspect of the visualisation. To create the graph shown at the start of this article, use the following code:&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Visualise graph&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;par&lt;/span&gt;(mar &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot&lt;/span&gt;(g,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       layout &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; layout.fruchterman.reingold,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       mark.border &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; c&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;membership,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.label &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;degree&lt;/span&gt;(g, mode &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;in&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.frame.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       edge.arrow.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       edge.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;lightgrey&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The layout of graphs in this example follows the Fruchterman-Reingold method. This method tries to position the nodes so that the ones with the highest centrality are in the centre. Several other methods are available to compute an optimal layout.&lt;/p&gt;
&lt;p&gt;
The colour of each node relates to its community. The node&amp;#39;s size is the square root of the number of backlinks (indegree) plus one so that larger nodes don&amp;#39;t overpower the picture and small nodes vanish. &lt;/p&gt;
&lt;p&gt;
The remainder of the options improve the readability of the graph. This image is aesthetically pleasing, but it is not very informative. Adding text to the nodes would make it unreadable. &lt;/p&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Subnetworks
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;When a network is fairly large it might be more informative to visualise only a section. The code below determines the number of the relevant node. The &lt;code class=&#34;verbatim&#34;&gt;V()&lt;/code&gt; function holds the properties of al vertices (the nodes) in the network. The &lt;code class=&#34;verbatim&#34;&gt;make_ego_graph()&lt;/code&gt; subsets a network from a given node (ego) and the order. This function creates a list of networks as you can enter more than one node. &lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Subnetwork&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  node &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;names&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;V&lt;/span&gt;(g)) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Topology&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  g1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;make_ego_graph&lt;/span&gt;(g, order&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;, nodes &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; node)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  c1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cluster_walktrap&lt;/span&gt;(g1[[1]])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot&lt;/span&gt;(g1[[1]], layout &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; layout.kamada.kawai,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       mark.border &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;degree&lt;/span&gt;(g1[[1]])) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; c1&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;membership,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.frame.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.label.family &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Sanserif&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.label.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       edge.arrow.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.3&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/emacs/org-roam-subnetwork.png&#34; alt=&#34;/images/emacs/org-roam-subnetwork.png&#34; title=&#34;/images/emacs/org-roam-subnetwork.png&#34; /&gt;&lt;figcaption&gt;
Subnetwork example.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Interactive visualisation
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;https://christophergandrud.github.io/networkD3/&#34;&gt;networkD3 package&lt;/a&gt; can create interactive graphs, as implemented in this code snippet. The first step converts the iGraph object to a D3 object. Then, the htmlwidgets package lets you save this object as an interactive HTML file.&lt;/p&gt;
&lt;p&gt;
The code below adds the number of backlinks to the node table. Then, it defines the legend using the community names described above.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Interactive visualisation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(networkD3)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(htmlwidgets)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Convert to object suitable for networkD3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  d3 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;igraph_to_networkD3&lt;/span&gt;(g, group &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; communities&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Name&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[membership&lt;/span&gt;(c)])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  d3&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;nodes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;backlinks &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;degree&lt;/span&gt;(g, mode &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;in&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Create force directed network plot&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  p &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;forceNetwork&lt;/span&gt;(Links &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; d3&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;links, Nodes &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; d3&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;nodes, 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    Source &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;source&amp;#34;&lt;/span&gt;, Target &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;target&amp;#34;&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    NodeID &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;name&amp;#34;&lt;/span&gt;, Group &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;group&amp;#34;&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    Nodesize &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;backlinks&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    zoom &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;, legend &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;saveWidget&lt;/span&gt;(p, file&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;( &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;getwd&lt;/span&gt;(), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;/org-roam.html&amp;#34;&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
Further Analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Graph theory is a broad field with lots of approaches to analyse graphs. This article only scathes the surface of what you can find out about your personal knowledge garden. Graph theory is a vital tool in many applications, including the fight against the Coronavirus.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/lJHcg5rRAJQ?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Graph theory lectures by Anthony Bosman.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Generate H-Fractals using ggplot</title>
      <link>https://lucidmanager.org/data-science/generate-h-fractals-ggplot/</link>
      <pubDate>Fri, 04 Jun 2021 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/generate-h-fractals-ggplot/</guid>
      <description>
	
&lt;p&gt;
A fractal is a geometric figure in which the same pattern repeats infinitely at an ever-smaller scale. One of the most simple examples is the H-Fractal. You construct a H-Fractal by starting with the line segments that resemble the capital letter H. You then iteratively place smaller H’s centred at the top and bottom of each free line segment. This article shows how to generate H-Fractals with the R language.&lt;/p&gt;
&lt;p&gt;
The H-Fractal or H-Tree is a self-similar fractal with ever-smaller line segments. This fractal is a Paeno Curve, which means that it eventually will fill a whole area and becomes a 2-dimensional object. The H-Fractal is a canopy fractal, a type of graph where a line segment is split into smaller lines at the end. Fractal canopies are very useful in creating models of plants. &lt;/p&gt;
&lt;p&gt;
The H-Fractal principle has practical applications in electronics. For example, microstrip antennae are printed on circuit boards and resemble the tree structure in this fractal. In addition, the splitting of fractal canopies is similar to the structure of bronchial tubes in the human body. A &lt;a href=&#34;https://patents.google.com/patent/US20070236406&#34;&gt;US Patent from 2006&lt;/a&gt; lists a H-Fractal as the geometry for a microwave antenna.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/fractals/h-fractal-5.png&#34; alt=&#34;H-Fractal with five iterations&#34; title=&#34;H-Fractal with five iterations.&#34;/&gt;
&lt;figcaption&gt;
H-Fractal with five iterations.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Method
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The algorithm starts with a horizontal line on the interval $[-1,1]$. Each iteration adds new shortened lines to the ends of the existing lines. The first iteration results in a shape that resembles the letter H. After that, the direction of the lines switches at each iteration from horizontal to vertical.&lt;/p&gt;
&lt;p&gt;
If the number of iterations of the fractal is $p$, then each iteration adds $2^p$ lines to the tree, and the total number of lines in the fractal is $2^{p+1} + 1$.  &lt;/p&gt;
&lt;p&gt;
The new lines are shortened by a factor, which is set at $\frac{1}{\sqrt{2}}$. If you set it any higher, the lines will overlap—a lower value results in a more sparse design.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Generate H-Fractals with ggplot
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The code below starts with setting the initial variables and defines the first line in a data frame. The data frame holds the start and end coordinates and the iteration number.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## H-Fractal Parameters&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  p &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;## Number of iterations&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;## Shortening parameter&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Define horizontal starting line&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  h_fractal &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(x1 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                          y1 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                          x2 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                          y2 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                          m &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The loop defines the iterations and adds a new row to the data frame for each line. First, the direction flips by setting the &lt;code class=&#34;verbatim&#34;&gt;dx&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;dy&lt;/code&gt; values to either 0 or 1. The second part defines the row numbers for the previously defined lines and the new lines. The code then calculates the coordinates for the new line segments.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Generate coordinates (each line on a row)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (m &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;p) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;## Flip direction&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    dx &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (m &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    dy &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; m &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;# Previous and current line numbers&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;^&lt;/span&gt;(m &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;))&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;^m &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    j &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;^m)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;^&lt;/span&gt;(m &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;## Calculate coordinates&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    h_fractal[j, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;x1&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(h_fractal[i, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;x1&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; dx &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; a^m, h_fractal[i, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;x2&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; dx &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; a^m)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    h_fractal[j, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;x2&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(h_fractal[i, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;x1&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; dx &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; a^m, h_fractal[i, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;x2&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; dx &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; a^m)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    h_fractal[j, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;y1&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(h_fractal[i, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;y1&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; dy &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; a^m, h_fractal[i, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;y2&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; dy &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; a^m)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    h_fractal[j, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;y2&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(h_fractal[i, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;y1&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; dy &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; a^m, h_fractal[i, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;y2&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; dy &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; a^m)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;## Set line property&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    h_fractal[j, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;m&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; m
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Lastly, The fractal is visualised with ggplot and the line segment geometry. The colour of the line slowly fades by setting it to the iteration number.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Visualise&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(h_fractal) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; x1, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; y1, xend &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; x2, yend &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; y2,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; m) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_segment&lt;/span&gt;(size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.5&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_size&lt;/span&gt;(guide &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_colour_gradientn&lt;/span&gt;(colours &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gray.colors&lt;/span&gt;(p), guide &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/fractals/h-fractal.png&#34; alt=&#34;H-Fractal example with twelve iterations&#34; title=&#34;H-Fractal example with twelve iterations&#34;/&gt;
&lt;figcaption&gt;
H-Fractal with twelve iterations.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Variations on the Theme
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Besides changing the number of iterations and the shortening factor, you can also play with line thickness, colours, and the lines’ direction. &lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Tantalising Games in R: Fun with Statistical Computing</title>
      <link>https://lucidmanager.org/data-science/games-in-r/</link>
      <pubDate>Sat, 26 Dec 2020 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/games-in-r/</guid>
      <description>
	
&lt;p&gt;
Computers exist to solve pressing problems to improve the human condition. Although our world is full of urgent issues to address, the human need for play is a robust internal motivator. This general statement also applies to the &lt;em&gt;R Project for Statistical Computing&lt;/em&gt;. Analysing data analysis is a serious business without much room for fun. This specialised computer language is not designed for games in R.&lt;/p&gt;
&lt;p&gt;
Hacking culture is one of the main reasons that computer science has evolved so fast. One of the many definitions of hacking is to use technology for a purpose it was not designed for, and thus writing games in the R language is an exciting challenge.&lt;/p&gt;
&lt;p&gt;
Not many R developers have written games. R has a &lt;a href=&#34;https://cran.r-project.org/web/packages/games/&#34;&gt;games package&lt;/a&gt; in CRAN, but this library is about the mathematics of game theory. This article explains the R language’s possibilities and limitations for writing games, plus links to actual games others and myself have developed.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Action Games
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Fully functioning action or arcade games are not easy to create in the R language because it has no interrupt function to process input from a keyboard or joystick while the battle continues. R can process keyboard input and mouse clicks on a graph, but the game waits for input. This makes it impossible to have moving elements on a screen.&lt;/p&gt;
&lt;p&gt;
The other impediment in R to write arcade games is the lack of support for sound. The &lt;a href=&#34;https://cran.r-project.org/web/packages/beepr/index.html&#34;&gt;beepr package&lt;/a&gt; by Rasmus Bååth plays a sound after a process has completed. The &lt;code class=&#34;verbatim&#34;&gt;beep&lt;/code&gt; function in this package can play eleven different sounds. However, R can only do one thing at a time, so paying a sound stops any other gameplay.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://lucidmanager.org/data-science/creepy-computer-games-in-r/&#34;&gt;Gravedigger game&lt;/a&gt; from the 1980s book &lt;em&gt;Creepy Computer Games&lt;/em&gt; is a pseudo arcade game that was initially developed for the venerable ZX81, my first computer. In this game, the antagonist only moves once after the player moved. It is thus as much a strategy game as it is an action game.&lt;/p&gt;
&lt;p&gt;
MattSen has interpreted of the classic ZX81 game 3D Monster Maze in the R language. &lt;a href=&#34;https://github.com/MattSen/Games-in-R&#34;&gt;His version&lt;/a&gt; of this game is a cross between an action and an adventure game. &lt;/p&gt;
&lt;p&gt;
Although R is unsuitable for arcade games, I have managed to simulate the classic game of &lt;a href=&#34;https://lucidmanager.org/data-science/pong/&#34;&gt;Pong&lt;/a&gt;. This code simulates a player that follows the path of the ball. Since I wrote this rudimentary Pong version, two people have developed exciting functionality to make arcade games possible.&lt;/p&gt;
&lt;p&gt;
Carsten Croonenbroek has developed the classic &lt;a href=&#34;https://cran.r-project.org/web/packages/Snake/index.html&#34;&gt;Snake game&lt;/a&gt;. This package uses tcltk to obtain user interaction via callback functions (almost as flexible as a real system-level message pump). Perhaps we can generalise the code in this package to create a joystick function in other games.&lt;/p&gt;
&lt;p&gt;
Stephen Kozak wrote a library that uses a Windows executable to constantly check for keyboard input. The &lt;a href=&#34;https://github.com/Teggom/KeyboardCheckeR&#34;&gt;KeyboardCheckR&lt;/a&gt; provides the &lt;code class=&#34;verbatim&#34;&gt;QueryKeyboard()&lt;/code&gt; function. This package is not on CRAN, and you will need to use devtools to install it.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Strategy Games
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Developing software to play strategic games has been an objective of artificial intelligence research from the early days of computing. Deep Blue defeating Gary Kasparov in 1997 was one of the significant milestones in the history of computing.&lt;/p&gt;
&lt;p&gt;
More recently, Google’s AlphaGo beat the European Go champion, Fan Hui. Deep Blue and AlphaGo used quite different approaches. Whereas Deep Blue used traditional brute force, AlphaGo uses deep learning. Strategic games are ideal for the R language because of its specialised functionalities in statistical computing and machine learning.&lt;/p&gt;
&lt;p&gt;
You can play the famous combinatorial number-placement puzzle with the &lt;a href=&#34;https://cran.r-project.org/web/packages/sudoku/index.html&#34;&gt;Sudoku package&lt;/a&gt;. This library generates, plays, and solves Sudoku puzzles. The &lt;code class=&#34;verbatim&#34;&gt;playSudoku()&lt;/code&gt; graphical version depends on &lt;code class=&#34;verbatim&#34;&gt;tkrplot&lt;/code&gt;, if you are not on Windows. The &lt;code class=&#34;verbatim&#34;&gt;sudokuALT&lt;/code&gt; package provides an alternative. This package presents more tools, such as plot and print methods.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://cran.r-project.org/web/packages/rchess/index.html&#34;&gt;rchess package&lt;/a&gt; by Joshua Kunst provides some functionality to play chess, but it is not a fully playable game. This package can plot beautiful chess boards, move pieces and detect check. However, this package is not able to generate moves by the computer and does not include a playable interface.&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/tic-tac-toe-war-games/&#34;&gt;Tic Tac Toe&lt;/a&gt;, or Noughts and Crosses is one of the most accessible strategic board games. The minimax algorithm can easily play a perfect game, which means that the computer can never beat itself. The Tic Tac Toe game in R uses the locator function to manage the human player. This function reads the position of the graphics cursor when the user presses the left mouse button.&lt;/p&gt;
&lt;p&gt;
Roland Krasser developed a library to play &lt;a href=&#34;https://rolkra.github.io/R-Console-Gaming/&#34;&gt;Codebreaker&lt;/a&gt;, inspired by the classic Mastermind game and classic 1980s design. He also developed &lt;a href=&#34;https://github.com/rolkra/pixelpuzzle&#34;&gt;Pixelpuzzle&lt;/a&gt;, both games are available on CRAN. MattSen has also developed a version of this game, called &lt;a href=&#34;https://github.com/MattSen/Games-in-R&#34;&gt;Bulls and Crows&lt;/a&gt;.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/rgames/pixelpuzzle-allstars.png&#34; alt=&#34;/images/rgames/pixelpuzzle-allstars.png&#34; title=&#34;/images/rgames/pixelpuzzle-allstars.png&#34; /&gt;&lt;figcaption&gt;
Pixelpuzzle by Roland Krasser.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Adventure Games
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A text adventure is a form of interactive fiction where a player can freely explore a virtual world described in prose. These games were trendy in the 1980s. The basic principle is that the computer shows a text that describes the current situation. The player enters a text command, usually a simple verb-noun combination. The computer processes the command and displays the new status. This interchange continues until the game reaches a defined state. Either the player dies, or the player has achieved the game’s objectives.&lt;/p&gt;
&lt;p&gt;
Most games are set in typical Dungeons and Dragons settings with wizards, dragons and other usual characters. The lines below are a short extract from &lt;em&gt;Colossal Cave&lt;/em&gt;, by Will Crowther and Don Woods, the very first text adventure written in the mid-1970s:&lt;/p&gt;
&lt;div class=&#34;src src-text&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;You are standing at the end of a road before a small brick building. 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Around you is a forest. A small stream flows out of the building and down a gully.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&amp;gt; go south 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;You are in a valley in the forest beside a stream tumbling along a rocky bed.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&amp;gt; enter stream 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Your feet are now wet.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The &lt;a href=&#34;https://www.r-bloggers.com/2016/06/frequency-analysis-challenge-a-console-based-game-for-rpython/&#34;&gt;BetaBit package&lt;/a&gt; by Smart Poland provides an educational console game where the user has to crack codes. This game comes close to the look-and-feel of traditional text adventures but is not quite the same.&lt;/p&gt;
&lt;p&gt;
This website has two adventure games. The &lt;a href=&#34;https://lucidmanager.org/data-science/tenliner-cave-adventure/&#34;&gt;Tenliner Cave Adventure&lt;/a&gt; is a programming challenge to cram as much functionality as possible into ten lines of BASIC code. This version uses the minimal amount of R code to recreate this masterpiece of programming.&lt;/p&gt;
&lt;p&gt;
My &lt;a href=&#34;https://lucidmanager.org/data-science/text-adventure/&#34;&gt;Secret of Landusia&lt;/a&gt; game provides a fully-functioning set of functions to write classic adventure games. The code can be easily expanded or modified to create new stories.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Games in R: Having fun with the R Language
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;R is not an optimal language for writing computer entertainment. Multipurpose languages such as Python or Java are much more suited to meet the expectations of gamers.&lt;/p&gt;
&lt;p&gt;
The many limitations don’t hold me back from writing computer games in the R language because working with limitations create a significant challenge. The &lt;em&gt;Devil is in the Data&lt;/em&gt; irregularly publishes code to have fun with R. Subscribe to the blog to receive updates or follow the Rgames repository on Github.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/RGames/&#34; target=&#34;_blank&#34;
   title=&#34;Download RGames from GitHub&#34;
   alt=&#34;Download RGames from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;RGames&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;
If you know of any other games written in R, then please &lt;a href=&#34;https://lucidmanager.org/contact/&#34;&gt;contact me&lt;/a&gt;. I would love to create a complete compendium of how to have fun in this quirky computing language.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Tenliner Cave Adventure in R: Miniature Text Adventure</title>
      <link>https://lucidmanager.org/data-science/tenliner-cave-adventure/</link>
      <pubDate>Wed, 19 Aug 2020 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/tenliner-cave-adventure/</guid>
      <description>
	
&lt;p&gt;
Computing has come a long way in the past 75 years. I learned how to write code in the 1980s on my tiny 1 kilobyte ZX81 home computer. With only 1 kilobyte of memory, capabilities were limited, but this machine set me off on an adventure writing code in the BASIC language. An active subculture of computer enthusiasts still develops new code and keeps these old machines alive. I recently stumbled across the fantastic &lt;a href=&#34;https://spectrumcomputing.co.uk/index.php?cat=96&amp;amp;id=30392&#34;&gt;Tenliner Cave Adventure&lt;/a&gt; (2016) by Einar Saukas from Brazil. This tiny ZX81 program provides a fully functional classical text adventure using some cunning techniques. This article contains a port of this game to the R language to explore its inner workings.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Interactive Fiction
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Text adventures, or interactive fiction, were trendy in the 1980s. The basic premise is that the computer shows a text and the player responds with a text command. The computer parses the command, calculates the new state of play and progresses the game with a new bit of prose. Last year I wrote an article about writing interactive fiction using the R language with a translation of &lt;a href=&#34;https://lucidmanager.org/data-science/text-adventure/&#34;&gt;Secret of Landusia&lt;/a&gt;. The &lt;em&gt;Tenliner Cave Adventure&lt;/em&gt;  provides a minimalist approach by squashing the basic principles of a text adventure into 1024 bytes of memory. The backstory of this Saukas&amp;#39; mini-adventure is a typical fantasy setting:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;As a young warrior apprentice, you have been chosen by the village elders to seek out the evil menace that lurks in some nearby caves. Once found, use any means at your disposal to defeat it… Good luck on your quest!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/rgames/zx81.png&#34; alt=&#34;ZX81 Screenshot of the Tenliner Cave Adventure&#34; title=&#34;ZX81 Screenshot of the Tenliner Cave Adventure&#34;/&gt;
&lt;figcaption&gt;
ZX81 Screenshot of the Tenliner Cave Adventure.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Tenliner Cave Adventure in R
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Tenliner Cave Adventure is a jewel of efficient programming. The game is simple, but it has all typical elements of a text adventure.  As I no longer own a ZX81, I could not resist translating this code to R to be able to play and reverse-engineer the game. &lt;/p&gt;
&lt;p&gt;
The game recognises the following commands:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;north, south, east, west (move)&lt;/li&gt;
&lt;li&gt;inventory&lt;/li&gt;
&lt;li&gt;look&lt;/li&gt;
&lt;li&gt;look &amp;lt;object&amp;gt;&lt;/li&gt;
&lt;li&gt;get &amp;lt;object&amp;gt;&lt;/li&gt;
&lt;li&gt;open &amp;lt;object&amp;gt;&lt;/li&gt;
&lt;li&gt;kill &amp;lt;object&amp;gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Most advanced games understand abbreviations and synonyms, but in this simple version, you have to provide precise commands. Can you rid the village of the evil menace?&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/RGames/&#34; target=&#34;_blank&#34;
   title=&#34;Download RGames from GitHub&#34;
   alt=&#34;Download RGames from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;RGames&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Tenliner Cace Adventure by Einar Saukas&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Ported from ZX81 BASIC to R by Peter Prevos&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Helper functions to keep syntax close to ZX81&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  val &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(p) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(p)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(p, q &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; p) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;substr&lt;/span&gt;(X, p, q)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Ported ZX81 code&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  X &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;100cannot doyou walk opened   closed   a sword  a key    nothing  a chest  a dragon a corpse taken    you died you won. &amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;repeat&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cat&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;You are in a&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;substr&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;cavepit halllake&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;val&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;val&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\n&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      u &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tolower&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readline&lt;/span&gt;(prompt &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;What would you like to do? &amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      m &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (u &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;north&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;3&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (u &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;south&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; u &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;west&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;3&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; u &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;east&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;val&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; u &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;look chest&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;11&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;3&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; u &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;kill dragon&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (m &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;val&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;))) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (u &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;look&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;val&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;))) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (u &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;inventory&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;0&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; u &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;look corpse&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;400&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; u &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;get key&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;201&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; u &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;open chest&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;211&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; u &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;get sword&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      X &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;val&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; m, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;val&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;val&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;substring&lt;/span&gt;(X, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cat&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;substr&lt;/span&gt;(X, a &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;, a &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;12&lt;/span&gt;), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\n&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;11&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This port of the &lt;em&gt;Ten-liner Text Adventure&lt;/em&gt; stay as close as possible to the original code by creating two helper functions, &lt;code class=&#34;verbatim&#34;&gt;val()&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;x()&lt;/code&gt;. In ZX81 basic, you can subset a string with parenthesis, which is mimicked in this code with the &lt;code class=&#34;verbatim&#34;&gt;x()&lt;/code&gt; function. The &lt;code class=&#34;verbatim&#34;&gt;val()&lt;/code&gt; function in ZX81 BASIC converts a string to a value. The rest of the code is almost literally the same as the ZX81 version.&lt;/p&gt;
&lt;p&gt;
The workings of the game are ingenious and minimise memory usage on the ZX81 to a minimum. All numeric values are stored in the &lt;code class=&#34;verbatim&#34;&gt;X&lt;/code&gt; string to save memory, which also contains all game responses. The first number is the room number the player is in, the second number records whether the chest is closed or open and the third number records the objects held by the player (the inventory). The responses in the &lt;code class=&#34;verbatim&#34;&gt;X&lt;/code&gt; variable are all nine characters long. &lt;/p&gt;
&lt;p&gt;
In ZX81 BASIC, all lines have numbers to control sequencing. This version uses a &lt;code class=&#34;verbatim&#34;&gt;repeat{}&lt;/code&gt; loop that keeps running until the game ends.&lt;/p&gt;
&lt;p&gt;
The game opens with displaying the room the player is in. Next, the player is asked to provide a response.&lt;/p&gt;
&lt;p&gt;
The variable &lt;code class=&#34;verbatim&#34;&gt;m&lt;/code&gt; determines the movement of the player depending on their direction. The result is a number between -2 and 2, which indicates the difference between the current and new room. The code uses a complex boolean expression to work this out.&lt;/p&gt;
&lt;p&gt;
The variable &lt;code class=&#34;verbatim&#34;&gt;a&lt;/code&gt; determines the outcome after the command if it is not a change in direction. This is the most sophisticated line in the game. In the original listing, it took three lines to determine the new game state due to line-length restrictions. In this code, I concatenated it into one line in line with the games minimalism philosophy. This line combines the input of the player with the current game state to determine the new situation.&lt;/p&gt;
&lt;p&gt;
In the next step, the code changes the state of the game by updating the three numbers in &lt;code class=&#34;verbatim&#34;&gt;X&lt;/code&gt;. The game displays a response, depending on the content of &lt;code class=&#34;verbatim&#34;&gt;a&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
It takes much more space to describe how this game works than the size of the code itself.&lt;/p&gt;
&lt;p&gt;
Have fun!&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Storytelling with Data: Visualising the Receding Sea Ice Sheets</title>
      <link>https://lucidmanager.org/data-science/storytelling-with-data/</link>
      <pubDate>Fri, 14 Aug 2020 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/storytelling-with-data/</guid>
      <description>
	
&lt;p&gt;
Good data science has to be aesthetic to ensure that the person who consumes your data product draws the right conclusion. Storytelling with data is a craft where mathematics and aesthetics meet. For data science to provide value, it has to be &lt;a href=&#34;https://lucidmanager.org/data-science/strategic-data-science/&#34;&gt;sound, useful and aesthetic&lt;/a&gt;. The aesthetics of data science refers to the way the results are communicated. This article discusses an informative but messy graph about the extent of global sea ice. The second part describes how to improve it with the ggplot2 library.&lt;/p&gt;
&lt;p&gt;
Many data scientists discuss at length which computing language they should learn. I claim that English is the most essential language an analyst can learn (or whatever other language yous peak) and the language of art. A good visualisation is a piece of data art that is composed to achieve a purpose. Whenever somebody looks at your visualisation, you want them to reach the same conclusion as you and they should be able to do so without having to dissect the information.&lt;/p&gt;
&lt;p&gt;
I subscribe to both the &lt;a href=&#34;https://www.reddit.com/r/dataisbeautiful/comments/5ky8rr/live_chart_of_global_sea_ice_shows_2016_falling/&#34;&gt;Data is Beautiful&lt;/a&gt; and &lt;a href=&#34;https://www.reddit.com/r/dataisugly/&#34;&gt;Data is Ugly&lt;/a&gt; subreddits. While beauty might be in the eye of the beholder, aesthetic data science has to follow some rules. I subscribe to the concept that you need to maximise the data-pixel-ratio of your graphs. In other words, each pixel in your chart should ideally form part of the story. No superfluous elements, only use colour if it is part of the story. Also, the type of chart is quite important, as each geometry tells a different story. Lets put this to practice with some ggplot code.&lt;/p&gt;
&lt;p&gt;
This post has been updated based on feedback from Clark Richards as the original used the wrong data set.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Storytelling with data case study: Receding sea ice sheets
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A little while ago, one of the posts on the &lt;a href=&#34;https://www.reddit.com/r/dataisbeautiful/comments/5ky8rr/live_chart_of_global_sea_ice_shows_2016_falling/&#34;&gt;Data is Beautiful&lt;/a&gt; subreddit showed a disturbing graph about the changes in the extent of global sea ice from 1978 till recently. The chart is created by an anonymous citizen data scientist who calls him or herself &lt;a href=&#34;https://neven1.typepad.com/&#34;&gt;Wipneus&lt;/a&gt;, which is Dutch for a snub nose and also a character in an old Dutch comic.&lt;/p&gt;
&lt;p&gt;
This graph contains all the necessary information to come to the conclusion that the total surface area of global sea ice in the has reduced significantly over the past forty years. This conclusion does, however, require quite a bit of squinting and close examination of the graph. &lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/nsidc_global_area_byyear_b.jpg&#34; alt=&#34;Global Sea Ice Area 1978--2020&#34; title=&#34;Global Sea Ice Area 1978--2020&#34;/&gt;
&lt;figcaption&gt;
Global Sea Ice Area 1978–2020.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This graph is a typical multivariate time series where the colour of each line indicates a category. While this approach might work fine for one or two lines, the cacophony of colours makes it hard to distinguish which line belongs to which year. This graph would be impossible to interpret for the eight per cent of men who are colour blind. Also, the story this graph tells is confusing. While the story seems to be that sea ice sheets are melting the past forty years, the chart shows the seasonal variations.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Storytelling with data and ggplot
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To redesign this graph, we first need to define what the story is we are telling with this data. The original chart shows that the area of the global sea ice is receding over the past forty years. This means that our dependent variable (y-axis) is the surface area, and the independent variable (x-axis) is the year.  &lt;/p&gt;
&lt;p&gt;
The original graph shows the month as the independent variable. The sea ice sheets grows and shrink with the seasons, as the sinusoidal shape in the chart indicates. While this is an interesting pattern, it is not the story we want to tell with this data. To show the influence over time, the year should be the independent variable and perhaps a colour for each month. To prevent a palette with twelve colours, it is probably better to use a grid for each month. The graph below is my proposed improved version. &lt;/p&gt;
&lt;p&gt;
The ribbon indicates the maximum and minimum extent of ice for each month over the years. For many months, the maximum amount of ice in recent years is about the same as the minimum amount at the start of this time series. The dark blue line is the linear regression of the mean sea ice area, which clearly indicates the downward trend.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/ice-data-beautiful.png&#34; alt=&#34;Global Sea Ice Area 1978-2020 for each month of the year&#34; title=&#34;Global Sea Ice Area 1978-2020 for each month of the year&#34;/&gt;
&lt;figcaption&gt;
Global Sea Ice Area 1978-2020 for each month of the year.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Good storytelling with data requires that you first define the conclusion you want the consumer of your data product to draw. The next step is to identify the dependent and independent variables and perhaps some grouping as well. Only after you can clearly define these aspects can you choose the best geometry. There are many chart choosers available on the web that help you with this choice.&lt;/p&gt;
&lt;p&gt;
The code below loads the data from the website and transforms it into a tidy format, calculates the minimum, mean and maximum sea ice area and visualises the results.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(dplyr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(forcats)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(readr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;download.file&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;https://sites.google.com/site/arctischepinguin/home/sea-ice-extent-area/data/nsidc_global_nt_final_and_nrt.txt.gz&amp;#34;&lt;/span&gt;, destfile &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;global-sea-ice.gz&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;system&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;gunzip global-sea-ice.gz&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  sea_ice &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read_csv&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;global-sea-ice&amp;#34;&lt;/span&gt;, skip &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;21&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Original plot&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(sea_ice, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(yearday, area, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;format&lt;/span&gt;(date, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%Y&amp;#34;&lt;/span&gt;))) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_line&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_color_discrete&lt;/span&gt;(name &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Global Sea Ice Area&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;from NSIDC NASA Team sea ice concentration data&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;expression&lt;/span&gt;(Sea&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;Ice&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;Area&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;^6&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;km^2))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Ribbon version&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  sea_ice_min_max &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; sea_ice &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(month &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;fct_relevel&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.factor&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;format&lt;/span&gt;(date, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%b&amp;#34;&lt;/span&gt;)), month.abb),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           year &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;format&lt;/span&gt;(date, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%Y&amp;#34;&lt;/span&gt;))) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;group_by&lt;/span&gt;(year, month) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;summarise&lt;/span&gt;(min_area &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;min&lt;/span&gt;(area, na.rm &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              mean_area &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mean&lt;/span&gt;(area, na.rm &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;),    
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              max_area &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(area, na.rm &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(sea_ice_min_max, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; year, ymin &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; min_area, ymax &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; max_area)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_ribbon&lt;/span&gt;(fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dodgerblue&amp;#34;&lt;/span&gt;, alpha &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.5&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_y_continuous&lt;/span&gt;(breaks &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;12&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_smooth&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; mean_area), se &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;, method &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;lm&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;facet_wrap&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;month) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Global Sea Ice Area&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;from NSIDC NASA Team sea ice concentration data\nMinimum and maximum sea ice area and linear regression over the mean&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;expression&lt;/span&gt;(Sea&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;Ice&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;Area&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;^6&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;km^2)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_light&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme&lt;/span&gt;(panel.background &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;element_rect&lt;/span&gt;(fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#f5f5dc&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggsave&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;../../static/images/data-science/ice-data-beautiful.png&amp;#34;&lt;/span&gt;, width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;, height &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Strategic Data Science
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;If you like to know more about this topic and how to use data science to create business value, perhaps you like to read my book &lt;em&gt;Principles of Strategic Data Science&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2019_sds.jpg&#34; alt = &#34;Principles of Strategic Data Science&#34; title = &#34;Principles of Strategic Data Science&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Principles of Strategic Data Science&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Principles of Strategic Data Science helps you join the dots between mathematics, programming, and business analysis. With a unique approach that bridges the gap between mathematics and computer science, this book takes you through the entire data science pipeline.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.packtpub.com/en-us/product/principles-of-strategic-data-science-9781838985509&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Packt Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Cheesecake Diagrams: Pie Charts with a Different Flavour</title>
      <link>https://lucidmanager.org/data-science/cheesecake-diagram/</link>
      <pubDate>Wed, 05 Aug 2020 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/cheesecake-diagram/</guid>
      <description>
	
&lt;p&gt;
Part of my job at a regional water utility involves visualising operational data. We manage water and sewerage services for a large number of small and medium-sized towns in regional Victoria (Australia).  Traditionally, performance reports consist of extensive tables filled with numbers with a line for each city. To make this data easier to consume, I developed the cheesecake diagram to spatially visualise performance data. A cheesecake diagram is just like a pie chart, but different. It is a semantic glyph rather than a statistical one.&lt;/p&gt;
&lt;p&gt;
In a pie chart the data is encoded with the angle of each slice. In a cheesecake diagram, the size of all slices is the same, but the colour of the slice indicates data. This method of visualisation is ideal for amalgamating multiple traffic light performance indicators by plotting the cheesecakes in a map.&lt;/p&gt;
&lt;p&gt;
The code for this article is available on GitHub:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Reporting performance spatially
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Displaying geographic performance requires geometric objects at appropriate locations. The  &lt;a href=&#34;https://lucidmanager.org/data-science/geographic-bubble-chart/&#34;&gt;geographic bubble chart&lt;/a&gt; visualises a single quantitative variable through the size of the circles, plus a second qualitative variable through the colour.&lt;/p&gt;
&lt;p&gt;
The performance data is randomised for the purpose of this example. Performance is measured using four aggregated parameters. My paper on &lt;a href=&#34;https://www.researchgate.net/publication/326533569_Visualising_water_quality_A_graphical_index_for_drinking_water_system_performance&#34;&gt;visualising water quality performance&lt;/a&gt;  describes the algorithm in detail.&lt;/p&gt;
&lt;p&gt;
The size of the bubbles in the diagram below communicates the consumed volume of water. Due to the orders of magnitude difference in town size, the area is transformed with the square root. The colour of the bubble communicates a random level of performance.&lt;/p&gt;
&lt;p&gt;
In most traffic-light reporting systems, the colour for negative performance is red and excellent performance is green. This combination is, however, not useful for the 8% of men who struggle to see the difference between red and green. The &lt;a href=&#34;https://cran.r-project.org/web/packages/RColorBrewer/index.html&#34;&gt;RColorBrewer&lt;/a&gt; package provides several diverging colourblind-safe colour palates.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/bubble-chart-performance.png&#34; alt=&#34;Visualising a single qualitative value with a bubble chart&#34; title=&#34;Visualising a single qualitative value with a bubble chart&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Visualising a single qualitative value with a bubble chart.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The first part of the code creates mock performance data. The &lt;a href=&#34;https://lucidmanager.org/data-science/geocoding-with-ggmap/&#34;&gt;geocode function of the ggmap package&lt;/a&gt; provides the latitude and longitude for each location. The consumption data is taken from the 2019 Coliban Water annual report. The data has a row for each location, the total consumption, four performance variables and the average over these four.&lt;/p&gt;
&lt;p&gt;
The background map comes from &lt;a href=&#34;https://stamen.com/&#34;&gt;Stamen Design&lt;/a&gt;, under &lt;a href=&#34;https://creativecommons.org/licenses/by/3.0/&#34;&gt;CC BY 3.0&lt;/a&gt;. Data by &lt;a href=&#34;https://www.openstreetmap.org/&#34;&gt;OpenStreetMap&lt;/a&gt;, under &lt;a href=&#34;https://www.openstreetmap.org/copyright&#34;&gt;ODbL&lt;/a&gt;. The second part of the code projects the point geometry on the map and sets the scales and labels. The toner version of the Stamen maps is ideal for this visualisation because of its sparse background.&lt;/p&gt;
&lt;p&gt;
The next section shows how to split these bubbles into quadrants to separately visualise each variable.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Cheesecake diagram&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggmap)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(RColorBrewer)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Register Google Maps API&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  api &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;case-studies/google-maps.api&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;register_google&lt;/span&gt;(key &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; api)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Create mock performance data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Towns with water treatment plants&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  towns &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Bendigo&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Boort&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Bridgewater&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Castlemaine&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Cohuna&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Echuca&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Elmore&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Goornong&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Gunower&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Heathcote&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Korong Vale&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Kyneton&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Laanecoorie&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Leitchville&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Lockington&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Pyramid Hill&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Rochester&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Serpentine&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Trentham&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  t &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(towns)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Volume produced&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## https://www.coliban.com.au/files/2019-10/FINAL_CW_AnnualReport2019_200919pm.pdf p. 24&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  consumption &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;11682&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;138&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;141&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2064&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;610&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3017&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;106&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;44&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;48&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;243&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;117&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;862&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;106&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;161&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;55&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;84&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;857&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;17&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;94&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;set.seed&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1969&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  performance &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(Town &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; towns) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;bind_cols&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geocode&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(towns, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Victoria, Australia&amp;#34;&lt;/span&gt;))) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(Consumption &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; consumption,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             Treatment &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, t),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             Network &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, t),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             Regulation &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, t),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             Perception &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, t),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             Performance &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;round&lt;/span&gt;((Treatment &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; Network &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; Regulation &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; Perception) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Get map&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  bbox &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;make_bbox&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;range&lt;/span&gt;(performance&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;range&lt;/span&gt;(performance&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lat), f &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  map &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;get_stamenmap&lt;/span&gt;(bbox, maptype &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;toner-hybrid&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Single variable&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggmap&lt;/span&gt;(map, extent &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;device&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; performance,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                 &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(lon, lat, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(Consumption), col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; Performance),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                 alpha &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.9&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_size_area&lt;/span&gt;(max_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt;, guide &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;none&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_color_gradientn&lt;/span&gt;(colors &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;brewer.pal&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;7&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;RdYlBu&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;System Performance&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Simulated data&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Introducing the Cheesecake Diagram 
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If we want to report more than one variable per location, the circle needs to he divided into two or more sectors. While this might sound like a pie chart, it is not. A pie chart visualises information through the size of the sectors in the diagram. The colours of the sectors communicate the data categories. Visualisation experts generally discourage using pie charts because they are not easy to interpret, but cheesecake diagrams are different.&lt;/p&gt;
&lt;p&gt;
A cheesecake diagram visualises information through the size of the circle and the colour of the sectors. The size of the sector is the same for each. A cheesecake diagram is a type of pie chart, but with a different flavour. The cheesecake diagram should not be used for more than four slices to ensure it remains readable.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://cran.r-project.org/web//packages/scatterpie/index.html&#34;&gt;Scatterpie&lt;/a&gt; package provides functionality to plot pie charts on a map, but it does not allow you to link the colours to the aesthetics. The code below uses the powerful &lt;a href=&#34;https://ggforce.data-imaginist.com/&#34;&gt;ggforce package&lt;/a&gt; to construct the cheesecakes from four circle sectors. To create the sectors, the &lt;code class=&#34;verbatim&#34;&gt;performance&lt;/code&gt; data frame is pivoted, and each sector is defined by its starting and ending angle, being 90 degrees ($\pi/2$ radians). Because the circle now contains information, it is not sized to the level of consumption to keep the sectors clearly visible.&lt;/p&gt;
&lt;p&gt;
Adding the legend is a bit finicky. The &lt;code class=&#34;verbatim&#34;&gt;annotation_custom()&lt;/code&gt; function allows you to plot two ggplot graphs on top of each other. In this case we need to transform the coordinate systems to match as the map is in latitude /longitude and the legend .&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/cheesecake-performance.png&#34; alt=&#34;Cheesecake diagram with randomised variables&#34; title=&#34;Cheesecake diagram with randomised variables&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Cheesecake diagram with randomised variables.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Cheesecake diagram&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggforce)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(gridExtra)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Convert data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  cheesecake &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;pivot_longer&lt;/span&gt;(performance, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-4&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                            names_to &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Aspect&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                            values_to &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Performance&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(Aspect &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Performance&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(start &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;pi&lt;/span&gt;, length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;)[&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-5&lt;/span&gt;], t),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           end &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;pi&lt;/span&gt;, length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;)[&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;], t))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Legend&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  cheesecake_legend &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(x0 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-.1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-.1&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                              y0 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-.1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-.1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.1&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                              start &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;pi&lt;/span&gt;, length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;)[&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-5&lt;/span&gt;],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                              end &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;pi&lt;/span&gt;, length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;)[&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                              dimension &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unique&lt;/span&gt;(cheesecake&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Aspect))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(cheesecake_legend) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x0 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; x0, y0 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; y0, r0 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, r &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, start &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; start, end &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; end) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_arc_bar&lt;/span&gt;(col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;lightgrey&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_text&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x0 &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;, y0 &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  label &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unique&lt;/span&gt;(cheesecake&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Aspect)), size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_equal&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Visualise&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  m &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggmap&lt;/span&gt;(map, extent &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;device&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             base_layer &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; cheesecake,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                 &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x0 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lon,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                     y0 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lat,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                     r0 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                     r &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.05&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                     start &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; start,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                     end &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; end,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                     fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; Performance))) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_arc_bar&lt;/span&gt;(col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;darkgrey&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_size_area&lt;/span&gt;(max_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;12&lt;/span&gt;, guide &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_fill_gradientn&lt;/span&gt;(colors &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;brewer.pal&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;7&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;RdYlBu&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;System Performance&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Simulated data&amp;#34;&lt;/span&gt;)  &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  m &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_cartesian&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_equal&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;annotation_custom&lt;/span&gt;(grob &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplotGrob&lt;/span&gt;(l),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                      xmin &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; bbox[3] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.3&lt;/span&gt;, xmax &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; bbox[3],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                      ymin &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; bbox[4] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.3&lt;/span&gt;, ymax &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; bbox[4])&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Export WordPress to Hugo Markdown or Org Mode with R</title>
      <link>https://lucidmanager.org/data-science/export-wordpress-to-hugo/</link>
      <pubDate>Sat, 18 Jul 2020 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/export-wordpress-to-hugo/</guid>
      <description>
	
&lt;p&gt;
I started my first website in 1996 with hand-written HTML. That became a bit of a chore, so for about fifteen years, WordPress became my friend. WordPress has been great to me, but it is slowly becoming a pain to keep updating plugins, security issues, slow performance and the annoying block editor. I am also always looking for additional activities I can do with Emacs. Hugo takes a lot of the pain of managing site away as you can focus on the content and &lt;a href=&#34;https://lucidmanager.org/productivity/create-websites-with-org-mode-and-hugo/&#34;&gt;Emacs provides me with powerful editing functionality&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
I recently returned to a static website using &lt;a href=&#34;https://gohugo.io/&#34;&gt;Hugo&lt;/a&gt;. This article explains how to export a WordPress blog to Hugo and customise it with R code. The only reason I used R is because it is the only programming language I know well enough.&lt;/p&gt;
&lt;p&gt;
You will also need to install the mighty &lt;a href=&#34;https://pandoc.org/&#34;&gt;Pandoc software&lt;/a&gt; to convert the content to Org mode and the &lt;a href=&#34;https://wordpress.org/plugins/wp-all-export/&#34;&gt;WP All Export&lt;/a&gt; WordPress plugin to export your website to a CSV file.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Convert the content to Markdown or Org Mode
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The first step is to export the WordPress posts database to a CSV file. Several plugins are available that help you with this task. I have used the &lt;a href=&#34;https://wordpress.org/plugins/wp-all-export/&#34;&gt;WP All Export plugin&lt;/a&gt; to export the data. You need to download the ZIP file and install this plugin manually in your WordPress setup. Follow the steps in the All Export plugin and create a CSV file from your posts with at least these fields:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Title&lt;/li&gt;
&lt;li&gt;Slug&lt;/li&gt;
&lt;li&gt;Date&lt;/li&gt;
&lt;li&gt;Content&lt;/li&gt;
&lt;li&gt;Categories&lt;/li&gt;
&lt;li&gt;Tags&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Alternatively, you can &lt;a href=&#34;https://lucidmanager.org/data-science/analyse-site-structure/&#34;&gt;link directly to the WordPress database&lt;/a&gt; and extract the data with the RMySQL package. &lt;/p&gt;
&lt;p&gt;
The content files for Hugo are either Markdown or Org Mode. I prefer to use Org Mode as it provides me with access to the extensive functionality that Emacs has to offer, including &lt;a href=&#34;https://opensource.com/article/20/5/r-emacs-data-science&#34;&gt;writing and evaluating R code&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;Content&lt;/code&gt; field in the exported CSV file contains HTML code of the article. The code below reads the CSV file and saves each content field as an HTML file, using the post&amp;#39;s slug as the filename. The mighty Pandoc software converts this file to Org mode. Any draft posts or pages in the export file will have &lt;code class=&#34;verbatim&#34;&gt;NA&lt;/code&gt; as the file name and are as such skipped.&lt;/p&gt;
&lt;p&gt;
Now that we have some content, we need to add the Org mode front matter so that Hugo can build a site. The last part of the code generates the front matter for each post, prepends it to the exported Org mode file and cleans some entries.&lt;/p&gt;
&lt;p&gt;
Copy the code below and save it as &lt;code class=&#34;verbatim&#34;&gt;wp2org.R&lt;/code&gt;. You need to change the filename in the line that starts with &lt;code class=&#34;verbatim&#34;&gt;file&lt;/code&gt; to the name of your export file. The script also creates two subdirectories to store the HTML and Org files.&lt;/p&gt;
&lt;p&gt;
You run this code with &lt;code class=&#34;verbatim&#34;&gt;Rscript wp2org.R&lt;/code&gt; from the same directory where the CSV file is stored. The result will be a collection of Org mode files.&lt;/p&gt;
&lt;p&gt;
This new site will not be perfect just yet. To show the images, you need to download your &lt;code class=&#34;verbatim&#34;&gt;wp-content&lt;/code&gt; folder and move it to the &lt;code class=&#34;verbatim&#34;&gt;static/images&lt;/code&gt; folder in Hugo.&lt;/p&gt;
&lt;p&gt;
The internal links in your blogs will be hard-coded, which means that you need to configure Hugo to ensure your slugs stay the same.&lt;/p&gt;
&lt;p&gt;
There will be other bits and pieces that might not have adequately converted, so do check your pages. &lt;/p&gt;
&lt;p&gt;
All you have to do now is to add a theme to your website, and your blog is fully converted. The Hugo website has a great &lt;a href=&#34;https://gohugo.io/getting-started/quick-start/&#34;&gt;Quick Start&lt;/a&gt; page that will get you going.&lt;/p&gt;
&lt;p&gt;
You can create new posts and edit your content with your favourite text editor. I use &lt;a href=&#34;https://lucidmanager.org/productivity/create-websites-with-org-mode-and-hugo/&#34;&gt;Org mode in Emacs to develop this website&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Summary
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In summary, you need to take the following steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install pandoc software and WP All Export WordPress plugin.&lt;/li&gt;
&lt;li&gt;Download your website as a &lt;code class=&#34;verbatim&#34;&gt;CSV&lt;/code&gt; file with the WordPress plugin.&lt;/li&gt;
&lt;li&gt;Copy the R script in a file called &lt;code class=&#34;verbatim&#34;&gt;wp2org.R&lt;/code&gt; and save it in the same location as the &lt;code class=&#34;verbatim&#34;&gt;CSV&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Open your console and move to  the folder with the script and &lt;code class=&#34;verbatim&#34;&gt;CSV&lt;/code&gt; file&lt;/li&gt;
&lt;li&gt;Run &lt;code class=&#34;verbatim&#34;&gt;Rscript wp2org.R&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Review the Org mode files and clean-up any issues&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Script
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Export WP to Hugo&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Read exported WP content&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tibble)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(readr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(dplyr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(stringr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Replace the filename with the exported file&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  posts &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read.csv&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;filename&amp;#34;&lt;/span&gt;, skipNul &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Create subdirectories&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dir.exists&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;tmp&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dir.create&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;tmp&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dir.exists&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;org&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dir.create&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;org&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Read posts&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(posts)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Save content as temporary html file&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      filename &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(posts&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Slug[i], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;.html&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;writeLines&lt;/span&gt;(posts&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Content[i], &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;tmp/&amp;#34;&lt;/span&gt;, filename))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Convert to Org mode with Pandoc&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      pandoc &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;pandoc -o &amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;org/&amp;#34;&lt;/span&gt;, posts&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Slug[i],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                            &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;.org &amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;tmp/&amp;#34;&lt;/span&gt;, filename)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;system&lt;/span&gt;(pandoc)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Create front matter for all posts&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  fm &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#+title:&amp;#34;&lt;/span&gt;, posts&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Title),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               date &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#+date: [&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(posts&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Date, origin &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;1970-01-01&amp;#34;&lt;/span&gt;), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;]&amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               lastmod &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#+lastmod: [&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;Sys.Date&lt;/span&gt;(), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;]&amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               categories &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#+categories[]:&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(posts&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Categories, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;-&amp;#34;&lt;/span&gt;)),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               tags &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#+tags[]:&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(posts&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Tags, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;-&amp;#34;&lt;/span&gt;)),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               draft &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#+draft: true&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(categories &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(categories, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\|&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             tags &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(tags, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\|&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Load Hugo files an prepend front matter&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (f &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(posts)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      filename &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;org/&amp;#34;&lt;/span&gt;, posts&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Slug[f], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;.org&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      post &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(fm[f, ]), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(filename))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Repoint images&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      post &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(post, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;http.*wp-content&amp;#34;&lt;/span&gt;), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;/images&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Cleanup LaTeX&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      post &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_replace_all&lt;/span&gt;(post, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\\$latex &amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;$&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Remove remaining Wordpress artefacts&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      post &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_remove_all&lt;/span&gt;(post, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#39;:::|\\{.wp.*|.*\\&amp;#34;\\}&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Write to disk&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;writeLines&lt;/span&gt;(post, filename)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>GEDCOM Reader for the R Language: Analysing Family History</title>
      <link>https://lucidmanager.org/data-science/gedcom-reader/</link>
      <pubDate>Sat, 20 Jul 2019 21:15:37 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/gedcom-reader/</guid>
      <description>
	
&lt;p&gt;
Understanding who you are is strongly related to understanding your family history. Discovering ancestors is now a popular hobby, as many archives are available on the internet. The GEDCOM format provides a standardised way to store information about ancestors. This article shows how to develop a GEDCOM reader using the R language.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The GEDCOM format
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The GEDCOM format is not an ideal way to store information, but it has become the de-facto standard for family history. This format includes metadata and two sets of data. The file contains a list of the individuals, and it lists the families to which they belong.&lt;/p&gt;
&lt;p&gt;
The basic principle is that each line has a level, indicated by the first digit. At level zero, we find metadata and the individuals and their family. At level one, we see the various types of data, such as births, deaths and marriages. The deeper levels provide the data for these events.&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;http://heiner-eichmann.de/gedcom/gedcom.htm&#34;&gt;Heiner Eichmann&lt;/a&gt; maintains a website that explains the format and provides some examples of files to help you understand the syntax.&lt;/p&gt;
&lt;p&gt;
The GEDCOM format is not only old in the way it stores data, but it is also limited in the types of human relationships. These files only store genetic relationships between people and assume that these relationships are marriages between a wife and a husband. Human relationships are, however, a lot more complicated than the genetic relationships between children and their parents, grandparents and ancestors.&lt;/p&gt;
&lt;p&gt;
These issues aside, all genealogical software can export a file to GEDCOM. The next section shows how to create a basic GEDCOM reader using the &lt;a href=&#34;https://stringr.tidyverse.org/&#34;&gt;stringr&lt;/a&gt;, &lt;a href=&#34;https://tibble.tidyverse.org/&#34;&gt;tibble&lt;/a&gt; and &lt;a href=&#34;https://dplyr.tidyverse.org/&#34;&gt;dplyr&lt;/a&gt; packages from the &lt;a href=&#34;https://www.tidyverse.org/&#34;&gt;Tidyverse&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
GEDCOM Reader
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;code class=&#34;verbatim&#34;&gt;read.gedcom()&lt;/code&gt; function takes a GEDCOM file as input and delivers a data frame (tibble) with basic information:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ID&lt;/li&gt;
&lt;li&gt;Full name&lt;/li&gt;
&lt;li&gt;Gender&lt;/li&gt;
&lt;li&gt;Birthdate and place&lt;/li&gt;
&lt;li&gt;Father&lt;/li&gt;
&lt;li&gt;Mother&lt;/li&gt;
&lt;li&gt;Death date and place&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This code only can be easily expanded to include further fields by adding lines in the while-loops and including the fields in the data frame.&lt;/p&gt;
&lt;p&gt;
The first lines read the file and setup the data frame. The &lt;code class=&#34;verbatim&#34;&gt;extract()&lt;/code&gt; function extracts an individual&amp;#39;s ID from a line in the file. The for loop runs through each line of the GEDCOM file. When the start of a new individual is detected, the GEDCOM reader collects the relevant information.&lt;/p&gt;
&lt;p&gt;
Births and christenings are considered equal to simplify the data. In older data, we often only know one or the other. The function looks for the start of a family. It extracts the husband and wife and assigns these as parents to each of the children. The last section cleans the data and returns the result.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/digital-humanities/&#34; target=&#34;_blank&#34;
   title=&#34;Download digital-humanities from GitHub&#34;
   alt=&#34;Download digital-humanities from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;digital-humanities&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Read GEDCOM file for individuals&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(stringr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(lubridate)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(dplyr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  read_gedcom_ind &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(gedcom_loc) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    gedcom &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_squish&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(gedcom_loc))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    idv &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;^0.*INDI$&amp;#34;&lt;/span&gt;, gedcom))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    fam &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;^0.*FAM$&amp;#34;&lt;/span&gt;, gedcom))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cat&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Individuals: &amp;#34;&lt;/span&gt;, idv, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\n&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cat&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Families: &amp;#34;&lt;/span&gt;, fam, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\n&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    family &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(id &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                         Full_Name &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                         Gender &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                         Birth_Date &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                         Birth_Place &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                         Father_id &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                         Mother_id &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                         Death_Date &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                         Death_Place &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;## Extract data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    extract &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(line, type) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_trim&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_sub&lt;/span&gt;(line, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_locate&lt;/span&gt;(line, type)[2] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    id &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (l &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(gedcom)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_detect&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;^0&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_detect&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;INDI$&amp;#34;&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        id &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; id &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        family[id, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;id&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_split&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;@&amp;#34;&lt;/span&gt;))[2]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_detect&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;^0&amp;#34;&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;NAME&amp;#34;&lt;/span&gt;, gedcom[l]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            family[id, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Full_Name&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;extract&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;NAME&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;SEX&amp;#34;&lt;/span&gt;, gedcom[l]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            family[id, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Gender&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;extract&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;SEX&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;BIRT|CHR&amp;#34;&lt;/span&gt;, gedcom[l])) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_detect&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;^1&amp;#34;&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;DATE&amp;#34;&lt;/span&gt;, gedcom[l]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                family[id, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Birth_Date&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;extract&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;DATE&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;PLAC&amp;#34;&lt;/span&gt;, gedcom[l]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                family[id, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Birth_Place&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;extract&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;PLAC&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;DEAT|BURI&amp;#34;&lt;/span&gt;, gedcom[l])) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_detect&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;^1&amp;#34;&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;DATE&amp;#34;&lt;/span&gt;, gedcom[l]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                family[id, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Death_Date&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;extract&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;DATE&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;PLAC&amp;#34;&lt;/span&gt;, gedcom[l]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                family[id, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Death_Place&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;extract&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;PLAC&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_detect&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;^0&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_detect&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;FAM&amp;#34;&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_detect&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;^0&amp;#34;&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;HUSB&amp;#34;&lt;/span&gt;, gedcom[l]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            husband &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_split&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;@&amp;#34;&lt;/span&gt;))[2]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;WIFE&amp;#34;&lt;/span&gt;, gedcom[l]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            wife &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_split&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;@&amp;#34;&lt;/span&gt;))[2]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;CHIL&amp;#34;&lt;/span&gt;, gedcom[l])) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            child &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(family&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;id &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_split&lt;/span&gt;(gedcom[l], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;@&amp;#34;&lt;/span&gt;))[2])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            family[child, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Father_id&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; husband
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            family[child, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Mother_id&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; wife
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    family &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(Full_Name &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;/&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_trim&lt;/span&gt;(Full_Name)),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             Birth_Date &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.Date&lt;/span&gt;(family&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Birth_Date, format &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%d %b %Y&amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             Death_Date &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.Date&lt;/span&gt;(family&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Death_Date, format &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%d %b %Y&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Analysing the data
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;There are many websites with GEDCOM files of family histories of famous and not so famous people. The
&lt;a href=&#34;https://webtreeprint.com/tp_famous_gedcoms.php&#34;&gt;Famous GEDCOMs&lt;/a&gt; website has a few useful examples to test the GEDCOM reader.&lt;/p&gt;
&lt;p&gt;
Once the data is in a data frame, you can analyse it any way you please. The code below downloads a file with the presidents of the US, with their ancestors and descendants. The &lt;code class=&#34;verbatim&#34;&gt;alive()&lt;/code&gt; function filters people who are alive at a certain date. For people without birth date, it sets a maximum age of 100 years.&lt;/p&gt;
&lt;p&gt;
The histogram shows the distribution of ages at time of death of all the people in the presidents file.&lt;/p&gt;
&lt;p&gt;
These are just some random examples of how to analyse family history data with this GEDCOM reader. The next article will explain how to plot a population pyramid using this data. A future article will discuss how to visualise the structure of family history.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/us-presidents-birth-years.png&#34; alt=&#34;Birth years of people of U SPresidents&#34; title=&#34;Birth years of people of US Presidents&#34;/&gt;
&lt;figcaption&gt;
Birth years of people of in the Presidents file.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Basic family history statistics&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  presidents &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read_gedcom_ind&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;https://webtreeprint.com/tp_downloader.php?path=famous_gedcoms/pres.ged&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(presidents, Year &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;year&lt;/span&gt;(Birth_Date)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(Year)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_histogram&lt;/span&gt;(binwidth &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#6A6A9D&amp;#34;&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Birth years in the presidents file&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggsave&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;us-presidents-birth-year.png&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 144: Laser Beams and Elliptical Billiards</title>
      <link>https://lucidmanager.org/data-science/project-euler-144/</link>
      <pubDate>Thu, 16 May 2019 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-144/</guid>
      <description>
	
&lt;p&gt;
Playing pool at a square table can be hard enough for most people. But what about testing your skills on an oval table? &lt;a href=&#34;https://projecteuler.net/problem=144&#34;&gt;Project Euler 144&lt;/a&gt; investigates multiple reflections of a laser beam. This problem is mathematically equivalent to bouncing billiard balls in an elliptical pool table, demonstrated by Ales Bellow in the video below. This article provides a solution to the Euler problem and simulates playing pool in an elliptical table. &lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/4KHCuXN2F3I?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Alex Bellos, Elliptical Pool Table - Numberphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 144 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In laser physics, a “white cell” is a mirror system that acts as a delay line for the laser beam. The beam enters the cell, bounces around on the mirrors, and eventually works its way back out.&lt;/p&gt;
&lt;p&gt;
The specific white cell we will be considering is an ellipse with the equation $4x^2 + y^2= 100$. The section corresponding to $-0.01 \leq \times \leq +0.01$ at the top is missing, allowing the light to enter and exit through the hole.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/project-euler/problem-144a.png&#34; alt=&#34;Project Euler 144: Laser Beams and Elliptical Billiards&#34; title=&#34;Project Euler 144: Laser Beams and Elliptical Billiards&#34;/&gt;
&lt;figcaption&gt;
White cell.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The light beam in this problem starts at the point (0.0, 10.1) just outside the white cell, and the beam first impacts the mirror at (1.4, -9.6). Each time the laser beam hits the surface of the ellipse, it follows the usual law of reflection “angle of incidence equals the angle of reflection.”&lt;/p&gt;
&lt;p&gt;
Both the incident and reflected beams make the same angle with the normal line at the point of incidence. In the figure on the left, the red line shows the first two points of contact between the laser beam and the wall of the white cell; the blue line indicates the line tangent to the ellipse at the point of incidence of the first bounce.&lt;/p&gt;
&lt;p&gt;
The slope $m$ of the tangent line at any point $(x,y)$ of the given ellipse is $m = -4x/y$. The normal line is perpendicular to this tangent line at the point of incidence.&lt;/p&gt;
&lt;p&gt;
How many times does the beam hit the internal surface of the white cell before exiting?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The first step was to rewrite the equation to use functions to generalise the problem. The general Cartesian equation for an ellipse is:&lt;/p&gt;
&lt;p&gt;
$$\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1, a &amp;lt; b$$&lt;/p&gt;
&lt;p&gt;
The length of the axes for this problem is $a =5$ and $b = 10$. While the Project Euler description gives the formula for the tangent slope to the ellipse, I have generalised the code to reuse it for the elliptical billiards table. The slope of the tangent to an ellipse at point $(x,y)$ is:&lt;/p&gt;
&lt;p&gt;
$$m=-\frac{b^2x}{a^2y}$$&lt;/p&gt;
&lt;p&gt;
This first code snippet defines functions to draw an ellipse and calculate the bouncing angle. The last part of the code bounces the laser inside the cell until it exits through the top.&lt;/p&gt;
&lt;p&gt;
The formula to find the intersection between a line and an ellipse has two possible solutions, one of which is the same as the original point.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  plot_ellipse &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(a, b, colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;, line &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot.new&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot.window&lt;/span&gt;(xlim &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;a, a), ylim &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;b, b), asp &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;par&lt;/span&gt;(mar &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;a, a, length &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;200&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      y &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(b^2 &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; (b^2 &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; a^2) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; x^2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lines&lt;/span&gt;(x, y, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; line)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lines&lt;/span&gt;(x, &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;y, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; line)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;polygon&lt;/span&gt;(x, y, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; colour, border &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;polygon&lt;/span&gt;(x, &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;y, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; colour, border &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  bounce &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(coords) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      y &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Tangent to ellipse&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      t &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;(b^2 &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; a^2) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (x[2] &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; y[2])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Deflection on sloping mirror y = mx + c&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      dydx &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;diff&lt;/span&gt;(y) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;diff&lt;/span&gt;(x)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      m &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tan&lt;/span&gt;(&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;pi&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;atan&lt;/span&gt;(dydx) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;atan&lt;/span&gt;(t))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      c &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; y[2] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; m &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; x[2]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Determine intersection point&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Source: http://www.ambrsoft.com/TrigoCalc/Circles2/Ellipse/EllipseLine.htm&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      x[1] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; x[2]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      y[1] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; y[2]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      x2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;a^2 &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; m &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; c &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; b &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(a^2 &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; m^2 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; b^2 &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; c^2))) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            (a^2 &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; m^2 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; b^2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      x[2] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ifelse&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;round&lt;/span&gt;(x[1] &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; x2[1], &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, x2[2], x2[1])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      y[2] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; m &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; x[2] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; c
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(x, y))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Initial conditions&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  b &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  x1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  y1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10.1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  x2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  y2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-9.6&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot_ellipse&lt;/span&gt;(a, b)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;points&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;c, c), pch &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Bounce laser breams&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  laser &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(x1, x2), y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(y1, y2))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt;((laser&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x[2] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-0.01&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; laser&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x[2] &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.01&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; laser&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y[2] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) { &lt;span style=&#34;color:#888&#34;&gt;## Escape?&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lines&lt;/span&gt;(laser&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x, laser&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, lwd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.5&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      laser &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;bounce&lt;/span&gt;(laser)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; answer &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/project-euler/problem-144-laser-beams.png&#34; alt=&#34;Multiple reflections of a laser beam.&#34; title=&#34;Multiple reflections of a laser beam.&#34;/&gt;
&lt;figcaption&gt;
Multiple reflections of a laser beam.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Elliptical Pool Table
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;We can use the solution to Euler problem 144 to play billiards on an elliptical billiards table. To close the article, we return to the elliptical pool table demonstrated by Alex Bellos. This code draws the pool table to the dimensions mentioned in the video. We know that the table has an eccentricity of $e = 0.43$ and a long axis of $a = 130$ cm. The code defines the short axis ($b$) and the distance of the focal points from the centre.&lt;/p&gt;
&lt;p&gt;
The code selects a random starting point and angle of the shot. The code first determines whether the line passes through the pocket. If this is not the case, the algorithm then finds the place where the ball hits and keeps bouncing it until it falls into the pocket, or the ball bounces 100 times.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/project-euler/problem-144-pool-table.png&#34; alt=&#34;/images/project-euler/problem-144-pool-table.png&#34; title=&#34;/images/project-euler/problem-144-pool-table.png&#34; /&gt;&lt;figcaption&gt;
Elliptical pool table simulation.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Elliptical billiard tables have four possible outcomes. Any ball the pass through a focal point will fall into the pocket, ending the simulation. Any ball that passes outside the focal points will bounce around, and the combined trajectories form an ellipse. When the ball moves between the foci, the result is a hyperbola. Lastly, some unique circumstances result in a regular polygon.&lt;/p&gt;
&lt;p&gt;
If simulations are not enough for you, then head over to the &lt;a href=&#34;http://www.instructables.com/id/Elliptical-Pool-Table/&#34;&gt;Instructables&lt;/a&gt; website to find out how you can construct an elliptical billiards table. There is even a patent for an &lt;a href=&#34;https://patents.google.com/patent/US5226644&#34;&gt;elliptical pocket billiard table&lt;/a&gt;, with the pockets at the edge.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  e &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.43&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;130&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  b &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; a &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;((&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; e) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; e)) &lt;span style=&#34;color:#888&#34;&gt;# a &amp;gt; b&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  f &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(a^2 &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; b^2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot_ellipse&lt;/span&gt;(a, b, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;darkgreen&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;points&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;f, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, pch &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;, cex &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;points&lt;/span&gt;(f, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, pch &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;grey&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Simulate random shot&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  angle &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;runif&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;pi&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  x1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;runif&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;a, a)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ymax &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(b^2 &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; (b^2 &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; a^2) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; x1^2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  y1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;runif&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;ymax, ymax)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## First shot&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  m &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tan&lt;/span&gt;(angle)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  c &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; y1 &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; m &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; x1
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  x2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;a^2 &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; m &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; c &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; b &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(a^2 &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; m^2 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; b^2 &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; c^2))) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; (a^2 &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; m^2 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; b^2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  y2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; m &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; x2 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; c
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  x2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; x2&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[which&lt;/span&gt;(((x2 &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; x1) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cos&lt;/span&gt;(angle) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;))]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  y2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; y2&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[which&lt;/span&gt;(((y2 &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; y1) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sin&lt;/span&gt;(angle) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;))]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  shot &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(x1, x2), y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(y1, y2)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Bounce ball&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      dydx &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;diff&lt;/span&gt;(shot&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;diff&lt;/span&gt;(shot&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;all.equal&lt;/span&gt;(dydx, (shot&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y[1] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; (shot&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x[1] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;f)) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          shot[2, ] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;f, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lines&lt;/span&gt;(shot&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x, shot&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;yellow&amp;#34;&lt;/span&gt;, lwd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (shot[2,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      shot &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;bounce&lt;/span&gt;(shot)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;points&lt;/span&gt;(x1, y1, pch &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;blue&amp;#34;&lt;/span&gt;, cex &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.8&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Secret of Landusia: A Text Adventure in the R Language</title>
      <link>https://lucidmanager.org/data-science/text-adventure/</link>
      <pubDate>Sun, 12 May 2019 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/text-adventure/</guid>
      <description>
	
&lt;p&gt;
In the 1980s and early 1990s, I spent a lot of time playing and writing text adventure games on my Atari 8-bit computer. Text adventures, or interactive fiction, are games where the player reads a story on the screen. The player can change the outcomes of the story by issuing text instructions to the computer. These lines are an extract from &lt;a href=&#34;http://rickadams.org/adventure/&#34;&gt;Colossal Cave&lt;/a&gt;, by Will Crowther and Don Woods, the very first text adventure written in the mid-1970s:&lt;/p&gt;
&lt;pre class=&#34;example&#34;&gt;
You are standing at the end of a road before a small brick building. Around you is a forest. A small stream flows out of the building and down a gully.
&amp;gt; go south
You are in a valley in the forest beside a stream tumbling along a rocky bed.
&amp;gt; enter stream
Your feet are now wet.
&lt;/pre&gt;
&lt;p&gt;
The basic premise of a text adventure is that the player finds herself in a simulated world. Unlike contemporary simulations, this virtual world is created only with text. This might seem a strange idea to modern games, but simulated worlds through text have existed for thousands of years. A text adventure enhances the traditional book by giving the player the freedom to act within the narrative. The objective of these games is to solve problems to reach a specified goal. &lt;/p&gt;
&lt;p&gt;
This article describes how to write a text adventure in the R language. This article replicates a game and the techniques described by Hal Renko and Sam Edwards in the Dutch book &lt;em&gt;Adventures!&lt;/em&gt; (1986).&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/rgames/renko-edwards.jpg&#34; alt=&#34;Hal Renko and Sam Edwarks. Adventures! (1986).&#34; title=&#34;Hal Renko and Sam Edwarks. Adventures! (1986).&#34;/&gt;
&lt;figcaption&gt;
Cover of the 1986 book &lt;em&gt;Adventures!&lt;/em&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Spoiler Alert!
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The sections below describe the detailed workings and the narrative of the game. If you don&amp;#39;t like spoilers, then perhaps you should download the code and play &lt;em&gt;The Secret of Landusia&lt;/em&gt; before reading further.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/RGames/&#34; target=&#34;_blank&#34;
   title=&#34;Download RGames from GitHub&#34;
   alt=&#34;Download RGames from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;RGames&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Secret of Landusia Text Adventure
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This section explains the detailed workings of the Landusia game. The text adventure consists of four files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;adventure.R&lt;/code&gt;: The code.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;actions.md&lt;/code&gt;: Markdown file with descriptions of rooms and actions.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;map.csv&lt;/code&gt;: Matrix of the relationship between rooms.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;objects.csv&lt;/code&gt;: Matrix of the status of objects and actors.&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
The Game Loop
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The computer displays the current state of the game with a short piece of prose. The player then enters a command in natural language, which changes the state of the game. When the state of the player or the game reaches a certain point, the player has either won or lost the game. The game loop processes the commands of the player and determines the new state of the game. The state of the game consists of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Player&lt;/em&gt;: The player can have many attributes, such as health, objects
they are carrying and their location.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Map&lt;/em&gt;: Logic of the game localities and a description of each area.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Objects&lt;/em&gt;: Are either placed in a room or are with the player.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Actors&lt;/em&gt;: Can act independently.&lt;/li&gt;
&lt;/ul&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/rgames/landusia-flowchart.png&#34; alt=&#34;Text adventure flowchart&#34; title=&#34;Text adventure flowchart&#34;/&gt;
&lt;figcaption&gt;
Text adventure flowchart.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Initialisation
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The initialisation defines the vocabulary through a vector of verbs and a vector of directions. The code reads the map, objects and prose into memory and sets the starting variables for the player. The initialisation includes two auxiliary functions that the player cannot call directly.&lt;/p&gt;
&lt;p&gt;
The prose function takes a key phrase and finds the location of the heading for that key in the &lt;code class=&#34;verbatim&#34;&gt;actions&lt;/code&gt; variable. The following lines of code print the text up to the next heading indicator. The prose function describes rooms, actions, actors and so on. Using a markdown file simplifies writing the text so it is not hidden amongst code. The prose function reads keywords after double hashtags. Other headings are used for convenience.&lt;/p&gt;
&lt;p&gt;
The inventory function lists all objects that the player carries. This function is a separate verb in most adventure games, but in this game, it is integrated with other verbs.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
The Player
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The program simulates the player with a set of parameters, such as their location, level of health and whatever other aspect is relevant. A player can, for example, only carry a certain number of objects, can only endure two blows by a sword, and so on.&lt;/p&gt;
&lt;p&gt;
In the Landusia game, the player has a level of &lt;code class=&#34;verbatim&#34;&gt;health&lt;/code&gt; and maximum carrying &lt;code class=&#34;verbatim&#34;&gt;capacity&lt;/code&gt;. The &lt;code class=&#34;verbatim&#34;&gt;room&lt;/code&gt; variable keeps track of where the player is located.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-6&#34;&gt;
The Map
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;The game consists of 28 &amp;#39;rooms&amp;#39;. The map is stored in a matrix which indicates the relationships between the rooms. Each direction can have one or no exit. The map can also dynamically change during the game. Specific directions can, for example, only become available after the player opens a door. A rockfall could close an entrance, and so on. The player can move around the map by issuing directional commands. These commands are the four cardinal compass directions, and up and down.&lt;/p&gt;
&lt;p&gt;
In Landusia, the first nine rooms are a forest. The blacksmith lives south of the forest. Clovar&amp;#39;s castle lies to the south-east and the temple north-east of the forest. The connection between room 14 and 15 opens after the player uses the rope in room 14.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/rgames/landusia-map.png&#34; alt=&#34;Secret of Landusia map&#34; title=&#34;Secret of Landusia map&#34;/&gt;
&lt;figcaption&gt;
Secret of Landusia map.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-7&#34;&gt;
Objects
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;The descriptions of the different rooms of the game can contain objects. These objects are fixed in that their description is hard-coded into the game. A text adventure can also have movable objects. Each object can have its own properties, such as weight, and location. The location of the object can either be a room or the player (room zero). These properties are stored in another matrix.&lt;/p&gt;
&lt;p&gt;
The Landusia game has four objects: bandage, sword, flute and rope. These objects are scattered around the map and have a certain weight. The &lt;code class=&#34;verbatim&#34;&gt;capacity&lt;/code&gt; variable limits what the layer can carry simultaneously.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/rgames/landusia-battlements.jpg&#34; alt=&#34;Landusia castle battlements&#34; title=&#34;Landusia castle battlements&#34;/&gt;
&lt;figcaption&gt;
Landusia castle battlements.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-8&#34;&gt;
Actors
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;Actors are like objects, with the difference that they are active in the game. As the game progresses, actors take independent actions. Actors can move around the map and respond to the actions of the player. They can have properties, such as health and strength. Actors can be either friends or enemies that create a dynamic narrative.&lt;/p&gt;
&lt;p&gt;
Landusia has four actors which are stored in the same matrix a the objects. Each actor has a name, location, health and status. The actors function controls their actions.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-5&#34;&gt;
&lt;h5 id=&#34;headline-9&#34;&gt;
Wizard
&lt;/h5&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-5&#34;&gt;
&lt;p&gt;The wizard appears in the living quarters. His only task is to give the player the flute, once they manage to reach him. After this one action, the wizard vanishes by changing his location to room 100.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-5&#34;&gt;
&lt;h5 id=&#34;headline-10&#34;&gt;
Crow
&lt;/h5&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-5&#34;&gt;
&lt;p&gt;When the player is in the forest, a random variable determine whether they are swooped by a crow. Another random variable determines whether the player was hurt. If the crow manages to hit the player, the code reduces the &lt;code class=&#34;verbatim&#34;&gt;health&lt;/code&gt; variable.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/rgames/landusia-crow.jpg&#34; alt=&#34;Crow attacking the player&#34; title=&#34;Crow attacking the player&#34;/&gt;
&lt;figcaption&gt;
Crow attacking the player.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-5&#34;&gt;
&lt;h5 id=&#34;headline-11&#34;&gt;
Dragon
&lt;/h5&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-5&#34;&gt;
&lt;p&gt;The dragon sequence depends on the room the player is in. In room 17, the dragon has a 50% chance of hitting, while in room 18, the dragon is always sucessful. The player needs to kill the dragon with the sword (see below). The success of these fights depends on a random variable.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-5&#34;&gt;
&lt;h5 id=&#34;headline-12&#34;&gt;
Blacksmith
&lt;/h5&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-5&#34;&gt;
&lt;p&gt;The blacksmith has the most complex handler of them all. He starts lying wounded on the floor. If the player does not help the blacksmith by using the bandage, he will die. If the player uses the bandage, the blacksmith is healed and move to the workshop to forge a sword for the player. The status variable controls the evolution of the blacksmith in the game.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-13&#34;&gt;
Command interpreter
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;The command interpreter asks the player for instructions, which the program then interprets. The state of the game (player, map, objects and actors) is changed, depending on the input. If the state of the game reaches a particular defined state, the game will end either successfully or miserably.&lt;/p&gt;
&lt;p&gt;
The basic principle of all command translators in interactive fiction is that they analyse the input using
&lt;a href=&#34;https://www.regular-expressions.info/rlanguage.html&#34;&gt;regex&lt;/a&gt;-type approaches. The interpreter compares the player&amp;#39;s instructions with a vocabulary and strips verbs and nouns.&lt;/p&gt;
&lt;p&gt;
For example, &amp;#34;take lamp&amp;#34; calls the take function and passes it the parameter &lt;em&gt;lamp&lt;/em&gt;. The object &lt;em&gt;lamp&lt;/em&gt; will then be moved from its current location to the player. The game could also check if the player still has enough carrying capacity and so on.&lt;/p&gt;
&lt;p&gt;
If the player enters a command that the interpreter cannot parse, then a negative response follows. The better the text adventure, the higher the likelihood that the game understands the command. Traditional text adventures use elaborate command interpreters to maximise the level of realism of the simulated world. This text adventure uses a minimised vocabulary and each of the verbs has its own function.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/rgames/landusia-dragon.jpg&#34; alt=&#34;The dragon of Landusia&#34; title=&#34;The dragon of Landusia&#34;/&gt;
&lt;figcaption&gt;
The dragon of Landusia.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-14&#34; class=&#34;outline-5&#34;&gt;
&lt;h5 id=&#34;headline-14&#34;&gt;
Look
&lt;/h5&gt;
&lt;div id=&#34;outline-text-headline-14&#34; class=&#34;outline-text-5&#34;&gt;
&lt;p&gt;The look function takes a room number as input and displays the prose related to the room. The next section lists the available passages and objects in the room. The final part of the look function displays any objects that the player is carrying.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-15&#34; class=&#34;outline-5&#34;&gt;
&lt;h5 id=&#34;headline-15&#34;&gt;
Take and Put
&lt;/h5&gt;
&lt;div id=&#34;outline-text-headline-15&#34; class=&#34;outline-text-5&#34;&gt;
&lt;p&gt;These two functions allow a player to take an object or place it on the ground. The weight of the object is added or subtracted to the carrying capacity. When the object is not present in the room or not carried by the player, the code responds appropriately.&lt;/p&gt;
&lt;p&gt;
These functions cannot respond to objects mentioned in the room descriptions or actors, such as trees or the dragon. This can be easily remedied by creating two types of objects, moveable and immovable.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-16&#34; class=&#34;outline-5&#34;&gt;
&lt;h5 id=&#34;headline-16&#34;&gt;
Wait
&lt;/h5&gt;
&lt;div id=&#34;outline-text-headline-16&#34; class=&#34;outline-text-5&#34;&gt;
&lt;p&gt;The wait function does nothing. Waiting might be useful to let other actors do their thing. The wait function has a dummy parameter because there is none, but the main loop assigns one to each verb. This verb is needed to give the blacksmith enough time to forge the sword.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-17&#34; class=&#34;outline-5&#34;&gt;
&lt;h5 id=&#34;headline-17&#34;&gt;
Use
&lt;/h5&gt;
&lt;div id=&#34;outline-text-headline-17&#34; class=&#34;outline-text-5&#34;&gt;
&lt;p&gt;The use function starts by checking whether the player actually has the object in their possession. The remainder of the function contains instructions for each of the four objects. The bandage will either heal yourself or the blacksmith. The sword is not very useful in this context. The flute activates the magical teleportation by changing the &lt;code class=&#34;verbatim&#34;&gt;room&lt;/code&gt; variable. Finally, using the rope changes the map by opening the connection between rooms 14 and 15. This action also changes the prose so that the room descriptions are enhanced.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-18&#34; class=&#34;outline-5&#34;&gt;
&lt;h5 id=&#34;headline-18&#34;&gt;
Kill
&lt;/h5&gt;
&lt;div id=&#34;outline-text-headline-18&#34; class=&#34;outline-text-5&#34;&gt;
&lt;p&gt;This last function is conditional upon having the sword. If the player has no sword, then their fists are the weapon of choice. If an opponent is present in the same room as the player, they have a 60% chance of hitting the opponent. The sword has a higher strength than a fist fight. The actor function controls the return hits.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-19&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-19&#34;&gt;
Expanding the Game
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-19&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;This game is modular in structure so that it should be easy to enhance this game or to write a completely different game. They key to writing a good adventure is simplicity. It is easy to get carried away with writing complex command structure that the player has to guess are available.&lt;/p&gt;
&lt;p&gt;
Feel free to leave a message below if you find bugs or like to enhance the prose or code.&lt;/p&gt;
&lt;p&gt;
A lot has changed in computing since the heyday of text adventures. Although these games provided an illusion of freedom to act in a simulated world, the player is always limited by what the writer intended them to do.&lt;/p&gt;
&lt;p&gt;
Perhaps natural language processing, complex Markov chains and text-generating deep learning methods can generate the ultimate text adventure. Imagine a text adventure where the computer understands the basic structure but freely develops the prose and interactions.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Analyse Site Structure networks with R and igraph</title>
      <link>https://lucidmanager.org/data-science/analyse-site-structure/</link>
      <pubDate>Tue, 09 Apr 2019 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/analyse-site-structure/</guid>
      <description>
	
&lt;p&gt;
One of the essential parts of Search Engine Optimisation (SEO) is a logical site structure. Site structure relates to how the pages of a website link to each other. A well-designed structure of internal links improves the user&amp;#39;s experience. It also helps web crawlers to find their way through the website. This article shows how to use the igraph software to analyse site structure.&lt;/p&gt;
&lt;p&gt;
The Lucid Manager website has been around for ten years now, and the content has grown organically over time, which is a reflection of my changing interests and evolving career. Although I use categories and tags to organise the articles, internal linking between posts is a bit haphazard. This post shows how I extracted the relevant data from the Wordpress database and visualised the internal links with the iGraph package. This analysis shows that my website needs a bit of rework to improve its jungle of internal links to provide you and search engines a better experience.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Site Structure
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A website needs to have a &lt;a href=&#34;https://yoast.com/site-structure-the-ultimate-guide/&#34;&gt;logical structure&lt;/a&gt; to prevent it from being a loose collecting of articles. Internal links on a website organise the available information through taxonomy, and these links provide context to the text by referring to related pages. The taxonomy consists of menus, breadcrumbs, categories, tags and other structural elements. The body of the text of each article contains the contextual which provide additional or related information to the reader.&lt;/p&gt;
&lt;p&gt;
Wordpress automatically adds links to categories and tags and the creates an ordered structure. Body text links are created organically and can therefore quickly turn into a chaotic jungle of relationships. Wordpress has plugins that help with site structure, but not of these tools provide a complete overview of the structure in the internal links.&lt;/p&gt;
&lt;p&gt;
The taxonomy provides an automated structure of the website by categorising articles. The internal linking structure is organic and needs some further consideration. This analysis focuses on the organic links within the body of the text by visualising and analysing the internal linking structure.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Extracting Wordpress Data
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Lucid Manager used to be created with Wordpress. This system stores the body text of all articles in the &lt;code class=&#34;verbatim&#34;&gt;wp_posts&lt;/code&gt; table in the database. To analyse site structure, we need the following fields:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;post_name&lt;/code&gt; (slug)&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;post_content&lt;/code&gt; (full text)&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;post_type&lt;/code&gt; (page, post or other types)&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;post_status&lt;/code&gt; (use only published posts)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The post type is in most instances either a page or a post, but can also be attachments and so on. The post name (slug) links posts together, and the post content contains the full text of the article in HTML.&lt;/p&gt;
&lt;p&gt;
Several methods are available to extract the required data from the Wordpress database. The easiest way is to use a plugin such as &lt;a href=&#34;https://www.wpallimport.com/export/&#34;&gt;WP All Export&lt;/a&gt;. You can drag-and-drop the required fields or run a SQL query. The second method is to log in to the phpMyAdmin on your cPanel and run the relevant queries.&lt;/p&gt;
&lt;p&gt;
The third method involves using the &lt;a href=&#34;https://cran.r-project.org/web/packages/RMySQL/index.html&#34;&gt;RMySQL&lt;/a&gt; package in R to directly download data from the site. You will need to create a new user with limited access rights and open the database to your IP address.&lt;/p&gt;
&lt;p&gt;
The first step reads the data from the database and selects all published posts. The credentials are read from the &lt;code class=&#34;verbatim&#34;&gt;dbconnect.R&lt;/code&gt; file, so I don&amp;#39;t publish sensitive data on this website. The table names will be different if you use a Wordpress network. Thanks to &amp;#39;phaskat&amp;#39; on the &lt;a href=&#34;https://wordpress.stackexchange.com/questions/333163/i-would-like-some-help-wth-an-sql-query-to-link-posts-with-categories/333189#333189&#34;&gt;Wordpress StackExchange&lt;/a&gt; for helping with the queries. Please note that when using a Wordpress network, you will need to replace the wp prefix in the table name with the relevant string.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/digital-humanities/&#34; target=&#34;_blank&#34;
   title=&#34;Download digital-humanities from GitHub&#34;
   alt=&#34;Download digital-humanities from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;digital-humanities&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Load data (CSV exported from wp_posts table in MySQL database)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidytext)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(igraph)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(RMySQL)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(RColorBrewer)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Download data using RmySQL&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;source&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dbconnect.R&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## lucidmanager &amp;lt;- dbConnect(MySQL(),&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;##                          user = &amp;#34;username&amp;#34;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;##                          password = &amp;#34;Password1&amp;#34;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;##                          dbname = &amp;#34;databe name&amp;#34;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;##                          host = &amp;#34;URL&amp;#34;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;posts.query &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;SELECT p.post_name, p.post_content, t.name
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                FROM wp_posts p
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                JOIN wp_term_relationships tr ON (tr.object_id = p.ID)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                JOIN wp_term_taxonomy tt ON (tt.term_taxonomy_id = tr.term_taxonomy_id )
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                JOIN wp_terms t ON (t.term_id = tt.term_id)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                WHERE p.post_type=&amp;#39;post&amp;#39; AND p.post_status=&amp;#39;publish&amp;#39; 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                      AND tt.taxonomy = &amp;#39;category&amp;#39;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;pages.query &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;SELECT post_name, post_content
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                FROM wp_posts
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                WHERE post_type=&amp;#39;page&amp;#39; AND post_status=&amp;#39;publish&amp;#39;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;posts.data &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dbSendQuery&lt;/span&gt;(lucidmanager, posts.query)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;posts &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;fetch&lt;/span&gt;(posts.data, n &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;pages.data &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dbSendQuery&lt;/span&gt;(lucidmanager, pages.query)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;pages &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;fetch&lt;/span&gt;(pages.data, n &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dbDisconnect&lt;/span&gt;(lucidmanager)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;pages&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;name &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Page&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;content &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rbind&lt;/span&gt;(posts, pages)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as_tibble&lt;/span&gt;(content)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
  The result of this code is a data frame with all posts and pages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;post_name&lt;/code&gt;: The slug of the post or page.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;post_content&lt;/code&gt;: Content of the page (HTML file without headers).&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;name&lt;/code&gt;: Post category.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I currently no longer use Wordpress but have moved everything to the &lt;a href=&#34;https://lucidmanager.org/data-science/export-wordpress-to-hugo/&#34;&gt;Hugo static website generator&lt;/a&gt;, using &lt;a href=&#34;https://lucidmanager.org/productivity/create-websites-with-org-mode-and-hugo/&#34;&gt;Emacs Org Mode to write content&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Converting the data to a network
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The second step uses the &lt;a href=&#34;https://www.tidytextmining.com/&#34;&gt;tidytext package&lt;/a&gt; to convert the texts of the articles into tokens. In this case, a token is any set of characters between spaces. In the default setting, the tokenisation function also splits words at dashes, which is not helpful because we want to preserve the hyperlinks as one token.&lt;/p&gt;
&lt;p&gt;
The code uses regular expressions to filter all internal links (detect &lt;code class=&#34;verbatim&#34;&gt;lucidmanager.org&lt;/code&gt;) and retain the slug. The slug is the text after the website name. The &lt;code class=&#34;verbatim&#34;&gt;post_name&lt;/code&gt; field in the database contains the slug for the post itself. We thus identify a link from one internal page to another.&lt;/p&gt;
&lt;p&gt;
These steps result in a table that shows how all slugs link to each other. In network analysis, this is an &lt;a href=&#34;https://en.wikipedia.org/wiki/Adjacency_list&#34;&gt;adjacency list&lt;/a&gt; as each line represents a relationship in the network. The category variable identifies the post category, which is helpful to colour the resulting graph. Note that any post without outgoing links will not appear in this list.&lt;/p&gt;
&lt;p&gt;
This code also works with any data frame that contains the slug and content of the web pages as fields. The category variable is optional. Replace &lt;code class=&#34;verbatim&#34;&gt;lucidmanager.org&lt;/code&gt; with the URL of the website you are analysing.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  links &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; content &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unnest_tokens&lt;/span&gt;(word, post_content,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  token &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; stringr&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;str_split, pattern &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;.+lucidmanager.org/&amp;#34;&lt;/span&gt;, word)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(link &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;.+lucidmanager.org/&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, word),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           link &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;/.+&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, link)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(link &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;tag&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; link &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt;  &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;wp-content&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; link &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;author&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(category &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; name, post_name, link)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The resulting adjacency list will look something like this:&lt;/p&gt;
&lt;figure&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;category&lt;/th&gt;
&lt;th&gt;post_name&lt;/th&gt;
&lt;th&gt;link&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;RStats&lt;/td&gt;
&lt;td&gt;analyse-site-structure&lt;/td&gt;
&lt;td&gt;export-wordpress-to-hugo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RStats&lt;/td&gt;
&lt;td&gt;export-wordpress-to-hugo&lt;/td&gt;
&lt;td&gt;analyse-site-structure&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;figcaption&gt;
Extract from adjacency list with two pages referring each other.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Analyse Site Structure with iGraph
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Network analysis is the perfect tool to analyse site structure because each post on the website is a node and a link between two articles is a graph edge (arrow). &lt;/p&gt;
&lt;p&gt;
The Lucid Manager currently discusses strategic and fun data analysis, but in the past, I wrote articles about water utility marketing and critical perspectives on management theories. The questions I like to answer with this analysis are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Are all pages connected to each other in one or more steps?&lt;/li&gt;
&lt;li&gt;What is the most linked page?&lt;/li&gt;
&lt;li&gt;Which pages link to themselves?&lt;/li&gt;
&lt;li&gt;Are there duplicated links within one post?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The iGraph software transforms the link table to a network. Any posts and pages without any links (solitary pages) are added separately. Each post is also given a colour related to its category, and pages are a separate colour.&lt;/p&gt;
&lt;p&gt;
This analysis shows that the internal link structure contains several sub networks, which are groups of pages that are only linked to each other. This graph will help in to identify more linking opportunities to dissolve sub networks.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://igraph.org/r/doc/degree.html&#34;&gt;degree function&lt;/a&gt; in iGraph determines the number of adjacent edges of each graph. The degree function can specify incoming and outgoing links. My article about service quality in water utilities is the most linked post on this site.
In network analysis, this is the node with the highest degree of linking.&lt;/p&gt;
&lt;p&gt;
The loops in the diagram indicate self-referencing articles. The &lt;a href=&#34;https://igraph.org/r/doc/which_multiple.html&#34;&gt;which_loop&lt;/a&gt; function identifies which arrows have the same start and end. The &lt;code class=&#34;verbatim&#34;&gt;E&lt;/code&gt; function shows the list of edges, which shows that four pages on my website refer to themselves.&lt;/p&gt;
&lt;p&gt;
Lastly, the &lt;a href=&#34;https://igraph.org/r/doc/which_multiple.html&#34;&gt;which_multiple&lt;/a&gt; function identifies any duplicated edges in the graph. Within this context, these are pages that contain the same link more than once. The Lucid Manager website had seventeen instances of duplicated links when I first analysed its structure.&lt;/p&gt;
&lt;p&gt;
This first phase gives me plenty of homework to improve the internal linking structure of this website.&lt;/p&gt;
&lt;p&gt;
&lt;figure&gt;&lt;a href=&#34;https://lucidmanager.org/images/digital-humanities/lucidmanager_links.png&#34;&gt;&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/lucidmanager_links.png&#34;
			alt=&#34;Visualising website structure.&#34;&gt;&lt;/a&gt;&lt;figcaption&gt;
			&lt;p&gt;Visualising website structure. (click to enlarge)&lt;/p&gt;
		&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  solitary &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(posts&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;post_name, pages&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;post_name)[&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(posts&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;post_name, pages&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;post_name) &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                                    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unique&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(links&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;post_name, links&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;link)))]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  network &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(links, post_name, link) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;graph_from_data_frame&lt;/span&gt;(directed &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vertices&lt;/span&gt;(solitary)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  colour &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(post_name &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;V&lt;/span&gt;(network)&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;name) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;left_join&lt;/span&gt;(content) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(name &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;factor&lt;/span&gt;(name),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;brewer.pal&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unique&lt;/span&gt;(content&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;name)), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Set2&amp;#34;&lt;/span&gt;)[name]) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;post_content)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;V&lt;/span&gt;(network)&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;color &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.vector&lt;/span&gt;(colour&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;colour)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;par&lt;/span&gt;(mar &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot&lt;/span&gt;(network,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       layout &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; layout.fruchterman.reingold,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.label.cex &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.7&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;degree&lt;/span&gt;(network),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.label.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.frame.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       edge.arrow.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.2&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       edge.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;darkgray&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Diagnose network&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which.max&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;degree&lt;/span&gt;(network, mode &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;in&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;E&lt;/span&gt;(network)&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[which_loop&lt;/span&gt;(network)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;E&lt;/span&gt;(network)&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[which_multiple&lt;/span&gt;(network)]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Future improvements
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This analysis is a great step to start systematically analysing organic website structure. Several other techniques help to understand the structure of a website further. Community detection and the inclusion of tags and categories in the data can provide additional context. SEO experts might find this concept useful. Perhaps somebody else can develop a Wordpress plugin to provide this visualisation.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Decode Lyrics in Pop Music with the Songsim algorithm</title>
      <link>https://lucidmanager.org/data-science/decoding-lyrics-with-songsim/</link>
      <pubDate>Sat, 23 Mar 2019 03:14:17 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/decoding-lyrics-with-songsim/</guid>
      <description>
	
&lt;p&gt;
Music is an inherently mathematical form of art. Ancient Greek mathematician Pythagoras was the first to describe the logic of the scales that form melody and harmony. Numbers can also represent the rhythm of the music. Even the lyrics have a mathematical structure. Poets structure syllables and repeat words to create pleasing sounding prose. This article shows how to decode lyrics from pop songs and visualise them using the Songsim method to analyse their metre.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Decode Lyrics using the Songsim algorithm
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Data visualiser, pop music appreciator and machine learner &lt;a href=&#34;https://twitter.com/HalfEatenScone&#34;&gt;Colin Morris&lt;/a&gt; has extensively analysed the repetitiveness of song lyrics. Colin demonstrated that lyrics are becoming more repetitive since the early days of pop music. The most repetitive song is &lt;em&gt;Around the World&lt;/em&gt; by Daft Punk, which should not be a surprise since the artist repeats the same phrase 144 times. &lt;em&gt;Bohemian Rhapsody&lt;/em&gt; by Queen has some of the least repetitive lyrics in popular music.&lt;/p&gt;
&lt;p&gt;
The TedX presentation (see below) by Colin Morris shows how he visualises the repetitiveness of song lyrics with what he calls the &lt;a href=&#34;https://colinmorris.github.io/SongSim/&#34;&gt;Songsim&lt;/a&gt; algorithm. As a result, the more points in the graph, the more often the composer repeated a word&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/daft-punk-queen.png&#34; alt=&#34;Visualisation of the lyrics of Daft Punk&amp;#39;s &amp;#39;Around the World&amp;#39; and Queen&amp;#39;s &amp;#39;Bohemian Rhapsody&amp;#39;&#34; title=&#34;Visualisation of the lyrics of Daft Punk&amp;#39;s &amp;#39;Around the World&amp;#39; and Queen&amp;#39;s &amp;#39;Bohemian Rhapsody&amp;#39;&#34;/&gt;
&lt;figcaption&gt;
Visualisation of the lyrics of Daft Punk&amp;#39;s &amp;#39;Around the World&amp;#39; and Queen&amp;#39;s &amp;#39;Bohemian Rhapsody&amp;#39;.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The visual language of song lyrics
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Morris decided to use a self-similarity matrix, which biologists use to visualise DNA sequences, to decode lyrics. In this method, the individual words of the song are the names of the columns and the names of the rows in a matrix. For every point in the song where the row name equals the column name, shows a dot. By definition, the diagonal of every similarity matrix is filled. The timeline of the song thus runs along the diagonal from top left to bottom right.&lt;/p&gt;
&lt;p&gt;
Patterns away from the diagonal represent two different points in time that have the same words. The more of these patterns we see, the more repetitive a song is. Let&amp;#39;s demonstrate this with the &lt;a href=&#34;https://www.youtube.com/watch?v=g3qPT30LejM&#34;&gt;first words ever recorded&lt;/a&gt; by Thomas Edison in 1877.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/g3qPT30LejM?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Original Edison 1877 tin foil recording.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;blockquote&gt;
&lt;p&gt;Mary had a little lamb, whose fleece was white as snow. And everywhere that Mary went, the lamb was sure to go.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The similarity matrix below visualises the two first sentences of the famous nursery rhyme. It shows where the words &amp;#34;Mary&amp;#34;, &amp;#34;lamb&amp;#34; and &amp;#34;was&amp;#34; are repeated once.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/edison-little-lamb.png&#34; alt=&#34;Self-similarity matrix for Mary had a Little Lamb by Thomas Edison.&#34; title=&#34;Self-similarity matrix for Mary had a Little Lamb by Thomas Edison.&#34;/&gt;
&lt;figcaption&gt;
Self-similarity matrix for Mary had a Little Lamb by Thomas Edison.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The snowflake diagrams are a visual language to decode lyrics. The verses are the gutters with only diagonal lines. A verse is not very repetitive besides some stop words. The verse repeats through the song. Many songs have a bridge that contrasts with the rest of the song. As a result, the bridge is in most songs a unique pattern with self-similarity.&lt;/p&gt;
&lt;p&gt;
The diagram below visualises the lyrics of one of the most famous pop songs ever, &lt;em&gt;Waterloo&lt;/em&gt; by Abba. The first 30 words are the opening verse, which shows little repetition, other than stop words such as and the pronoun I. After that we see diagonal lines appearing that represent the repetitive use of the song title. Towards the end of the song, we see the bridge, which is like a little snowflake within the diagram.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/abba-waterloo.png&#34; alt=&#34;/images/digital-humanities/abba-waterloo.png&#34; title=&#34;Decoding lyrics: Waterloo by Abba.&#34; at=&#34;Decoding lyrics: Waterloo by Abba.&#34;/&gt;
&lt;figcaption&gt;
Decoding lyrics: Waterloo by Abba.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The next section shows how to implement this approach with ggplot, scraping pop song lyrics from the azlyrics.com website.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/_tjFwcmHy5M?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Pop Music is Stuck on Repeat | Colin Morris | TEDxPenn
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Implementing Songsim with ggplot
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The code below visualises song lyrics or poetry as suggested by Colin Morris. The code uses four libraries. I use the tidyverse series of libraries because it makes life very easy. The tidytext library uses the tidyverse principles to analyse text. The old reshape2 library helps to transform a matrix, and lastly, rvest helps to scrape song lyrics from the azlyrics website.&lt;/p&gt;
&lt;p&gt;
The first function scrapes song lyrics from the azlyrics website using the artist and song as input. The first three lines clean the artist and song variables. This code removes any character that is not a number or a letter, converts to lowercase and lastly removes the definite article in the artist name. These two fields are then concatenated to create the URL, which the function prints. The remainder of the code scrapes the lyrics from the website or trips on an error 404 when it cannot find the song/artist combination.&lt;/p&gt;
&lt;p&gt;
The second function implements the Morris method to visualise the lyrics. The code extracts single words from the text and places them in a data frame (tibble). This data frame is subsequently converted to a boolean matrix that contains the visualisation.&lt;/p&gt;
&lt;p&gt;
The code looks at each word and places the value TRUE where reappears in the song. Each of the vectors is then concatenated to a matrix. Lastly, ggplot visualises the matrix is visualised as a raster.&lt;/p&gt;
&lt;p&gt;
What does your favourite song look like a snowflake diagram?&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com///&#34; target=&#34;_blank&#34;
   title=&#34;Download  from GitHub&#34;
   alt=&#34;Download  from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Decoding lyrics&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidytext)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(reshape2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(rvest)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  get_lyrics &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(artist, song) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      artist &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;[^A-Za-z0-9]+&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tolower&lt;/span&gt;(artist))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      song &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;[^A-Za-z0-9]+&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tolower&lt;/span&gt;(song))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      artist &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;^the&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, artist)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      url &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;http://azlyrics.com/lyrics/&amp;#34;&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  artist, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;/&amp;#34;&lt;/span&gt;, song, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;.html&amp;#34;&lt;/span&gt;, sep &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(url)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      azlyrics &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read_html&lt;/span&gt;(url)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      lyrics &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;html_nodes&lt;/span&gt;(azlyrics, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;div&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      lyrics &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;html_text&lt;/span&gt;(lyrics[23])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\r|\n&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;, lyrics)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  plot_snowflake &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(artist, song){
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      lyrics &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;get_lyrics&lt;/span&gt;(artist, song)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      lyrics &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data_frame&lt;/span&gt;(line &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lyrics) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(line &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      words &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; lyrics  &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unnest_tokens&lt;/span&gt;(word, line) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      words_matrix &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lapply&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(words),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                             &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(w){
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                 &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(words[w, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;]) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; words
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                             }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                             ) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;do.call&lt;/span&gt;(cbind, .)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rownames&lt;/span&gt;(words_matrix) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(words)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;colnames&lt;/span&gt;(words_matrix) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(words)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;melt&lt;/span&gt;(words_matrix, varnames &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;x&amp;#34;&lt;/span&gt;,  &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;y&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x, &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;y, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; value)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_raster&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_fill_manual&lt;/span&gt;(values &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dodgerblue4&amp;#34;&lt;/span&gt;), guide &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;     
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggtitle&lt;/span&gt;(artist, subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; song)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot_snowflake&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Abba&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Waterloo&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggsave&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Abba-Waterloo.png&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  artist &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Thomas Edison&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  song &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Mary Had a Little Lamb&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  lyrics &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Mary had a little lamb, whose fleece was white as snow. And everywhere that Mary went, the lamb was sure to go.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(gridExtra)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;png&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;DaftPunk-Queen.png&amp;#34;&lt;/span&gt;, width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1024&lt;/span&gt;, height &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;768&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  l1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot_snowflake&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Daft Punk&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Around the world&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  l2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot_snowflake&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Queen&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Bohemian Rhapsody&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grid.arrange&lt;/span&gt;(l1, l2, ncol &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dev.off&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;getwd&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  artist &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Frank Zappa&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  song &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Titties Beer&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Strategic Data Science: Create Value from Data Big and Small</title>
      <link>https://lucidmanager.org/data-science/strategic-data-science/</link>
      <pubDate>Sun, 24 Feb 2019 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/strategic-data-science/</guid>
      <description>
	
&lt;p&gt;
Data science is without a doubt the most popular business fad of the past decade. The wonderful promises of machine learning blind many managers, so they forget about deploying these new approaches strategically. To create value from data, managers need to use a strategic approach to data science. This article provides a framework for data science, following my book &lt;em&gt;Principles of Strategic Data Science&lt;/em&gt;, published by Packt.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2019_sds.jpg&#34; alt = &#34;Principles of Strategic Data Science&#34; title = &#34;Principles of Strategic Data Science&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Principles of Strategic Data Science&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Principles of Strategic Data Science helps you join the dots between mathematics, programming, and business analysis. With a unique approach that bridges the gap between mathematics and computer science, this book takes you through the entire data science pipeline.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.packtpub.com/en-us/product/principles-of-strategic-data-science-9781838985509&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Packt Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
What is Data Science?
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The manager to understand the importance of data was &lt;a href=&#34;https://lucidmanager.org/management/frederick-taylor-management-fundamentalism/&#34;&gt;Frederick Taylor&lt;/a&gt;. He was a pioneer in using data to manage a business. He used data because he wanted to lower the influence of opinions and rules-of-thumb in favour of a scientific approach to management. The term data science emerged in the middle of the last century when electronic computation first became a topic of study. In those days, the discipline was literally a science of storing and manipulating data.&lt;/p&gt;
&lt;p&gt;
The current definition has drifted away from this initial academic activity to a business activity. The current data science hype can be traced back to an article in the 2012 edition of &lt;a href=&#34;https://hbr.org/2012/10/data-scientist-the-sexiest-job-of-the-21st-century&#34;&gt;Harvard Business Review&lt;/a&gt;. Davenport and Patil proclaimed data scientist to be the sexiest job of the twenty-first century. Subsequently, in the wake of this article, the number of data science searches in Google increased rapidly.&lt;/p&gt;
&lt;p&gt;
Organisations have for a long time used data to improve the lives of their customers, shareholders or society overall. Management gurus promoted concepts such as the data-driven organisation, evidence-based management, business intelligence and Six Sigma to help businesses realise the benefits of their data. Data science is an evolution of these methods enabled by the data revolution.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
The Data Revolution
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Recent developments in information technology have significantly improved what we can do with data, resulting in what we now know as data science. Firstly, most business processes are managed electronically, which has exponentially increased the amount of available data. Developments in communication, such as the Internet of Things and personal mobile devices, have significantly reduced the price of collecting data.&lt;/p&gt;
&lt;p&gt;
Secondly, the computing capabilities on the average office worker&amp;#39;s desk outstrip the capabilities of the supercomputers of the past. Not only is it cheaper to collect vast amounts of electronic data, but processing these enormous volumes has also come within reach of the average office worker.&lt;/p&gt;
&lt;p&gt;
Lastly, developments in applied mathematics and open source licensing have accelerated our capabilities in analysing this data. These new technologies allow us to discover patterns that were previously invisible. Data science is available to anyone wanting to learn because most tools to examine data are freely available on the internet with a helpful community sharing knowledge on how to use them.&lt;/p&gt;
&lt;p&gt;
These three developments enabled an evolution from traditional business analysis to data science. Subsequently, data science has become the strategic and &lt;em&gt;systematic&lt;/em&gt; approach to analysing data to achieve organisational objectives using electronic computing. This definition is agnostic of the promises of machine learning and leverages the three developments mentioned above. Data science as such is the next evolution in business analysis that maximises the value we can extract from data.&lt;/p&gt;
&amp;nbsp;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Data Science Strategy Competencies
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The craft of data science combines three different competencies. To illustrate this idea, data scientist Drew Conway visualised these core competencies of data science in a &lt;a href=&#34;http://drewconway.com/zia/2013/3/26/the-data-science-venn-diagram&#34;&gt;Venn diagram&lt;/a&gt;.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/conway-venn-diagram.png&#34; alt=&#34;Conway Venn Diagram&#34; title=&#34;Conway Venn Diagram&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Data science competencies (Based on Conway, 2009).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Firstly and most importantly, data science requires &lt;em&gt;domain knowledge&lt;/em&gt;. Any analysis needs to be grounded in the reality it seeks to improve. Subject-matter expertise is a necessary condition to make sense of an investigation. Professional expertise in most areas uses &lt;em&gt;mathematics&lt;/em&gt; to understand and improve outcomes. New mathematical tools expand the traditional approaches to develop a deeper understanding of the domain under consideration. Lastly, &lt;em&gt;computer science&lt;/em&gt; is the competency that binds the available data with mathematics. Writing computer code to extract, transform and analyse data to create information and stimulate knowledge is an essential skill for any data scientist.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Good Data Science
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In order to create value with data, we need to know how to create or recognise good data science. The second chapter of the book uses three principles originally introduced two thousand years ago by the Roman architect and engineer Vitruvius. He wrote that buildings need to be &lt;em&gt;useful&lt;/em&gt;, &lt;em&gt;sound&lt;/em&gt; and &lt;em&gt;aesthetic&lt;/em&gt;. These requirements are also ideally suited to define best-practice in data science.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/vitrivius.png&#34; alt=&#34;The Vitruvian triangle for data science&#34; title=&#34;The Vitruvian triangle for data science&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
The Vitruvian triangle for data science.
&lt;/figcaption&gt;
&lt;/figure&gt;
&amp;nbsp;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Usefulness
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;For data science to be useful, it needs to contribute to the objectives of an organisation positively. It is in this sense that data science is an applied science and not an academic pursuit. The famous Data-Information-Knowledge pyramid visualises the process of creating value from data.&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Useful&lt;/em&gt; data science meaningfully improves our reality through data. Data is a representation of either a social or physical reality. Any data source is ever only a sample of the fullness and complexity of the real world. Information is data imbued with context. The raw data collected from reality needs to be summarised, visualised and analysed so that managers understand the reality of their business. This information increases knowledge about a business process, which is subsequently used to improve the reality from which the data was collected. This feedback loop visualises the essence of analysing data in businesses. Data science is a seductive activity because it is reasonably straightforward to create impressive visualisations with sophisticated algorithms. If data products don&amp;#39;t improve or enlighten the current situation, they are in essence useless.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/feedback-loop.png&#34; alt=&#34;Reality - Data - Information - Knowledge pyramid&#34; title=&#34;Reality - Data - Information - Knowledge pyramid&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Reality - Data - Information - Knowledge pyramid.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Soundness
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Data science needs to be &lt;em&gt;sound&lt;/em&gt; to ensure that the outcomes are valid and reliable. The validity and reliability of data are where the science meets the traditional approaches to analysing data. Validity is the extent to which the data represents the reality it describes. The reliability of data relates to the accuracy of the measurement. These
two concepts depend on the type of data under consideration. Measuring physical processes is less complicated than the social aspects of society. Validity and reliability are in essence a sophisticated way of expressing the well-known Garbage-In-Garbage-Out principle.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/soundness.png&#34; alt=&#34;/images/data-science/soundness.png&#34; title=&#34;Reliability and validity of data and analysis&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Reliability and validity of data and analysis.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The soundness of data science also relates to the reproducibility of the analysis to ensure that other professionals can review the outcomes. Reproducibility prevents that the data and the process by which it was transformed and analysed become a black-box where we have no reason to trust the results. Data science also needs to be sound concerning the governance of the workflow. All data sources need to be curated by relevant subject matter experts to ensure their validity and reliability. Data experts provide that the data is available to those who need it.&lt;/p&gt;
&amp;nbsp;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Aesthetics
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Lastly, data science needs to be &lt;em&gt;aesthetic&lt;/em&gt; to ensure that any visualisation or report is easy to understand by the consumer of the analysis. This requirement is not about beautification through infographics. Aesthetic data products minimise the risk or making wrong decisions because the information is presented without room for misinterpretation. Any visualisation needs to focus on telling a story with the data. This story can be a comparison, a prediction, a trend or whatever else is relevant to the problem.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/data-pixel-ratio.jpg&#34; alt=&#34;Example of low and high data-to-pixel ratio&#34; title=&#34;Example of low and high data-to-pixel ratio&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Example of low and high data-to-pixel ratio.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
One of the essential principles of aesthetic data science is the data-to-pixel ratio. This principle means that we need to maximise the ratio between all the pixels on a screen and those pixels that present information. Good data visualisation practices austerity to ensure that the people that consume the information understand the story that needs to be told.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Strategic Data Science
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The data science continuum is a strategic journey for organisations that seek to maximise value from data. As an organisation moves along the continuum, increased complexity is the payoff for increased value. This continuum looks like hierarchy, but all phases are equally important. The last stages cannot exist without the previous ones. Therefore, implementing machine learning without a solid grasp of data collection will result in useless outcomes.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/data-science-continuum.png&#34; alt=&#34;Data science strategy continuum&#34; title=&#34;Data science strategy continuum&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Data science strategy continuum.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Collecting data requires considerations on what to collect, how to collect it and at what frequency. To collect meaningful data requires a good understanding of the relationship between reality and data. There is no such thing as raw data as all information relies on assumptions and practical limitations.&lt;/p&gt;
&amp;nbsp;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
Type of Value from Data
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;ul&gt;
&lt;li&gt;Describing the data is the first step in extracting value.&lt;/li&gt;
&lt;li&gt;Descriptive statistics are the core of most business reporting and are
an essential first step in analysing the data.&lt;/li&gt;
&lt;li&gt;Diagnostics or analysis is the core activity of most professions. Each
subject area uses specialised methods to create new information from
data.&lt;/li&gt;
&lt;li&gt;Predictive analysis seems to be the holy grail for many managers. A
prediction is not a perfect description of the future but it provides
the distribution of possible futures. Managers can use this
information to change the present to construct their desired future.&lt;/li&gt;
&lt;li&gt;Prescriptive analysis uses the knowledge created in the previous
phases to automatically run a business process and even decide on
future courses of action.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Any organisation starting with data science should follow the five phases in this process and not jump ahead to try to bypass the seemingly less valuable stages.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-10&#34;&gt;
The Data-Driven Organisation
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Implementing a data science strategy is more than a matter of establishing a specialised team and solve complex problems. Creating a data-driven organisation that maximises the value of data requires a whole-of-business approach that involves people with the right attitude and skills, appropriate systems and robust processes.&lt;/p&gt;
&lt;p&gt;
A data science team combines the three competencies described in the Conway Venn diagram. People that have skills in all three of these areas are rare, and the industry calls them unicorns. There is no need for recruiters to start hunting unicorns because these three areas of expertise can also exist within a team. Possibly more important than the technical skills are the social skills of a data scientist. Not only need they create useful, sound and aesthetic data science, they also need to convince the consumers of their work of its value.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-11&#34;&gt;
Data Literacy
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;One of the problems of creating value with data is ensuring that the results are implemented in the organisation. A starting point to achieve this is to ensure that the users of data products have a relevant level of data literacy. Developing data literacy among consumers of data science is probably one of the greatest challenges. The required level of data literacy depends on the type of position and the role of the data consumer within the organisation.&lt;/p&gt;
&lt;p&gt;
Data scientists use an extensive range of tools and are often opportunistic in their choice of software. &lt;a href=&#34;https://lucidmanager.org/data-science/spreadsheets-for-data-science/&#34;&gt;Spreadsheets&lt;/a&gt; are not very suitable to create good data science. Data science requires coding skills and the Python and R languages are powerful tools to solve complex problems. After the data specialists have developed the best way to analyse data, they need to communicate these to their customers. Many specific products exist to communicate data to users with interactive dashboards and many other dynamic systems.&lt;/p&gt;
&lt;p&gt;
The final part of this book on data science strategy delves into the ethics of data science. From the fact that something can be done, we certainly cannot conclude that it should be done. Just like any other profession that impacts humans, data scientists need ethical guidelines to ensure that their activities cause no harm. The book provides some basic guidelines that can assist data scientists to assess the ethical merits of their projects.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-12&#34;&gt;
Summary
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In summary, data science is about more than using the latest algorithms to analyse data. Good data science has to be useful in that it positively influences the objectives of the organisation. Furthermore, good data science has to be sound through a methodical approach.&lt;/p&gt;
&lt;p&gt;
My books &lt;em&gt;Principles of Strategic Data Science&lt;/em&gt; and &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; provide detailed insights into these topics.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2019_sds.jpg&#34; alt = &#34;Principles of Strategic Data Science&#34; title = &#34;Principles of Strategic Data Science&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Principles of Strategic Data Science&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Principles of Strategic Data Science helps you join the dots between mathematics, programming, and business analysis. With a unique approach that bridges the gap between mathematics and computer science, this book takes you through the entire data science pipeline.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.packtpub.com/en-us/product/principles-of-strategic-data-science-9781838985509&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Packt Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Factor Analysis in R: Measuring Consumer Involvement</title>
      <link>https://lucidmanager.org/data-science/measuring-consumer-involvement/</link>
      <pubDate>Sat, 19 Jan 2019 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/measuring-consumer-involvement/</guid>
      <description>
	
&lt;p&gt;
The first step for anyone who wants to promote or sell something is to understand the psychology of potential customers. Getting into consumers&amp;#39; minds is often problematic because measuring psychological traits is complex. Consumer involvement is a measure of people&amp;#39;s attitudes towards a product or service. This article introduces the concept of consumer involvement. An example using data from tap water consumers illustrates the theory. This article analyses data collected from these consumers using factor analysis in R, with the &lt;a href=&#34;https://personality-project.org/r/&#34;&gt;psych package&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The most common method to measure psychological traits is to ask people several questions. Analysing this data is complicated because it is difficult to determine how the survey responses relate to the software of the mind. While the answers given by survey respondents are the directly measured variables, we like to know the hidden (latent) states in their minds. Factor Analysis is a technique that identifies latent variables within a data set, such as a customer survey.&lt;/p&gt;
&lt;p&gt;
The basic principle of measuring consumer attitudes is that their state of mind causes them to respond in a certain way. Factor analysis reverses this causality by analysing patterns in responses that indicate the consumer&amp;#39;s state of mind. Using a computing analogy, factor analysis is a technique for reverse-engineering source code by analysing the input and output.&lt;/p&gt;
&lt;p&gt;
The data and code for this article are available on GitHub in the &lt;code class=&#34;verbatim&#34;&gt;case-studies&lt;/code&gt; folder:&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
What is Consumer Involvement?
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Involvement is a marketing metric that describes the relevance of a product or service in somebody&amp;#39;s life. &lt;a href=&#34;http://www.sfu.ca/~zaichkow/research.html&#34;&gt;Judy Zaichkowsky&lt;/a&gt; defines consumer involvement formally as “a person&amp;#39;s perceived relevance of the object based on inherent needs, values, and interests”. People who own a car will most likely be highly involved with purchasing and driving the vehicle due to the money involved and the social role it plays in &lt;a href=&#34;https://horizonofreason.com/culture/first-law-of-consumer-behaviour/&#34;&gt;developing their public self&lt;/a&gt;. Consumers will most likely have a much lower level of involvement with the instant coffee they drink than with their clothes.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Managerial Relevance
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The level of consumer involvement depends on a complex array of factors. These factors relate to psychology, situational factors, and the service provider&amp;#39;s marketing mix. The lowest level of involvement is considered a state of inertia which occurs when people habitually purchase a product without comparing alternatives.&lt;/p&gt;
&lt;p&gt;
From a managerial point of view, involvement is crucial because it is causally related to willingness to pay and perceptions of quality. Consumers with a higher level of involvement are willing to pay more for a service and have a more favourable perception of quality. Understanding involvement in the context of urban water supply is also crucial because sustainably managing water as a common pool resource requires the active involvement of all users.&lt;/p&gt;
&lt;p&gt;
Cult products have the highest possible level of involvement as customers are fully devoted to a particular product or brand. Commercial organisations use this knowledge to their advantage by maximising consumer involvement through branding and advertising. This strategy is used effectively by the &lt;a href=&#34;https://lucidmanager.org/marketing/bottled-water-marketing/&#34;&gt;bottled water industry&lt;/a&gt;. Manufacturers focus on enhancing the emotional aspects of their products rather than on improving the cognitive elements. Water utilities tend to use a reversed strategy and emphasise the cognitive aspects of tap water, the pipes, plants and pumps rather than trying to create an emotional relationship with their consumers. &lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Measuring Consumer Involvement
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;For my dissertation about &lt;a href=&#34;https://lucidmanager.org/tags/invisible-water-utility/&#34;&gt;customer service in water utilities&lt;/a&gt;, I measured the level of involvement that consumers have with tap water using the &lt;em&gt;Personal Involvement Index&lt;/em&gt; (PII).&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
Asking consumers directly about their level of involvement would not yield a stable answer, as each respondent would interpret the question differently. The best way to measure psychological states or psychometrics is to ask a series of questions linguistically related to the topic of interest.&lt;/p&gt;
&lt;p&gt;
The most cited method for measuring consumer involvement is the &lt;em&gt;Personal Involvement Index&lt;/em&gt;, developed by Judy Zaichowsky. This index is a two-dimensional scale consisting of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Cognitive involvement (importance, relevance, meaning, value, and need)&lt;/li&gt;
&lt;li&gt;Affective involvement (involvement, fascination, appeal, excitement, and interest).&lt;/li&gt;
&lt;/ul&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/pii-model.png&#34; alt=&#34;Personal Involvement Inventory measurement model&#34; title=&#34;Personal Involvement Inventory measurement model&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Personal Involvement Inventory measurement model.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The survey instrument consists of ten &lt;em&gt;Semantic Differential&lt;/em&gt; items. A Semantic Differential is a rating scale designed to measure the meaning of objects, events, or concepts. The researcher translates the concept, such as involvement, into a list of synonyms and their associated antonyms.&lt;/p&gt;
&lt;p&gt;
In the involvement survey, participants position their views along a continuum, such as Worthless-Valuable or Boring-Interesting. The level of involvement is the sum of all answers, ranging from 10 to 70.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/involvement-pii-scale.jpg&#34; alt=&#34;Personal Involvement Inventory semantic-differential scale&#34; title=&#34;Personal Involvement Inventory semantic-differential scale&#34;/&gt;
&lt;figcaption&gt;
Personal Involvement Inventory semantic-differential scale (Zaichowsky 1994).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Obtaining the Data
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The data form part of a survey of tap water customers. &lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Consumer Involvement&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(psych)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Clean data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  customers &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read_csv&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/customer_survey.csv&amp;#34;&lt;/span&gt;)[&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;, ] &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;type_convert&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;is.na&lt;/span&gt;(term)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;21&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;51&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-33&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rename&lt;/span&gt;(customer_id &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The scale uses reverse polarity as some of the items are from low to high (boring – interesting) and others from high to low (important – unimportant), so we need to correct this by reversing the scores for six items. The data also has missing values, so we only use the complete cases.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;# Correct polarity&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;pii &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(customers, customer_id, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;starts_with&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;p&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(p01 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; p01,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         p02 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; p02,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         p07 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; p07,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         p08 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; p08,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         p09 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; p09,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         p10 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; p10)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;# Remove missing values&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;pii &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; pii&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[complete.cases&lt;/span&gt;(pii), ]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Exploratory Analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;
This data set contains additional information, and the code selects only variable names that start with &amp;#34;&lt;em&gt;p&lt;/em&gt;&amp;#34; (for the Personal Involvement Inventory). Before we analyse data, we remove customers who provided the same answers to all items or did not respond to all questions. These responses are most likely invalid, which leaves 757 rows of data.&lt;/p&gt;
&lt;p&gt;
A boxplot is a convenient way to visualise responses to multiple survey items in a single chart. This plot immediately shows an interesting pattern in the answers. Responses to the first five items were generally higher than those for the last five. This result indicates a distinction between cognitive and affective involvement.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;# Visualise PII&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    pii_long &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; pii &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;pivot_longer&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;customer_id, names_to &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Item&amp;#34;&lt;/span&gt;, values_to &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Response&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(pii_long) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(Item, Response) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_boxplot&lt;/span&gt;(fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#f7941d&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_bw&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;12&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Personal Involvement Index&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Tap Water Consumers USA and Australia (n = &amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                            &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(pii), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;)&amp;#34;&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/involvement-explore.png&#34; alt=&#34;Responses to Personal Involvement Index by tap water consumers&#34; title=&#34;Responses to Personal Involvement Index by tap water consumers&#34;/&gt;
&lt;figcaption&gt;
Responses to Personal Involvement Index by tap water consumers.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The next step in the exploratory analysis is to investigate how these factors correlate. The correlation plot below shows that all items strongly correlate with each other. As shown in the boxplots above, the first five and the last five items correlate more strongly. This plot suggests that the two dimensions of the involvement index correlate. The following section shows how to use factor analysis in R to check the significance of these correlation patterns.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Visualise correlation matrix&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  c_matrix &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cor&lt;/span&gt;(pii[, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggcorrplot)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggcorrplot&lt;/span&gt;(c_matrix, outline.col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Personal Inventory Index&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Correlation Matrix&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/involvement-correlation.png&#34; alt=&#34;Correlation matrix for the Personal Involvement Index&#34; title=&#34;Correlation matrix for the Personal Involvement Index&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Correlation matrix for the Personal Involvement Index.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Factor Analysis in R
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Researchers often confuse Factor Analysis with Principal Component Analysis. The outcomes are very similar when applied to the same data set. Both methods are similar but serve different purposes. Principal Component Analysis is a data-reduction technique that reduces the number of variables in a problem. The specific purpose of Factor Analysis is to uncover latent variables. The mathematical principles for both methods are similar but not identical, and they should not be confused.&lt;/p&gt;
&lt;p&gt;
One of the most crucial decisions in factor analysis is to decide how to rotate the factors. There are two types: orthogonal and oblique. In simple terms, orthogonal rotations reduce the correlation between dimensions, whereas oblique rotations allow dimensions to relate to each other. Because of the strong correlations in the correlation plot and the fact that both dimensions measure involvement, this analysis uses oblique rotation. The visualisation below shows how each item and the two dimensions relate to one another.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(psych)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  pii_fa &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;fa&lt;/span&gt;(pii[, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;], nfactors &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;, rotate &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;oblimin&amp;#34;&lt;/span&gt;, fm &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;ml&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;fa.diagram&lt;/span&gt;(pii_fa, main &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;, marg &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/involvement-factors.png&#34; alt=&#34;Factor analysis in R with Psych package&#34; title=&#34;Factor analysis in R with Psych package&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Factor analysis in R with Psych package.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Consumer Involvement Scores
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This analysis suggests that the items for the PII measure an underlying construct, which we can call consumer involvement. To work out the scores for this measure, we can sum the items for each respondent.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Calculating the PII&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  pii_scores &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; pii &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(cognitive &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; p01 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; p02 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; p03 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; p04 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; p05,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           affective &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; p06 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; p07 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; p08 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; p09 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; p10) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(customer_id, cognitive, affective) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;pivot_longer&lt;/span&gt;(cols &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;customer_id)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(pii_scores) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(value) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_histogram&lt;/span&gt;(fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dodgerblue 4&amp;#34;&lt;/span&gt;, binwidth &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;facet_wrap&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;name) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_minimal&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;12&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Consumer Involvement with Tap Water&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Personal Involvement Index&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Score&amp;#34;&lt;/span&gt;, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/involvement-scores.png&#34; alt=&#34;Personal Involvement Index for tap water&#34; title=&#34;Personal Involvement Index for tap water&#34;/&gt;
&lt;figcaption&gt;
Personal Involvement Index for tap water.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This simple factor analysis in R shows the basic principle of analysing psychometric data. The psych package has many more specialised tools to dig deeper into the information. This article has not assessed this construct&amp;#39;s validity or evaluated the factors&amp;#39; reliability. That may be for a future article.&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/analysing-the-customer-experience/&#34;&gt;Chapter 8&lt;/a&gt; in &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; explains the principles of analysing survey data to understand the customer experience in more detail.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>5½ Reasons to Ditch Spreadsheets for Data Science</title>
      <link>https://lucidmanager.org/data-science/spreadsheets-for-data-science/</link>
      <pubDate>Tue, 11 Dec 2018 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/spreadsheets-for-data-science/</guid>
      <description>
	
&lt;p&gt;
When I studied civil engineering some decades ago, we solved all our computing problems by writing code. Writing in BASIC or PASCAL, I could quickly perform fundamental engineering analysis, such as reinforced concrete beams, with my home-brew software library. Soon after I started my career, spreadsheets became widely available, and I fully embraced this fantastic business tool, first Lotus 123 and later grudgingly moved to MS Excel. This article describes why you should ditch spreadsheets for data science and start writing code in R or Python instead. Computer code is Poetry, spreadsheets are chaos.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/wapening.jpg&#34; alt=&#34;Screendump of Atari BASIC program&#34; title=&#34;Screendump of Atari BASIC program&#34;/&gt;
&lt;figcaption&gt;
Screendump of Atari BASIC program to estimate concrete reinforcement surface area.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Spreadsheets were excellent in those early days because data, code, visualisations and tabular output are all stored in one convenient file. Creating graphs with computer code was a bit of a nightmare in those days, so spreadsheets were a minor miracle. The next twenty years, I must have created thousands of spreadsheets of varying complexity. I even developed a ‘jungle&amp;#39; of interlinked spreadsheets to manage progress reporting.&lt;/p&gt;
&lt;p&gt;
In the pioneering days of spreadsheets, they provided enormous convenience for engineers and other professionals to quickly develop analytical tools. But after using this tool for a few years, cracks started to appear.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/YDvbDiJZpy0?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Meet the inventor of the spreadsheet | Dan Bricklin
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Spreadsheets for Data Science are Chaos
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Throughout my career, I had many nightmarish experiences trying to reverse engineer spreadsheets, even the ones I wrote myself. The combination of data, code and output that I loved at the start of my career had reached its limits. Spreadsheets use incomprehensible names for variables (&lt;code class=&#34;verbatim&#34;&gt;AZ346&lt;/code&gt;, &lt;code class=&#34;verbatim&#34;&gt;XC89&lt;/code&gt; and so on) and the formulas are impossible to read because all code is cramped on one line with deeply nested logic. The multiple parentheses make Excel formulas are even harder to read than LISP expressions.&lt;/p&gt;
&lt;p&gt;
Furthermore, spreadsheets hide the formulas behind the results, which renders spreadsheets notoriously hard to understand. My love affair with the spreadsheet came to an end when I started writing my dissertation about customer service for water utilities. Excel was incapable of helping my need for solving complex mathematical problems. A colleague suggested I look into this new thing called &amp;#39;Data Science&amp;#39; and this advice changed my career.&lt;/p&gt;
&lt;p&gt;
My focus is to implement &lt;a href=&#34;https://lucidmanager.org/data-science/strategic-data-science/&#34;&gt;strategic data science&lt;/a&gt; to help organisations to create value from data. One of the ways to achieve this goal is to ditch the spreadsheet and start writing code instead.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/data-science/reverse-engineer-spreadsheet.jpg&#34; alt=&#34;Example of a reverse-engineering a spreadsheet&#34; title=&#34;Example of a reverse-engineering a spreadsheet&#34;/&gt;
&lt;figcaption&gt;
Example of a reverse-engineering a spreadsheet.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Code is Poetry
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;I decided to learn how to write code in the R language for statistical analysis. The R language is like a Swiss army chainsaw for engineers with capabilities that far exceed anything a spreadsheet can do. Writing in code, such as R or Python, is like writing an instruction manual on how to analyse data. Anyone who understands the language will be able to know how you derived your conclusions. Modern data science languages can generate print-quality visualisations and can output results in many formats, including a spreadsheet. In my job as a data science manager
for a water utility, I use R code for everything.&lt;/p&gt;
&lt;p&gt;
The awesome power of being able to easily combine large data sets, visualise data and undertake complex analysis. Now that I have rediscovered the poetry of writing computer code, I advocate learning to use R or perhaps Python and ditch the spreadsheet. On my this website, I share examples of creating value and having fun with the R language. Computer code is poetry in the sense that you can read it like a poem. Computer code consists of a sequential logic that is easy to follow. A spreadsheet is a chaotic jumble of formulas in a geometrical pattern. Each spreadsheet has a different pattern. The only purpose I still have for spreadsheets is as an interface for small data sets.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
5½ Reasons to Ditch the Spreadsheet
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you are still using spreadsheets, or you are trying to convince a colleague to ditch this tool, here are 5½ reasons to start using code to analyse data:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Good analysis is reproducible and can be peer-reviewed. Spreadsheets are hard to understand because of non-sequential references. Computer code is like an instruction book that can be read step-by-step.&lt;/li&gt;
&lt;li&gt;Spreadsheet variables are hard to understand (e.g. &lt;code class=&#34;verbatim&#34;&gt;ZX81:ZX99&lt;/code&gt;). In computer code, you give them meaningful names (e.g. &lt;code class=&#34;verbatim&#34;&gt;sales[81:99]&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Best practice in data management is to separate data, code and output. In spreadsheets, it is not immediately clear which cell is the result of another cell and which ones are raw data. Computer code separates the data from the code and the output.&lt;/li&gt;
&lt;li&gt;You can only share spreadsheet output with people who have access to the relevant software package. Computer code can produce output in multiple formats, such as HTML, PD or even Excel, including &lt;a href=&#34;https://shiny.rstudio.com&#34;&gt;interactive dashboards&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Functionality in spreadsheets is limited to what is made available by Microsoft. The R and Python languages are extendable and have extensive libraries to solve complex problems.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The bonus reason to ditch the spreadsheet is that the best data science software, such as R and Python, is Open Source and freely available on the web. No license fees and it comes with terrific community support. &lt;/p&gt;
&lt;p&gt;
Feel free to leave a comment if you like to defend the spreadsheet. If you have additional reasons to ditch this venerable but largely obsolete tool. Subscribe to this monthly blog if you are interested in using the R language for practical data science and some fun.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2019_sds.jpg&#34; alt = &#34;Principles of Strategic Data Science&#34; title = &#34;Principles of Strategic Data Science&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Principles of Strategic Data Science&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Principles of Strategic Data Science helps you join the dots between mathematics, programming, and business analysis. With a unique approach that bridges the gap between mathematics and computer science, this book takes you through the entire data science pipeline.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.packtpub.com/en-us/product/principles-of-strategic-data-science-9781838985509&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Packt Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Discourse Network Analysis: Undertaking Literature Reviews in R</title>
      <link>https://lucidmanager.org/data-science/discourse-network-analysis-literature-review/</link>
      <pubDate>Thu, 15 Nov 2018 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/discourse-network-analysis-literature-review/</guid>
      <description>
	
&lt;p&gt;
Literature reviews are the cornerstone of science. Keeping abreast of developments within any given field of enquiry has become increasingly difficult given the enormous amounts of new research. Databases and search technology have made finding relevant literature easy but, keeping a coherent overview of the discourse within a field of enquiry is an ever more encompassing task.&lt;/p&gt;
&lt;p&gt;
Scholars have proposed many approaches to analysing literature, which can be placed along a continuum from traditional narrative methods to systematic analytic syntheses of text using machine learning. Traditional reviews are biased because they rely entirely on the interpretation of the researcher. Analytical approaches follow a process
that is more like scientific experimentation. These systematic methods are reproducible in the way literature is searched and collated but still rely on subjective interpretation.&lt;/p&gt;
&lt;p&gt;
Machine learning provides new methods to analyse large swaths of text. Although these methods sound exciting, these methods are incapable of providing insight. Machine learning cannot interpret a text; it can only summarise and structure a corpus. Machine learning still requires human interpretation to make sense of the information.&lt;/p&gt;
&lt;p&gt;
This article introduces a mixed-method technique for reviewing literature, combining qualitative and quantitative methods. I used this method to analyse literature published by the International Water Association as part of my dissertation into &lt;a href=&#34;https://lucidmanager.org/tags/invisible-water-utility/&#34;&gt;water utility marketing&lt;/a&gt;. Detailed information about the methodology is available through &lt;a href=&#34;https://doi.org/10.26181/5bd90ca36da85&#34;&gt;FigShare&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
A literature review with RQDA
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The purpose of this review was to ascertain the relevance of marketing theory to the discourse of literature in water management. This analysis uses a sample of 244 journal abstracts, each of which was coded with the &lt;a href=&#34;http://rqda.r-forge.r-project.org/&#34;&gt;RQDA&lt;/a&gt; library. This library provides functionality for &lt;a href=&#34;https://lucidmanager.org/data-science/qualitative-data-science/&#34;&gt;qualitative data analysis&lt;/a&gt;. RQDA provides a graphical user interface to mark sections of text and assign them to a code, as shown below.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/rqda_abstract.png&#34; alt=&#34;Marking topics in an abstract with RQDA&#34; title=&#34;Marking topics in an abstract with RQDA&#34;/&gt;
&lt;figcaption&gt;
Marking topics in an abstract with RQDA.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
You can load a corpus of text into RQDA and mark each of the texts with a series of codes. The texts and the codes are stored in an SQLite database, which can be easily queried for further analysis.&lt;/p&gt;
&lt;p&gt;
I used a marketing dictionary to assess the abstracts from journals published by the International Water Association from the perspective of marketing. This phase resulted in a database with 244 abstracts and their associated coding.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Discourse Network Analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Once all abstracts are coded, we can start analysing the internal structure of the IWA literature. First, let&amp;#39;s have a look at the occurrence of the topics identified for the corpus of abstracts.&lt;/p&gt;
&lt;p&gt;
The first lines in this snippet call the tidyverse and RQDA libraries and open the abstracts database. The &lt;code class=&#34;verbatim&#34;&gt;getCodingTable&lt;/code&gt; function provides a data frame with each of the marked topics and their location. This function allows us to visualise the occurrence of the topics in the literature.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(RQDA)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Open project&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;openProject&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;IWA_Abstracts.rqda&amp;#34;&lt;/span&gt;, updateGUI &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Visualise codes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;getCodingTable&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;group_by&lt;/span&gt;(codename) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;count&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;arrange&lt;/span&gt;(n) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ungroup&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(codename &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;factor&lt;/span&gt;(codename, levels &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; codename)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(codename, n)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_col&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_flip&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;xlab&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Code name&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ylab&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Occurence&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/code_frequencies.png&#34; alt=&#34;Frequencies of topics in IWA literature&#34; title=&#34;Frequencies of topics in IWA literature&#34;/&gt;
&lt;figcaption&gt;
Frequencies of topics in IWA literature.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This bar chart tells us that the literature is preoccupied with asset management and the quality of the product (water) or the service (customer perception). This insight is interesting, but not very enlightening information. We can use discourse network analysis to find a deeper structure in the literature.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Discourse Network Structure
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;We can view each abstract with two or more topics as a network where each topic is connected. The example below shows four abstracts with two or more codes and their internal networks.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/complete-graphs.png&#34; alt=&#34;Examples of complete networks for four abstracts&#34; title=&#34;Examples of complete networks for four abstracts&#34;/&gt;
&lt;figcaption&gt;
Examples of complete networks for four abstracts.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The union of these four networks forms a more extensive network that allows us to analyse the structure of the corpus of literature, shown below.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/mix_example.communities.png&#34; alt=&#34;Union of networks and community detection&#34; title=&#34;Union of networks and community detection&#34;/&gt;
&lt;figcaption&gt;
Union of networks and community detection.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
We can create a network of topics with the &lt;a href=&#34;https://igraph.org/r/&#34;&gt;igraph package&lt;/a&gt;. The first step is to create a &lt;a href=&#34;https://en.wikipedia.org/wiki/Document-term_matrix&#34;&gt;Document-Term-Matrix&lt;/a&gt;. This matrix counts how often a topic occurs within each abstract. From this matrix, we can create a graph by transforming it into an &lt;a href=&#34;https://en.wikipedia.org/wiki/Adjacency_matrix&#34;&gt;Adjacency Matrix&lt;/a&gt;. This matrix describes the graph which can be visualised and analysed. For more detailed information about this method, refer to &lt;a href=&#34;http://hdl.handle.net/1959.9/561679&#34;&gt;my dissertation&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(igraph)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(reshape2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;dtm &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;getCodingTable&lt;/span&gt;()[,&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)] &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(freq &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;acast&lt;/span&gt;(filename &lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt; codename, sum)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;adj &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;crossprod&lt;/span&gt;(dtm)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;g &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;graph.adjacency&lt;/span&gt;(adj, weighted &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;T&lt;/span&gt;, mode &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;undirected&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;g &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;simplify&lt;/span&gt;(g)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Network Graphs&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;V&lt;/span&gt;(g)&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;name &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\n&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;V&lt;/span&gt;(g)&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;name)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;par&lt;/span&gt;(mar &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot&lt;/span&gt;(g,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     layout &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; layout.fruchterman.reingold,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.label.cex &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;degree&lt;/span&gt;(g),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.label.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.frame.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Dodgerblue&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     edge.width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;E&lt;/span&gt;(g)&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;weight &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     edge.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;darkgray&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/iwa_network.jpg&#34; alt=&#34;/images/digital-humanities/iwa_network.jpg&#34; title=&#34;The network of topics in IWA literature&#34;/&gt;
&lt;figcaption&gt;
The network of topics in IWA literature.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
In this graph, each node is a topic in the literature, and each edge implies that a topic is used in the same abstract. This graph uses the Fruchterman-Reingold algorithm to position each of the nodes, with the most connected topic in the centre.&lt;/p&gt;
&lt;p&gt;
The last step is to identify the structure of this graph using community detection. A community is a group of nodes that are more connected with each other than with nodes outside the community.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;set.seed&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;123&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;comms &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;spinglass.community&lt;/span&gt;(g, spins &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;par&lt;/span&gt;(mar &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot&lt;/span&gt;(comms, g,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     layout &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; layout.fruchterman.reingold,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.label.cex &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.7&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;degree&lt;/span&gt;(g),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.label.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.frame.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     edge.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.label.family &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;sanserif&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     mark.border &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/iwa_communities.jpg&#34; alt=&#34;Community detection in IWA literature&#34; title=&#34;Community detection in IWA literature&#34;/&gt;
&lt;figcaption&gt;
Community detection in IWA literature.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
We have now succeeded to convert a corpus of 244 journal abstracts to a parsimonious overview of four communities of topics. This analysis resulted in greater insight into how marketing theory applies to water management, which was used to structure a book about water utility marketing.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;

&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Celebrate Halloween with Creepy Computer Games in R</title>
      <link>https://lucidmanager.org/data-science/creepy-computer-games-in-r/</link>
      <pubDate>Sun, 28 Oct 2018 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/creepy-computer-games-in-r/</guid>
      <description>
	
&lt;p&gt;
Halloween is upon us once more and who ever said that data science can&amp;#39;t be scare. This article translates the &lt;em&gt;Gravedigger&lt;/em&gt; game from the 1983 &lt;em&gt;Creepy Computer Games&lt;/em&gt; book to celebrate Halloween. This article is part of my series on &lt;a href=&#34;https://lucidmanager.org/tags/r-games/&#34;&gt;gaming with the R language&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
In the 1980s I spent my time writing code on my 8-bit ZX81 and Atari computers. I learnt everything I know about programming from copying and modifying printed code listings from books with computer games. The games in these books are mostly simple text-based games. The authors gave them enticing names, often imaginatively illustrated to visualise the virtual world they represent. A &lt;a href=&#34;https://lucidmanager.org/data-science/pong/&#34;&gt;line and a dot&lt;/a&gt; become a game of tennis, and a computer that was able to play &lt;a href=&#34;https://lucidmanager.org/data-science/tic-tac-toe-war-games/&#34;&gt;Tic Tac Toe&lt;/a&gt; seemed like your machine had come alive.&lt;/p&gt;
&lt;p&gt;
Let&amp;#39;s step into the creepy world of computer games as imagined by Usborne Publishing.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/rgames/creepy-computer-games.jpg&#34; alt=&#34;Creepy Computer Games&#34; title=&#34;Creepy Computer Games&#34;/&gt;
&lt;figcaption&gt;
Reynold, Colin and McCaig, Rob, Creepy Computer Games (Usborne, London).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Creepy Computer Games - Gravedigger
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Alan Ramsey&amp;#39;s &lt;em&gt;Gravedigger&lt;/em&gt; is a typical example of the games of the early days of home computing. You can download the original book for free from the &lt;a href=&#34;https://drive.google.com/file/d/0Bxv0SsvibDMTRUl3SFRONGN0MFk/view&#34;&gt;publisher&amp;#39;s Google drive&lt;/a&gt;. The &lt;em&gt;Gravedigger&lt;/em&gt; listing starts on page 10. The lyrical description of the game provides the instructions:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It&amp;#39;s dark and windy—not the kind of night to be lost in a graveyard, but that&amp;#39;s where you are. You have until midnight to find your way out. Skeletons lurk in the shadows waiting to scare you to death should you come to close. You can dig holes to help keep them away but digging is tiring work and you cannot manage more than five in one game. You have to be careful not to fall down the holes you have dug. Grave stones (marked &lt;code class=&#34;verbatim&#34;&gt;+&lt;/code&gt;) and  the walls of the graveyard (marked &lt;code class=&#34;verbatim&#34;&gt;:&lt;/code&gt;) block your way. The holes you digs are marked &lt;code class=&#34;verbatim&#34;&gt;O&lt;/code&gt;, you are &lt;code class=&#34;verbatim&#34;&gt;*&lt;/code&gt; and the skeletons are &lt;code class=&#34;verbatim&#34;&gt;X&lt;/code&gt;. See if you can escape.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/rgames/gravedigger.png&#34; alt=&#34;/images/rgames/gravedigger.png&#34; title=&#34;/images/rgames/gravedigger.png&#34; /&gt;&lt;figcaption&gt;
Gravedigger screenshot (Emacs ESS).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Creepy Alien
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Roland Krasser has developed vastly improved version of the code and published the &lt;a href=&#34;https://cran.r-project.org/web/packages/creepyalien/index.html&#34;&gt;Creepy Alien game on CRAN&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;install.packages&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;creepyalien&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  creepyalien&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;creepyalien&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/rgames/creepy-alien.png&#34; alt=&#34;/images/rgames/creepy-alien.png&#34; title=&#34;/images/rgames/creepy-alien.png&#34; /&gt;&lt;figcaption&gt;
Creepy Alien by Roland Kasser.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
The Gravedigger code
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;I translated the BASIC code as close to the original as possible. I changed some of the variable names because, in BASIC, single variables and vectors can have the same name and names of character vectors end in a &lt;code class=&#34;verbatim&#34;&gt;$&lt;/code&gt; character.&lt;/p&gt;
&lt;p&gt;
The game is quite tricky, and I have only managed to escape the graveyard once. It looks like the likelihood of success very much depends on the random distribution of the graves. Perhaps we need some machine learning to optimise strategy.&lt;/p&gt;
&lt;p&gt;
I leave it up to you to deconstruct the program and safely work your way through the graveyard.&lt;/p&gt;
&lt;p&gt;
Happy Halloween!&lt;/p&gt;
&lt;figure&gt;
&lt;p&gt;indicate different versions for various dialects of the BASIC language.
&lt;img src=&#34;https://lucidmanager.org/images/rgames/graveyard.jpg&#34; alt=&#34;/images/rgames/graveyard.jpg&#34; title=&#34;/images/rgames/graveyard.jpg&#34; /&gt;&lt;/p&gt;
&lt;figcaption&gt;
Partial page of the Gravedigger game in BASIC. The markings
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/RGames/&#34; target=&#34;_blank&#34;
   title=&#34;Download RGames from GitHub&#34;
   alt=&#34;Download RGames from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;RGames&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Creepy Computer Games&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Reynold, Colin and McCaig, Rob, Creepy Computer Games (Usborne, London).&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## https://archive.org/details/Creepy_Computer_Games_1983_Usborne_Publishing/&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Gravedigger by Alan Ramsey&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Initiate board&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;A &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;matrix&lt;/span&gt;(ncol &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;, nrow &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;A[, ] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Starting variables&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;W &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Move number&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;X &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Remaining holes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;death &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Game over?&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Initiate pieces&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Y &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;*&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;B &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;+&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;C &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;O&amp;#34;&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;D &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;:&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;E &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;X&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Z &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Draw board&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Add borders&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;A&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;), ] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; D
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;A[, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; D
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;A[1&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; D
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Add graves&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;){
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    A&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[floor&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;runif&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;7&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;runif&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;)] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; B
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Starting positions&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Player&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;M &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;N &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;A[N, M] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; Y
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Skeletons&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;S &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Game play&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;repeat&lt;/span&gt;{    
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;## Position skeletons&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (J &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;, by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        A[S[J], S[J &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;]] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; E
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    W &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; W &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;## Move counter&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (W &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;The clock&amp;#39;s struck midnight&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Aghhhhh!!!!&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;## Print board&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    v &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.vector&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;t&lt;/span&gt;(A)), collapse &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)        
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;substr&lt;/span&gt;(v, (i &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, (i &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;## Enter move&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    A1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;toupper&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readline&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Enter move &amp;#34;&lt;/span&gt;, W, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; (You can go N, S, E or W): &amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;## Move player&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#007020&#34;&gt;T&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; N
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    U &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; M
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (A1 &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;N&amp;#34;&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#007020&#34;&gt;T&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; N &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (A1 &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;E&amp;#34;&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        U &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; M &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (A1 &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;S&amp;#34;&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#007020&#34;&gt;T&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; N &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (A1 &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;W&amp;#34;&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        U &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; M &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;## Collision detection&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (A[T, U] &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; D &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; A[T, U] &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; B) { &lt;span style=&#34;color:#888&#34;&gt;# Edge or grave&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;That way&amp;#39;s blocked&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (A[T, U] &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; C) { &lt;span style=&#34;color:#888&#34;&gt;# Hole&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;You&amp;#39;ve fallen into one of your own holes&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (A[T, U] &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; E) { &lt;span style=&#34;color:#888&#34;&gt;# Skeleton&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        death &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#007020&#34;&gt;T&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; U &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;) { &lt;span style=&#34;color:#888&#34;&gt;# Escaped&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;You&amp;#39;re free!&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Your performance rating is &amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;((&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; W) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;96&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; X)), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (death &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Urk! You&amp;#39;ve been scared to death by a skeleton.&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (A[T, U] &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; Z) { &lt;span style=&#34;color:#888&#34;&gt;# Player can move&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#888&#34;&gt;## Move player and dig hole&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        A [N, M] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; Z
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (X &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            B1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;toupper&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readline&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Would you like to dig a hole (Y or N): &amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (B1 &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Y&amp;#34;&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                X &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; X &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                A[N, M] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; C
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        N &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;T&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        M &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; U
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        A[T, U] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; Y
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#888&#34;&gt;## Move skeletons&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (J &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;, by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#888&#34;&gt;## Store skeleton position in temp variable&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            P &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; S[J]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            Q &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; S[J &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;any&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(A[P &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, Q], A[P &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; , Q], A[P, Q &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;], A[P, Q &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;]) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; Y)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                death &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#888&#34;&gt;## Move skeletons&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (A1 &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;S&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; A[P &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, Q] &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; Z){
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    S[J] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; S[J] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Follow player&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    A[P, Q] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; Z
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (A1 &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;N&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; A[P &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, Q] &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; Z){
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    S[J] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; S[J] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Follow player&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    A[P, Q] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; Z
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (A1 &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;E&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; A[P, Q &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; Z &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; M &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; Q){
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    S[J &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; S[J &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Move towards player&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    A[P, Q] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; Z
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (A1 &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;E&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; A[P, Q &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; Z &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; M &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; Q) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    S[J &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; S[J &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Reverse direction&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    A[P, Q] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; Z
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Mapping and Geocoding with ggmap and the Google API</title>
      <link>https://lucidmanager.org/data-science/geocoding-with-ggmap/</link>
      <pubDate>Wed, 10 Oct 2018 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/geocoding-with-ggmap/</guid>
      <description>
	
&lt;p&gt;
In the old days, obtaining latitude and longitude required a physical survey and lots of mathematics. Google Maps has made this task much easier. This article describes how to use the Google Maps API with the &lt;a href=&#34;https://cran.r-project.org/web/packages/ggmap/index.html&#34;&gt;ggmap library&lt;/a&gt;. Geocoding with ggmap is a convenient way to create meaningful spatial visualisations.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The ggmap package
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Several R libraries exist to visualise spatial information. ggmap by David Kahle which aligns with the ggplot philosophy of layered visualisations.&lt;/p&gt;
&lt;p&gt;
The geocode function from the ggmap package extracts longitude and latitude from Google maps, based on a location query. The example below shows the result of a simple geocoding call for the White House and Uluru. The geocode function essentially constructs a URL to obtain the data. However, when you run this code you see an error:&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggmap)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geocode&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;White House&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Uluru&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  Error&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt; Google now requires an API key.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         See &lt;span style=&#34;color:#333&#34;&gt;?&lt;/span&gt;register_google &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; details.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
In the middle of 2018, Google tightened access to the database, which means you need to register an API for it to work. This article explains how to use the latest version of ggmap and a Google account to continue using this function.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Google API
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Before we can start geocoding, we need to obtain an &lt;a href=&#34;https://developers.google.com/maps/documentation/geocoding/get-api-key&#34;&gt;API key from Google&lt;/a&gt;. Go to the &lt;a href=&#34;https://cloud.google.com/maps-platform/#get-started&#34;&gt;registration page&lt;/a&gt;, and follow the instructions (select all mapping options). The geocoding API is a free service, but you nevertheless need to associate a credit card with the account. Please note that the Google Maps API is &lt;a href=&#34;https://developers.google.com/maps/documentation/geocoding/usage-and-billing&#34;&gt;not a free service&lt;/a&gt;. There is a free allowance of 40,000 calls to the geocoding API per month, and beyond that calls are $0.005 each.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Geocoding with ggmap
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;You will need to ensure that you have the latest version of ggmap installed on your system. The current version on CRAN is 3.0.&lt;/p&gt;
&lt;p&gt;
The code snippet below shows a minimum-working-example of how you can map coordinates using ggplot. The &lt;code class=&#34;verbatim&#34;&gt;register_google&lt;/code&gt; function stores the API key. I have stored the key itself in a private text file. The &lt;code class=&#34;verbatim&#34;&gt;getOption(&amp;#34;ggmap&amp;#34;)&lt;/code&gt; function summarises the Google credentials to check how you are connected.&lt;/p&gt;
&lt;p&gt;
The geocode function converts the request into a URL and captures the output into a data frame. The plot shows the places I have lived, projected orthogonally on the globe. The mapproj library provides the orthogonal projection.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/geography/&#34; target=&#34;_blank&#34;
   title=&#34;Download geography from GitHub&#34;
   alt=&#34;Download geography from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;geography&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;api &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;google.api&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Text file with the API key&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;register_google&lt;/span&gt;(key &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; api)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;getOption&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;ggmap&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;locations &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Hoensbroek&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Johannesburg&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Barrow-in-Furness&amp;#34;&lt;/span&gt;,                
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Hong Kong&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Singapore&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Tangail&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Maastricht&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Bendigo&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geocode&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(mapproj)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;world &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;map_data&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;world&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_polygon&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; world,  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(long, lat, group &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; group),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;grey&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; locations, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(lon, lat),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_map&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;ortho&amp;#34;&lt;/span&gt;, orientation &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;80&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;p alt=&#34;Places where I have worked and lived&#34; title=&#34;Places where I have worked and lived.&#34;&gt;&lt;img src=&#34;https://lucidmanager.org/images/geography/worldhomes.png&#34; alt=&#34;/images/geography/worldhomes.png&#34; title=&#34;/images/geography/worldhomes.png&#34;/&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;figcaption&gt;
Places where I have worked and lived.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Flat Earth Mathematics with examples in the R Language</title>
      <link>https://lucidmanager.org/data-science/flat-earth-mathematics/</link>
      <pubDate>Sun, 02 Sep 2018 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/flat-earth-mathematics/</guid>
      <description>
	
&lt;p&gt;
One of the craziest fake news trends is the flat earth conspiracy. Some of you might ask whether my trip actually &lt;em&gt;around&lt;/em&gt; the world or am I travelling across a &lt;em&gt;flat disk&lt;/em&gt;? This article discusses flat earth mathematics, and how to convert and visualise map projections in R. This article discusses flat earth mathematics, using code I published earlier in articles about &lt;a href=&#34;https://lucidmanager.org/data-science/pacific-island-hopping/&#34;&gt;pacific island hopping&lt;/a&gt; and &lt;a href=&#34;https://lucidmanager.org/data-science/create-air-travel-route-maps/&#34;&gt;creating air travel maps&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Flat Earth
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;YouTube contains thousands of videos from people that claim the earth is flat. These people pontificate that science as we know it is a &amp;#34;globalist conspiracy&amp;#34;. The claims about a flat earth are hilarious and entertaining. People who believe our planet is flat even conduct simple experiments and engage in naive flat earth mathematics. Needless to say that these experiments are not very convincing, but I respect their entrepreneurial attitude.&lt;/p&gt;
&lt;p&gt;
Adherents to the idea that the world is flat often propose Gleason&amp;#39;s Map as their version of the correct representation of our planet. Every printed map of the earth is flat, but somehow this one seems to have a special status.&lt;/p&gt;
&lt;p&gt;
The Gleason map is not a map of a flat earth but a polar &lt;a href=&#34;https://en.wikipedia.org/wiki/Azimuthal_equidistant_projection&#34;&gt;azimuthal equidistant projection&lt;/a&gt; of the globe. Even though the map itself states that it is a &lt;em&gt;projection&lt;/em&gt; of the world, flat earth believers nevertheless see it as a literal representation of the world they live on.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/geography/gleasons-map.jpg&#34; alt=&#34;Section of Gleason&amp;#39;s map&#34; title=&#34;Section of Gleason&amp;#39;s map&#34;/&gt;
&lt;figcaption&gt;
Section of Gleason&amp;#39;s map.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Their belief is based on an appeal to common sense as the world appears to be flat when we look at the horizon. The second ingredient is a deep distrust in science, often inspired by religious motives.&lt;/p&gt;
&lt;p&gt;
This article shows two different ways to look at the earth and show that the spherical model better fits the reality of my trip around the world.&lt;/p&gt;
&lt;p&gt;
Projecting the spherical earth on a flat surface is a complex task. Maps require compromise as it is impossible to truthfully draw the surface of the globe on a piece of paper without distortion. The video below provides a practical introduction to map projections and shows how maps are stretched to display them on a flat surface.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/kIID5FDi2JQ?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Why all world maps are wrong.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The Azimuthal equidistant method is popularised in the flag of the United Nations. Antarctica is in this projection displayed as a ring around the world because the south pole projects to infinity. Flat earth evangelists believe that the South Pole a ring of ice that prevents us from proceeding beyond the disc. The edge of this disc cannot be shown because this method projects the south pole at an infinite distance from the centre of the map. We can recreate Gleason&amp;#39;s map with &lt;a href=&#34;https://ggplot2.tidyverse.org/reference/coord_map.html&#34;&gt;ggplot&lt;/a&gt;, which incorporates the &lt;a href=&#34;https://cran.r-project.org/web/packages/mapproj/index.html&#34;&gt;mapproj package&lt;/a&gt; to show maps in various projections.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/geography/&#34; target=&#34;_blank&#34;
   title=&#34;Download geography from GitHub&#34;
   alt=&#34;Download geography from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;geography&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Flat Earth Mathematics&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  world &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;map_data&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;world&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(world) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_path&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; long, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lat, group &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; group), linewidth &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.2&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme&lt;/span&gt;(axis.text &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;element_blank&lt;/span&gt;(),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          axis.ticks &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;element_blank&lt;/span&gt;()) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_map&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;azequidistant&amp;#34;&lt;/span&gt;, orientation &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;90&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;270&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The &lt;a href=&#34;https://ggplot2.tidyverse.org/reference/coord_map.html&#34;&gt;coord_map&lt;/a&gt; function allows you to change projections. The orientation argument defines the centre point of the projection. The most common location is the North Pole (90, 0). The third value gives the clockwise rotation in degrees. Gleason&amp;#39;s map uses a rotation of 270 degrees.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/geography/azequidistant.png&#34; alt=&#34;/images/geography/azequidistant.png&#34; title=&#34;Polar azimuthal equidistant projection with ggmap&#34; at=&#34;Polar azimuthal equidistant projection with ggmap&#34;/&gt;
&lt;figcaption&gt;
Polar azimuthal equidistant projection with ggmap.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
My Round-the-World Itinerary
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In September 2018 I embarked on a trip around the world to speak at the &lt;a href=&#34;http://worldwatercongress.org/&#34;&gt;World Water Congress&lt;/a&gt; in Tokyo. I also visited family and friends in the Netherlands and did some tourism in San Francisco. One of the workshops I speak at is about Fake News in the water industry. &lt;/p&gt;
&lt;p&gt;
My trip started in Australia, onward to Japan, from where I go to the Netherlands. The last two legs will bring me back to Australia via San Francisco. The itinerary is stored in a data frame. The ggmap package geocodes the longitude and latitude of each of the locations on my trip. You will need a Google API to enable the &lt;a href=&#34;https://lucidmanager.org/data-science/geocoding-with-ggmap/&#34;&gt;geocoding function&lt;/a&gt;. As the earth is a sphere, an intermediate point needs to be added for trips that pass the dateline, as I explained in my article about &lt;a href=&#34;https://lucidmanager.org/data-science/create-air-travel-route-maps/&#34;&gt;flight maps&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The geosphere package helps to estimate the total travel distance. The travel distance is approximately 38,995 km, slightly less than a trip around the equator. This distance is the &lt;a href=&#34;https://en.wikipedia.org/wiki/Great-circle_distance&#34;&gt;great circle distance&lt;/a&gt;, which is the shortest distance between two points on a sphere. The flight paths on this map are curved because of the inevitable distortions when projecting a sphere on a flat surface.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Round the World Itinerary&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggmap)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(dplyr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  api &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;google.api&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Text file with the secret API key&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;register_google&lt;/span&gt;(key &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; api)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  airports &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Melbourne&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Tokyo&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Amsterdam&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;San Francisco&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  itinerary &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geocode&lt;/span&gt;(airports)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  itinerary &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rbind&lt;/span&gt;(itinerary, itinerary[1, ]) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(location &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(airports, airports[1]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Split travel past dateline&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  dl &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;diff&lt;/span&gt;(itinerary&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon) &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;180&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  dr &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ifelse&lt;/span&gt;(itinerary&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon[dl] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-180&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;180&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  dateline &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(lon &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(dr, &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;dr),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                     lat &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mean&lt;/span&gt;(itinerary&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lat[dl&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(dl &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)]), &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                     location &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dateline&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  itinerary &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rbind&lt;/span&gt;(itinerary[1&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;dl, ], dateline,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                     itinerary&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(dl &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(itinerary), ])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  itinerary
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Visualise&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  worldmap &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; itinerary, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(lon, lat), colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_path&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; itinerary, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(lon, lat), colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_map&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;azequidistant&amp;#34;&lt;/span&gt;, orientation &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;90&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;270&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Great Circle Distance&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(geosphere)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(itinerary) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;), &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(l)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;distVincentyEllipsoid&lt;/span&gt;(itinerary[l, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;], itinerary&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(l &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;), &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;]) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/geography/rtw.png&#34; alt=&#34;Round the world trip in polar Azimuthal equidistant projection&#34; title=&#34;Round the world trip in polar Azimuthal equidistant projection&#34;/&gt;
&lt;figcaption&gt;
Round the world trip in polar Azimuthal equidistant projection.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Flat Earth Mathematics
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If the Gleason map were an actual map of the flat earth, then the flight paths on the map would show as straight lines.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://cran.r-project.org/web/packages/mapproj/index.html&#34;&gt;mapproj package&lt;/a&gt; contains the mapproject function that calculates the projected coordinates based on longitude and latitude. The output of this function is a grid with limits from $-\pi$ to  $\pi$. The first part of the code converts the longitude and latitude from the world data frame to projected coordinates.&lt;/p&gt;
&lt;p&gt;
A line from the lon/lat 0,0 to the north pole has a projected distance of \(\pi/2\), which in the spherical world is \(\frac{\pi}{2} 6378.137 = 10018.75\) km. We need to multiply the Euclidean distances with the radius of the Earth to derive the Gleason map coordinates.&lt;/p&gt;
&lt;p&gt;
This last code snippet converts the world map to flat earth coordinates. It calculates the Euclidean distance between the points on the itinerary and multiplies this with the Earth&amp;#39;s diameter. &lt;/p&gt;
&lt;p&gt;
The best way to show that Gleason&amp;#39;s map is not a map of a flat earth is best demonstrated with a flight between Australia and Chili because the distortions are huge in the Southern hemisphere. This last code snippet shows why the Gleason map is not a map of a flat earth. On this map, the shortest distance between Sydney and Santiago de Chili is about 25,000 km, more than twice the real value. The &lt;a href=&#34;https://www.travelmath.com/from/Sydney,+Australia/to/Santiago,+Chile&#34;&gt;actual travel time&lt;/a&gt; is about 14 hours, which implies that passenger jets break the sound barrier. This problem exists for all journeys along the lines of latitude in the Southern hemisphere.&lt;/p&gt;
&lt;p&gt;
This map looks like the first one, but the coordinate system is now Euclidean instead of polar (longitudes and latitudes), as indicated by the square grid. On a projected map, the shortest distance is a curved line, parallel to Antarctica, which is how ships and aeroplanes move between these cities.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/geography/flatearth.png&#34; alt=&#34;Sydney to Santiago de Chili on a flat earth map&#34; title=&#34;Sydney to Santiago de Chili on a flat earth map&#34;/&gt;
&lt;figcaption&gt;
Sydney to Santiago de Chili on a flat earth map.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This video shows a unique insight into the navigational issues for intercontinental flights in the Southern hemisphere.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/TqWmjtbGs-M?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Aerolineas Argentinas Southern Transpolar Flight from Sydney to Buenos Aires.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(mapproj)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flatearth.coords &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mapproject&lt;/span&gt;(world&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;long, world&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lat,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                          &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;azequidistant&amp;#34;&lt;/span&gt;, orientation &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;90&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;270&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  r &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6378.137&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flatearth.coords &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(world,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; flatearth.coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; r,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; flatearth.coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; r) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(x, y, group, order, region, subregion)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flatearth &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(flatearth.coords) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_path&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x, y, group &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; group), size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.2&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme&lt;/span&gt;(axis.text &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;element_blank&lt;/span&gt;(),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            axis.ticks &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;element_blank&lt;/span&gt;()) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Australia - South America&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  airports &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(city &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Sydney&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Santiago de Chili&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  itinerary &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geocode&lt;/span&gt;(airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;city) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(location &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;city)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  itinerary
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  coords &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mapproject&lt;/span&gt;(itinerary&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon, itinerary&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lat, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;azequidistant&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                       orientation &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;90&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;270&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  coords &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; r, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; r)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;diff&lt;/span&gt;(coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x)^2 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;diff&lt;/span&gt;(coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y)^2))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flatearth &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; coords, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x, y), colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_path&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; coords, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x, y), colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
  &lt;a href = &#34;https://github.com/pprevos/geography/&#34; target=&#34;_blank&#34;
     title=&#34;Download geography from GitHub&#34;
     alt=&#34;Download geography from GitHub&#34;&gt;
    &lt;button class=&#34;button is-medium is-primary&#34;&gt;
      &lt;span class=&#34;icon is-large&#34;&gt;
        &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
      &lt;/span&gt;
      &lt;span style=&#34;font-family: monospace&#34;&gt;geography&lt;/span&gt;
    &lt;/button&gt;
  &lt;/a&gt;
  
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Conclusion
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This article proves that the Gleason map is not a representation of a flat earth. Aeroplanes would have to break the sound barrier to fly these distances in the time it takes to travel. Whichever way you project the globe on a flat map will lead to inevitable distortions. The Gleason map itself mentions that it is a projection and not a flat earth. However, these facts will not dissuade people from believing in a flat earth. I am after all an engineer and thus part of the globalist science conspiracy.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Call Centre Workforce Planning Using Erlang C in R language</title>
      <link>https://lucidmanager.org/data-science/call-centre-workforce-planning-erlang-c-in-r/</link>
      <pubDate>Thu, 19 Jul 2018 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/call-centre-workforce-planning-erlang-c-in-r/</guid>
      <description>
	
&lt;p&gt;
We all hate the experience of calling a service provider and being placed on hold for a very long time. Organisations that take their service levels seriously plan their call centres. Good planning ensures that customer waiting times remain within acceptable limits. Having said this, making people wait for something can, in some instances, increase perceived value. This article shows how to implement call centre workforce planning with the R language.&lt;/p&gt;
&lt;p&gt;
Contact centre workforce planning involves an exciting mix of rational production management and the soft skills of providing service with a smile. The mathematics of managing a call centre ensures customers have a great experience by limiting waiting times.&lt;/p&gt;
&lt;p&gt;
The Grade of Service can numerically express call centre performance. This KPI is the percentage of calls answered within a specific time. For example, 90% of calls are responded to within 30 seconds.&lt;/p&gt;
&lt;p&gt;
This Grade of Service depends on the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The volume of calls made to the centre.&lt;/li&gt;
&lt;li&gt;The number of available agents&lt;/li&gt;
&lt;li&gt;The time it takes to service a customer.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Working in a call centre can be chaotic, so we need some maths to understand it. The &lt;a href=&#34;https://www.callcentrehelper.com/erlang-c-formula-example-121281.htm&#34;&gt;Erlang C formula&lt;/a&gt; describes the relationship between the Grade of Service and various variables to bring some order to the chaos.&lt;/p&gt;
&lt;p&gt;
Call centre workforce planning is a complex activity that is a perfect problem to solve in R code. This article explains how to use the Erlang C formula in R to manage a contact centre. The presented code calculates the number of agents needed to meet a required Grade of Service. This approach is extended to a Monte Carlo setting to better understand the real world&amp;#39;s stochastic nature.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Erlang C Formula
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Erlang C formula describes the probability that a customer must queue rather than be immediately serviced $(P_w)$. This formula is closely related to the &lt;a href=&#34;https://en.wikipedia.org/wiki/Poisson_distribution&#34;&gt;Poisson distribution&lt;/a&gt;, which describes queues such as traffic lights or hospital waiting lists.&lt;/p&gt;
&lt;p&gt;
$$P_w = \frac{\frac{A^N}{N!}\frac{N}{N-A}}{\Big( \sum_{i=0}^{N-1} \frac{A^i}{i!} \Big)+\frac{A^N}{N!}\frac{N}{N-A}}$$&lt;/p&gt;
&lt;p&gt;
The intensity of traffic $A$ is the number of calls per hour multiplied by the average duration of a call. Traffic intensity is measured in dimensionless Erlang units, which expresses the time it would take to manage all calls if they arrived sequentially. Intensity measures the effort required in an hour. In reality, calls arrive at random times during the hour, which is where the Poisson distribution comes in. The waiting time is also influenced by the number of available operators $N$.&lt;/p&gt;
&lt;p&gt;
Both common sense and the formula show that increasing the number of calls or decreasing the number of operators increases the likelihood that customers are placed in a queue. The more staff, the higher the service level, but how many people do you need to achieve your desired grade of service efficiently?&lt;/p&gt;
&lt;p&gt;
The Grade of Service $S$ is a function of the outcome of the Erlang C formula ($P_w$), the number of agents ($N$), the call intensity ($A$), call duration ($\lambda$) and lastly the target answering time ($t$).&lt;/p&gt;
&lt;p&gt;
The Erlang C formula can be reworked to provide that answer. I sourced this solution from &lt;a href=&#34;https://www.callcentrehelper.com/erlang-c-formula-example-121281.htm&#34;&gt;callcenterhelper.com&lt;/a&gt;. We now have a toolset for call centre planning that we can implement in R.&lt;/p&gt;
&lt;p&gt;
$$S = 1 - \Large[ P_w e^ {-[(N-A](t/ \lambda)]} \large]$$&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Erlang C in R
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Erlang C formula contains factorials and powers, which become problematic at high call volumes or with many agents. The Multiple Precision Arithmetic library enables working with &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-20/&#34;&gt;large integer factorials&lt;/a&gt;, but there is no need to wield such strong computing powers. To make life easier, the Erlang C formula includes the &lt;a href=&#34;https://en.wikipedia.org/wiki/Erlang_(unit)#Erlang_B_formula&#34;&gt;Erlang B formula&lt;/a&gt;, the inverse of which can be calculated using a small loop.&lt;/p&gt;
&lt;p&gt;
This implementation is very similar to an unpublished R package by &lt;a href=&#34;https://github.com/phubers/erlang&#34;&gt;Patrick Hubers&lt;/a&gt;, enhanced with work from &lt;a href=&#34;https://www.callcentrehelper.com/erlang-c-formula-example-121281.htm&#34;&gt;callcenterhelper.com&lt;/a&gt;. This code contains four functions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;intensity&lt;/code&gt;: Determines intensity in &lt;a href=&#34;https://en.wikipedia.org/wiki/Erlang_(unit)&#34;&gt;Erlangs&lt;/a&gt; based on the rate of calls per interval, the total call handling time and the interval time in minutes. All functions default to a 60-minute interval. Erlangs are a dimensionless unit of measure of the offered load.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;erlang_c&lt;/code&gt;: Processes the Erlang C formula using the number of agents and the variables determining intensity (call rate and call handling time). The output is the probability that a customer has to wait for service.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;service_level&lt;/code&gt;: Calculates the service level. The inputs are the same as above, plus the period for the Grade of Service in seconds.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;resource&lt;/code&gt;: Seeks the number of agents needed to meet a Grade of Service. This function starts with the minimum number of agents (the intensity plus one agent) and keeps searching until it finds the number of agents that achieve the desired Grade of Service.&lt;/li&gt;
&lt;/ol&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Erlang C Code
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Call Centre Workforce Planning Using Erlang C in R language&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Erlang-C Functions&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  intensity &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(rate, duration, interval &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (rate &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; interval) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; duration
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  erlang_c &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(agents, rate, duration, interval &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      int &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;intensity&lt;/span&gt;(rate, duration, interval)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      erlang_b_inv &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;agents) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          erlang_b_inv &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; erlang_b_inv &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; int
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      erlang_b &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; erlang_b_inv
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      agents &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; erlang_b &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; (agents &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; int &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; erlang_b))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  service_level &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(agents, rate, duration, target, interval &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      pw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;erlang_c&lt;/span&gt;(agents, rate, duration, interval)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      int &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;intensity&lt;/span&gt;(rate, duration, interval)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; (pw &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;exp&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;(agents &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; int) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (target &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; duration)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  resource &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(rate, duration, target, gos_target, interval &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      agents &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;round&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;intensity&lt;/span&gt;(rate, duration, interval) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      gos &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;service_level&lt;/span&gt;(agents, rate, duration, target, interval)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (gos &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; gos_target &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (gos_target &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          agents &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; agents &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          gos &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;service_level&lt;/span&gt;(agents, rate, duration, target, interval)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(agents, gos))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Call centre workforce planning using R
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;For example, you manage a call centre with 100 calls every 30 minutes and an average handling time of 3 minutes. These numbers result in an intensity of &lt;code class=&#34;verbatim&#34;&gt;intensity(100, 3, 30)&lt;/code&gt; 10 Erlangs, or 10 call hours of traffic per hour. This result means we need at least 10 agents, assuming all calls arrive in sequence.&lt;/p&gt;
&lt;p&gt;
The reality of a contact centre is chaotic: calls arrive randomly, so there is a high probability that an operator will be busy if we use only 10 agents. You can enter this data into the Erlang C in R function to find the probability that a customer will need to wait. With ten agents, the likelihood is 100%. With 11 agents, it is 68%. The = sapply function helps to view the impact of adding more customer service
agents.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;erlang_c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;11&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  [1] &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.6821182&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;, erlang_c, rate &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, duration &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, interval &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  [1] &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.000000000&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.682118205&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.449388224&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.285270453&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.174131934&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.102042367&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  [7] &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.057340331&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.030876110&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.015928277&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.007873558&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.003731126&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The likelihood of a customer having to wait is the main target for any service that involves queueing. We need to set a target service level or Grade of Service. The service_level function calculates the Grade of Service using the previous parameters plus the target in seconds. Let&amp;#39;s make some assumptions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Required Grade of Service 80%&lt;/li&gt;
&lt;li&gt;Target answer time: 20 seconds&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Using the function, we can quickly see that with 11 agents and 100 calls per 30 minutes, the Grade of Service is only 39%, well below the required 80%. Using &lt;code class=&#34;verbatim&#34;&gt;sapply()&lt;/code&gt;, we can see that we need just over 13 available agents.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/call-centre-example.png&#34; alt=&#34;Grade of Service for a call centre with 100 calls per 30 minutes and 3-minute contacts&#34; title=&#34;Grade of Service for a call centre with 100 calls per 30 minutes and 3-minute contacts&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Grade of Service for a call centre with 100 calls per 30 minutes and 3-minute contacts.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;resource()&lt;/code&gt; function ties everything together and seeks the number of agents needed to meet the required grade of service. We need at least 14 available agents to answer 80% of calls within 20 seconds, which gives us an actual predicted Grade of Service of 88%.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Example&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;service_level&lt;/span&gt;(agents &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;11&lt;/span&gt;, rate &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, duration &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, target &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;, interval &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  service &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(agents &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                        GoS &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;, service_level, rate &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, duration &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, target &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;, interval &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(service, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(agents, GoS)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_line&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_x_continuous&lt;/span&gt;(breaks &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_y_continuous&lt;/span&gt;(labels &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; scales&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;percent) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_hline&lt;/span&gt;(yintercept &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.8&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;blue&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_bw&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Call Centre Simulation&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Erlang-C Formula&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggsave&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;call-centre-example.png&amp;#34;&lt;/span&gt;, width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;, height &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;resource&lt;/span&gt;(rate &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, duration &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, target &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;, gos_target &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;80&lt;/span&gt;, interval&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Call Centre Workforce Planning with Erlang C Monte Carlo Simulation
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;I used the Erlang C model to recommend staffing levels in a contact centre some years ago. This experience taught me that the mathematical model is the first step towards call centre workforce planning. Several other metrics can be built on the Erlang C model, such as agents&amp;#39; average occupancy and handling time.&lt;/p&gt;
&lt;p&gt;
Like all mathematical models, the Erlang C formula is an idealised version of reality. Agents are not always available; they need breaks, toilet stops and might even go on leave. Employers call this loss of labour&amp;#39; shrinkage,&amp;#39; a somewhat negative term for something positive for the employee. The Erlang C model provides the number of &amp;#39;bums on seats&amp;#39;.&lt;/p&gt;
&lt;p&gt;
Like every model, the Erlang C formula is not a perfect representation of reality. The formula tends to overestimate the required resources because it assumes that people will stay on hold indefinitely, while the queue will automatically shorten as people lose patience.&lt;/p&gt;
&lt;p&gt;
The number of employees required to provide this capacity depends on the call centre&amp;#39;s working conditions. For example, if employees are only available to take calls 70% of their contracted time, you will need $1/0.7=1.4$ staff members for each live agent to meet the Grade of Service.&lt;/p&gt;
&lt;p&gt;
Another problem is the stochastic nature of call volumes and handling times. The Erlang C model assumes that a manager can estimate call volume and handling time (intensity) as static variables, whereas in reality they are stochastic and subject to variation. Time series analysis can help predict call volumes, but every prediction carries some uncertainty. We can manage this uncertainty by using a Monte Carlo simulation.&lt;/p&gt;
&lt;p&gt;
All the functions listed above can be rewritten to return a vector of possible answers based on the average call volume and duration, along with their standard deviations. This simulation assumes normal distributions for both call volume and call length. The outcome of this simulation is a distribution of service levels.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Monte Carlo Simulation
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;A &lt;a href=&#34;https://lucidmanager.org/data-science/monte-carlo-cost-estimates/&#34;&gt;Monte Carlo simulation&lt;/a&gt; is a method to simulate reality by defining a probability distribution of the events in the model.&lt;/p&gt;
&lt;p&gt;
For example, a call centre receives, on average, 100 calls per half hour, with a standard deviation of 10. The average time to manage a call, including wrap-up time, is 180 seconds, with a standard deviation of 20 seconds. The centre needs to answer 80% of calls within 20 seconds. What is the likelihood of achieving this level of service?&lt;/p&gt;
&lt;p&gt;
The average intensity of this scenario is 10 Erlangs. Using the resource formula suggests that we need 14 agents to meet the Grade of Service. Simulating the scenario 1000 times indicates that the intensity lies between 5.4 and 15.9 Erlangs (see the code at the end of this article).&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;resource&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;180&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;80&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  [1] &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;14.0000000&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.88835&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;intensity_mc&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;180&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;summary&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  Min. &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;st Qu. Median Mean &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;rd Qu. Max.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5.480&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8.975&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9.939&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10.025&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10.993&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15.932&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The next step is to simulate the expected service level for this scenario. The plot visualises the outcome of the Monte Carlo simulation and shows that in 95% of situations, the Grade of Service is more than 77% and half the time, it is more than 94%.&lt;/p&gt;
&lt;pre class=&#34;example&#34;&gt;
  service_level_mc(15, 100, 10, 180, 20, 20, 30, sims = 1000) %&amp;gt;%
  + quantile(c(.05, .5, .95))
  5% 50% 95%
  0.7261052 0.9427592 0.9914338
&lt;/pre&gt;
&lt;p&gt;
This article shows that Erlang C in R helps managers plan the call centre workforce. We may need a Shiny application to develop a tool to manage the complexity of these functions. I would love to hear from people with practical experience in managing call centres about how they analyse data.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/call-centre-monte-carlo.png&#34; alt=&#34;Simulated service levels using Erlang C and Monte Carlo simulation&#34; title=&#34;Simulated service levels using Erlang C and Monte Carlo simulation&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Simulated service levels using Erlang C and Monte Carlo simulation.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Monte Carlo Simulation Code
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;


&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Monte Carlo Simulation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  intensity_mc &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(rate_m, rate_sd, duration_m, duration_sd, interval &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;, sims &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rnorm&lt;/span&gt;(sims, rate_m, rate_sd) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; interval)) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rnorm&lt;/span&gt;(sims, duration_m, duration_sd)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;intensity_mc&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;180&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;, interval &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;summary&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  erlang_c_mc &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(agents, rate_m, rate_sd, duration_m, duration_sd, interval &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    int &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;intensity_mc&lt;/span&gt;(rate_m, rate_sd, duration_m, duration_sd, interval)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    erlang_b_inv &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;agents) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      erlang_b_inv &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; erlang_b_inv &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; int
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    erlang_b &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; erlang_b_inv
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    agents &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; erlang_b &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; (agents &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; int &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; erlang_b))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  service_level_mc &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(agents, rate_m, rate_sd, duration_m, duration_sd, target, interval &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;, sims &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    pw &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;erlang_c_mc&lt;/span&gt;(agents, rate_m, rate_sd, duration_m, duration_sd, interval)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    int &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;intensity_mc&lt;/span&gt;(rate_m, rate_sd, duration_m, duration_sd, interval, sims)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; (pw &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;exp&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;(agents &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; int) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (target &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rnorm&lt;/span&gt;(sims, duration_m, duration_sd))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(ServiceLevel &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;service_level_mc&lt;/span&gt;(agents &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;14&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                         rate_m &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                         rate_sd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                         duration_m &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;180&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                         duration_sd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                         target &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                         interval &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                         sims &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(ServiceLevel)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_histogram&lt;/span&gt;(binwidth &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.05&lt;/span&gt;, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#008da1&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_x_continuous&lt;/span&gt;(labels &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; scales&lt;span style=&#34;color:#333&#34;&gt;::&lt;/span&gt;percent) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_bw&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Call Centre Monte Carlo Simulation&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 33: Digit Cancelling Fractions</title>
      <link>https://lucidmanager.org/data-science/project-euler-033/</link>
      <pubDate>Mon, 09 Jul 2018 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-033/</guid>
      <description>
	
&lt;p&gt;
Project Euler 33 takes us back to the world of fractions from our primary school days. This article provides a solution for the Euler problem and discusses how to solve this problem using Farey sequences and how to visualise Ford Circles with the &lt;em&gt;ggplot2&lt;/em&gt; package.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 33 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The fraction 49/98 is curious, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the nines. We shall consider fractions like 30/50 = 3/5, to be trivial examples.&lt;/p&gt;
&lt;p&gt;
There are precisely four nontrivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator. If the product of these four fractions is given in its lowest common terms, &lt;a href=&#34;https://projecteuler.net/problem=33&#34;&gt;find the value of the denominator&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution in R
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To solve this problem, we create a pseudo-Farey sequence by generating all different fractions with two decimals in the numerator and denominator. The loop generates all combinations of denominators and numerators, excluding the trivial ones (multiples of 10 and 11). This solution converts the numbers to strings, strips any common duplicates, and tests the condition. The code concatenates vectors, which is not good practice. However, the loop is so short it does not matter much.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 33: Digit Cancelling Fractions&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  num &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  den &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (a &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;11&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;99&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (b &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;99&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          trivial &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; b &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; a &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;11&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; b &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;11&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;trivial) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;strsplit&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(a), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              j &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;strsplit&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(b), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              digs &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(i, j)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              dup &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; digs&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[duplicated&lt;/span&gt;(digs)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              digs &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; digs&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[which&lt;/span&gt;(digs &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; dup)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(digs) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; a&lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt;b &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; digs[1]&lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt;digs[2]) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  num &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(num, a)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  den &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(den, b)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(num, den, sep &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;/&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;prod&lt;/span&gt;(den) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;prod&lt;/span&gt;(num)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Farey Sequences and Ford Circles
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Next step is to generalise Euler problem 33 and write a function to generate Farey Sequences and visualise them using Ford Circles. This Numberphile video below explains fractions and Farey sequences. A Farey sequence contains all fractions between 0 and 1 with a maximum denominator. More formally, a Farey sequence of order n is the sequence of completely reduced fractions between 0 and 1. These fractions have denominators less than or equal to n, arranged in order of increasing size. For example, the Farey Sequence with order 3 is:&lt;/p&gt;
&lt;p&gt;
$$F_3 = \Big\{ \frac{0}{1},\frac{1}{3},\frac{1}{2},\frac{2}{3},\frac{1}{1}\Big\}$$&lt;/p&gt;
&lt;p&gt;
Ford Circles are a fractal-esque way to visualise Farey sequences, but before we get to this, first solve Euler problem 33.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/0hlvhQZIOQw?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Funny Fractions and Ford Circles by Numberphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The farey function generates a data table with the numerators (p) and denominators (q) of a Farey sequence. The function builds a list of all possible fractions for the solution space, excluding those with one as a Greatest Common Denominator, as defined by the &lt;code class=&#34;verbatim&#34;&gt;gcd()&lt;/code&gt; function.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Farey sequence function&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  farey &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      fseq &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;list&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      fseq[[1]] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      gcd &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(a, b) { &lt;span style=&#34;color:#888&#34;&gt;# Euclid&amp;#39;s method&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(b)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (b &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(a)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gcd&lt;/span&gt;(b, a &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; b)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (q &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (p &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(q &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)){
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gcd&lt;/span&gt;(p, q) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  fseq[[i]] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(p, q)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      fseq[[i]] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      fseq &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.data.frame&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;do.call&lt;/span&gt;(rbind, fseq))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;names&lt;/span&gt;(fseq) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;p&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;q&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      fseq &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; fseq&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[order&lt;/span&gt;(fseq&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;p &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; fseq&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;q), ]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(fseq)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Standard ggplot2 cannot draw circles where the radius of the circles is related to the coordinate system. I used a circle function sourced from &lt;a href=&#34;https://stackoverflow.com/questions/6862742/draw-a-circle-with-ggplot2&#34;&gt;StackOverflow&lt;/a&gt;. This function is called in a for-loop to build the circles on top of the empty canvas.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/project-euler/problem-033.png&#34; alt=&#34;/images/project-euler/problem-033.png&#34; title=&#34;Farey Sequence and Ford Circles (n = 20).&#34;/&gt;
&lt;figcaption&gt;
Farey Sequence and Ford Circles (n = 20).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  lm_palette &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#008da1&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#005395&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#262e43&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#3b2758&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#865596&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#f26230&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ford_circles &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;farey&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; p &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; q,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; q^2),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           r &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; y,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           c &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lm_palette&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(q &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  g_circle &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(r, x, y, color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;...&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; x &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; r &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cos&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;pi&lt;/span&gt;, length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ymax &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; y &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; r &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sin&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;pi&lt;/span&gt;, length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ymin &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; y &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; r &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sin&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;pi&lt;/span&gt;, length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;annotate&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;ribbon&amp;#34;&lt;/span&gt;, x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; x, ymin &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; ymin, ymax &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; ymax,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; color, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; fill, &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;...&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  p &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(ford_circles, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x, y))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(ford_circles)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    p &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; p &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;g_circle&lt;/span&gt;(ford_circles&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;r[i], ford_circles&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x[i], ford_circles&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y[i],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                      fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; ford_circles&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;c[i])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  p &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;xlim&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_fixed&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggsave&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;images/problem-033.png&amp;#34;&lt;/span&gt;, width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;, height &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Analyse Definitions of Marketing with Rvest and Tidytext</title>
      <link>https://lucidmanager.org/data-science/marketing-wordcloud/</link>
      <pubDate>Thu, 31 May 2018 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/marketing-wordcloud/</guid>
      <description>
	
&lt;p&gt;
I am preparing to facilitate another session of the marketing course for the &lt;a href=&#34;https://www.latrobe.edu.au/courses/mba&#34;&gt;La Trobe University MBA&lt;/a&gt;. The first lecture delves into the definition of marketing. Like most other social phenomena, marketing is tough to define. Definitions of social constructs often rely on the perspective taken by the person or group writing the definition. As such, definitions also change over time. While a few decades ago, definitions of marketing revolved around sales and advertising,
&lt;a href=&#34;https://web.archive.org/web/20190201101014/https://www.ama.org/AboutAMA/Pages/Definition-of-Marketing.aspx&#34;&gt;contemporary definitions&lt;/a&gt; are more holistic and reference creating value. &lt;/p&gt;
&lt;p&gt;
Heidi Cohen wrote a blog post where she collated &lt;a href=&#34;https://heidicohen.com/marketing-definition/&#34;&gt;72 definitions of marketing&lt;/a&gt;. So rather than arguing over which definition is the best, why not use all definitions simultaneously? This article attempts to define a new definition of marketing, using a data science approach. We can use the R language to scrape the 72 definitions from Heidi&amp;#39;s website and attempt text analysis to extract the essence of marketing from this data set.&lt;/p&gt;
&lt;p&gt;
I have mentioned in a previous post about &lt;a href=&#34;https://lucidmanager.org/data-science/qualitative-data-science/&#34;&gt;qualitative data science&lt;/a&gt; that automated text analysis is not always a useful method to extract meaning from a text. I decided to delve a little deeper into automated text analysis to see if we find out anything useful about marketing using the rvest and tidytext packages.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Scraping Definitions of Marketing with Rvest
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Web scraping is a technique to download data from websites where this data is not available as a clean data source. Web scraping starts with downloading the HTML code from the website and the filtering the wanted text from this file. The &lt;a href=&#34;https://cran.r-project.org/web/packages/rvest/&#34;&gt;rvest package&lt;/a&gt; simplifies this process.&lt;/p&gt;
&lt;p&gt;
The code for this article uses a pipe (&lt;code class=&#34;verbatim&#34;&gt;%&amp;gt;%&lt;/code&gt;) with three rvest commands. The first step is to download the wanted html code from the web using the &lt;code class=&#34;verbatim&#34;&gt;read_html&lt;/code&gt; function. The output of this function is piped to the &lt;code class=&#34;verbatim&#34;&gt;html_nodes&lt;/code&gt; function, which does all the hard work. In this case, the code picks all lines of text that are embedded in an ordered list. You  can use the &lt;a href=&#34;https://selectorgadget.com/&#34;&gt;SelectorGadget&lt;/a&gt; to target the text you like to scrape. The last scraping step cleans the text by piping the output of the previous commands to the &lt;code class=&#34;verbatim&#34;&gt;html_text&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;
The result of the scraping process is converted to a &lt;a href=&#34;https://tibble.tidyverse.org/&#34;&gt;Tibble&lt;/a&gt;, which is a type of data frame used in the Tidyverse. The definition number is added to the data, and the Tibble is converted to the format required by the Tidytext package.
The resulting data frame is much longer than the 72 definitions because there are other lists on the page. Unfortunately, I could not find a way to filter only the 72 definitions.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/digital-humanities/&#34; target=&#34;_blank&#34;
   title=&#34;Download digital-humanities from GitHub&#34;
   alt=&#34;Download digital-humanities from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;digital-humanities&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(rvest)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidytext)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(wordcloud)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(RColorBrewer)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  lm_palette &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#f7881f&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#55ace1&amp;#34;&lt;/span&gt;,  &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#5f6c36&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Scrape definitions from website&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  definitions &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read_html&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;https://heidicohen.com/marketing-definition/&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;html_nodes&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;ol li&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;html_text&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as_tibble&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(No &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(.)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(No, Definition &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; value)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Tidying the Text
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;https://www.tidytextmining.com/&#34;&gt;Tidytext&lt;/a&gt; package extends the &lt;a href=&#34;http://vita.had.co.nz/papers/tidy-data.html&#34;&gt;tidy data&lt;/a&gt; philosophy to a text. In this approach to text analysis, a corpus consists of a data frame where each word is a separate item. The code snippet below takes the first 72 rows, and the &lt;code class=&#34;verbatim&#34;&gt;unnest_tokens&lt;/code&gt; function extracts each word from the 72 definitions. This function can also extract ngrams and other word groups from the text. The Tidytext package is an extremely versatile piece of software which goes far beyond the scope of this article. Julia Silge and David Robinson have written a book about &lt;a href=&#34;https://www.tidytextmining.com/&#34;&gt;text mining&lt;/a&gt; using this package, which provides a very clear introduction to the craft of analysing text.&lt;/p&gt;
&lt;p&gt;
The last section of the pipe removes the trailing &amp;#34;s&amp;#34; from each word to convert plurals into single words. The mutate function in the Tidyverse creates or recreates a new variable in a data frame.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## bag of words&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  def_words &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; definitions[1&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;72&lt;/span&gt;, ] &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unnest_tokens&lt;/span&gt;(word, Definition) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(word &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;s$&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, word))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This section creates a data frame with two variables. The No variable indicates the definition number (1–72) and the word variable is a word within the definition. The order of the words is preserved in the row name. To check the data frame you can run &lt;code class=&#34;verbatim&#34;&gt;unique(def_words$No[which(def_words$word =&lt;/code&gt; &amp;#34;marketing&amp;#34;)])=. This line finds all definition numbers with the word &amp;#34;marketing&amp;#34;, wich results, as expected, in the number 1 to 72.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Using Rvest and Tidytext to define marketing
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;We can now proceed to analyse the definitions scraped from the website
with Rvest and cleaned with Tidytext. The first step is to create a word
cloud, which is a popular way to visualise word frequencies. This code
creates a data frame for each unique word, excluding the word marketing
itself, and uses the wordcloud package to visualise the fifty most
common words.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  word_freq &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; def_words &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;anti_join&lt;/span&gt;(stop_words) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;count&lt;/span&gt;(word) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;(word &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;marketing&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;vice&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;president&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;chief&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;executive&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;’&amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;pdf&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;marketingcloud.pdf&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  word_freq &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;with&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;wordcloud&lt;/span&gt;(word, n, max.words &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;50&lt;/span&gt;, rot.per &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.5&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                     colors &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rev&lt;/span&gt;(lm_palette)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dev.off&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/marketing-definition.png&#34; alt=&#34;Wordcloud of 72 definitios of marketing&#34; title=&#34;Wordcloud of 72 definitios of marketing&#34;/&gt;
&lt;figcaption&gt;
Wordcloud of 72 definitios of marketing.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
While a word cloud is indeed a pretty way to visualise the bag of words in a text, it is not the most useful way to get the reader to understand the data. The words are jumbled, and the reader needs to search for meaning. A better way to visualise word frequencies is a bar chart. This code takes the data frame created in the previous snippet, determines the top ten occurring words. The mutate statement reorders to factor levels so that the words are plotted in order.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    word_freq &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;top_n&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(word &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;reorder&lt;/span&gt;(word, n)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(word, n)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_col&lt;/span&gt;(fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lm_palette[2]) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_flip&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme&lt;/span&gt;(text &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;element_text&lt;/span&gt;(size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggsave&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;marketing-words.png&amp;#34;&lt;/span&gt;, width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;, height &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/marketing-words.png&#34; alt=&#34;Top ten words in marketing definitions&#34; title=&#34;/images/digital-humanities/marketing-words.png&#34; tite=&#34;Top ten words in marketing definitions&#34;/&gt;
&lt;figcaption&gt;
Top ten words in marketing definitions.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
A first look at the word cloud and bar chart suggests that marketing is about customers and products and services. Marketing is a process that includes branding and communication. This definition is simplistic but functional.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Topic Modeling using Tidytext
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Word frequencies are a weak method to analyse text because it interprets each word as a solitary unit. Topic modelling is a more advanced method that examines the relationships between words, i.e. the distance between them. The first step is to create a &lt;a href=&#34;https://en.wikipedia.org/wiki/Document-term_matrix&#34;&gt;Document-Term Matrix&lt;/a&gt;, which is a matrix that indicates how often a word appears in a text. As each of the 72 texts are very short, I decided to treat the collection of definitions as one text about marketing. The &lt;code class=&#34;verbatim&#34;&gt;cast_dtm()&lt;/code&gt; function converts the data frame to a Document-Term Matrix.&lt;/p&gt;
&lt;p&gt;
The following pipe determines the top words in the topics. Just like k-means clustering, the analyst needs to choose the number of topics before analysing the text. In this case, I have opted for four topics. The code determines the contribution of each word to the four topics and selects the five most common words in each topic. The faceted bar chart shows each of the words in the four topics.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Topic modeling&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(topicmodels)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  marketing_dtm &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; word_freq &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(doc &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cast_dtm&lt;/span&gt;(doc, word, n)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  marketing_lda &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;LDA&lt;/span&gt;(marketing_dtm, k &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tidy&lt;/span&gt;(matrix &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;beta&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;group_by&lt;/span&gt;(topic) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;top_n&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;, beta) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ungroup&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;arrange&lt;/span&gt;(topic, &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;beta)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  marketing_lda &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(term &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;reorder&lt;/span&gt;(term, beta)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(term, beta, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;factor&lt;/span&gt;(topic))) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_col&lt;/span&gt;(show.legend &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;facet_wrap&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;topic, scales &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;free&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_flip&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme&lt;/span&gt;(text &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;element_text&lt;/span&gt;(size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/marketing-topics.png&#34; alt=&#34;Topic modelling 72 definitions of marketing&#34; title=&#34;Topic modelling 72 definitions of marketing&#34;/&gt;
&lt;figcaption&gt;
Topic modelling 72 definitions of marketing.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This example also does not tell me much more about what marketing is, other than giving a slightly more sophisticated version of the word frequency charts. This chart shows me that marketing is about customers that enjoy a service and a product. Perhaps the original definitions are not distinctive enough to be separated from each other.&lt;/p&gt;
&lt;p&gt;
This article is only a weak summary of the great work by Julia Silge who co-authored the Tidytext package. The video below provides a comprehensive introduction to topic modelling.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/evTuL-RcRpc?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Topic modelling with R andtidy data principles.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
What have we learnt?
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This excursion into text analysis using rvest and Tidytext shows that data science can help us to make some sense out of an unread text. If I did not know what this page was about, then perhaps this analysis would enlighten me. This kind of analysis can assist us in wading through to large amounts of text to select the ones we want to read. I am still not convinced that this type of analysis will provide any knowledge beyond what can be obtained from actually reading and engaging with a text.&lt;/p&gt;
&lt;p&gt;
Although I am a data scientist and want to maximise the use of code in analysing data, I am very much in favour of developing human intelligence before we worry about the artificial kind.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Qualitative Data Science: Using RQDA to analyse interviews</title>
      <link>https://lucidmanager.org/data-science/qualitative-data-science/</link>
      <pubDate>Thu, 03 May 2018 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/qualitative-data-science/</guid>
      <description>
	
&lt;p&gt;
Qualitative data science sounds like a contradiction in terms. Data scientists generally solve problems using numerical solutions. Even the analysis of a text is reduced to a numerical problem using Markov chains, topic analysis, &lt;a href=&#34;https://lucidmanager.org/data-science/tap-water-sentiment-analysis/&#34;&gt;sentiment analysis&lt;/a&gt; and other mathematical tools.&lt;/p&gt;
&lt;p&gt;
Scientists and professionals consider numerical methods to be the gold standard of analysis. There is, however, a price to pay when relying on numbers alone. Numerical analysis reduces the complexity of the social world. When analysing people, numbers present an illusion of precision and accuracy. Giving primacy to quantitative research in the social sciences comes at a high price. The dynamics of reality are reduced to statistics, losing the narrative of the people that the research aims to understand.&lt;/p&gt;
&lt;p&gt;
Being both an engineer and a social scientist, I acknowledge the importance of both numerical and qualitative methods. My dissertation used a mixed-method approach to review the relationship between employee behaviour and customer perception in water utilities. This article introduces some aspects of qualitative data science with an example from my dissertation.&lt;/p&gt;
&lt;p&gt;
In this article, I show how I analysed data from interviews using both quantitative and qualitative methods and demonstrate why qualitative data science is better to understand text than numerical methods. &lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Qualitative Data Science
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The often celebrated artificial intelligence of machine learning is impressive but does not come close to human intelligence and ability to understand the world. Many data scientists are working on automated text analysis to solve this issue (the &lt;a href=&#34;https://cran.r-project.org/web/packages/topicmodels/&#34;&gt;topicmodels&lt;/a&gt; package is an example of such an attempt). These efforts are impressive, but even the smartest text analysis algorithm is not able to derive &lt;em&gt;meaning&lt;/em&gt; from text. To fully embrace all aspects of data science we need to be able to methodically undertake &lt;a href=&#34;https://en.wikipedia.org/wiki/Qualitative_research&#34;&gt;qualitative data analysis&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The capabilities of R in numerical analysis are impressive, but it can also assist with Qualitative Data Analysis (QDA). Huang Ronggui from Hong Kong developed the &lt;a href=&#34;http://rqda.r-forge.r-project.org/&#34;&gt;RQDA package&lt;/a&gt; to analyse texts in R. RQDA assists with qualitative data
analysis using a GUI front-end to analyse collections texts. &lt;/p&gt;
&lt;p&gt;
For my dissertation about &lt;a href=&#34;https://lucidmanager.org/tags/invisible-water-utility/&#34;&gt;water utility marketing&lt;/a&gt;, I interviewed seven people from various organisations. The purpose of these interviews was to learn about the value proposition for water utilities. The data consists of the transcripts of six interviews which I manually coded using RQDA. For reasons of agreed anonymity, I cannot provide the raw data file of the interviews through GitHub.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Numerical Text Analysis
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Word clouds are a popular method for exploratory analysis of texts. The wordcloud is created with the &lt;a href=&#34;https://cran.r-project.org/web/packages/tm/index.html&#34;&gt;text mining&lt;/a&gt; and wordcloud packages. The transcribed interviews are converted to a text corpus (the native format for the tm package) and whitespace, punctuation etc is removed. This code snippet opens the RQDA file and extracts the texts from the database. RQDA stores all text in an SQLite database and the package provides a query command to extract data.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/digital-humanities/&#34; target=&#34;_blank&#34;
   title=&#34;Download digital-humanities from GitHub&#34;
   alt=&#34;Download digital-humanities from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;digital-humanities&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(RQDA)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tm)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(wordcloud)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(igraph)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;openProject&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;stakeholders.rqda&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;interviews &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(name &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;RQDAQuery&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;SELECT name FROM source&amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                         text &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;RQDAQuery&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;SELECT file FROM source&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;interviews &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;Corpus&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;VectorSource&lt;/span&gt;(interviews&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;file))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;interviews &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tm_map&lt;/span&gt;(interviews, stripWhitespace)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;interviews &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tm_map&lt;/span&gt;(interviews, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;content_transformer&lt;/span&gt;(tolower))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;interviews &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tm_map&lt;/span&gt;(interviews, removeWords, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;stopwords&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;english&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;interviews &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tm_map&lt;/span&gt;(interviews, removePunctuation)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;interviews &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tm_map&lt;/span&gt;(interviews, removeNumbers)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;interviews &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tm_map&lt;/span&gt;(interviews, removeWords, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;interviewer&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;interviewee&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;# Word cloud&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;set.seed&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1969&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;wordcloud&lt;/span&gt;(interviews, min.freq &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;, max.words &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;50&lt;/span&gt;, rot.per&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.35&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          colors &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;brewer.pal&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Blues&amp;#34;&lt;/span&gt;)[&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-5&lt;/span&gt;])&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/wordcloud.png&#34; alt=&#34;Word cloud of interview transcripts&#34; title=&#34;Word cloud of interview transcripts&#34;/&gt;
&lt;figcaption&gt;
Word cloud of interview transcripts.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This word cloud makes it clear that the interviews are about water businesses and customers, which is a pretty obvious statement. The interviews are also about the opinion of the interviewees (think). While the word cloud is aesthetically pleasing and provides a quick snapshot of the content of the texts, they cannot inform us about their meaning.&lt;/p&gt;
&lt;p&gt;
Topic modelling is a more advanced method to extract information from the text by assessing the proximity of words to each other. The &lt;a href=&#34;https://eight2late.wordpress.com/2015/09/29/a-gentle-introduction-to-topic-modeling-using-r/&#34;&gt;topic modelling&lt;/a&gt; package provides functions to perform this analysis. I am not an expert in this field and simply followed basic steps using default settings with four topics.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;dtm &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;DocumentTermMatrix&lt;/span&gt;(interviews)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;dtm &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;removeSparseTerms&lt;/span&gt;(dtm, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.99&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ldaOut &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;LDA&lt;/span&gt;(dtm, k &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;terms&lt;/span&gt;(ldaOut,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This code converts the corpus created earlier into a &lt;a href=&#34;https://en.wikipedia.org/wiki/Document-term_matrix&#34;&gt;Document-Term Matrix&lt;/a&gt;, which is a matrix of words and documents (the interviews) and the frequency at which each of these words occurs. The LDA function applies a &lt;a href=&#34;https://en.wikipedia.org/wiki/Latent_Dirichlet_allocation&#34;&gt;Latent Dietrich Allocation&lt;/a&gt; to the matrix to define the topics. The variable &lt;code class=&#34;verbatim&#34;&gt;k&lt;/code&gt; defines the number of anticipated topics. An LDA is similar to clustering in multivariate data. The final output is a table with six words for each topic.&lt;/p&gt;
&lt;figure&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Topic 1&lt;/th&gt;
&lt;th&gt;Topic 2&lt;/th&gt;
&lt;th&gt;Topic 3&lt;/th&gt;
&lt;th&gt;Topic 4&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;water&lt;/td&gt;
&lt;td&gt;water&lt;/td&gt;
&lt;td&gt;customers&lt;/td&gt;
&lt;td&gt;water&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;think&lt;/td&gt;
&lt;td&gt;think&lt;/td&gt;
&lt;td&gt;water&lt;/td&gt;
&lt;td&gt;think&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;actually&lt;/td&gt;
&lt;td&gt;inaudible&lt;/td&gt;
&lt;td&gt;customer&lt;/td&gt;
&lt;td&gt;companies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;customer&lt;/td&gt;
&lt;td&gt;people&lt;/td&gt;
&lt;td&gt;think&lt;/td&gt;
&lt;td&gt;yeah&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;businesses&lt;/td&gt;
&lt;td&gt;service&lt;/td&gt;
&lt;td&gt;business&lt;/td&gt;
&lt;td&gt;issues&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;customers&lt;/td&gt;
&lt;td&gt;businesses&lt;/td&gt;
&lt;td&gt;service&lt;/td&gt;
&lt;td&gt;don&amp;#39;t&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;figcaption&gt;
Topic modelling of interviews.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This table does not tell me much at all about what was discussed in the interviews. Perhaps it is the frequent use of the word &amp;#34;water&amp;#34; or &amp;#34;think&amp;#34;—I did ask people their opinion about water-related issues. To make this analysis more meaningful, I could perhaps manually remove the words water, yeah, and so on. This introduces a bias in the analysis and reduces the reliability of the topic analysis because I would be interfering with the text.&lt;/p&gt;
&lt;p&gt;
Numerical text analysis sees a text as a bag of words instead of a set of meaningful words. It seems that any automated text mining needs a lot of manual cleaning to derive anything meaningful. This excursion shows that automated text analysis is not a sure-fire way to analyse the meaning of a collection of words. After a lot of trial and error to try to make this work, I decided to go back to my roots of qualitative analysis using RQDA as my tool.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Qualitative Data Science Using RQDA
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;To use RQDA for qualitative data science, you first need to manually analyse each text and assign codes (topics) to parts of the text. The image below shows a question and answer and how it was coded. All marked text is blue, and the codes are shown between markers. Coding a text is an iterative process that aims to extract meaning from a text. The advantage of this method compared to numerical analysis is that the researcher injects meaning into the analysis. The disadvantage is that the analysis will always be biased, which in the social sciences is unavoidable. My list of topics was based on words that appear in a marketing dictionary so that I analysed the interviews from that perspective.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/coding.png&#34; alt=&#34;Example of text coded with RQDA&#34; title=&#34;Example of text coded with RQDA&#34;/&gt;
&lt;figcaption&gt;
Example of text coded with RQDA.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
My first step was to look at the occurrence of codes (themes) in each of the interviews.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Load and transform data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;codings &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;getCodingTable&lt;/span&gt;()[,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;categories &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;RQDAQuery&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;SELECT filecat.name AS category, source.name AS filename 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                         FROM treefile, filecat, source 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;                         WHERE treefile.catid=filecat.catid AND treefile.fid=source.id AND treefile.status=1&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;codings &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;merge&lt;/span&gt;(codings, categories, all.y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;head&lt;/span&gt;(codings)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Open coding&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;reorder_size &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;factor&lt;/span&gt;(x, levels &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;names&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sort&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;table&lt;/span&gt;(x))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(codings, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;reorder_size&lt;/span&gt;(codename), fill&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;category)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_bar&lt;/span&gt;(stat&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;count&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;facet_grid&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;filename) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_flip&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme&lt;/span&gt;(legend.position&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;bottom&amp;#34;&lt;/span&gt;, legend.title&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;element_blank&lt;/span&gt;()) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ylab&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Code frequency in interviews&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;xlab&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Code&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The code uses an internal RQDA function &lt;em&gt;getCodingTable&lt;/em&gt; to obtain the primary data. The &lt;em&gt;RQDAQuery&lt;/em&gt; function provides more flexibility and enables more complex queries of the data. You can view the structure of the RQDA database using the &lt;em&gt;RQDATables&lt;/em&gt; function. &lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/interviewcode.png&#34; alt=&#34;Occurrence of themes from six interviews&#34; title=&#34;Occurrence of themes from six interviews&#34;/&gt;
&lt;figcaption&gt;
The occurrence of themes from six interviews.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This bar chart helps to explore the topics that interviewees discussed, but it does not help to understand how these topic relate to each other. This method provides better insights into the text than the &amp;#39;bag of words&amp;#39; approach. Qualitative data analysis provides meaning to a text that no algorithm can discern. Although this meaning is ultimately subjective, proper methodology clarified any biases.&lt;/p&gt;
&lt;p&gt;
RQDA provides a facility to assign each code to a code category. A network diagram is a good tool to visualise this structure. The igraph package provides extensive functionality to analyse graphs. &lt;/p&gt;
&lt;p&gt;
Qualitative data analysis can create value from a text by interpreting it from a given perspective. This article is not even an introduction to the science and art of qualitative data science. I hope it invites you to explore RQDA and similar tools.&lt;/p&gt;
&lt;p&gt;
If you are interested in finding out more about this method, then feel free to read chapter three of my dissertation on &lt;a href=&#34;http://hdl.handle.net/1959.9/561679&#34;&gt;customer service in water utilities&lt;/a&gt;.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/network.png&#34; alt=&#34;Network of interview topics&#34; title=&#34;Network of interview topics&#34;/&gt;
&lt;figcaption&gt;
The network of interview topics.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  edges &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;RQDAQuery&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;SELECT codecat.name, freecode.name FROM codecat, freecode, treecode WHERE codecat.catid=treecode.catid AND freecode.id=treecode.cid&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  g &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;graph_from_edgelist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.matrix&lt;/span&gt;(edges), directed &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;simplify&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;V&lt;/span&gt;(g)&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;name &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;\n&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;V&lt;/span&gt;(g)&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;name)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  c &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;spinglass.community&lt;/span&gt;(g)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;par&lt;/span&gt;(mar&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;set.seed&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;666&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot&lt;/span&gt;(c, g, 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.frame.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       layout &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; layout.drl)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
  &lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
    &lt;button class=&#34;button is-link is-medium&#34;&gt;
      &lt;span class=&#34;icon is-large&#34;&gt;
        &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
      &lt;/span&gt;
      &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
    &lt;/button&gt;
  &lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Tap Water Sentiment Analysis using Twitter and Tidytext</title>
      <link>https://lucidmanager.org/data-science/tap-water-sentiment-analysis/</link>
      <pubDate>Thu, 29 Mar 2018 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/tap-water-sentiment-analysis/</guid>
      <description>
	
&lt;p&gt;
In developed countries, tap water is safe to drink and available cheaply. Even though high-quality drinking water is almost freely available, the consumption of bottled water is increasing every year. Bottled water companies use sophisticated marketing strategies, while water utilities are mostly passive public service providers. Australian marketing expert Russell Howcroft even called water utilities &amp;#34;lazy marketers&amp;#34;. Can we use a tap water sentiment analysis to learn how people feel about tap water? What can we learn about the reasons behind this loss of trust in the municipal water supply?&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/Cg9YH4bm2Sk?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Gruen Transfer (2009).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This tap water sentiment analysis estimates people&amp;#39;s attitudes towards tap water by analysing tweets. This article explains how to examine tweets about tap water using the R language and the &lt;a href=&#34;https://www.tidytextmining.com/sentiment.html&#34;&gt;Tidytext package&lt;/a&gt;. &lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Sentiment Analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Sentiment indicates the perception a group of people has about a particular topic. Traditionally, assessing the sentiment of a group of people &lt;a href=&#34;https://lucidmanager.org/data-science/analysing-the-customer-experience/&#34;&gt;requires surveys&lt;/a&gt; or interviews. These methods are problematic because it creates an artificial environment where the respondent often answers to meet the perceived expectations of the study or customers exaggerate to get their point across. Using sentiment analysis of ego documents written by consumers can overcome these problems. Ego-documents, i.e. forms of personal writing, are a more direct way to
find out what consumers think, but they are challenging to obtain and analyse.&lt;/p&gt;
&lt;p&gt;
With the advent of social media, access to ego documents has become much more straightforward, and many tools exist to collect and interpret this data. Using ego documents brings you closer to the consumer than possible with surveys or focus groups. One medium gaining popularity with market researchers is &lt;a href=&#34;https://twitter.com/&#34;&gt;Twitter&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Tap Water Sentiment Analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Each tweet containing &amp;#34;tap water&amp;#34; reveals the author&amp;#39;s attitude towards that topic. Each text expresses a sentiment about the subject it describes. &lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://en.wikipedia.org/wiki/Sentiment_analysis&#34;&gt;Sentiment analysis&lt;/a&gt; is a data science technique that extracts personal information from a text. The basic method compares a string of words with a set of words with calibrated sentiments. These calibrated sets are created by asking many people how they feel about a specific term. For example, &amp;#34;stink&amp;#34; expresses a negative sentiment, while &amp;#34;nice&amp;#34; would be a positive sentiment.&lt;/p&gt;
&lt;p&gt;
This tap water sentiment analysis consists of three steps. The first step extracts 1000 tweets containing &amp;#34;tap water&amp;#34; from Twitter. The second step cleans the data, and the third step analyses the results.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://sites.google.com/view/watercoinzerocom/home&#34;&gt;Water Data Aggregator&lt;/a&gt; is a commercial application of sentiment analysis for tap water. This website sells the regional social credit score to interested parties.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Extracting tweets using the TwitteR package
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;https://cran.r-project.org/web/packages/twitteR/index.html&#34;&gt;TwitteR package&lt;/a&gt; by Geoff Gentry makes it very easy to retrieve tweets using search criteria. You must create an API on Twitter to receive the keys and tokens. In the code below, the actual values have been removed.&lt;/p&gt;
&lt;p&gt;
Follow the instructions in &lt;a href=&#34;https://www.r-bloggers.com/setting-up-the-twitter-r-package-for-text-analytics/&#34;&gt;this article&lt;/a&gt; to obtain these codes for yourself. This code snippet calls a private file to load the API codes, extracts the tweets and creates a data frame with a tweet id number and its text.&lt;/p&gt;
&lt;p&gt;
The TwitteR package is no longer availabe. A CSV file of tap water tweets is available on the GitHub repository.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Tapwater tweet sentiment analysis&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidytext)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  tapwater_tweets &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read_csv&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/tapwater-tweets-&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;Sys.time&lt;/span&gt;(), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;.csv&amp;#34;&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
When I first extracted these tweets, a tweet by CNN about &lt;a href=&#34;https://edition.cnn.com/2018/03/30/health/kentucky-water-crisis/index.html&#34;&gt;tap water in Kentucky that smells like diesel&lt;/a&gt; was retweeted many times, so I removed all duplicate tweets from the set. Unfortunately, this left less than 300 original tweets in the corpus.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Sentiment analysis with Tidytext
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Text analysis can be a powerful tool to help to analyse large amounts of text. The R language has an extensive collection of packages to help you undertake such a task. The &lt;a href=&#34;https://www.tidytextmining.com/&#34;&gt;Tidytext&lt;/a&gt; package extends the &lt;a href=&#34;http://vita.had.co.nz/papers/tidy-data.html&#34;&gt;Tidy Data&lt;/a&gt; logic promoted by Hadley Wickham and his Tidyverse software collection.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Data Cleaning
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The first step in cleaning the data is to create unigrams, which involve splitting the tweets into individual words that can be analysed. The first step is determining which words are most commonly used in the tap water tweets and visualising the result. The most common phrases are related to drinking and bottled water, which makes sense—also, the recent issues in Kentucky feature in this list.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/tapwater-common-words.png&#34; alt=&#34;Most common words in tweets about tap water&#34; title=&#34;Most common words in tweets about tap water&#34;/&gt;
&lt;figcaption&gt;
Most common words in tweets about tap water.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Tokenise and clean the tweets&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  tidy_tweets &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; tapwater_tweets &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unnest_tokens&lt;/span&gt;(word, text)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data&lt;/span&gt;(stop_words)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  tidy_tweets &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; tidy_tweets &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;anti_join&lt;/span&gt;(stop_words) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;word &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;tap&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;water&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;rt&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;https&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;t.co&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;gt&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;amp&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Most common words&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  tidy_tweets &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;count&lt;/span&gt;(word, sort &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;top_n&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(word &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;reorder&lt;/span&gt;(word, n)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(word, n)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_col&lt;/span&gt;(fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dodgerblue4&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;xlab&lt;/span&gt;(&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_flip&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_bw&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggtitle&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Most common words in tap water tweets&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Sentiment Analysis
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The Tidytext package contains three lexicons of thousands of single English words (unigrams) that were manually assessed for their sentiment. The principle of sentiment analysis is to compare the words in the text with the words in the lexicon and analyse the results. For example, the statement: &amp;#34;This tap water tastes horrible&amp;#34; has a sentiment score of -3 in the AFFIN system by &lt;a href=&#34;http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6010&#34;&gt;Finn Årup Nielsen&lt;/a&gt; due to the word &amp;#34;horrible&amp;#34;. In this analysis, I have used the &amp;#34;Bing&amp;#34; method published by &lt;a href=&#34;https://www.cs.uic.edu/~liub/FBS/sentiment-analysis.html&#34;&gt;Liu et al. in 2005&lt;/a&gt;. This method assigns a word to either positive, negative or neutral sentiment.&lt;/p&gt;
&lt;p&gt;
This method is not foolproof, as words with the same spelling can mean different things. For example, &amp;#34;This tap water contains too much lead&amp;#34; will be assessed as a positive sentiment because the verb lead is seen as positive. The noun lead has no sentiment, as it depends on context.&lt;/p&gt;
&lt;p&gt;
The other problem with sentiment analysis is that we only see negative commentary. Very few people contact a water utility about an excellent morning shower or a wonderful glass of water. Tap water resides in the background of everyday life, and people don&amp;#39;t have any opinion about it unless it is unavailable or does not meet their aesthetic expectations.&lt;/p&gt;
&lt;p&gt;
This tap water sentiment analysis shows that two-thirds of the words that express a sentiment were negative. The most common negative comments were &amp;#34;smells&amp;#34; and &amp;#34;scared&amp;#34;. This analysis is not a positive result for water utilities. Unfortunately, most tweets were not spatially located, so that I couldn&amp;#39;t determine the origin of the sentiment.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/tapwater-sentiment.png&#34; alt=&#34;Tap water sentiment analysis&#34; title=&#34;Tap water sentiment analysis&#34;/&gt;
&lt;figcaption&gt;
Tap water sentiment analysis.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Sentiment analysis&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  sentiment_bing &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; tidy_tweets &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;inner_join&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;get_sentiments&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;bing&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  sentiment_bing &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;summarise&lt;/span&gt;(Negative &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(sentiment &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;negative&amp;#34;&lt;/span&gt;), 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              positive &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(sentiment &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;positive&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  sentiment_bing &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;group_by&lt;/span&gt;(sentiment) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;count&lt;/span&gt;(word, sort &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;top_n&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(word, n, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; sentiment)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_col&lt;/span&gt;(show.legend &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_flip&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;facet_wrap&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;sentiment, scales &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;free_y&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Contribution to sentiment&amp;#34;&lt;/span&gt;, x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Using Tap Water Sentiment Analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Sentiment analysis is an exciting exploration technique but not an absolute truth. This method cannot detect sarcasm or irony, and words don&amp;#39;t always have the same meaning as described in the dictionary. For example, the algorithm interprets the word &amp;#34;lead&amp;#34; as positive sentiment in its function as a verb. In water, however, the chemical lead is never a positive sentiment. Interpreting tweets as bags of words is exciting but can lead to misunderstanding of the context.&lt;/p&gt;
&lt;p&gt;
The critical message for water utilities is that they need to start taking the aesthetic properties of tap water as seriously as the health parameters. A lack of trust will drive consumers to bottled water or less healthy alternatives such as soft drinks are alternative water sources.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Analyse Digital Water Meter Data using the Tidyverse</title>
      <link>https://lucidmanager.org/data-science/analyse-digital-water-meter-data/</link>
      <pubDate>Thu, 08 Feb 2018 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/analyse-digital-water-meter-data/</guid>
      <description>
	
&lt;p&gt;
In &lt;a href=&#34;https://lucidmanager.org/data-science/simulating-water-consumption/&#34;&gt;last week&amp;#39;s article&lt;/a&gt;, I discussed how to simulate water consumption data to help develop analytics and reporting. This post describes how to analyse digital water meter data and create a diurnal consumption curve.&lt;/p&gt;
&lt;p&gt;
The code is available in the GitHub repository in the &lt;code class=&#34;verbatim&#34;&gt;case-studies&lt;/code&gt; folder.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Data Source
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The simulated data consists  of three fields:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;device_id&lt;/code&gt;: Unique identifier of the digital water meter.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;timestamp&lt;/code&gt;: Time stamp in &lt;a href=&#34;https://en.wikipedia.org/wiki/Coordinated_Universal_Time&#34;&gt;Coordinated Universal Time&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;count&lt;/code&gt;: Cumulative &lt;em&gt;count&lt;/em&gt; of pulses.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that all data is recorded in UTC. The digital water meters send an hourly pulse at a random time within the hour. Each transmitter (RTU) uses a random offset to avoid network congestion. The digital meter counts each time the impeller makes a full turn, and for this analysis, we assume that this equates to a five-litre volume. The ratio between volume and count depends on the meter brand and type. The image below shows a typical data set for an RTU, including some missing data points.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/simulated-missing.png&#34; alt=&#34;Simulated water consumption&#34; title=&#34;Simulated water consumption&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Simulated water consumption with missing reads (In Australian time).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
To analyse the data we need two auxiliary functions: one to slice the data we need and one to interpolate data for the times we need it. The &lt;a href=&#34;https://www.tidyverse.org/&#34;&gt;Tidyverse&lt;/a&gt; heavily influences the code in this article. I prefer the Tidyverse way of doing things because it leads to elegant code that is easy to understand.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Analyse digital meter data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(lubridate)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(magrittr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Load data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  meter_reads &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read_csv&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/meter_reads.csv&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  rtu &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unique&lt;/span&gt;(meter_reads&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;device_id)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Prepare the Analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To construct a diurnal curve we need to slice to data to the required window and interpolate the hourly flows.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Slicing Digital Water Metering Data
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Analysis is undertaken on slices of the complete data set. This function slices the available data by a vector of RTU ids and a timestamp range in AEST. This function adds a new timestamp variable in AEST. If no date range is provided, all available data for the selected RTUs is provided. The output of this function is a data frame (a Tibble in Tydiverse language).&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Slicing meter reads&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  slice_reads &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(rtus, dates &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;range&lt;/span&gt;(meter_reads&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;timestamp)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(meter_reads, device_id &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; rtus) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(timestamp &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(dates[1], tz &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;UTC&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             timestamp &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(dates[2], tz &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;UTC&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;arrange&lt;/span&gt;(device_id, timestamp)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;slice_reads&lt;/span&gt;(rtu[12], &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2050-02-12&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2050-02-13&amp;#34;&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Interpolation of Meter Reads
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;This function interpolates the cumulative counts for a series of RTUs over a vector of timestamps in AEST. The function creates a list to store the results for each RTU, interpolates the data using the &lt;a href=&#34;https://stat.ethz.ch/R-manual/R-devel/library/stats/html/approxfun.html&#34;&gt;approx function&lt;/a&gt; and then flattens the list back to a data frame. The interpolation function contains a different type of pipe because the approx for interpolation function does not take a data argument. The &lt;code class=&#34;verbatim&#34;&gt;%$%&lt;/code&gt; pipe from the Magrittr &lt;a href=&#34;https://cran.r-project.org/web/packages/magrittr/&#34;&gt;package&lt;/a&gt; solves that problem.&lt;/p&gt;
&lt;p&gt;
The output is a data frame with DevEUI, the timestamp in AEST and the interpolated cumulative count. The image above shows the counts for two meters over two days an the graph superimposes an interpolated point over the raw data. Although the actual data consists of integer counts, interpolated values are numeric values. The decimals are retained to distinguish them from real reads.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Interpolation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  interpolate_count &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(rtus, timestamps) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      timestamps &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(timestamps, tz &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;UTC&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      results &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;list&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(rtus))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (r &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq_along&lt;/span&gt;(rtus)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          interp &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;slice_reads&lt;/span&gt;(rtus[r]) &lt;span style=&#34;color:#333&#34;&gt;%$%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;approx&lt;/span&gt;(timestamp, count, timestamps)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          results[[r]] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data_frame&lt;/span&gt;(device_id &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(rtus[r], 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                                     &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(timestamps)),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                     timestamp &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; timestamps, count &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; interp&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;do.call&lt;/span&gt;(rbind, results))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;interpolate_count&lt;/span&gt;(rtu[2&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;], &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq.POSIXt&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2050-02-01&amp;#34;&lt;/span&gt;), 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                         by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;day&amp;#34;&lt;/span&gt;, length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  sample &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;slice_reads&lt;/span&gt;(rtu[sample], &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2050-02-01 20:00&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2050-02-02 04:00&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(timestamp, count, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;factor&lt;/span&gt;(device_id))) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_line&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;interpolate_count&lt;/span&gt;(rtu[sample], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2050-02-02 00:00&amp;#34;&lt;/span&gt;), 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                 col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;blue&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;facet_wrap&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;device_id, scale &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;free_y&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggtitle&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Device&amp;#34;&lt;/span&gt;, rtu[2&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;])) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_bw&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/digital-meters-interpolation.png&#34; alt=&#34;Interpolated digital metering data&#34; title=&#34;Interpolated digital metering data&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Interpolated digital metering data.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
With these two auxiliary functions, we can start analysing the data.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Analyse Daily Consumption
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Daily consumption for each connection is a critical metric in managing water resources and billing customers. The daily consumption of any water connection is defined by the difference between the cumulative counts at midnight. The interpolation function makes it easy to determine daily consumption. This function interpolates the midnight reads for each of the RTUs over the period, starting the previous day. The output of the function is a data frame that can be piped into the plotting function to visualise the data. When you group the data by date, you can also determine the total consumption over a group of services.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Daily consumption&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  daily_consumption &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(rtus, dates) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    timestamps &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq.POSIXt&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;min&lt;/span&gt;(dates), tz &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;UTC&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3600&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                             &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(dates), tz &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;UTC&amp;#34;&lt;/span&gt;), by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;day&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;interpolate_count&lt;/span&gt;(rtus, timestamps) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;group_by&lt;/span&gt;(device_id) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(consumption &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;diff&lt;/span&gt;(count)) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(timestamp &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; timestamps[1])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;daily_consumption&lt;/span&gt;(rtu[32&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;33&lt;/span&gt;], &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2050-02-01&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2050-02-07&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(timestamp, consumption)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_col&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;facet_wrap&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;device_id) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_bw&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggtitle&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Daily consumption&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/digital-meters-daily.png&#34; alt=&#34;Daily water consumption&#34; title=&#34;Daily water consumption&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Daily water consumption.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Diurnal Curves
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The diurnal curve is one of the most important pieces of information used in the design of water supply systems. This curve shows the usage of one or more services for each hour in the day. This curve is a reflection of human behaviour, as we use most water in the morning and the evenings.&lt;/p&gt;
&lt;p&gt;
This function slices data for a vector of RTUs over a period and then plots the average diurnal curve. The data is obtained by interpolating the cumulative counts for each whole hour in the period. The function then calculates the flow in litres per hour and visualises the minimum, mean and maximum value.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Diurnal curves&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  plot_diurnal_connections &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(rtus, dates) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    timestamps &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq.POSIXt&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(dates[1], tz &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;UTC&amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                             &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(dates[2], tz &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;UTC&amp;#34;&lt;/span&gt;), by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;hour&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;interpolate_count&lt;/span&gt;(rtus, timestamps) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;group_by&lt;/span&gt;(device_id) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(rate &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;diff&lt;/span&gt;(count &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;)),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             hour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.integer&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;format&lt;/span&gt;(timestamp, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%H&amp;#34;&lt;/span&gt;))) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(rate &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;group_by&lt;/span&gt;(hour) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;summarise&lt;/span&gt;(min &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;min&lt;/span&gt;(rate), mean &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mean&lt;/span&gt;(rate), max &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(rate)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; hour, ymin &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; min, ymax &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; max)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_ribbon&lt;/span&gt;(fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;lightblue&amp;#34;&lt;/span&gt;, alpha &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.5&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_line&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; hour, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; mean), col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;orange&amp;#34;&lt;/span&gt;, linewidth &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggtitle&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Connections Diurnal flow&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ylab&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Flow rate [L/h]&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_bw&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot_diurnal_connections&lt;/span&gt;(rtu[10&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;], &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2050-02-01&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2050-03-01&amp;#34;&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Boxplots are also an informative way to visualise this curve. This method provides more statistical information on one page, and the ggplot function performs the statistical analysis.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/digital-meters-diurnal-curve.png&#34; alt=&#34;Diurnal curve in UTC&#34; title=&#34;Diurnal curve in UTC&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Diurnal curve in UTC.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Analysing digital metering data is explained in more detail in &lt;a href=&#34;https://lucidmanager.org/data-science/working-with-dates-and-times-in-r/&#34;&gt;chapter 11&lt;/a&gt; of &lt;em&gt;Data Science for Water Utilities&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Simulating Water Consumption to Develop Analysis Tools</title>
      <link>https://lucidmanager.org/data-science/simulating-water-consumption/</link>
      <pubDate>Thu, 01 Feb 2018 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/simulating-water-consumption/</guid>
      <description>
	
&lt;p&gt;
I am currently working on developing analytics for a digital water metering project. Over the next five years, we are enabling 70,000 customer water meters with digital readers and transmitters. The data is yet to be available, but we want to build reporting systems before the data is live. The R language comes to the rescue as it has magnificent capabilities to simulate data. Simulating data is a valuable technique to progress a project when data is being collected. Simulated data also helps because the analysis outcomes are known, which allows for validating the results.&lt;/p&gt;
&lt;p&gt;
The raw data that we will eventually receive from the digital customer meters has the following basic structure:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;device_id&lt;/code&gt;: Unique device identifier.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;timestamp&lt;/code&gt;: Date and time in (UTC) of the transmission.&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;count&lt;/code&gt;: The number of revolutions the water meter makes. Each revolution is a pulse which equates to five litres of water in a regular customer water meter.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Every device will send an hourly data burst which contains the cumulative meter read in pulse counts. The transmitters are set at a random offset from the whole hour to minimise the risk of congestion at the receivers. The timestamp for each read is set in the &lt;a href=&#34;https://en.wikipedia.org/wiki/Coordinated_Universal_Time&#34;&gt;Coordinated Universal Time&lt;/a&gt; (UTC). Using this time zone prevents issues with daylight savings. All analysis will be undertaken in the Australian Eastern (Daylight) Time zone.&lt;/p&gt;
&lt;p&gt;
This article explains how we simulated test data to assist with developing reporting and analysis. The analysis of digital metering data follows in a future post.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Simulating water consumption
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;For simplicity, this simulation assumes a standard domestic diurnal curve (average daily usage pattern) for indoor water use. Diurnal curves are an essential piece of information in water management. The curve shows water consumption over a day, averaged over a fixed period. The example below is sourced from a journal article. This generic diurnal curve consists of 24 data points based on measured indoor water consumption, shown in the graph below.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/diurnal-curve.jpg&#34; alt=&#34;Diurnal curve&#34; title=&#34;/images/hydroinformatics/diurnal-curve.jpg&#34; titel=&#34;Diurnal curve&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Source: Gurung et al. (2014) Smart meters for enhanced water supply network modelling and infrastructure planning. Resources, Conservation and Recycling (90), 34-50.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This diurnal curve only includes indoor water consumption and is assumed independent of seasonal variation. This assumption is unrealistic, but the purpose of this simulation is not to accurately model water consumption but to provide a data set to validate the reporting and analyses.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Simulating water consumption in R
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The first code snippet sets the parameters used in this simulation. The unique device identifiers (DevEUI) are simulated as six-digit random numbers. The timestamps vector consists of hourly date-time variables in UTC. For each transmitter, this timestamp is offset by a random time. Each transmitter is also associated with the number of people living in each house. This number is based on a Poisson distribution.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Simulate water consumption&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rm&lt;/span&gt;(list &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ls&lt;/span&gt;())
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Boundary conditions&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Number of simulated meters&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  d &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Number of days to simulate&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  s &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2050-01-01&amp;#34;&lt;/span&gt;, tz &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;UTC&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Start of simulation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;set.seed&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1969&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Seed random number generator for reproducibility&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  rtu &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1E6&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2E6&lt;/span&gt;, n, replace &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# 6-digit id&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  offset &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3599&lt;/span&gt;, n, replace &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Unique Random offset for each RTU&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Number of occupants per connection&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  occupants &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rpois&lt;/span&gt;(n, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.5&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Visualise&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as_tibble&lt;/span&gt;(occupants) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(occupants)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_bar&lt;/span&gt;(fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dodgerblue2&amp;#34;&lt;/span&gt;, alpha &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.5&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;xlab&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Occupants&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ylab&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Connections&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_bw&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;   
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Occupants per connection&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/simulated-occupants.png&#34; alt=&#34;Simulated number of occupants per connection&#34; title=&#34;Simulated number of occupants per connection&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Simulated number of occupants per connection.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The diurnal curve is based on actual data, including leaks, as the nighttime use shows a consistent flow of about one litre per hour. Therefore, the figures are rounded and reduced by one litre per hour to show a zero flow when people are usually asleep. The curve is also shifted by eleven hours because the raw data is stored in UTC.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Diurnal Curve&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  diurnal_au &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;round&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.36&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.085&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.98&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.05&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.58&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3.87&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9.37&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;13.3&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;12.1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10.3&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8.44&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;7.04&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6.11&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5.68&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5.58&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6.67&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8.32&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10.0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9.37&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;7.73&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6.59&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5.18&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3.55&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2.11&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  tdiff &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;11&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  diurnal_utc &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(diurnal_au&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(tdiff &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt;], diurnal_au[1&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;tdiff])&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This simulation only aims to simulate a realistic data set and not to present an accurate depiction of reality. This simulation could be enhanced by using different diurnal curves for various customer segments, including outdoor watering, temperature dependencies and so on.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Simulating Water Consumption
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A leak is defined by a constant flow through the meter and the idealised diurnal curve. A weighted binomial distribution (θ = 0.1) models approximately one in ten properties with a leak. The size of the leak is derived from a random number between 10 and 50 litres per hour.&lt;/p&gt;
&lt;p&gt;
The data is stored in a matrix through a loop that cycles through each connection. The DevEUI is repeated over the simulated period (24 times the number of days). The second variable is the timestamp plus the predetermined offset for each RTU. &lt;/p&gt;
&lt;p&gt;
The meter count is defined by the cumulative sum of the diurnal flow multiplied by the number of occupants. Each point in the diurnal deviates from the model curve by ±10%. Any predetermined leakage is added to each meter read over the whole period of 100 days. The hourly volumes are summed cumulatively to simulate meter reads. The flow is divided by five as each meter revolution indicates five litres.&lt;/p&gt;
&lt;p&gt;
The following code snippet simulates the digital metering data using the above assumptions and parameters.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Leaking properties&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  leaks &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rbinom&lt;/span&gt;(n, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, prob &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;50&lt;/span&gt;, n, replace &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(device_id &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; rtu, leak &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; leaks) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;subset&lt;/span&gt;(leak &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Digital metering data simulation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  meter_reads &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;matrix&lt;/span&gt;(ncol &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, nrow &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; d)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;colnames&lt;/span&gt;(meter_reads) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;device_id&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;timestamp&amp;#34;&lt;/span&gt; , &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;count&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    r &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; ((i &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; d &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(i &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; d)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    meter_reads[r, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(rtu[i], each &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; d))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    meter_reads[r, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq.POSIXt&lt;/span&gt;(s, by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;hour&amp;#34;&lt;/span&gt;, length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; d) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; offset[i]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    meter_reads[r, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;round&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cumsum&lt;/span&gt;((&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(diurnal_utc &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; occupants[i], d) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                       leaks[i]) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;runif&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; d, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.9&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.1&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  meter_reads &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as_tibble&lt;/span&gt;(meter_reads) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(timestamp &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(timestamp, origin &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;1970-01-01&amp;#34;&lt;/span&gt;, tz &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;UTC&amp;#34;&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Missing Data Points
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The data transmission process is not 100% reliable, and the base station will not receive some reads. This simulation identifies reads to be removed from the data through the temporary variable removal. This simulation includes two types of failures:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Faulty RTUs (2% of RTUs with missing 95% of data)&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Randomly missing data points (1% of data)&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Set missing indicator&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  meter_reads &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(meter_reads, remove &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Define faulty RTUs (2% of the fleet)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  faulty &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; rtu&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[rbinom&lt;/span&gt;(n, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, prob &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.02&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  meter_reads&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;remove[meter_reads&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;device_id &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; faulty] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rbinom&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(meter_reads&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;device_id &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; faulty), &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, prob &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.5&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Data loss&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  missing &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(meter_reads) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;), &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.005&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(meter_reads))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (m &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; missing){
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    meter_reads[m&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(m &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;remove&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Remove missing reads&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  meter_reads &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(meter_reads, remove &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;remove)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Write to disk&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;write_csv&lt;/span&gt;(meter_reads, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/meter_reads.csv&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;##Visualise&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(meter_reads, device_id &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(faulty, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(timestamp &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;format&lt;/span&gt;(timestamp,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                         tz &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Australia/Melbourne&amp;#34;&lt;/span&gt;))) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(timestamp &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2050-02-06&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           timestamp &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2050-02-08&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;arrange&lt;/span&gt;(device_id, timestamp) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; timestamp, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; count, colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;factor&lt;/span&gt;(device_id))) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_line&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The graph shows an example of the cumulative reads and some missing data points.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/simulated-missing.png&#34; alt=&#34;Simulated water consumption&#34; title=&#34;Simulated water consumption&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Simulated water consumption with missing reads.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Analysing Digital Metering Data
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Data simulation is a good way to develop your analysis algorithms before you have real data. I have also used this technique while waiting for survey results during my dissertation. When the data finally arrived, I plugged it into the code and finetuned it. R has great capabilities to simulate reality to help you understand the data. The ggplot package provides excellent functionality to &lt;a href=&#34;https://lucidmanager.org/data-science/geographic-bubble-chart/&#34;&gt;visualise water consumption&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
In &lt;a href=&#34;https://lucidmanager.org/data-science/analyse-digital-water-meter-data/&#34;&gt;next week&amp;#39;s article&lt;/a&gt;, I will outline how I used R and the Tidyverse package to develop libraries to analyse digital metering data.&lt;/p&gt;
&lt;p&gt;
This data was used as a case study in the book &lt;em&gt;Data Science for Water Utilities&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 32: Pandigital Products</title>
      <link>https://lucidmanager.org/data-science/project-euler-32/</link>
      <pubDate>Thu, 21 Sep 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-32/</guid>
      <description>
	
&lt;p&gt;
Project Euler 32 returns to pandigital numbers, which are numbers that contain one of each digit. Like so many of the Euler Problems, these numbers serve no practical purpose whatsoever. Just like palindromic products, other than some entertainment value and increasing your understanding of numbers.&lt;/p&gt;
&lt;p&gt;
You can find all pandigital numbers with digits zero to nine in &lt;a href=&#34;https://oeis.org/A050278&#34;&gt;sequence A050278&lt;/a&gt; of the Online Encyclopedia of Integers. The Numberphile video below explains everything you ever wanted to know about pandigital numbers but were afraid to ask.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/gaVMrqzb91w?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Why 381,654,729 is awesome – Numberphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 32 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital.&lt;/p&gt;
&lt;p&gt;
The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital.&lt;/p&gt;
&lt;p&gt;
Find the sum of all products whose multiplicand/multiplier/product identity can be written as a 1 through 9 pandigital.&lt;/p&gt;
&lt;p&gt;
HINT: Some products can be obtained in more than one way, so be sure to only include it once in your sum.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;code class=&#34;verbatim&#34;&gt;pandigital.9()&lt;/code&gt; function tests whether a string classifies as a pandigital number. The &lt;code class=&#34;verbatim&#34;&gt;pandigital.prod&lt;/code&gt; vector stores the multiplication.&lt;/p&gt;
&lt;p&gt;
The only way to solve this problem is by brute force and try all multiplications. We can limit the solution space to a manageable number. The multiplication result needs to have ten digits. For example, when the starting number has two digits, the second number should have three digits so that the total has four digits, e.g., 39 × 186 = 7254. When the first number only has one digit, the second number needs to have four digits.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 32: Pandigital Products&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  pandigital.9 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x) &lt;span style=&#34;color:#888&#34;&gt;# Test if string is 9-pandigital&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(x)&lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;duplicated&lt;/span&gt;(x))&lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(x&lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)&lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Brute force&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  pandigital.prod &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (m &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (m &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      n_start &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1234&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      n_start &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;123&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (n &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; n_start&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;round&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10000&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; m)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                          &lt;span style=&#34;color:#888&#34;&gt;# List of digits&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      digs &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;strsplit&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(m, n, m &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; n), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                          &lt;span style=&#34;color:#888&#34;&gt;# is Pandigital?&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;pandigital.9&lt;/span&gt;(digs)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        pandigital.prod[i] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; m &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; n
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(m, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;*&amp;#34;&lt;/span&gt;, n, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;=&amp;#34;&lt;/span&gt;, m &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; n))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unique&lt;/span&gt;(pandigital.prod))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Analysing soil moisture data with the ncdf4 library</title>
      <link>https://lucidmanager.org/data-science/ncdf4-library/</link>
      <pubDate>Thu, 07 Sep 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/ncdf4-library/</guid>
      <description>
	
&lt;p&gt;
The &lt;a href=&#34;https://www.unidata.ucar.edu/software/netcdf/&#34;&gt;netCDF&lt;/a&gt; format is popular in sciences that analyse sequential spatial data. It is a self-describing and machine-independent data format for creating, accessing and sharing array-oriented information. The netCDF format provides spatial time series such as meteorological or environmental data. This article shows how to load this data type with the ncdf4 library. This article also shows how to visualise and analyse this data format by reviewing soil moisture data published by the Australian Bureau of Meteorology.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Soil Moisture data
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;https://awo.bom.gov.au/products/historical/soilMoisture-rootZone/7,-37.405,144.635/nat,-25.609,134.362/r/d/2025-06-22&#34;&gt;Australian Bureau of Meteorology&lt;/a&gt; publishes hydrological data in the NetCDF format on their &lt;em&gt;Australian Water Outlook&lt;/em&gt;. The NetCDF format provides a three-dimensional matrix of spatial data over time. You need to download the monthly time aggregation, which is approximately 1GB large.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/soil-moisture.jpg&#34; alt=&#34;Australian Landscape Water Balance (Bureau of Meteorology)&#34; title=&#34;Australian Landscape Water Balance (Bureau of Meteorology)&#34; width=&#34;300&#34;/&gt;
&lt;figcaption&gt;
Australian Landscape Water Balance (Bureau of Meteorology).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Reading, Extracting and Transforming with the ncdf4 library
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;https://cran.r-project.org/web/packages/ncdf4/index.html&#34;&gt;ncdf4 library&lt;/a&gt;, developed by David W. Pierce, provides the necessary functionality to manage this data. To install this R library on a non-Windows system, you must first install the NetCDF package for your relevant operating system. &lt;/p&gt;
&lt;p&gt;
The first step is to load the data, extract the relevant information and transform the data for visualisation and analysis. The data forms a complex list containing the metadata and measurements. The &lt;code class=&#34;verbatim&#34;&gt;ncvar_get()&lt;/code&gt; function extracts  data from the list.&lt;/p&gt;
&lt;p&gt;
The time data is stored as the number of days since 1 January 1900. The spatial coordinates are stored in decimal degrees with 0.05-decimal degree intervals. The moisture data is transformed to a three-dimensional matrix with dimensions of longitude, latitude, and time.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Analysing soil moisture data with the ncdf4 library&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Reading, Extracting and Transforming with the ncdf4 library&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ncdf4)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  bom &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nc_open&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/sm_pct.nc&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Generate matrix&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  longitude &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ncvar_get&lt;/span&gt;(bom, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;longitude&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  latitude &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ncvar_get&lt;/span&gt;(bom, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;latitude&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  month &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.Date&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;1900-01-01&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ncvar_get&lt;/span&gt;(bom, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;time&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  moisture &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ncvar_get&lt;/span&gt;(bom, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;sm_pct&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dimnames&lt;/span&gt;(moisture) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;list&lt;/span&gt;(longitude, latitude, month)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Visualising the data with ggplot
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This first code snippet extracts and plots a matrix from the cube for 31 May 2025. This code creates a data frame with the grid for the required date. Although I use the Tidyverse, I still need reshape2 because the &lt;code&gt;pivot_longer&lt;/code&gt; function does not like matrices.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Visualising the data with ggplot&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(dplyr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(reshape2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ozmaps)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  plot_date &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2025-05-31&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Generate data frame&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  soil_moisture &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; moisture[, , &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(month &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; plot_date)] &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;melt&lt;/span&gt;(varnames &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;longitude&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;latitude&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;subset&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;is.na&lt;/span&gt;(value))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## State boundaries&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  sf_aus &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ozmap&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;states&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(soil_moisture) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_tile&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; longitude, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; latitude, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; value)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_fill_gradient&lt;/span&gt;(low &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;chocolate4&amp;#34;&lt;/span&gt;, high &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dodgerblue&amp;#34;&lt;/span&gt;, name &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_sf&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; sf_aus, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Relative Total rootzone soil moisture (0-100 cm)&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;format&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.Date&lt;/span&gt;(plot_date), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%d %B %Y&amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         caption &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Source: Australian Landscape Water Balance AWRA-L Model&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/soil-moisture-australia.jpg&#34; alt=&#34;Relative soil moisture in Australia, May 2025&#34; title=&#34;Relative soil moisture in Australia, May 2025&#34;/&gt;
&lt;figcaption&gt;
Relative soil moisture in Australia, May 2025.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
With the ggmap package we can add some mapping tiles. You will need a &lt;a href=&#34;https://lucidmanager.org/data-science/geocoding-with-ggmap/&#34;&gt;Google Maps API&lt;/a&gt; to enable this functionality.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Plot on Google Maps&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggmap)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  api &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;case-studies/google-maps.api&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Text file with the API key&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;register_google&lt;/span&gt;(key &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; api)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggmap&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;get_map&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Australia&amp;#34;&lt;/span&gt;, zoom &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;, color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;bw&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_tile&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; soil_moisture, 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; longitude, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; latitude, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; value), alpha &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.5&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_fill_gradient&lt;/span&gt;(low &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;chocolate4&amp;#34;&lt;/span&gt;, high &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dodgerblue&amp;#34;&lt;/span&gt;, name &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Relative Total rootzone soil moisture (0-100 cm)&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;format&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.Date&lt;/span&gt;(plot_date), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;%d %B %Y&amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         caption &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Source: Australian Landscape Water Balance AWRA-L Model&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/soil-moisture-google-maps.jpg&#34; alt=&#34;Relative soil moisture in Australia, May 2025&#34; title=&#34;Relative soil moisture in Australia, May 2025&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Relative soil moisture in Australia, May 2025.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Analysing the data
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;For my analysis, I am interested in the time series of moisture data for a specific point on the map. The previous code slices the data for all location at a specific month.&lt;/p&gt;
&lt;p&gt;
We can also pierce the data vertically for a particular coordinate to create a time series. The coordinate needs to be rounded to  the nearest 0.05 decimal degrees to match the source data.&lt;/p&gt;
&lt;p&gt;
This time series was used to investigate the relationship between sewer main blockages and deep soil data, which can be a topic for a future post.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/soil-moisture-time-series.png&#34; alt=&#34;Soil moisture time series for Bendigo&#34; title=&#34;Soil moisture time series for Bendigo&#34;/&gt;
&lt;figcaption&gt;
Soil moisture time series for Bendigo.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Time series&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  location &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;round&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geocode&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Bendigo, Australia&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.05&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.05&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  soil_moisture_time &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(month,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                               moisture &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; moisture&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[as.character&lt;/span&gt;(location&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon), 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                                   &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(location&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lat), ]) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(month &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2000-01-01&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(soil_moisture_time) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_line&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; month, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; moisture)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Relative Total rootzone soil moisture (0-100 cm)&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(location), collapse &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;, &amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         caption &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Source: Australian Landscape Water Balance AWRA-L Model&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Relative Soil Moisture&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_minimal&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;16&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Pacific Island Hopping using R and the iGraph package</title>
      <link>https://lucidmanager.org/data-science/pacific-island-hopping/</link>
      <pubDate>Thu, 31 Aug 2017 10:00:56 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/pacific-island-hopping/</guid>
      <description>
	
&lt;p&gt;
Last month I enjoyed a relaxing holiday in the &lt;a href=&#34;https://horizonofreason.com/culture/vanuatu-sand-drawings-sandroing/&#34;&gt;tropical paradise of Vanuatu&lt;/a&gt;. One rainy day I contemplated how to go island hopping across the Pacific ocean visiting as many island nations as possible. The Pacific ocean is a massive body of water between, Asia and the Americas, which covers almost half the surface of the earth. The southern Pacific is strewn with island nations from Australia to Chile. In this post, I describe how to use R to plan your next Pacific island
hopping journey.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/geography/pacific-ocean.png&#34; alt=&#34;The Pacific Ocean&#34; title=&#34;The Pacific Ocean&#34;/&gt;
&lt;figcaption&gt;
The Pacific Ocean with UN Geoscheme regions (source: Oceania_ISO_3166-1.svg: User:Tintazulderivative work: Cruickshanks / &lt;a href=&#34;https://creativecommons.org/licenses/by-sa/3.0&#34;&gt;CC BY-SA&lt;/a&gt;).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Geocoding the airports
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;My first step was to create a list of flight connections between each of the island nations in the Pacific ocean. I am not aware of a publicly available data set of international flights so unfortunately, I created the list manually by collecting route maps on &lt;em&gt;Pinterest&lt;/em&gt; (if you do know of a fomal data set with international flights, then please leave a comment).&lt;/p&gt;
&lt;p&gt;
My manual research resulted in a list of international flights from or to island airports. This list might not be complete, but it is a start. My &lt;a href=&#34;https://www.pinterest.com.au/HorizonOfReason/pacific-island-hopping/&#34;&gt;Pinterest board with Pacific island airline route maps&lt;/a&gt; was the information source for this list.&lt;/p&gt;
&lt;p&gt;
The first code section reads the list of airline routes and uses the ggmap package to extract their coordinates from Google maps. You will need a Google API to enable the &lt;a href=&#34;https://lucidmanager.org/data-science/geocoding-with-ggmap/&#34;&gt;geocoding function&lt;/a&gt;. The data frame with airport coordinates is saved for future reference to avoid repeatedly pinging Google for the same information.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/geography/&#34; target=&#34;_blank&#34;
   title=&#34;Download geography from GitHub&#34;
   alt=&#34;Download geography from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;geography&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggmap)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggrepel)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(geosphere)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(stringr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Google maps api&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  api &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;google.api&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Text file with the API key&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;register_google&lt;/span&gt;(key &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; api)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Read flight list and airport list&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read_csv&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;pacific/pacific-flights.csv&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  f &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;pacific/pacific-airports.csv&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;file.exists&lt;/span&gt;(f)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    airports &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read.csv&lt;/span&gt;(f)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    airports &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(airport &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;, lat &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;, lon &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Lookup coordinates for new airports&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  all_airports &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unique&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;From, flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;From.Country, sep &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;, &amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                           &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;To, flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;To.Country, sep &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;, &amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  new_airports &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; all_airports[&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;(all_airports &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;airport)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(new_airports) &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    coords &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geocode&lt;/span&gt;(new_airports)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    temp_airports &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(airport &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; new_airports, coords)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    airports &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rbind&lt;/span&gt;(airports, temp_airports) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;is.na&lt;/span&gt;(lat), &lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;is.na&lt;/span&gt;(lon))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    new_airports &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; all_airports[&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;(all_airports &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;airport)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Remove countries and save&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;airport &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_remove_all&lt;/span&gt;(airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;airport, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;,.*&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;write_csv&lt;/span&gt;(airports, f)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Add coordinates to flight list&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;merge&lt;/span&gt;(flights, airports, by.x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;From&amp;#34;&lt;/span&gt;, by.y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;airport&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;merge&lt;/span&gt;(flights, airports, by.x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;To&amp;#34;&lt;/span&gt;, by.y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;airport&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Create the map
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To create a map, I modified the code to create &lt;a href=&#34;https://lucidmanager.org/data-science/create-air-travel-route-maps/&#34;&gt;flight maps&lt;/a&gt; I published in an earlier article. This code had to be changed to centre the map on the Pacific.&lt;/p&gt;
&lt;p&gt;
Mapping the Pacific ocean is problematic because the -180 and +180 degree meridians meet around the dateline. Longitudes west of the antemeridian are positive, while longitudes east are negative. The &lt;code class=&#34;verbatim&#34;&gt;world2&lt;/code&gt; data set in the borders function of the ggplot2 package is centred on the Pacific ocean. To enable plotting on this map, all negative longitudes are made positive by adding 360 degrees to them and &lt;a href=&#34;https://lucidmanager.org/data-science/mapping-antipodes/&#34;&gt;defining&lt;/a&gt; the antipode.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Pacific centric&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon.x[flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon.x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon.x[flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon.x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;360&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon.y[flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon.y &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon.y[flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon.y &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;360&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon[airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon[airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;360&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Plot flight routes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  worldmap &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;borders&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;world2&amp;#34;&lt;/span&gt;, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;grey&amp;#34;&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; worldmap &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; airports, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lon, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lat), col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#970027&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_text_repel&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; airports, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lon, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lat, label &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; airport), col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    segment.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_curve&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; flights, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lon.x, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lat.x, xend &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lon.y, yend &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lat.y, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; Airline), size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               curvature &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.2&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;xlim&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;90&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;300&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ylim&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-50&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;50&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Pacific Island Hopping&amp;#34;&lt;/span&gt;, subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;lucidmanager.org&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggsave&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;pacific-flights.png&amp;#34;&lt;/span&gt;, width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;, height &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/geography/pacific-flights.png&#34; alt=&#34;Pacific island hopping flight route map&#34; title=&#34;Pacific island hopping flight route map&#34;/&gt;
&lt;figcaption&gt;
Pacific island hopping - flight route map.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Pacific Island Hopping
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This visualisation is aesthetic and full of context, but it is not the best visualisation to solve the travel problem. This map can also be expressed as a graph with nodes (airports) and edges (routes). Once the map is represented mathematically, we can generate travel routes and begin our Pacific Island hopping.&lt;/p&gt;
&lt;p&gt;
The igraph package converts the flight list to a graph that can be analysed and plotted. The &lt;code class=&#34;verbatim&#34;&gt;shortest_path&lt;/code&gt; function can then be used to plan routes. If I would want to travel from Auckland to Saipan in the Northern Mariana Islands, I have to go through Port Vila, Honiara, Port Moresby, Chuuk, Guam and then to Saipan. I am pretty sure there are quicker ways to get there, but this would be an exciting journey through the Pacific.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(igraph)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  g &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;graph_from_edgelist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.matrix&lt;/span&gt;(flights[,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;]), directed &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;png&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;pacific-network.png&amp;#34;&lt;/span&gt;, width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;600&lt;/span&gt;, height &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;600&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;par&lt;/span&gt;(mar &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot&lt;/span&gt;(g, layout &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; layout.fruchterman.reingold,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.label.cex &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.2&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       edge.width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dev.off&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;shortest_paths&lt;/span&gt;(g, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Auckland&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Saipan&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/geography/pacific-network.png&#34; alt=&#34;Pacific island hopping - network model&#34; title=&#34;Pacific island hopping - network model&#34;/&gt;
&lt;figcaption&gt;
Pacific island hopping - network model.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This diagram looks a lot like a &lt;a href=&#34;http://www.thenonist.com/index.php/thenonist/permalink/stick_charts/&#34;&gt;Polynesian stick chart&lt;/a&gt;. These are maps made from sticks bound together with strings. These maps allowed the per-colonial Polynesians to navigate between their islands. The maps are not mathematical projections of the earth, like our first map, but a logical model.&lt;/p&gt;
&lt;p&gt;
Stick charts indicate the local swell patterns that allowed the ancient mariners to find their way across the vast distances in the pacific. All we have to do is hop on a plane and we get to wherever we want withing a few hours.&lt;/p&gt;
&lt;p&gt;
Happy island hopping!&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 30: Digit Fifth Powers</title>
      <link>https://lucidmanager.org/data-science/project-euler-30/</link>
      <pubDate>Thu, 24 Aug 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-30/</guid>
      <description>
	
&lt;p&gt;
Project Euler 30 is another number-crunching problem that deals with numbers to the power of five. Two other Euler problems dealt with raising numbers to a power. The &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-29/&#34;&gt;previous problem&lt;/a&gt; looked at permutations of powers, and &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-16/&#34;&gt;problem 16&lt;/a&gt; asks for the sum of the digits of \(2^{1000}\).&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 30 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:&lt;/p&gt;
&lt;p&gt;
$$1634 = 1^4 + 6^4 + 3^4 + 4^4$$&lt;/p&gt;
&lt;p&gt;
$$8208 = 8^4 + 2^4 + 0^4 + 8^4$$&lt;/p&gt;
&lt;p&gt;
$$9474 = 9^4 + 4^4 + 7^4 + 4^4$$&lt;/p&gt;
&lt;p&gt;
As \(1 = 1^4\) is not a sum, it is not included.&lt;/p&gt;
&lt;p&gt;
The sum of these numbers is \(1634 + 8208 + 9474 = 19316\). Find the sum of all the numbers that can be written as the sum of the fifth powers of their digits.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The problem asks for a brute-force solution, but we have a halting problem. How far do we need to go before we can be sure there are no sums of fifth power digits? Do we need to search until infinity, which means we can never solve the problem? We can limit the solution space because the solution will have lower and upper limits. An upper bound is a number with \(log 9^5\) digits.&lt;/p&gt;
&lt;p&gt;
In base ten, the highest digit is 9 and \(9^5=59049\), which has five digits. This implies that the highest possible number, which equals the sum of the fifth power of its digits is 5 times \(9^5=295245\). The lowest possible number is 2 times \(2^5 = 64\). All numbers with this property thus must range between these two values.&lt;/p&gt;
&lt;p&gt;
The code to solve this project first declares the exponent and determines the lower and upper boundaries of the solution space. Change the variable n to try other exponents. The loop cycles through the digits of each number and tests whether the sum of the fifth powers equals the number. &lt;/p&gt;
&lt;p&gt;
The digit sum of a number \(x\) in base 10 is given by:&lt;/p&gt;
&lt;p&gt;
$$\sum_{n=0}^{\lfloor \log_{10} x\rfloor} \frac{1}{10^n}(x \bmod 10^{n + 1} - x \bmod 10^n)$$&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 30: Digit Fifth Powers&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  m &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  highest &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;round&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;log10&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;^m)) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;^m
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (x &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;highest) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;log10&lt;/span&gt;(x)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      power.sum &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(((&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;^n) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;^&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; x &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;^n))^m)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (power.sum &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(x)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; answer &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; x
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Digit sums
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The mathematics in this problem is about the digit sum, which is the sum of all digits in the relevant number base.&lt;/p&gt;
&lt;p&gt;
Computer scientists use digit sums in cryptography and data validation. You can find the digital sum base-10 numbers in &lt;a href=&#34;http://oeis.org/A007953&#34;&gt;sequence A007953&lt;/a&gt; of the Online Encyclopedia of Integer Sequences. Checksum algorithms use digit sums as a quality assurance method. For example, the final digit in the ten-digit International Standard Book Numbers is a check digit. You can compute the check digit by multiplying each digit by its position in the ISBN number (alternating by 3 and 1), and taking the sum of these products. The check digit is 0 when the modules 10 of this modulus is zero, otherwise it is 10 minus the remainder. In R code, determining the check digit for a 13-digit ISBN number works as follows:&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Check ISB number&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  check_isbn13 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(isbn) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      isbn &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; |-&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, isbn)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      check_sum &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;12&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          m &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ifelse&lt;/span&gt;(i &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          check_sum &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; check_sum &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; m &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;substr&lt;/span&gt;(isbn, i, i))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      check_sum &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ifelse&lt;/span&gt;(check_sum &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; check_sum &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      check_sum &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;substr&lt;/span&gt;(isbn, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;13&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;13&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;check_isbn13&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;978-0-9875669-4-2&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Visualise Water Consumption with a Geographic Bubble Chart</title>
      <link>https://lucidmanager.org/data-science/geographic-bubble-chart/</link>
      <pubDate>Thu, 17 Aug 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/geographic-bubble-chart/</guid>
      <description>
	
&lt;p&gt;
A geographic bubble chart is a straightforward method to visualise quantitative information with a geospatial relationship. Last week, I was in Vietnam helping the Phú Thọ Water Supply Joint Stock Company with their data science. They asked me to create a map of a sample of their water consumption data. In this post, I share this little ditty to explain how to plot a bubble chart over a map using the ggmap package. &lt;/p&gt;
&lt;p&gt;
In this post, I share this little ditty to explain how to plot a bubble chart over a map using the ggmap package. Thanks to Ms Quy and Mr Tuyen of Phu Tho Water for their permission to use this data. Other posts on this blog detail how to analyse water consumption from &lt;a href=&#34;https://lucidmanager.org/data-science/analyse-digital-water-meter-data/&#34;&gt;digital metering data&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
This map visualises water consumption in the targeted area of Việt Trì. The larger the bubble, the larger the consumption. It is no surprise that two commercial customers used the most water.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/vietwater.jpg&#34; alt=&#34;Viet Water conference 2018&#34; title=&#34;Viet Water conference 2018&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Viet Water Conference 2018.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Load and Explore the Data
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The sample data contains a list of just over 100 readings from water meters in the city of Việt Trì, Vietnam, along with their geospatial locations. This data uses the World Geodetic System of 1984 (WGS84), compatible with Google Maps and similar systems. &lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Water consumption bubble chart&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  water &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read.csv&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/viet-tri-consumption.csv&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  water&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Consumption &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; water&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;read_new &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; water&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;read_old
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Summarise the data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;summary&lt;/span&gt;(water&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Consumption)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Consumption per connection ranges from 0 to 529 cubic metres, with an average of 23.45 cubic metres.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Visualise the data with a geographic bubble chart
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;With the &lt;a href=&#34;https://r-graph-gallery.com/324-map-background-with-the-ggmap-library.html&#34;&gt;ggmap&lt;/a&gt; extension of the ggplot package, we can visualise any spatial data set on a map. The only condition is that the spatial coordinates are in the WGS84 datum. The ggmap package adds a geographical layer to ggplot by providing a Google Maps or OpenStreetMap canvas. The first step is to download the map canvas. You need to know the centre coordinates and the zoom factor to do this. Determining the perfect zoon factor requires some trial and error. The ggmap package provides for various map types, which are described in detail in the &lt;a href=&#34;https://cran.r-project.org/web/packages/ggmap/ggmap.pdf&#34;&gt;documentation&lt;/a&gt;. You will need a &lt;a href=&#34;https://lucidmanager.org/data-science/geocoding-with-ggmap/&#34;&gt;Google Maps API&lt;/a&gt; to enable this functionality.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Plot on Google Maps&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggmap)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  api &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/google-maps.api&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Text file with the API key&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;register_google&lt;/span&gt;(key &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; api)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  centre &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mean&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;range&lt;/span&gt;(water&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon)), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mean&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;range&lt;/span&gt;(water&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lat)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  viettri &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;get_map&lt;/span&gt;(centre, zoom &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;17&lt;/span&gt;, maptype &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;hybrid&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  g &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggmap&lt;/span&gt;(viettri)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The ggmap package follows the same conventions as ggplot. We first call the map layer and then add any required geom. The point geom creates a nice bubble chart when combined with the &lt;code class=&#34;verbatim&#34;&gt;scale_size_area option&lt;/code&gt;. This option scales the points to a maximum size to ensure they are easily visible. The transparency (alpha) minimises the problem of overplotting. This last code snippet plots the map with water consumption. &lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/viet-tri-consumption.jpg&#34; alt=&#34;Water consumption in  Việt Trì&#34; title=&#34;Water consumption in  Việt Trì.&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
Water consumption in  Việt Trì.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Add data to ggmap  &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  g &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; water, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lon, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lat, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; Consumption),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                 shape &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;21&lt;/span&gt;, colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dodgerblue4&amp;#34;&lt;/span&gt;, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dodgerblue&amp;#34;&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                 alpha &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.8&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_size_area&lt;/span&gt;(max_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Size of the biggest point&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggtitle&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Việt Trì sự tiêu thụ nước&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 29: Distinct Powers</title>
      <link>https://lucidmanager.org/data-science/project-euler-29/</link>
      <pubDate>Thu, 03 Aug 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-29/</guid>
      <description>
	
&lt;p&gt;
Project Euler 29 is another permutation problem that is quite easy to solve using brute force. The now defunct MathBlog site by Kristian Edlund has a nice solution using only pen and paper.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Euler 29 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Consider all integer combinations of: $a^b$ for $2 \leq a \leq 5$ and $b \leq b \leq 5$ .&lt;/p&gt;
&lt;p&gt;
$$2^2=4, \quad 2^3 = 8, \quad 2^4 = 16, \quad 2^5 = 32$$&lt;/p&gt;
&lt;p&gt;
$$3^2 = 9,\quad 3^3 = 27, \quad 3^4 = 81,\quad 3^5 = 243$$&lt;/p&gt;
&lt;p&gt;
$$4^2 = 16,\quad 4^3 = 64, \quad 4^4 = 256, \quad 4^5 = 1024$$&lt;/p&gt;
&lt;p&gt;
$$5^2 = 25,\quad 5^3 = 125, \quad 5^4 = 625,\quad 5^5 = 3125$$&lt;/p&gt;
&lt;p&gt;
If they are then placed in numerical order, with any repeats removed, we get the following sequence of 15 distinct terms:&lt;/p&gt;
&lt;p&gt;
$$4, \ 8, \ 9, \ 16, \ 25, \ 27, \ 32, \ 64, \ 81, \ 125, \ 243, \ 256,\ 625, \ 1024, \ 3125$$&lt;/p&gt;
&lt;p&gt;
How many &lt;a href=&#34;https://projecteuler.net/problem=29&#34;&gt;distinct terms&lt;/a&gt; are in the sequence generated by $a^b$ for $2 \leq a \leq 100$ and $2 \leq b \leq 100$ ?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This code calculates all powers from $2^2$ to $2^{100}$ and determines the number of unique values. There is no need to use Multiple Precision Arithmetic because we are only interested in their uniqueness and not the precise value.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 29: Distinct Powers&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  target &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  terms &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (a &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;target) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (b &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;target) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      terms[i] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; a^b
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unique&lt;/span&gt;(terms))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>How Virtual Tags have transformed SCADA data analysis</title>
      <link>https://lucidmanager.org/data-science/virtual-tags/</link>
      <pubDate>Thu, 27 Jul 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/virtual-tags/</guid>
      <description>
	
&lt;p&gt;
Yesterday, I delivered the International Keynote at the &lt;a href=&#34;https://web.archive.org/web/20180226010343/https://www.conferenz.co.nz/events/asset-data-insights-conference&#34;&gt;Asset Data &amp;amp; Insights Conference&lt;/a&gt; in Auckland, New Zealand (the place where R was initially developed). My talk was about creating value from CADA data using a method I developed with my colleagues called &amp;#34;Virtual Tags.&amp;#34; My address started with my views on data science strategy, which I also presented to the &lt;a href=&#34;https://lucidmanager.org/data-science/strategic-data-science/&#34;&gt;R User Group&lt;/a&gt; in Melbourne. In this post, I would like to explain what Virtual Tags are and how they can be used to improve the value of &lt;a href=&#34;https://www.researchgate.net/publication/326533741_Health-Based_Targets_Performance_Reporting_Using_Virtual_SCADA_Tags_to_Facilitate_Data_Aalysis&#34;&gt;SCADA data&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
SCADA Systems at Water Treatment Plants
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Water treatment plants are mostly fully automated, using analysers and the SCADA system to communicate this data. For those of you not familiar with water treatment plants, the video below gives a cute summary of the process.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/rj44AkHmVCo?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Water Treatment — SCADA Plant IQ
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Water treatment plants rely on sensors to track a broad range of parameters. These instruments capture data around the clock, supporting real-time operational decisions. When everything runs smoothly, all values stay within a precise band. Typically, these values are archived by the SCADA system for a year, then purged to manage storage needs.&lt;/p&gt;
&lt;p&gt;
Turbidity measurements—essentially a gauge of water clarity—help assess filtration effectiveness at water treatment plants. Below, you’ll find a code snippet simulating five hours of turbidity readings from one such instrument. Most of the time, these water quality values follow a log-normal distribution and cluster tightly together, making them ideal for precise monitoring.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Virtual tag simulation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Generate turbidity measurements&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;set.seed&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1234&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;300&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  wtp &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(timestamp &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq.POSIXt&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ISOdate&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1910&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;), length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; n, by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    turbidity &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rlnorm&lt;/span&gt;(n, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;log&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.1&lt;/span&gt;), &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.01&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  p1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(wtp) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; timestamp, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; turbidity) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_line&lt;/span&gt;(colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;grey&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ylim&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.09&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.11&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_bw&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Turbidity simulation&amp;#34;&lt;/span&gt;, x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Timestamp&amp;#34;&lt;/span&gt;, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Turbidity&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  p1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/turbidity-simulation.png&#34; alt=&#34;Turbidity simulation&#34; title=&#34;Turbidity simulation&#34;/&gt;
&lt;figcaption&gt;
Turbidity simulation.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
SCADA Historian
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The data generated by the SCADA system is used to make operational decisions. The data is created and structured to make decisions in the present, not to solve problems in the future. SCADA Historian systems archive this information for future analysis. Historian systems only store new values when the new reading is more or less than a certain percentage of the previous one. This method saves storage space without sacrificing much accuracy.&lt;/p&gt;
&lt;p&gt;
Imagine an instrument reads 0.20, and the limit is 5%: you’ll see new values recorded only when they fall below 0.19 or above 0.21. Each subsequent value gets stored only when it deviates by 5% from the last stored point. The following code snippet brings this process to life, simulating it using earlier turbidity readings. Notice: this Historian captures and stores only the data points shown in black.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Historise using dead banding&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  threshold &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.03&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  h &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# First historised point&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  wtp&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;historised &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  wtp&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;historised&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, n)] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Testing for delta &amp;gt; threshold&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(wtp)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    delta &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; wtp&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;turbidity[i] &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; wtp&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;turbidity[h] 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (delta &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; threshold) &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; delta &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; threshold)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      wtp&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;historised[i] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      h &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  historian &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;subset&lt;/span&gt;(wtp, historised)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  p2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; p1 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; historian, 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; timestamp, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; turbidity), 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, alpha &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.5&lt;/span&gt;, color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;blue&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Historised data&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  p2&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/turbidity-historised.png&#34; alt=&#34;Historised simulated turbidity data&#34; title=&#34;Historised simulated turbidity data&#34;/&gt;
&lt;figcaption&gt;
Historised simulated turbidity data.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Virtual Tags
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This standard method for generating and storing SCADA data works well for operational systems but not for post hoc analysis. The data in Historian are unequally spaced, making them harder to analyse. Using constant interpolation, the Virtual Tag approach expands these unequal time series into an equally spaced time series.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;vt()&lt;/code&gt; function undertakes the constant interpolation using the &lt;a href=&#34;https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/approxfun&#34;&gt;approx function&lt;/a&gt;. The function &lt;code class=&#34;verbatim&#34;&gt;vt&lt;/code&gt; is applied to all the &lt;code class=&#34;verbatim&#34;&gt;DateTime&lt;/code&gt; values using the historised data points. The red line shows how the value is constant until it jumps by more than 5%. This example demonstrates that we have a steady process with some minor spikes, which is the expected outcome of this simulation.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Virtual Tags extrapolation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  vt &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(t) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;approx&lt;/span&gt;(historian&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;timestamp, historian&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;turbidity, xout &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; t, method &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;constant&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  turbidity &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lapply&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.data.frame&lt;/span&gt;(wtp&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;timestamp), vt)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  wtp&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;virtual_tag &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; turbidity[[1]]&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  p3 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; p2 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_line&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; wtp,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; timestamp, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; virtual_tag), colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggtitle&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Virtual Tags&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  p3&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/turbidity-virtual-tags.png&#34; alt=&#34;Virtual tags for the simulated data&#34; title=&#34;Virtual tags for the simulated data&#34;/&gt;
&lt;figcaption&gt;
Virtual tags for the simulated data.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The next step in Virtual Tags is to combine tags from different data points for richer insights. For instance, imagine you&amp;#39;re curious about turbidity readings only when the filter is running. By combining this data with information such as the filter&amp;#39;s valve status and flow, you can gain a clearer picture of system performance.&lt;/p&gt;
&lt;p&gt;
Although this approach may seem cumbersome at first glance, it makes analysing data from SCADA Historian much more straightforward. With Virtual Tags, you can easily access a catalogue of analytical processes that would otherwise be challenging to perform. This system also provides valuable context for your SCADA information by linking tags to one another and to the operational processes they reflect. Curious to learn more? Download the &lt;a href=&#34;http://colibanwater.github.io/HBT/&#34;&gt;technical manual&lt;/a&gt; for an in-depth look at Virtual Tags and their implementation in SQL.&lt;/p&gt;
&lt;p&gt;
Interested in solving water challenges with R code? You might enjoy the book Data Science for Water Utilities, which goes deeper into practical techniques for the field.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 28: Number Spiral Diagonals</title>
      <link>https://lucidmanager.org/data-science/project-euler-28/</link>
      <pubDate>Thu, 20 Jul 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-28/</guid>
      <description>
	
&lt;p&gt;
Project Euler 28 takes us to the world of the Ulam Spiral. This is a spiral that contains sequential positive integers in a square spiral, marking the prime numbers. Stanislaw Ulam discovered that a lot of primes are located along the diagonals. These diagonals can be described as polynomials. The Ulam Spiral is thus a method to generate quadratic primes (&lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-27/&#34;&gt;Euler Problem 27&lt;/a&gt;).&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://upload.wikimedia.org/wikipedia/commons/3/3c/Ulam_spiral_howto_primes_only.svg&#34; alt=&#34;Ulam Spiral&#34; title=&#34;Ulam Spiral&#34; width=&#34;200&#34;/&gt;
&lt;figcaption&gt;
Ulam spiral (Wikimedia).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 28 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Starting with the number 1 and moving to the right in a clockwise direction, a 5 by 5 spiral is formed as follows:&lt;/p&gt;
&lt;div class=&#34;center-block&#34; style=&#34;text-align: center; margin-left: auto; margin-right: auto;&#34;&gt;
&lt;div class=&#34;src src-text&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;21  22  23  24  25
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;20   7   8   9  10
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;19   6   1   2  11
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;18   5   4   3  12
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;17  16  15  14  13&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
It can be verified that the sum of the numbers on the diagonals is 101.&lt;/p&gt;
&lt;p&gt;
What is the &lt;a href=&#34;https://projecteuler.net/problem=28&#34;&gt;sum of the numbers on the diagonals&lt;/a&gt; in a 1001 by 1001 spiral formed in the same way?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To solve this problem, we do not need to create a matrix. This code calculates the values of the corners of a matrix with size \(n\). The lowest number in the matrix with size \(n\) is \(n(n-3)+4\). The numbers increase by \(n-1\) . The code steps through all matrices from size 3 to 1001. The solution uses only the uneven sized matrices because these have a centre. The answer to the problem is the sum of all numbers.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 28: Number Spiral Diagonals&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  size &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1001&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Size of matrix&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Starting number&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Define corners of subsequent matrices&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (n &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(from &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, to &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; size, by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      corners &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(from &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; answer &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(corners)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Plotting the Ulam Spiral
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;We can go beyond Euler Problem 28 and play with the mathematics. This code snippet plots all the prime numbers in the Ulam Spiral. Watch the Numberphile video for an explanation of the patterns that appear along the diagonals.&lt;/p&gt;
&lt;p&gt;
The code creates a matrix of the required size and fills it with the Ulam Spiral. The system then identifies all primes using the &lt;code class=&#34;verbatim&#34;&gt;is.prime()&lt;/code&gt; function from &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-7/&#34;&gt;Euler Problem 7&lt;/a&gt;, as visualised on the top of this article.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/project-euler/problem-028.png&#34; alt=&#34;Ulam Spiral prime numbers.&#34; title=&#34;Ulam Spiral prime numbers.&#34;/&gt;
&lt;figcaption&gt;
Ulam Spiral prime numbers.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/iFuR97YcSLM?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Prime Spirals - Numberphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Prime Spirals&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;source&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;problem007.R&amp;#34;&lt;/span&gt;, verbose &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  size &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;201&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Size of matrix&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ulam &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;matrix&lt;/span&gt;(ncol &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; size, nrow &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; size)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  mid &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(size &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ulam[mid, mid] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (n &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(from &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, to &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; size, by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      numbers &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt; ((n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; ((n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      d &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; mid &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(numbers)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ulam[d, d&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(d &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; numbers&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(l &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;l]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ulam[d &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, (d &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;d] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; numbers&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; n)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ulam&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(d &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(d &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;), d] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; numbers&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(l &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; n)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(l &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ulam&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(d &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(d &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;), d &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; numbers[1&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ulam.primes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;apply&lt;/span&gt;(ulam, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;), is.prime)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(reshape2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ulam.primes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;melt&lt;/span&gt;(ulam.primes)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(ulam.primes, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; Var1, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; Var2, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; value)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_tile&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_fill_manual&lt;/span&gt;(values &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;guides&lt;/span&gt;(fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggsave&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;images/problem-028.png&amp;#34;&lt;/span&gt;, widt &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;, height &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Using the iGraph package to Analyse the Enron Corpus</title>
      <link>https://lucidmanager.org/data-science/analyse-enron-corpus/</link>
      <pubDate>Thu, 13 Jul 2017 10:00:01 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/analyse-enron-corpus/</guid>
      <description>
	
&lt;p&gt;
The Enron scandal is one of the most famous corporate governance failures in the history of capitalism. The case itself is interesting for its own sake, but in this post, I am more interested in one of the data sets that the subsequent investigation has provided. The code below show s how to analyse the Enron corpus using the R language.&lt;/p&gt;
&lt;p&gt;
This blog post analyses an extensive collection of e-mails from former Enron employees. The Enron corpus is analysed using network analysis tools provided by the &lt;a href=&#34;https://igraph.org/r/&#34;&gt;iGraph package&lt;/a&gt;. Network analysis is a versatile technique that can be used to add value to a lot of different data sets, including the complex corporate relationships of &lt;a href=&#34;https://lucidmanager.org/data-science/trumpworld-analysis/&#34;&gt;Donald Trump&lt;/a&gt;.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/jrEf8uabe7E?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
The Enron Scandal Explained in One Minute
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Enron Corpus
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Federal Energy Regulatory Commission used an extensive collection of emails from Enron employees as part of their inquiries. The Enron corpus is one of the only publicly available collections of emails available for research. This dataset also provides a fascinating playground for citizen data scientists.&lt;/p&gt;
&lt;p&gt;
The set has privacy issues as it contains messages from living people. When analysing this data set, we need to keep in mind that the majority of former Enron employees were innocent people who lost their jobs due to the greed of their overlords. The code in this post only analyses the e-mail headers, ignoring the content.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://fm.cnbc.com/applications/cnbc.com/resources/img/editorial/2014/10/13/102082546-675237.530x298.jpg&#34; alt=&#34;Laid-off Enron employees outside Enron headquarters as the company collapsed in 2001&#34; title=&#34;Laid-off Enron employees outside Enron headquarters as the company collapsed in 2001&#34;/&gt;
&lt;figcaption&gt;
Laid-off Enron employees outside Enron headquarters as the company collapsed in 2001 (Source cnbc.com).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The Enron Corpus is an extensive database of half a million emails generated by more than 100 Enron employees. You can download the corpus from the &lt;a href=&#34;https://www.cs.cmu.edu/~./enron/&#34;&gt;Carnegie Mellon School of Computer Science&lt;/a&gt;. The first code snippet downloads the 7 May 2015 version of the dataset (about 423Mb, tarred and gzipped) and untars it to your working directory. &lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/digital-humanities/&#34; target=&#34;_blank&#34;
   title=&#34;Download digital-humanities from GitHub&#34;
   alt=&#34;Download digital-humanities from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;digital-humanities&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;file.exists&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;enron_mail_20150507.tgz&amp;#34;&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;download.file&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;https://www.cs.cmu.edu/~./enron/enron_mail_20150507.tar.gz&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                     destfile &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;enron-mail-20150507.tgz&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;file.exists&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;enron-mail-20150507.tgz&amp;#34;&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;untar&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;enron-mail-20150507.tgz&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Preparing the Enron email
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The main folder is &lt;code class=&#34;verbatim&#34;&gt;maildir&lt;/code&gt;, which holds all the personal accounts. Our first task is to create a list of available emails. This code results in 517,401 e-mail files with 44,859 emails in the inboxes of users. The E-mail corpus consists of nested folders per user with each e-mail as a text file.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  emails &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;list.files&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;maildir/&amp;#34;&lt;/span&gt;, full.names &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;, recursive &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  emails &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; emails&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[grep&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;/inbox&amp;#34;&lt;/span&gt;, emails)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(emails)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The bulk of the code creates a list of emails between Enron employees. The code performs a lot of string manipulations to extract the information from the text files. The content of the e-mails is ignored, the code only retrieves the sender and the receiver. The analysis is limited to e-mails between Enron employees. The result of this code is a data frame with the usernames of the sender and receiver for each email. The data frame contains 2779 emails that meet these criteria. &lt;/p&gt;
&lt;p&gt;
The code below looks extracts all internal emails in the Inox folders. It then retrieves a lis of usernames from the e-mails. The data is cleaned by removing users without sent e-mails, and emails which users sent to themselves.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tibble)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  inboxes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      from &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;apply&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.data.frame&lt;/span&gt;(emails), &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                 &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x){&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(x, warn &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)[3]}),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      to &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; emails,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      stringsAsFactors &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  )
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Keep only enron.com and strip all but username&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(stringr) &lt;span style=&#34;color:#888&#34;&gt;# String manipulation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  inboxes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; inboxes&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;@enron.com&amp;#34;&lt;/span&gt;, inboxes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;from),]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  inboxes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;from &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_remove_all&lt;/span&gt;(inboxes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;from, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;From: |@enron.com&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  inboxes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;to &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_remove_all&lt;/span&gt;(inboxes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;to, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;maildir//|/inbox/[0-9]*.&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Create list of usernames&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  users &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(user &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;maildir/&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unique&lt;/span&gt;(inboxes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;to)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Remove those without sent mails&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  sent &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;apply&lt;/span&gt;(users, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grepl&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;sent&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dir&lt;/span&gt;(x))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  users &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;subset&lt;/span&gt;(users, sent &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Replace username with e-mail name&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  users&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;mailname &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(users)){
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      sentmail &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dir&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(users&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;user[i], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;/sent_items/&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      name &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(users&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;user[i], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;/sent_items/&amp;#34;&lt;/span&gt;, sentmail[1]), warn &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;F&lt;/span&gt;)[3]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      name &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_remove_all&lt;/span&gt;(name, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;From: |@enron.com&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      users&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;mailname[i] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; name
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  users&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;user &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;str_remove&lt;/span&gt;(users&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;user, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;maildir/&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  inboxes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;merge&lt;/span&gt;(inboxes, by.x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;to&amp;#34;&lt;/span&gt;, users, by.y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;user&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  inboxes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(from &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; inboxes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;from,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    to &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; inboxes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;mailname)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Only e-mails between users inside the corpus&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  inboxes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; inboxes[inboxes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;from &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; inboxes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;to,]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Remove no.address&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  inboxes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;subset&lt;/span&gt;(inboxes, from &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;no.address&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; to &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;no.address&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Remove emails to self&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  inboxes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;subset&lt;/span&gt;(inboxes, inboxes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;from &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; inboxes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;to)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  inboxes&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Analyse the Enron Corpus
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The last code snippet defines a &lt;a href=&#34;https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)&#34;&gt;graph&lt;/a&gt; from the table of e-mails. Each employee is a node in the network, and each e-mail is an edge (line). The iGraph package is a powerful tool to analyse networks. The &lt;code class=&#34;verbatim&#34;&gt;graph_from_edgelist&lt;/code&gt; function creates a network object that can be analysed using the iGraph package. The graph is directed because the information flows from the sender to the receiver.&lt;/p&gt;
&lt;p&gt;
In the next step, the Spingglass algorithm finds &lt;a href=&#34;https://en.wikipedia.org/wiki/Community_structure&#34;&gt;community structure&lt;/a&gt; within the data. A community is a group of nodes that are more connected with each other than with any other node.&lt;/p&gt;
&lt;p&gt;
The last step visualises the network. The diagram is drawn using the Fruchterman-Reingold algorithm, which places the most connected nodes at the centre of the picture. The background colours in the diagram indicate the eight communities.&lt;/p&gt;
&lt;p&gt;
The graph tells us a lot about the group of employees in the Enron corpus and how they relate to each other. Each of the communities represents a tightly connected group of employees that mainly e-mail each other. Any connections between communities are shown in red. When the &lt;code class=&#34;verbatim&#34;&gt;vertex.label = NA&lt;/code&gt; line is removed, the usernames are displayed at each node.&lt;/p&gt;
&lt;p&gt;
We can see groups that never email each other, lonely hangers-on and tightly knit cliques within Enron. In the centre of the graph, we see a few individuals who are connectors between groups because they send a lot of emails to people outside their community. On the fringes of the graph are the hangers-on who only once or twice emailed somebody in the corpus but were still included in the investigation.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(igraph)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  g &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;graph_from_edgelist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.matrix&lt;/span&gt;(inboxes), directed &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  coms &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;spinglass.community&lt;/span&gt;(g)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;par&lt;/span&gt;(mar &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot&lt;/span&gt;(coms, g,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      vertex.label&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      layout &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; layout.fruchterman.reingold,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      vertex.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/enron-email-network.jpg&#34; alt=&#34;Enron email corpus network with communities&#34; title=&#34;Enron email corpus network with communities&#34;/&gt;
&lt;figcaption&gt;
Enron email corpus network with communities.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This analysis provides only a quick glimpse into the knowledge contained in the Enron email corpus. An extensive range of tools is available to analyse such networks. An interesting exercise would be to overlap this network with the organisation chart to see the relationships between teams. Have fun playing with this fantastic, but somewhat sensitive, data set!&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 27: Quadratic Primes</title>
      <link>https://lucidmanager.org/data-science/project-euler-27/</link>
      <pubDate>Thu, 06 Jul 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-27/</guid>
      <description>
	
&lt;p&gt;
Prime numbers are the engine of the Internet economy. There is no algorithm that can generate these numbers which makes them ideal for as encryption keys. This impossibility has not stopped mathematicians from trying to find formulas to generate prime numbers. Project Euler 27 deals with quadratic formulas that can be used to generate sets of prime numbers.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 27 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Euler discovered the remarkable quadratic formula: \(n^2+n+41\)&lt;/p&gt;
&lt;p&gt;
It turns out that the formula will produce 40 primes for the consecutive integer values \(0 \leq n \leq 39\). However, when \(n=40\), \(40^2+40+41=40(40+1)+41\) is divisible by 41, and certainly when \(n=41\), \(41^2+41+41\) is clearly divisible by 41.&lt;/p&gt;
&lt;p&gt;
The incredible formula \(n^2-79n+1601\) produces 80 primes for the consecutive values \(0 \leq n \leq 79\). The product of the coefficients, -79 and 1601, is -126479.&lt;/p&gt;
&lt;p&gt;
Considering quadratics of the form: &lt;/p&gt;
&lt;p&gt;
\(n^2 + an + b\), where \(|a| &amp;lt; 1000\) and \(|b| \leq 1000\).&lt;/p&gt;
&lt;p&gt;
\(|n|\) is the absolute value of \(n\), e.g. \(|11|=11\) and \(|-4|=4\).&lt;/p&gt;
&lt;p&gt;
Find the &lt;a href=&#34;https://projecteuler.net/problem=27&#34;&gt;product of the coefficients&lt;/a&gt;, \(a\) and \(b\), for the quadratic expression that produces the maximum number of primes for consecutive values of \(n\), starting with \(n=0\).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The only way to solve this problem is through brute force and search for all possible combinations for \(a\) and \(b\). Without reducing the search space, that would mean testing four million options. We need to reduce the solution space to achieve a manageable running speed.&lt;/p&gt;
&lt;p&gt;
Because the outcome of the equation must be prime for \(n = 0\), \(b\) also has to be prime. We can use the prime sieve from &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-3/&#34;&gt;Euler Problem 3&lt;/a&gt; to use only prime numbers from 2 to 1000, which reduces it from 2000 to 168 permutations. &lt;/p&gt;
&lt;p&gt;
When we insert \(n = 1\), it follows that \(a\) has to be an even number. If \(1+a+b\) has to be prime and \(b\) is a prime number, then \(a\) can only be an odd number. However, when \(b = 2\), \(a\), also has to be even.&lt;/p&gt;
&lt;p&gt;
We can use these deliberations to write some code to solve this problem. We cycle through \(a\) and \(b\) and increment a counter every time we find a prime number. The &lt;code class=&#34;verbatim&#34;&gt;is.prime()&lt;/code&gt; function from &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-7/&#34;&gt;Project Euler 7&lt;/a&gt; helps to identify whether a number is prime.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 27: Quadratic Primes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;source&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;problem007.R&amp;#34;&lt;/span&gt;, verbose &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  seq.a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-999&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1001&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# a has to be odd&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  seq.b &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;esieve&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;)) &lt;span style=&#34;color:#888&#34;&gt;# b has to be prime&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  max.n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (a &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; seq.a) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (b &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; seq.b) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Find sequence of primes for a and b&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;is.prime&lt;/span&gt;(n^2 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; a &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; b)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Store maximum values&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; max.n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        max.n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; n
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        max.a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; a
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        max.b &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; b
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; max.a &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; max.b
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Test the answer&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(max.count &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(n^2 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; max.a &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; max.b, is.prime)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 26: Reciprocal Cycles</title>
      <link>https://lucidmanager.org/data-science/project-euler-26/</link>
      <pubDate>Thu, 29 Jun 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-26/</guid>
      <description>
	
&lt;p&gt;
Project Euler 26 delves into a topic many kids in primary school dread: fractions. A few years ago, a fraction broke the internet. What happens when you divide 1 by 998001?&lt;/p&gt;
&lt;p&gt;
$$\frac{1}{998001} = 0.000001002003004005006007008009010011012013014015 \ldots$$&lt;/p&gt;
&lt;p&gt;
What is unique about this fraction is that it lists every three-decimal number except for 998. Look carefully at the sequence to see that is 000, 001, 0002, 003, 004, 005 and so on. After it has reached 999, the sequence continues from the start. This fraction thus has 2997 recurring decimals. James Grime from Numberphile explains this mathematical oddity with his usual enthusiasm.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/daro6K6mym8?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
998,001 and its Mysterious Recurring Decimals - Numberphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The decimal fraction of 1/998001 is a recurring decimal. These are decimal numbers with periodic digits (repeating its values at regular intervals). &lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-033/&#34;&gt;Project Euler 33&lt;/a&gt; is also about fractions and asks us to analyse recurring decimals (reciprocal cycles) and Ford Circles.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 26 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:&lt;/p&gt;
&lt;p&gt;
1/2 = 0.5&lt;/p&gt;
&lt;p&gt;
1/3 = 0.(3) &lt;/p&gt;
&lt;p&gt;
1/4 = 0.25 &lt;/p&gt;
&lt;p&gt;
1/5 = 0.2 &lt;/p&gt;
&lt;p&gt;
1/6 = 0.1(6) &lt;/p&gt;
&lt;p&gt;
1/7 = 0.(142857) &lt;/p&gt;
&lt;p&gt;
1/8 = 0.125 &lt;/p&gt;
&lt;p&gt;
1/9 = 0.(1) &lt;/p&gt;
&lt;p&gt;
1/10 = 0.1 &lt;/p&gt;
&lt;p&gt;
Where 0.1(6) means 0.166666… and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle. Find the value of d &amp;lt; 1000 for which 1/d contains the &lt;a href=&#34;https://projecteuler.net/problem=26&#34;&gt;longest recurring cycle&lt;/a&gt; in its decimal fraction part.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://oeis.org/A051626&#34;&gt;Sequence A051626&lt;/a&gt; in the On-Line Encyclopaedia of Integer Sequences describes the length of the recurring numbers in 1/n. To solve Euler Problem 26, we need to generate the first 1000 numbers of this sequence and find out which number has the longest recurring cycle.&lt;/p&gt;
&lt;p&gt;
R can only display up to 22 decimals by using &lt;code class=&#34;verbatim&#34;&gt;options(digits=22)&lt;/code&gt;. The base R capability is unsuitable for solving this problem, so I wrote some code to perform long division the old-fashioned way.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;recur()&lt;/code&gt; function divides 1 by any arbitrary integer. The code continues until the decimal terminates, for example 1/4 = 0.25, or when a recurring pattern emerges, e.g. 1/7 = 0.(142857).&lt;/p&gt;
&lt;p&gt;
The function has two arguments: &lt;code class=&#34;verbatim&#34;&gt;n&lt;/code&gt; is the input number. The output argument determines the outcome of the function: “=len=” for the length of the recurring decimals. Any other value shows the result of the calculation. The output of the function is a string. Using the European notation, the recurring part of the decimals is shown between brackets, e.g. 1/14 = 0.0(714285).&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 26: Reciprocal Cycles&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  recur &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x, output &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Prepare variable&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NaN&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt;(x))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Initiate vectors to store decimals and remainders&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      dec &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      rem &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Initiate values&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      r &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      rem &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; r
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Long division&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;repeat&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          dec[i] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(r &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; x)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          r &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (r &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; x)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#888&#34;&gt;# Test wether the number is terminating or repeating&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (r &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; r &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; rem) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          rem[i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; r
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Determine number of recurring digits&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      rep &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ifelse&lt;/span&gt;(r &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(rem) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(r &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; rem) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Output&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (output &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;len&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(rep)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (rep &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (rep &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(dec)) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(dec[1&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(dec) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; rep)], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              dec &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(l, dec&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(dec) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; rep &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(dec)], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;)&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;0.&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(dec, collapse &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, sep &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  A051626 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;, recur, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;len&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which.max&lt;/span&gt;(A051626)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;recur&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;998001&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;len&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;recur&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;998001&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 25: Fibonacci number with 1000 digits</title>
      <link>https://lucidmanager.org/data-science/project-euler-25/</link>
      <pubDate>Thu, 22 Jun 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-25/</guid>
      <description>
	
&lt;p&gt;
Project Euler 25 asks us back to the Fibonacci numbers. This famous number sequence describes many natural processes, such as the patterns in this beautiful sunflower. The seeds inside the sunflower grow in a spiral pattern, and the number of spirals tends to be a Fibonacci number. This pattern is the most efficient way to pack the centre with as many seeds as possible.&lt;/p&gt;
&lt;p&gt;
Famous mathematician and father of computer science Alan Turing was fascinated by this problem until his death. In 2016, the Royal Society published a journal article that builds on his work in the Open Science journal. They collected sunflowers from &lt;a href=&#34;http://dx.doi.org/10.1098/rsos.160091&#34;&gt;citizen scientists&lt;/a&gt; from around the world and confirmed that for the majority of sunflowers, the number of spirals is a Fibonacci number. They did, however, also discover other patterns. Euler Problem 25 is a bit less poetic as it only asks to generate a huge Fibonacci number.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/DRjFV_DETKQ?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Sunflowers and Fibonacci - Numberphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 25 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Fibonacci sequence is defined by a recurrence relation:&lt;/p&gt;
&lt;p&gt;
$$F_n = F_{n-1} + F_{n-2} \quad | \quad F_1 = 1, F_2 = 1$$&lt;/p&gt;
&lt;p&gt;
The 12&lt;sup&gt;th&lt;/sup&gt; term, \(F_{12}=144\), is the first term to contain three digits.&lt;/p&gt;
&lt;p&gt;
What is the index of the first term in the Fibonacci sequence to &lt;a href=&#34;https://projecteuler.net/problem=25&#34;&gt;contain 1000 digits&lt;/a&gt;?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Large Integers in R
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;By default, numbers with more than 7 digits are shown in scientific notation in R, which reduces the accuracy of the calculation. You can change the precision of large integers with the &lt;code class=&#34;verbatim&#34;&gt;options()&lt;/code&gt; function, but R struggles with integers with more than 22 digits. This example illustrates this issue:&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;factorial&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[1] &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6.204484e+23&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;options&lt;/span&gt;(digits &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;22&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;factorial&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[1] &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;620448401733239409999872&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Finding a number with 1000 digits is a problem in R with using a special function or package. This article explains how to solve this problem using the &lt;a href=&#34;https://cran.r-project.org/web/packages/gmp/index.html&#34;&gt;GMP package&lt;/a&gt; and in base R code.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Project Euler 25 Solution in R
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;We have already seen various ways to generate Fibonacci numbers in R using a recursive function, a while loop and the GMP library in &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-2/&#34;&gt;Euler Problem 2&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Arbitrary-Precision Arithmetic
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The first solution uses the GMP package to manage large integers. This package implements the GNU Multiple Precision Arithmetic Library for working with huge numbers. This package also contains a function to generate Fibonacci numbers. This solution cycles through the Fibonacci sequence until it finds a number with 1000 digits.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 25: Fibonacci number with 1000 digits&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; &lt;span style=&#34;color:#888&#34;&gt;## GNU Multiple Precision Arithmetic Library&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(gmp) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  fib &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(fib)) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      fib &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;fibnum&lt;/span&gt;(answer) &lt;span style=&#34;color:#888&#34;&gt;# Determine next Fibonacci number&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; answer &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
R-base code
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;This is a very fast solution but my aim is to solve the first 100 Project Euler problems using only base-R code. The &lt;code class=&#34;verbatim&#34;&gt;big.add()&lt;/code&gt; function I developed to solve &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-13/&#34;&gt;Euler Problem 13&lt;/a&gt; uses only basic R to add large numbers. This function multiplies large numbers in the same way you would do on a piece of paper. This code to solve Euler Problem 25 is much slower than the GMP library but it was fun to develop.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Base-R Solution&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  fib &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# First Fibonaci number&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  cur &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Current number in sequence&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  pre &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Previous number in sequence&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(fib) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      fib &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;big.add&lt;/span&gt;(cur, pre) &lt;span style=&#34;color:#888&#34;&gt;# Determine next Fibonacci number&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      pre &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; cur
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      cur &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; fib
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; answer &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 24: Lexicographic Permutations</title>
      <link>https://lucidmanager.org/data-science/project-euler-24/</link>
      <pubDate>Thu, 15 Jun 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-24/</guid>
      <description>
	
&lt;p&gt;
Project Euler 24 asks to develop lexicographic permutations. These are ordered arrangements of objects in lexicographic order. Tushar Roy of Coding Made Simple has shared a great introduction on how to generate lexicographic permutations.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/nYFd7VHKyWQ?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
String Permutation Algorithm.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 24 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are:&lt;/p&gt;
&lt;p&gt;
$$012 \quad 021 \quad 102 \quad 120 \quad 201 \quad 210$$&lt;/p&gt;
&lt;p&gt;
What is the &lt;a href=&#34;https://projecteuler.net/problem=24&#34;&gt;millionth lexicographic permutation&lt;/a&gt; of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The digits 0 to 9 have $10! = 362880$  permutations (including combinations that start with 0). Most of these permutations are, however, not in lexicographic order. A brute-force way to solve the problem is to determine the next lexicographic permutation of a number string and repeat this one million times.
This code takes the following steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Find largest index $i$ such that$a_{i-1} &amp;lt; a_i$.&lt;/li&gt;
&lt;li&gt;If no such index exists, then this is already the last permutation.&lt;/li&gt;
&lt;li&gt;Find largest index $j$ such that $j \geq i$ and $a_j &amp;gt; a_{i-1}$.&lt;/li&gt;
&lt;li&gt;Swap $a_j$  and $a_{i-1}$.&lt;/li&gt;
&lt;li&gt;Reverse the suffix starting at $a_i$.&lt;/li&gt;
&lt;/ul&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;


&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 24: Lexicographic permutations&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  nextPerm &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(a) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Find longest non-increasing suffix&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(a)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (i &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; a[i &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;=&lt;/span&gt; a[i])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# i is the head index of the suffix&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Are we at the last permutation?&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# a[i - 1] is the pivot&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Frind rightmost element that exceeds the pivot&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      j &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(a)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (a[j] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; a[i &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;]) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          j &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; j &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Swap pivot with j&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      temp &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; a[i &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      a[i &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; a[j]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      a[j] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; temp
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Reverse the suffix&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      a[i&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(a)] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rev&lt;/span&gt;(a[i&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(a)])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(a)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  numbers &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1E6&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)) numbers &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nextPerm&lt;/span&gt;(numbers)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(numbers, collapse &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Combinatorics
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;A more efficient solution is to use combinatorics, thanks to the now defunct &lt;em&gt;MathBlog&lt;/em&gt;. The last nine digits can be ordered in 9! = 362880 ways. So the first 9! permutations start with a 0. By extending this thought, it follows that the millionth permutation must start with a 2.&lt;/p&gt;
&lt;p&gt;
$$\lfloor (1000000 - 1) / 9 ! \rfloor  = 2$$&lt;/p&gt;
&lt;p&gt;
From this rule, it follows that the 725761&lt;sup&gt;st&lt;/sup&gt; permutation is 2,013,456,789. We now need 274,239 more lexicographic permutations:&lt;/p&gt;
&lt;p&gt;
$$(1000000 - 1) - (2 \times 9!) = 274239$$&lt;/p&gt;
&lt;p&gt;
We can repeat this logic to find the next digit. The last 8 digits can be ordered in 40320 ways. The second digit is the 6th digit in the remaining numbers, which is 7 (2013456789).&lt;/p&gt;
&lt;p&gt;
$$\lfloor 274239 / 8 ! \rfloor  = 6$$&lt;/p&gt;
&lt;p&gt;
$$274239 - (6 \times 7 !) = 32319$$&lt;/p&gt;
&lt;p&gt;
This process is repeated until all digits have been used.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  numbers &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(numbers)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;(length &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  remain &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1E6&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      j &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(remain &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;factorial&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; i))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      answer[i] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; numbers[j &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      remain &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; remain &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;factorial&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; i)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      numbers &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; numbers[&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;(j &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(answer, collapse &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Tic Tac Toe Simulation: The Intelligent Minimax Algorithm</title>
      <link>https://lucidmanager.org/data-science/tic-tac-toe-war-games/</link>
      <pubDate>Thu, 08 Jun 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/tic-tac-toe-war-games/</guid>
      <description>
	
&lt;p&gt;
One of my favourite movies is &lt;em&gt;WarGames&lt;/em&gt;. One of the most memorable scenes is where the protagonist tries to teach the out-of-control AI that a nuclear war is unwinnable with a Tic Tac Toe simulation.&lt;/p&gt;
&lt;p&gt;
Tic Tac Toe might be a futile children&amp;#39;s game but it can also teach us about artificial intelligence. Tic Tac Toe, or Noughts and Crosses, is a &lt;a href=&#34;https://en.wikipedia.org/wiki/Zero-sum_game&#34;&gt;zero-sum game&lt;/a&gt; with perfect information. Both players have full information about each other. When nobody makes a mistake, the game always ends in a draw.&lt;/p&gt;
&lt;p&gt;
This article describes how to self-playing game of Tic Tac Toe, complete with a graphical interface, in the R language. This article is part of a series about &lt;a href=&#34;https://lucidmanager.org/tags/r-games/&#34;&gt;computer games&lt;/a&gt; in the R Language.&lt;/p&gt;
&lt;p&gt;
The first two parts of the article describe how to create the user interface and add a human player. The second part delves into creating computer players. My ultimate aim is to recreate this iconic scene in the &lt;em&gt;&lt;a href=&#34;https://www.youtube.com/watch?v=F7qOV8xonfY&#34;&gt;WarGames&lt;/a&gt;&lt;/em&gt; movie.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/F7qOV8xonfY?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Tic Tac Toe With Joshua (1983).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/RGames/&#34; target=&#34;_blank&#34;
   title=&#34;Download RGames from GitHub&#34;
   alt=&#34;Download RGames from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;RGames&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Game Board
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This first code snippet draws the Tic Tac Toe simulation board. The variable &lt;code class=&#34;verbatim&#34;&gt;xo&lt;/code&gt; holds the identity of the pieces and the vector &lt;code class=&#34;verbatim&#34;&gt;board&lt;/code&gt; holds the current game. The game board is a vector of length nine consisting of either -1 (X), 0 (empty field) or 1 (O). The vector indices correspond with locations on the game board:&lt;/p&gt;
&lt;div class=&#34;center-block&#34; style=&#34;text-align: center; margin-left: auto; margin-right: auto;&#34;&gt;
&lt;div class=&#34;src src-text&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;1 2 3
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;4 5 6
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;7 8 9&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The second part of the code checks for three in a row and draws the corresponding line.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Tic Tac Toe Simulation in the R language&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Peter Prevos&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## lucidmanager.org&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  draw.board &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(game) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      xo &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;X&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;O&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Symbols&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;par&lt;/span&gt;(mar &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot.new&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot.window&lt;/span&gt;(xlim &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;), ylim &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abline&lt;/span&gt;(h &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;), col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;darkgrey&amp;#34;&lt;/span&gt;, lwd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abline&lt;/span&gt;(v &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;), col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;darkgrey&amp;#34;&lt;/span&gt;, lwd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;text&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;25&lt;/span&gt;), &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;25&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;)), 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           xo[game &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;], cex &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Identify location of any three in a row&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      square &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;matrix&lt;/span&gt;(game, nrow &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, byrow &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      hor &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rowSums&lt;/span&gt;(square))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;any&lt;/span&gt;(hor &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;)) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          hor &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(hor &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          hor &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      ver &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;colSums&lt;/span&gt;(square))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;any&lt;/span&gt;(ver &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;)) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          ver &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(ver &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          ver &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      diag1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;diag&lt;/span&gt;(square))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      diag2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;diag&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;t&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;apply&lt;/span&gt;(square, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;, rev)))) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Draw winning lines &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;all&lt;/span&gt;(hor &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; hor)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lines&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(i, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;), lwd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;, col&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;all&lt;/span&gt;(ver &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; ver)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lines&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(i, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;), lwd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;, col&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt;(diag1) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lines&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;28&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;28&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;), lwd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt;(diag2) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lines&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;28&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;28&lt;/span&gt;), lwd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Human Player
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This second code snippet lets a human player move by clicking anywhere on the graphic display using the &lt;a href=&#34;https://www.rdocumentation.org/packages/graphics/versions/3.6.2/topics/locator&#34;&gt;locator&lt;/a&gt; function. The click location is converted to a number to denote the position on the board. The entered field is only accepted if it has not yet been used (the &lt;code class=&#34;verbatim&#34;&gt;empty&lt;/code&gt; variable contains the available fields).&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;move.human &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(game) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;text&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Click on screen to move&amp;#34;&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;grey&amp;#34;&lt;/span&gt;, cex&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.7&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    empty &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(game &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    move &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;move &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; empty) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        coords &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;locator&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# add lines&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt;(coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt;(coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        move &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;x &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; coords&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;y)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(move)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Computer Player
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The computer uses a modified &lt;a href=&#34;https://en.wikipedia.org/wiki/Minimax&#34;&gt;Minimax Algorithm&lt;/a&gt; to determine its next move. This article from the &lt;a href=&#34;https://neverstopbuilding.com/minimax&#34;&gt;Never Stop Building&lt;/a&gt; blog explains this method in great detail.&lt;/p&gt;
&lt;p&gt;
If the computer moves first, the algorithm takes a while because of the large number of permutations. There
are &lt;a href=&#34;http://www.se16.info/hgb/tictactoe.htm&#34;&gt;255,168 possible legal games&lt;/a&gt; in Tic Tac Toe, 46,080 (18%) of which end in a draw.&lt;/p&gt;
&lt;p&gt;
The code for this part is contributed by a reader (see comments below).  I originally made a mistake in the recurring function and Alberto was so kind to contribute a correct version.&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;ganador&lt;/em&gt; (Spanish for winning) function assesses the board condition by assigning -10 or + 10 for a winning game and 0 for any other situation.&lt;/p&gt;
&lt;p&gt;
The minimax function returns a list with the move and its valuation through the ganador function. The function calls itself until it has filled the board and retains the best scoring move using the minimax method. Random variables are added to avoid the computer always playing the same move in the same situation.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Minimax code by Alberto C.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ganador &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(juego, player) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    game &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;matrix&lt;/span&gt;(juego, nrow &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, byrow &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#007020&#34;&gt;T&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    hor &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rowSums&lt;/span&gt;(game)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ver &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;colSums&lt;/span&gt;(game)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    diag &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;diag&lt;/span&gt;(game)), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;diag&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;apply&lt;/span&gt;(game, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, rev))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-3&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(hor, ver, diag))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(hor, ver, diag))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;minimax &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(juego, player) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    free &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(juego &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(free) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        juego[free] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; player
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;list&lt;/span&gt;(move &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; free, U &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ganador&lt;/span&gt;(juego, player)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    poss.results &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt;(i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; free) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        game &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; juego
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        game[i] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; player
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        poss.results[i] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ganador&lt;/span&gt;(game, player)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mm &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ifelse&lt;/span&gt;(player &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;which.min&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;which.max&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;any&lt;/span&gt;(poss.results &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; (player &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;))) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        move &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;do.call&lt;/span&gt;(mm, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;list&lt;/span&gt;(poss.results))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;list&lt;/span&gt;(move &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; move, U &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; poss.results[move]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt;(i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; free) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        game &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; juego
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        game[i] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; player
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        poss.results[i] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;minimax&lt;/span&gt;(game, &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;player)&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;U
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    random &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;runif&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    poss.results[&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;free] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;player
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    poss.results &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; poss.results &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; (player &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; random)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    move &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;do.call&lt;/span&gt;(mm, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;list&lt;/span&gt;(poss.results))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;list&lt;/span&gt;(move &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; move, U &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; poss.results[move]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Play Tic Tac Toe
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The last bit of code defines a function to play the game. Each layer can be either a human or a computer. The function loops while there are still empty spots on the board and no winner is declared.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;tic.tac.toe &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(player1 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;human&amp;#34;&lt;/span&gt;, player2 &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;computer&amp;#34;&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    game &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Empty board&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    winner &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Define winner&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    player &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# First player&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    players &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(player1, player2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;draw.board&lt;/span&gt;(game)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; game &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; winner &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) { &lt;span style=&#34;color:#888&#34;&gt;# Keep playing until win or full board&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (players&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;(player &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;human&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Human player&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            move &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;move.human&lt;/span&gt;(game)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; { &lt;span style=&#34;color:#888&#34;&gt;# Computer player&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            move &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;minimax&lt;/span&gt;(game, player)[[1]]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        game[move] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; player &lt;span style=&#34;color:#888&#34;&gt;# Change board&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;draw.board&lt;/span&gt;(game)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        winner &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ganador&lt;/span&gt;(game, player)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        player &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;player &lt;span style=&#34;color:#888&#34;&gt;# Change player&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (winner &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;text&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt; , &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;DRAW&amp;#34;&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, cex &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tic.tac.toe&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Wargames Tic Tac Toe Simulation
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Now all elements are in place to recreate the simulation in the &lt;em&gt;Wargames&lt;/em&gt; movie. The animation package helps to create an animated gif where the computer keeps playing itself. All games end in a draw.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/rgames/wargames.gif&#34; alt=&#34;Wargames Tic Tac Toe simulation&#34; title=&#34;Wargames Tic Tac Toe simulation&#34;/&gt;
&lt;figcaption&gt;
Wargames Tic Tac Toe simulation.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 23: Non-Abundant Sums</title>
      <link>https://lucidmanager.org/data-science/project-euler-23/</link>
      <pubDate>Thu, 01 Jun 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-23/</guid>
      <description>
	
&lt;p&gt;
Project Euler 23 asks us to solve a problem with abundant or excessive numbers. These are numbers for which the sum of its proper divisors is higher than the number itself.&lt;/p&gt;
&lt;p&gt;
Twelve is an abundant number because the sum of its proper divisors (the aliquot sum) is larger than 12: (1 + 2 + 3 + 4 + 6 = 16). All highly composite numbers or anti-primes greater than six are abundant numbers. These numbers have so many divisors that they are the opposite of primes.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/2JM2oImb9Qg?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
5040 and other Anti-Prime Numbers - Numberphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 23 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is less than n and it is called abundant if this sum exceeds n.&lt;/p&gt;
&lt;p&gt;
As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the lowest number that can be written as the sum of two abundant numbers is 24. By mathematical analysis, it can be shown that all integers greater than 28123 can be written as the sum of two abundant numbers. However, this upper limit cannot be reduced any further by analysis, even though it is known that the highest number that cannot be expressed as the sum of two abundant numbers is less than this limit.&lt;/p&gt;
&lt;p&gt;
Find the &lt;a href=&#34;https://projecteuler.net/problem=23&#34;&gt;sum of all the positive integers&lt;/a&gt; which cannot be written as the sum of two abundant numbers.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This solution recycles the divisors function that determines the proper divisors for a number, introduced for &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-21/&#34;&gt;Euler Problem 21&lt;/a&gt;. The first code snippet creates the sequence of all abundant numbers up to 28123 (&lt;a href=&#34;https://oeis.org/A005101&#34;&gt;sequence A005101&lt;/a&gt; in the OEIS). An abundant number is one where its aliquot sum (sum of proper divisors) is larger than itself.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 23: Non-Abundant Sums&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;source&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;project-euler-021.R&amp;#34;&lt;/span&gt;, verbose &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  abundant &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x){
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      abundant &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (n &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          sigma &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;divisors&lt;/span&gt;(n))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (sigma &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              abundant[a] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; n
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; a &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(abundant)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The solution to this problem is provided in &lt;a href=&#34;http://oeis.org/A048242&#34;&gt;sequence A048242&lt;/a&gt; of the Online Encyclopedia of Integer Sequences. This website states that the highest number in this sequence is 20161, not 28123, as stated in the problem definition.&lt;/p&gt;
&lt;p&gt;
The second section of code creates a list of all potential numbers that are not the sum of two abundant numbers. The next bit of code sieves any sum of two abundant numbers from the list. You find the answer by adding the remaining numbers in the sequence.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  abundant &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abundant&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;28123&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  A048242 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20161&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(abundant)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (j &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; i&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(abundant)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (abundant[i] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; abundant[j] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20161&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              A048242[abundant[i] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; abundant[j]] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  A048242 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; A048242[&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;is.na&lt;/span&gt;(A048242)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(A048242)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 22: Names Scores</title>
      <link>https://lucidmanager.org/data-science/project-euler-22/</link>
      <pubDate>Thu, 25 May 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-22/</guid>
      <description>
	
&lt;p&gt;
Project Euler 22 is another trivial task that takes us to the realm of ASCII codes. ASCII is a method to convert symbols into numbers, initially invented for telegraphs. &lt;/p&gt;
&lt;p&gt;
Back in the 8-bit days, &lt;a href=&#34;https://www.asciiart.eu/&#34;&gt;ASCII art&lt;/a&gt; was a method to create images without using lots of memory. Each image consists of a collection of text characters that give the illusion of an image. &lt;/p&gt;
&lt;figure&gt;
&lt;pre class=&#34;example&#34;&gt;
        ,-&amp;#34;&amp;#34;&amp;#34;&amp;#34;&amp;#34;&amp;#34;-.        
     /\j__/\  (  \`--.    
hjw  \`@_@&amp;#39;/  _)  &amp;gt;--.`.  
    _{.:Y:_}_{{_,&amp;#39;    ) ) 
   {_}`-^{_} ```     (_/ .
&lt;/pre&gt;
&lt;figcaption&gt;
Art by Hayley Jane Wakenshaw.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Euler problem 22 is, unfortunately, a bit less poetic. This problem is similar to &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-17/&#34;&gt;Euler problem 17&lt;/a&gt; that asks to count the length of words expressing numbers.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 22 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Using &lt;code class=&#34;verbatim&#34;&gt;names.txt&lt;/code&gt;, a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetic value for each name, multiply this value by its alphabetical position in the list to obtain a name score.&lt;/p&gt;
&lt;p&gt;
For example, when the list is sorted into alphabetical order, COLIN, which is worth 3 + 15 + 12 + 9 + 14 = 53, is the 938&lt;sup&gt;th&lt;/sup&gt; name in the list. So, COLIN would obtain a score of 938 × 53 = 49714.&lt;/p&gt;
&lt;p&gt;
hat is the &lt;a href=&#34;https://projecteuler.net/problem=22&#34;&gt;total of all the name scores&lt;/a&gt; in the file?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This code reads and cleans the file and sorts the names alphabetically. The charToRaw function determines the numerical value of each character in each name. This output of this function is the hex ASCII code for each character. The letter A is number 65, so we subtract 64 from each value to get the sum total.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 22: Names Scores&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  names &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;https://projecteuler.net/project/resources/p022_names.txt&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                     warn &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  names &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;strsplit&lt;/span&gt;(names, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;,&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  names &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;[[:punct:]]&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, names)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  names &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sort&lt;/span&gt;(names)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Total Name scores&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; names) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      value &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;strsplit&lt;/span&gt;(i, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                   &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;charToRaw&lt;/span&gt;(x)) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;64&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      value &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; value &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(names&lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt;i)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; answer &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; value
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Modern computers in a globalised world don&amp;#39;t use ASCII because it cannot encode the tens of thousands of characters that are needed for the world&amp;#39;s languages. The video below explains the Unicode system to encode the world&amp;#39;s symbols.&lt;/p&gt;
&lt;figure&gt;
&lt;p&gt;&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/MijmeoH9LT4?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;figcaption&gt;
Characters, Symbols and the Unicode Miracle - Computerphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 21: Amicable Numbers</title>
      <link>https://lucidmanager.org/data-science/project-euler-21/</link>
      <pubDate>Thu, 18 May 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-21/</guid>
      <description>
	
&lt;p&gt;
Project Euler 21 takes us to the realm of amicable numbers. &lt;a href=&#34;https://oeis.org/A259180&#34;&gt;Sequence A259180&lt;/a&gt; in the OEIS lists all amicable, or friendly numbers. These are the most romantic numbers in all of maths. Amicable numbers &lt;/p&gt;
&lt;p&gt;
Recreational mathematicians love to find numbers with special properties. Other such special numbers are &amp;#39;perfect numbers&amp;#39;, which equal the sum of its proper divisors. Mathematicians have also defined sociable numbers and betrothed numbers, which are similar to amicable numbers. But perhaps these are for another Euler problem. &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-23/&#34;&gt;Euler Problem 23&lt;/a&gt; is about finding abundant numbers, which are numbers for which the sum of its proper divisors is higher than the number itself.&lt;/p&gt;
&lt;p&gt;
Amicable numbers were known to the Pythagoreans, who credited them with many mystical properties. Before we had access to computers, finding amicable numbers was a task that required a lot of patience. No algorithm can systematically generate all amicable numbers, and until 1946 only 390 pairs were known. Medieval Muslim mathematicians developed several formulas to create amicable numbers, but the only way to be complete is by using brute force.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 21 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Let \(d(n)\) be defined as the sum of proper divisors of \(n\) (numbers less than \(n\) which divide evenly into \(n\)). If \(d(a) = b\) and \(d(b) = a\), where \(a \neq b\), then \(a\) and \(b\) are an amicable pair and each of \(a\) and \(b\) are called amicable numbers.&lt;/p&gt;
&lt;p&gt;
For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore \(d(220) = 284\). The proper divisors of 284 are 1, 2, 4, 71 and 142; so, \(d(284) = 220\).&lt;/p&gt;
&lt;p&gt;
Evaluate the &lt;a href=&#34;https://projecteuler.net/problem=21&#34;&gt;sum of all the amicable numbers&lt;/a&gt; under 10000.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/fUSZBVYZdKY?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
220 and 284 (Amicable Numbers) - Numberphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The first part of the code provides for a function to list all proper divisors for a given integer &lt;code class=&#34;verbatim&#34;&gt;x&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;
The loop determines the divisors for numbers 220 to 10,000, calculates their sum and then checks if these numbers are amicable. &lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 21: Amicable Numbers&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  divisors &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    divisors &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    d &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(x))) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        divisors[d] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (i &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; x&lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt;i) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          d &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; d &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          divisors[d] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; x &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; i
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        d &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; d &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(divisors)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;220&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10000&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    div.sum &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;divisors&lt;/span&gt;(n)) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; n
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;divisors&lt;/span&gt;(div.sum)) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; div.sum &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; div.sum) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; answer &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; n
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;(&amp;#34;&lt;/span&gt;, n, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;, &amp;#34;&lt;/span&gt;, div.sum, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;)&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    } 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 20: Factorial Digit Sum</title>
      <link>https://lucidmanager.org/data-science/project-euler-20/</link>
      <pubDate>Thu, 11 May 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-20/</guid>
      <description>
	
&lt;p&gt;
Project Euler 20 is the third problem that requires special consideration for working with huge integers. In this problem, we look at factorials. These numbers are useful in combinatorics if, for example, you like to know in how many ways you can arrange a deck of cards.&lt;/p&gt;
&lt;p&gt;
The problem with computing factorials is that they are mostly vast numbers, beyond the generic capabilities of computers to process. For example, a humble pack of playing cards can be shuffled in \(52! = 80658175170943878571660636856403766975289505440883277824000000000000\) different configurations.&lt;/p&gt;
&lt;p&gt;
The largest number traditional handheld calculators can factorise is the mythical number 69. &lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/kw6l_uTakRA?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
69! - Numberphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 20 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;\(n!\) means \(n \times (n − 1) \times \ldots \times 3 \times 2 \times 1\)&lt;/p&gt;
&lt;p&gt;
For example, \(10! = 10 \times 9 \times \ldots \times 2 \times 1 = 3628800\),
and the sum of the digits in the number \(10!\) is \(3 + 6 + 2 + 8 + 8 + 0 + 0 = 27\).&lt;/p&gt;
&lt;p&gt;
Find the &lt;a href=&#34;https://projecteuler.net/problem=20&#34;&gt;sum of the digits in the number 100!&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The factorial of the number 100 contains 158 digits, which is a lot more digits than a 64-bit operating system can accurately produce. Using the standard function: &lt;code class=&#34;verbatim&#34;&gt;factorial(100) = 9.332622e+157&lt;/code&gt;. Without using a specialised algorithm, we cannot determine the sum of all digits. We need to deploy arbitrary-precision arithmetic to solve this problem.&lt;/p&gt;
&lt;p&gt;
This problem can be solved using a specialised R package and using only base-R code. Many computer languages, including R, have special libraries to deal with such large numbers. The &lt;a href=&#34;https://cran.r-project.org/web/packages/gmp/index.html&#34;&gt;GMP package&lt;/a&gt; renders this problem almost trivial.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 20: Factorial Digit Sum&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(gmp)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  digits &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;factorialZ&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  digits &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(digits)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;strsplit&lt;/span&gt;(digits, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Using base-R code
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The problem becomes more interesting when only using basic R code. I developed the big.add function to solve Euler Problem 13 through the addition of very large integers. We can extend this function to also calculate factorials. A factorial can be replaced by a series of additions, for example:&lt;/p&gt;
&lt;p&gt;
$$3! = 1 \times 2 \times 3 = (((1+1) + (1+1)) + (1+1))$$&lt;/p&gt;
&lt;p&gt;
This can be mimicked in R using the Reduce function. This function reduces a vector to a single value by recursively calling a function. &lt;code class=&#34;verbatim&#34;&gt;Reduce(&amp;#34;+&amp;#34;, rep(4, 5))&lt;/code&gt; is the same as:&lt;/p&gt;
&lt;p&gt;
$$4 \times 5 = ((((4 + 4) + 4) + 4) + 4) = 20$$&lt;/p&gt;
&lt;p&gt;
Using a loop, we can use the Reduce function to calculate a factorial, using only additions:&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Base-R Code&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;fact &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    fact &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;Reduce&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;+&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(fact, i))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(fact)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;big.factorial()&lt;/code&gt; function below implements this idea by combining the &lt;code class=&#34;verbatim&#34;&gt;big.add()&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;Reduce()&lt;/code&gt; functions to calculate large integer factorials. The function returns a value of 1, for factorial of 0 or 1. This function does not calculate the Gamma-function for fractions. For all other values, it goes through a loop from 2 to the requested factorial. The temporary values are stored in the bf variable. The code loops through the factorials by using the result of the previous Reduce call into the current one.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;source&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;problem013.R&amp;#34;&lt;/span&gt;, echo &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  big.factorial &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(x)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      bf &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              bf &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;Reduce&lt;/span&gt;(big.add, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(bf,i))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (bf)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  digits &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;big.factorial&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;strsplit&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(digits), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 19: Counting Sundays</title>
      <link>https://lucidmanager.org/data-science/project-euler-19/</link>
      <pubDate>Thu, 04 May 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-19/</guid>
      <description>
	
&lt;p&gt;
Project Euler 19 is so trivial it is almost not worth writing an article about. One exciting aspect of this problem is the naming of weekdays and deciding which day the week starts. This issue is more complicated than it sounds because data science is, in essence, not about data but about people.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 19 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;You are given the following information, but you may prefer to do some research for yourself.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;1 January 1900 was a Monday.&lt;/li&gt;
&lt;li&gt;Thirty days has September, April, June and November.&lt;/li&gt;
&lt;li&gt;All the rest have thirty-one,&lt;/li&gt;
&lt;li&gt;Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine.&lt;/li&gt;
&lt;li&gt;A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href=&#34;https://projecteuler.net/problem=19&#34;&gt;How many Sundays&lt;/a&gt; fell on the first of the month during the twentieth century (1 January 1901 to 31 December 2000)?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The problem can be quickly solved with R base code and a tiny bit faster when using the lubridate package.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 19: Counting Sundays&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Base-R&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  dates &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq.Date&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.Date&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;1901-01-01&amp;#34;&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.Date&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2000-12-31&amp;#34;&lt;/span&gt;), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;days&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  days &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;7&lt;/span&gt;, length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(dates))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(days&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[substr&lt;/span&gt;(dates, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;01&amp;#34;&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Using Lubridate&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(lubridate)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  dates &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq.Date&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.Date&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;1901-01-01&amp;#34;&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.Date&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2000-12-31&amp;#34;&lt;/span&gt;), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;months&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;wday&lt;/span&gt;(dates) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
To draw out this post a little bit further, I wrote some code to solve the problem without using any of the calendar functions in R.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Calculate from scratch&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  week.day &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (y &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1901&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2000&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (m &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;12&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          max.day &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;31&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (m &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;11&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              max.day &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#888&#34;&gt;# Leap years&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (m &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (y &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; y &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; y &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;400&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  max.day &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;29&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  max.day &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;28&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (d &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;max.day) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              week.day &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; week.day &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (week.day &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt;) week.day &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (week.day &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; d &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; answer &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Which day does the week start?
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The only aspect remotely interesting about this problem is the conversion from weekdays to numbers. In R, Monday is considered day one, which makes sense in the Christian context of Western culture. Saturday and Sunday are the weekends, the two last days of the week so they are day 6 and 7. According to international standard ISO 8601, Monday is the first day of the week. Although this is the international standard, several countries, including the United States and Canada, consider Sunday to be the first day of the week.&lt;/p&gt;
&lt;p&gt;
The international standard is biased towards Christianity. The Christian or Western world marks Sunday as their day of rest and worship. Muslims refer to Friday as their day of rest and prayer. The Jewish calendar counts Saturday—the Sabbath—as the day of rest and worship. This idea is also shared by Seventh-Day Adventists.&lt;/p&gt;
&lt;p&gt;
This Euler problem shows that data science is not only about data: it is always how people &lt;a href=&#34;https://lucidmanager.org/data-science/qualitative-data-science/&#34;&gt;interpret the world&lt;/a&gt;.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/project-euler/problem-019.png&#34; alt=&#34;First day of the week around the world.&#34; title=&#34;First day of the week around the world.&#34; width=&#34;600&#34;/&gt;
&lt;figcaption&gt;
First day of the week around the world.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## First day of the week&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  firstday &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read_csv&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/first_day.csv&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;map_data&lt;/span&gt;(map &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;world&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;full_join&lt;/span&gt;(firstday) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(long, lat, group &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; group, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; firstday)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_polygon&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_fixed&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;First day of the week&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggsave&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;images/problem-019.png&amp;#34;&lt;/span&gt;, width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;, height &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/JEyuQd-zMeg?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Where do the Days of the Week Get Their Names?
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>R-Cade Games: Simulating the Legendary Pong Game in R</title>
      <link>https://lucidmanager.org/data-science/pong/</link>
      <pubDate>Thu, 20 Apr 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/pong/</guid>
      <description>
	
&lt;p&gt;
Pong is one of the earliest &lt;a href=&#34;https://en.wikipedia.org/wiki/Arcade_game&#34;&gt;arcade games&lt;/a&gt; on the market, first released in 1972. From the day I first saw this miracle box, I wanted to know more about computers. There was something magical about being able to influence what happens on the television screen, even though the graphics left everything to t he imagintaion.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/fiShX2pTz9A?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Original Atari PONG (1972) arcade machine gameplay video.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
I learnt how to write code from the 1983 book &lt;a href=&#34;https://archive.org/details/Dr_Wackos_Guide_to_Creating_Arcade_Games&#34;&gt;Dr. C. Wacko&amp;#39;s Miracle Guide to Designing and Programming your own Atari Computer Arcade Games&lt;/a&gt;. This book explains in a very clear and humorous way how to write computer games in Atari basic. I devoured this book and spent many hours developing silly games. This article is an ode to Dr Wacko, a computer geek&amp;#39;s midlife-crisis and an attempt to replicate the software I developed thirty years ago.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/rgames/dr-wacko.jpg&#34; alt=&#34;Dr. C. Wacko&amp;#39;s Miracle Guide to Designing and Programming your own Atari Computer Arcade Games&#34; title=&#34;Dr. C. Wacko&amp;#39;s Miracle Guide to Designing and Programming your own Atari Computer Arcade Games&#34;/&gt;
&lt;figcaption&gt;
Dr. C. Wacko&amp;#39;s Miracle Guide to Designing and Programming your own Atari Computer Arcade Games
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
I showed in a other posts that R can be used for &lt;a href=&#34;https://lucidmanager.org/data-science/tic-tac-toe-war-games/&#34;&gt;board games&lt;/a&gt; or to play a &lt;a href=&#34;https://lucidmanager.org/data-science/text-adventure/&#34;&gt;text adventure&lt;/a&gt;. The question is whether we create arcade games in R. My challenge is to recreate the look and feel of 1980s arcade games, or &lt;em&gt;R-Cade&lt;/em&gt; games, using R? The code shown below simulates the legendary game of pong.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Playing Pong in R
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The code is based on the Wacko&amp;#39;s &lt;em&gt;Boing Program&lt;/em&gt; in the above-mentioned book. The R code is fully commented and speaks for itself. Please note that the animation is very clunky when you run it in &lt;a href=&#34;https://support.rstudio.com/hc/en-us/articles/200488548-Problem-with-Plots-or-Graphics-Device&#34;&gt;RStudio&lt;/a&gt;. Only the native R Terminal displays the animation correctly. &lt;/p&gt;
&lt;p&gt;
This version plays automatically with a randomiser routine to render the gameplay imperfect. The skill parameter indicates how good the computer player is between 0 and 1.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://cran.r-project.org/web/packages/beepr/index.html&#34;&gt;beepr&lt;/a&gt; library by Rasmus Bååth provides some much-needed sound.&lt;/p&gt;
&lt;p&gt;
The main issue with this code is that I have not been able to ad a human Pong player. I am not aware of a way to use continuous input in the R language. Perhaps somebody can help me perfect this little ditty. I love to know how to read real-time USB input to control the game, so we get a step closer to the first R-Cade game.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/A6ytTe8KcZ0?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
R language Pong simulation.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/RGames/&#34; target=&#34;_blank&#34;
   title=&#34;Download RGames from GitHub&#34;
   alt=&#34;Download RGames from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;RGames&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Simulating the Legendary Pong Game in R&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Sound library&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(beepr) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Game parameters&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  skill &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.87&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Skill (0-1)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  score &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  high.score &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Define playing field&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;x11&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;par&lt;/span&gt;(mar &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;), bg &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot.new&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot.window&lt;/span&gt;(xlim &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;), ylim &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lines&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;), type &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;l&amp;#34;&lt;/span&gt;, lwd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Playing field boundaries (depends on cex)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  xmin &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.5&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  xmax &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;29.4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ymin &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.5&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ymax &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;29.4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## initial position&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;25&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  y &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;25&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;points&lt;/span&gt;(x, y, pch &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;, cex &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Paddle control&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  psize &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ypaddle &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; y
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Set direction&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  dx &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;runif&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.5&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  dy &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;runif&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.5&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Game play&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; xmin &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      sound &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Silence&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;Sys.sleep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.05&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Pause screen&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;points&lt;/span&gt;(x, y, pch &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;, cex &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Erase ball&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Move ball&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; x &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; dx
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      y &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; y &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; dy
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Collision detection&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; xmax) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          dx &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;dx &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;runif&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.9&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.1&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Bounce&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; xmin) x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; xmax &lt;span style=&#34;color:#888&#34;&gt;# Boundary&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          sound &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Set sound&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (y &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; ymin &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; y &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; ymax) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (y &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; ymin) y &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; ymin
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (y &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; ymax) y &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; ymax
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          dy &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;dy &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;runif&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.9&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          sound &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Caught by paddle?&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; xmin &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; (y &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; ypaddle &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; (psize &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; y &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; ypaddle &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; (psize &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; xmin) x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; xmin
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          dx &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;dx &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;runif&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.9&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          sound &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          score &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; score &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Draw ball&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;points&lt;/span&gt;(x, y, pch &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;, cex &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (sound &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;beep&lt;/span&gt;(sound)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Move paddle&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;runif&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; skill) ypaddle &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; ypaddle &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; dy &lt;span style=&#34;color:#888&#34;&gt;# Imperfect follow&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Draw paddle&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Erase back line&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lines&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;), type &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;l&amp;#34;&lt;/span&gt;, lwd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Keep paddle in window&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (ypaddle &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; (psize &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)) ypaddle &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (psize &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (ypaddle &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; (psize &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)) ypaddle &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; (psize &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Draw paddle&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lines&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(ypaddle &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; (psize &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;), ypaddle &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; (psize &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)), type &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;l&amp;#34;&lt;/span&gt;, lwd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;beep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;text&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;GAME OVER&amp;#34;&lt;/span&gt;, cex&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  s &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ifelse&lt;/span&gt;(score &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;s&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;text&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(score, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; Point&amp;#34;&lt;/span&gt;, s), cex&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 18: Maximum Path Sum</title>
      <link>https://lucidmanager.org/data-science/project-euler-18/</link>
      <pubDate>Mon, 17 Apr 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-18/</guid>
      <description>
	
&lt;p&gt;
Project Euler 18 and 67 are identical, other than that the data in the second version is more extensive than in the first one. In this post, I kill two Eulers with one code. These two problems are logically similar to &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-15/&#34;&gt;Project Euler 15&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
These two problems concern binary trees, which is a data structure where each node has two children. A practical example of a binary tree is a pedigree chart, where each person or animal has two parents, four grandparents and so on. In this Project Euler problem, we need to navigate through such a tree.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 18 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.&lt;/p&gt;
&lt;div class=&#34;src src-text&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   3
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  7 4
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; 2 4 6
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;8 5 9 3&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
That is, 3 + 7 + 4 + 9 = 23.&lt;/p&gt;
&lt;p&gt;
Find the &lt;a href=&#34;https://projecteuler.net/problem=18&#34;&gt;maximum total&lt;/a&gt; from top to bottom of the triangle below:&lt;/p&gt;
&lt;div class=&#34;src src-text&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                            75
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                          95  64
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                        17  47  82
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                      18  35  87  10
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    20  04  82  47  65
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  19  01  23  75  03  34
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                88  02  77  73  07  63  67
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              99  65  04  28  06  16  70  92
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            41  41  26  56  83  40  80  70  33
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          41  48  72  33  47  32  37  16  94  29
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        53  71  44  65  25  43  91  52  97  51  14
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      70  11  33  28  77  73  17  78  39  68  17  57
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    91  71  52  38  17  14  91  43  58  50  2 7 2 9 48
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  63  66  04  68  89  53  67  30  73  16  69  87  40  31
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;04  62  98  27  23  09  70  98  73  93  38  53  60  04  23&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This problem seeks a maximum path sum in a binary tree. The brute force method, as indicated in the problem definition, is a very inefficient way to solve this problem. &lt;/p&gt;
&lt;p&gt;
A more efficient method is to define the maximum path layer by layer, starting at the bottom. The maximum sum of 2 + 8 or 2 + 5 is 10, the maximum sum of 4 + 5 or 4 + 9 is 13, and the last maximum sum is 15. These numbers are now placed in the next row. This process cycles until only one number is left. This algorithm solves the sample triangle into four steps:&lt;/p&gt;
&lt;p&gt;
Step 1:&lt;/p&gt;
&lt;div class=&#34;center-block&#34; style=&#34;text-align: center; margin-left: auto; margin-right: auto;&#34;&gt;
&lt;p&gt;3&lt;/p&gt;
&lt;p&gt;
7 4&lt;/p&gt;
&lt;p&gt;
2 4 6&lt;/p&gt;
&lt;p&gt;
8 5 9 3&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
Step 2:&lt;/p&gt;
&lt;div class=&#34;center-block&#34; style=&#34;text-align: center; margin-left: auto; margin-right: auto;&#34;&gt;
&lt;p&gt;3&lt;/p&gt;
&lt;p&gt;
7 4&lt;/p&gt;
&lt;p&gt;
10 13 15&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
Step 3:&lt;/p&gt;
&lt;div class=&#34;center-block&#34; style=&#34;text-align: center; margin-left: auto; margin-right: auto;&#34;&gt;
&lt;p&gt;3&lt;/p&gt;
&lt;p&gt;
20 19&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
Step 4:&lt;/p&gt;
&lt;div class=&#34;center-block&#34; style=&#34;text-align: center; margin-left: auto; margin-right: auto;&#34;&gt;
&lt;p&gt;23&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
In the code below, the data is a triangle matrix. The variables &lt;code class=&#34;verbatim&#34;&gt;rij&lt;/code&gt; (row) and &lt;code class=&#34;verbatim&#34;&gt;kol&lt;/code&gt; (column) drive the search for the maximum path. The triangle for Euler Problem 18 is manually created, and the triangle for Euler Problem 67 is read from the website.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 18: Maximum Path Sum&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  path.sum &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(triangle) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (rij &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(triangle)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (kol &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ncol&lt;/span&gt;(triangle)&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              triangle[rij &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;,kol] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(triangle[rij,kol&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(kol &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)]) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; triangle[rij &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, kol]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          triangle[rij,] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(triangle, na.rm &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;matrix&lt;/span&gt;(ncol &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;, nrow &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[1,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;75&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[2,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;95&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;64&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[3,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;17&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;47&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;82&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[4,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;18&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;35&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;87&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[5,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;04&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;82&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;47&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;65&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[6,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;01&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;23&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;75&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;03&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;34&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[7,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;7&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;88&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;02&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;77&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;73&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;07&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;63&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;67&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[8,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;99&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;65&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;04&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;28&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;06&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;16&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;70&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;92&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[9,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;41&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;41&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;26&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;56&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;83&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;40&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;80&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;70&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;33&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[10,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;41&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;48&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;72&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;33&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;47&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;32&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;37&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;16&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;94&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;29&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[11,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;11&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;53&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;71&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;44&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;65&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;25&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;43&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;91&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;52&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;97&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;51&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;14&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[12,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;12&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;70&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;11&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;33&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;28&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;77&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;73&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;17&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;78&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;39&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;68&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;17&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;57&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[13,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;13&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;91&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;71&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;52&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;38&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;17&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;14&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;91&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;43&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;58&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;50&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;27&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;29&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;48&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[14,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;14&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;63&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;66&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;04&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;68&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;89&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;53&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;67&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;73&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;16&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;69&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;87&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;40&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;31&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle[15,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;04&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;62&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;98&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;27&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;23&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;09&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;70&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;98&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;73&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;93&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;38&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;53&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;04&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;23&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;path.sum&lt;/span&gt;(triangle)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Project Euler 67
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The solution for &lt;a href=&#34;https://projecteuler.net/problem=67&#34;&gt;problem number 67&lt;/a&gt; is exactly the same. The data is read directly from the Project Euler website.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle.file &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read.delim&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;https://projecteuler.net/project/resources/p067_triangle.txt&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                              stringsAsFactors &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;, header &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  triangle.67 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;matrix&lt;/span&gt;(nrow &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, ncol &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      triangle.67[i,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;i] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;strsplit&lt;/span&gt;(triangle.file[i,], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;path.sum&lt;/span&gt;(triangle.67)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This video visualises the quest for the maximum path as a brute-force solution, which takes eleven minutes of hypnotic animation.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/z-AOWBztnpI?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Maximum path sum.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 17: Number Letter Counts</title>
      <link>https://lucidmanager.org/data-science/project-euler-17/</link>
      <pubDate>Thu, 23 Mar 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-17/</guid>
      <description>
	
&lt;p&gt;
Project Euler 17 asks to count the letters in numbers written as words. This is a skill we all learnt in primary school mainly useful when writing cheques—to those that still use them. The principle for this problem is similar to &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-22/&#34;&gt;Project Euler 22&lt;/a&gt;, which analyses given names.&lt;/p&gt;
&lt;p&gt;
Each language has its own rules for writing numbers. My native language Dutch has very different logic to English. Both Dutch and English use compound words after the number twelve.&lt;/p&gt;
&lt;p&gt;
Linguists have theorised this is evidence that early Germanic numbers were duodecimal. The importance of a “dozen” as a counting word and the twelve hours in the clock support this idea. There is even a Dozenal Society that promotes the use of a number system based on 12.&lt;/p&gt;
&lt;p&gt;
The English language changes the rules when reaching the number 21. While we say eight-teen in English, we do no say “one-twenty”. Dutch stays consistent and the last number is always spoken first. For example, 37 in English is “thirty-seven”, while in Dutch it is written as “zevenendertig” (seven and thirty).&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 17 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, &lt;a href=&#34;https://projecteuler.net/problem=17&#34;&gt;how many letters would be used&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;
Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters, and 115 (one hundred and fifteen) contains 20 letters. The use of “and” when writing out numbers is in compliance with British usage.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The first piece of code provides a function that generates the words for numbers 1 to 999,999. This is more than the problem asks for, but it might be a useful function for another application. The last line concatenates all words and removes the spaces to count the number of letters.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 17: Number Letter Counts&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  numword.en &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;999999&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Error: Oustide my vocabulary&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Vocabulary &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      single &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;one&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;two&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;three&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;four&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;five&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;six&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;seven&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;eight&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;nine&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      teens &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;( &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;ten&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;eleven&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;twelve&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;thirteen&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;fourteen&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;fifteen&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;sixteen&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;seventeen&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;eighteen&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;nineteen&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      tens &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;ten&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;twenty&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;thirty&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;forty&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;fifty&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;sixty&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;seventy&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;eighty&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;ninety&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      numword.10 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt; (y) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; y &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              and &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ifelse&lt;/span&gt;(y &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;and&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(and, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(single, teens)[a]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(and, tens&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[floor&lt;/span&gt;(a &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)], single[a &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      numword.100 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt; (y) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(y &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(single[a], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;hundred&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      numword.1000 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(y) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(y &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;numword.100&lt;/span&gt;(a), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;numword.10&lt;/span&gt;(a), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;thousand&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      numword &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;numword.1000&lt;/span&gt;(x), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;numword.100&lt;/span&gt;(x), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;numword.10&lt;/span&gt;(x)), collapse&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;trimws&lt;/span&gt;(numword))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;, numword.en), collapse&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Writing Numbers in Dutch
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;I went beyond Euler Problem 17 by translating the code to spell numbers in Dutch. Interesting bit of trivia is that it takes 307 fewer characters to spell the numbers 1 to 1000 in Dutch than it does in English. It would be good if other people can submit functions for other languages in the comment section. Perhaps we can create an R package with a multi-lingual function for spelling numbers.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Nederlandse nummers&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  numword.nl &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;999999&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Error: Getal te hoog.&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      single &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;een&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;twee&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;drie&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;vier&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;vijf&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;zes&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;zeven&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;acht&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;negen&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      teens &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;( &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;tien&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;elf&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;twaalf&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dertien&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;veertien&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;vijftien&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;zestien&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;zeventien&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;achtien&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;negentien&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      tens &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;tien&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;twintig&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dertig&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;veertig&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;vijftig&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;zestig&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;zeventig&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;tachtig&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;negengtig&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      numword.10 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(y) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; y &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(single, teens)[a])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(single[a &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;en&amp;#34;&lt;/span&gt;, tens&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[floor&lt;/span&gt;(a &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      numword.100 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(y) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(y &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;honderd&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(single[a], &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;honderd&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      numword.1000 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(y) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(y &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;duizend &amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;numword.100&lt;/span&gt;(a), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;numword.10&lt;/span&gt;(a), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;duizend &amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      numword&lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;numword.1000&lt;/span&gt;(x), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;numword.100&lt;/span&gt;(x), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;numword.10&lt;/span&gt;(x)), collapse&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;trimws&lt;/span&gt;(numword))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  antwoord &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gsub&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;, numword.nl), collapse&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(antwoord)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 16: Power digit sum</title>
      <link>https://lucidmanager.org/data-science/project-euler-16/</link>
      <pubDate>Thu, 16 Mar 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-16/</guid>
      <description>
	
&lt;p&gt;
Project Euler 16 is reminiscent of the &lt;a href=&#34;http://trailblazernetizens.blogspot.com.au/2015/08/the-amazing-chessboard-theory.html&#34;&gt;fable of wheat and chess&lt;/a&gt;. Lahur Sessa invented the game of chess for King Iadava. The king was delighted with the game and asked Lahur to name his reward. Lahur asked the king to place one grain of rice on the first square of a chessboard, two on the next square, four on the third square and so on until the board is filled. &lt;/p&gt;
&lt;p&gt;
The king was happy with his humble request until his mathematicians worked out that it would take millions of tonnes of grain. Assuming there are 25 grains of wheat in a gramme, the last field will contain more than 461,168,602,000 tonnes of grain.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 16 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;\(2^{15} = 32768\) and the sum of its digits is \(3 + 2 + 7 + 6 + 8 = 26\). &lt;/p&gt;
&lt;p&gt;
What is the &lt;a href=&#34;https://projecteuler.net/problem=16&#34;&gt;sum of the digits&lt;/a&gt; of the number \(2^{1000}\)?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Possible Solutions
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The most straightforward solution uses the GMP package for Multiple Precision Arithmetic to calculate big integers. The &lt;code class=&#34;verbatim&#34;&gt;as.bigz()&lt;/code&gt; function results in a special class of arbitrarily large integer numbers. To add the digits, the results is converted to a string and split into numbers.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 16: Power digit sum&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(gmp)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  digits &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.bigz&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;^1000) &lt;span style=&#34;color:#888&#34;&gt;# Define number&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;strsplit&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(digits), &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
We can also solve this problem in base-R with the &lt;code class=&#34;verbatim&#34;&gt;bigg.add()&lt;/code&gt; used for &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-13/&#34;&gt;Euler Problem 13&lt;/a&gt;. This function uses basic string operations to add to arbitrarily large numbers. Raising a number to the power of two can also be written as a series of additions:&lt;/p&gt;
&lt;p&gt;
$$2^4 = 2 \times 2 \times 2 \times 2 = ((2+2)+(2+2)) + ((2+2)+(2+2))$$&lt;/p&gt;
&lt;p&gt;
The solution to this problem is to add 2 + 2 then add the outcome of that equation to itself, and so on. Repeat this one thousand times to raise the number two to the power of one thousand.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Base-R Method&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;source&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;problem013.R&amp;#34;&lt;/span&gt;, echo &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  pow &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      pow &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;big.add&lt;/span&gt;(pow, pow)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;strsplit&lt;/span&gt;(pow, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;))))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 15: Lattice Paths</title>
      <link>https://lucidmanager.org/data-science/project-euler-15/</link>
      <pubDate>Thu, 09 Mar 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-15/</guid>
      <description>
	
&lt;p&gt;
Project Euler 15 analyses taxicab geometry. This system replaces the usual distance function with the sum of the absolute differences of their Cartesian coordinates. In other words, the distance a taxi would travel in a grid plan instead of the shortest distance between two points. In chess, the distance between squares on the chessboard for rooks is measured in taxicab distance.&lt;/p&gt;
&lt;p&gt;
The fifteenth Euler problem asks to determine the number of possible routes a taxi can take in a city. This problem is logically similar to &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-18/&#34;&gt;Euler Problem 18 and 67&lt;/a&gt;.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/Pll5MXk5AMA?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Taxicab Geometry.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 15 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Starting in the top left corner of a 2 by 2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://projecteuler.net/project/images/p015.png&#34; alt=&#34;Project Euler 15: Lattice Paths&#34; title=&#34;Project Euler 15: Lattice Paths&#34; align=&#34;center&#34;/&gt;
&lt;figcaption&gt;
Project Euler 15: Lattice Paths.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
How many such &lt;a href=&#34;https://projecteuler.net/problem=15&#34;&gt;routes are there&lt;/a&gt; through a 20×20 grid?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
proposed Solutions
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The matrix to solve the problem is one larger than the number of squares in the challenge. Along the edges of the matrix, only one pathway is possible: straight to the right or down. We can calculate the number of possible paths for the other squares by adding the number to the right and below the point under consideration. The code loops through the matrix backwards, adding the number of paths step by step.&lt;/p&gt;
&lt;p&gt;
$$p_{i,j}=p_{i,j-1}+p_{{i+1},j}$$&lt;/p&gt;
&lt;p&gt;
For the two by two lattice the solution space is:&lt;/p&gt;
&lt;div class=&#34;center-block&#34; style=&#34;text-align: center; margin-left: auto; margin-right: auto;&#34;&gt;
&lt;div class=&#34;src src-text&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;6  3  1
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;3  2  1
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;1  1  .&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The total number of pathways from the upper left corner to the lower right corner is thus 6. This logic can now be applied to a grid of any arbitrary size using the following code. The code defines the lattice and initiates the boundary conditions. The bottom row and the right column are filled with 1 as there is only one solution from these points. The code then calculates the pathways by working backwards through the matrix. The final solution is the number is the first cell.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 15: Lattice Paths&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Define lattice&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  nLattice &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  lattice &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;matrix&lt;/span&gt;(ncol &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; nLattice &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, nrow &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; nLattice &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Boundary conditions&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  lattice[nLattice &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;(nLattice &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  lattice[&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;(nLattice &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;), nLattice &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Calculate Pathways&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; nLattice&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (j &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; nLattice&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          lattice[i,j] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; lattice[i&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;+1&lt;/span&gt;, j] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; lattice[i, j&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;+1&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; lattice[1,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Create Air Travel Route Maps with ggplot2</title>
      <link>https://lucidmanager.org/data-science/create-air-travel-route-maps/</link>
      <pubDate>Tue, 07 Mar 2017 07:24:24 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/create-air-travel-route-maps/</guid>
      <description>
	
&lt;p&gt;
I have been lucky to fly to a few countries around the world. Like any other bored traveller, I thumb through the airline magazines and look at the &lt;a href=&#34;http://www.airlineroutemaps.com/&#34;&gt;air travel route maps&lt;/a&gt;. These maps are beautifully stylised depictions of the world with gently curved lines between the destinations serviced by the airline. I always wanted such a map for my own travel adventures. This article explains how to create air travel route maps with  ggplot2 in the style of the Emirates Airlines route map.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Create Air Travel Route Maps using ggplot2
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The first step was to create a list of all the places I have flown between at least once. Paging through my travel photos and diaries, I managed to create a pretty complete list. The structure of this document is simply a list of all routes (From, To) and every flight only gets counted once. The next step finds the spatial coordinates for each airport by searching Google Maps using the geocode function from the &lt;a href=&#34;https://cran.r-project.org/web/packages/ggmap/index.html&#34;&gt;ggmap&lt;/a&gt; package. You will need a Google API to enable the &lt;a href=&#34;https://lucidmanager.org/data-science/geocoding-with-ggmap/&#34;&gt;geocoding function&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
In some instances, I had to add the country name to avoid confusion between places. To prevent errors from the Google maps API, I have added a while loop that runs until all destinations have been geocoded. We now we have a data frame of airports with their coordinates and can create air travel route maps. The data frames are merged so that we can create air travel route maps using the &lt;a href=&#34;http://ggplot2.tidyverse.org/reference/geom_segment.html&#34;&gt;curve geom&lt;/a&gt;. The &lt;a href=&#34;http://ggplot2.tidyverse.org/reference/borders.html&#34;&gt;borders&lt;/a&gt; function of ggplot2 creates the map data. The &lt;a href=&#34;https://github.com/slowkow/ggrepel&#34;&gt;ggrepel&lt;/a&gt; package helps to prevent overplotting of text. This code also removes any return flights and splits flights that crossed the date line.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/geography/travel-diary.png&#34; alt=&#34;My personal Air Travel Route Maps in ggplot&#34; title=&#34;My personal Air Travel Route Maps in ggplot&#34;/&gt;
&lt;figcaption&gt;
My personal Air Travel Route Maps in ggplot: A Visual Travel Diary
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
In another article, I have used the same principle to create a route map of flights between islands in the &lt;a href=&#34;https://lucidmanager.org/data-science/pacific-island-hopping/&#34;&gt;Pacific Ocean&lt;/a&gt; using the schedules from several international airlines and to show demonstrate the nonsense of &lt;a href=&#34;https://lucidmanager.org/data-science/flat-earth-mathematics/&#34;&gt;Flat Earth&lt;/a&gt; theories.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/geography/&#34; target=&#34;_blank&#34;
   title=&#34;Download geography from GitHub&#34;
   alt=&#34;Download geography from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;geography&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Flightpath map&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## https://lucidmanager.org/create-air-travel-route-map&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Init&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggmap)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggrepel)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  api &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;../google-maps.api&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Text file with the API key&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;register_google&lt;/span&gt;(key &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; api)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Read flight and airports lists &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;#flights &amp;lt;- read_csv(&amp;#34;flights.csv&amp;#34;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read_csv&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;flight-map/flights.csv&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  airports_file &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;flight-map/airports.csv&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;file.exists&lt;/span&gt;(airports_file)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    airports &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read_csv&lt;/span&gt;(airports_file)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    airports &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(airport &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;, lon &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;, lat&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Lookup coordinates&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Some airports need country names to ensure Google finds the correct location&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## The geocoding keeps looping till all coordinates have been found&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  destinations &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unique&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;From, flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;To))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  new_destinations &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; destinations[&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;destinations &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;airport]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(new_destinations) &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      new_airports &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geocode&lt;/span&gt;(new_destinations) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(airport &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; new_destinations) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(airport, lon, lat)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      airports &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rbind&lt;/span&gt;(airports, new_airports) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;is.na&lt;/span&gt;(lon) &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;is.na&lt;/span&gt;(lat))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      new_destinations &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; destinations[&lt;span style=&#34;color:#333&#34;&gt;!&lt;/span&gt;destinations &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;airport]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;write_csv&lt;/span&gt;(airports, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;flight-map/airports.csv&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Remove country names&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;airport &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;airport)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  comma &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;regexpr&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;,&amp;#34;&lt;/span&gt;, airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;airport)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;airport&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[which&lt;/span&gt;(comma &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;substr&lt;/span&gt;(airports&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;airport&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[which&lt;/span&gt;(comma &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)], &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, comma[comma &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Remove return flights&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  d &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(flights)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      d &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;From, flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;To) &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                 &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;To[i], flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;From[i]))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;From[d] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;R&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; flights &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(From &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;R&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(From, To)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Add coordinates to flight list&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;merge&lt;/span&gt;(flights, airports, by.x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;From&amp;#34;&lt;/span&gt;, by.y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;airport&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;merge&lt;/span&gt;(flights, airports, by.x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;To&amp;#34;&lt;/span&gt;, by.y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;airport&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; flights &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(From, To, lon.x, lat.x, lon.y, lat.y) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as_tibble&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Split Circumnaviation Flights at -180/180 degrees&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  circ &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;abs&lt;/span&gt;(flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon.y &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon.x) &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;180&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights[circ,]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon.y[circ] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ifelse&lt;/span&gt;(flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon.y[circ] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;180&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-180&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lat.y[circ] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rowSums&lt;/span&gt;(flights[circ, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;lat.x&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;lat.y&amp;#34;&lt;/span&gt;)]) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  leg2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; airports &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(airport &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;To[circ]) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(From &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(circ))) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(lon.x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon.y[circ], lat.x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; flights&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lat.y[circ]) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(From, To &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; airport, lon.x, lat.x, lon.y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lon, lat.y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lat)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  flights &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rbind&lt;/span&gt;(flights, leg2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Plot flight routes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  worldmap &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;borders&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;world2&amp;#34;&lt;/span&gt;, colour&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#efede1&amp;#34;&lt;/span&gt;, fill&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#efede1&amp;#34;&lt;/span&gt;) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; worldmap &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; airports, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lon, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lat), col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#970027&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_text_repel&lt;/span&gt;(data&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;airports, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lon, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lat, label &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; airport), col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;, segment.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_curve&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; flights, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lon.x, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lat.x, xend &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lon.y, yend &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lat.y), col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#b29e7d&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.4&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggsave&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;flights_map.png&amp;#34;&lt;/span&gt;, dpi &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;300&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 14: Longest Collatz sequence</title>
      <link>https://lucidmanager.org/data-science/project-euler-14/</link>
      <pubDate>Thu, 02 Mar 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-14/</guid>
      <description>
	
&lt;p&gt;
Euler Problem 14 looks at the Collatz Conjecture. These playful sequences, named after German mathematician Lothar Collatz (1910–1990), cause mathematicians a lot of headaches. What is most interesting about this problem is how a simple set of rules can create intricate complexity.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 14 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The following iterative sequence is defined for the set of positive integers:&lt;/p&gt;
&lt;p&gt;
$f(n) = \begin{cases} \frac{n}{2} &amp;amp;\text{if } n \equiv 0 \pmod{2}\\[4px] 3n+1 &amp;amp; \text{if } n\equiv 1 \pmod{2} .\end{cases}$&lt;/p&gt;
&lt;p&gt;
Using the rule above, and starting with 13, we generate the following sequence:&lt;/p&gt;
&lt;p&gt;
$$13 \rightarrow 40 \rightarrow 20 \rightarrow 10 \rightarrow 5 \rightarrow 16 \rightarrow 8 \rightarrow 4 \rightarrow 2 \rightarrow 1 $$&lt;/p&gt;
&lt;p&gt;
It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is thought that all starting numbers finish at 1.&lt;/p&gt;
&lt;p&gt;
Which starting number, under one million, produces &lt;a href=&#34;https://projecteuler.net/problem=14&#34;&gt;the longest chain&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;
NOTE: Once the chain starts, the terms are allowed to go above one million.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/5mFpVDpKX70?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Uncrackable? The Collatz Conjecture - Numberphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Proposed solutions
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This problem is highly computationally intensive, and it highlights R&amp;#39;s lack of speed. Generating one million Collatz sequences and finding the longest one requires a lot more than a minute of processing time allowed for in Project Euler.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Brute Force
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The brute force solution tests every answer and takes a long time to run.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 14: Longest Collatz Sequence&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Brute Force&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  collatz.chain &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      chain &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (n&lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          chain[i] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; n
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(chain)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  collatz.max &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (n &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1E6&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      collatz.length &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;collatz.chain&lt;/span&gt;(n))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (collatz.length &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; collatz.max) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; n
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          collatz.max &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; collatz.length
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Optimised solution
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The optimised version of the code stores the length of all sequences in an array. When the code generates a sequence and lands on a number already analysed, then it adds that previous number to the current one and moves on to the next step. This approach requires more memory but saves a lot of computation time. A minor tweak to the code optimises the rule for uneven numbers. Tripling an uneven number and adding one will always result in an even number so we can skip one step. This solution is more than twice as fast as the first version.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Optimised method&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  collatz.length &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;(length &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1E6&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  collatz.length[1] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (n &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1E6&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; n
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      count &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; x &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;=&lt;/span&gt; n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (x &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; x &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              count &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; count &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; x &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              count &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; count &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      count &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; count &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; collatz.length[x]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      collatz.length[n] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; count
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which.max&lt;/span&gt;(collatz.length)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Visualising Collatz Sequences
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Collatz sequence is an example of a simple mathematical rule that can create an unpredictable pattern. The number of steps required to reach one is listed in &lt;a href=&#34;https://oeis.org/A006577&#34;&gt;sequence A006577&lt;/a&gt; of the Online Encyclopedia of Integer Sequences. The image below visualises the number of steps for the first 1000 positive numbers. The scatterplot shows some unusual patterns. Does this visualisation show that the Collatz Sequence does have a pattern after all?&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/project-euler/problem-014a.png&#34; alt=&#34;Number of steps to terminate a Collatz sequence.&#34; title=&#34;Number of steps to terminate a Collatz sequence.&#34;/&gt;
&lt;figcaption&gt;
Number of steps to terminate a Collatz sequence.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Visualise&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  collatz &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10000&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                        steps &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; collatz.length[1&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10000&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(collatz, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(n, steps)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.5&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;darkblue&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_minimal&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Collatz Sequence&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Number of steps to reach 1&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggsave&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;../../../../static/images/project-euler/problem-014a.png&amp;#34;&lt;/span&gt;, width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;, height &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Collatz Chains
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The Collatz sequences can also be visualised using networks. Each step between two numbers is an edge, and the numbers are the vertices. For example, the network for the Collatz sequence for number 10 is 5–16, 16–8, 8–4, 4–2, 2–1. When generating subsequent sequences, the network will start to overlap, and a tree of sequences appears. The tree below combines the Collatz sequences for the numbers 2 to 26. Number 27 has a very long sequence, making the tree much harder to read. The code to create this network uses the &lt;em&gt;igraph&lt;/em&gt; package. The edge list is a data frame where each row indicates a connected set of numbers.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/project-euler/problem-014b.png&#34; alt=&#34;Collatz network 1-26.&#34; title=&#34;Collatz netork 1-26&#34;/&gt;
&lt;figcaption&gt;
Collatz network \((n \leq 26)\).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Collatz Chains&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(igraph)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;edgelist &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(a &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;, b &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (n &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;26&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   chain &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(n, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;collatz.chain&lt;/span&gt;(n)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   chain &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(a &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; chain[&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(chain)], b &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; chain[&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   edgelist &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rbind&lt;/span&gt;(edgelist, chain)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;g &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;graph.edgelist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.matrix&lt;/span&gt;(edgelist))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;g &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;simplify&lt;/span&gt;(g)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;png&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;../../../../static/images/project-euler/problem-014b.png&amp;#34;&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1024&lt;/span&gt;, height &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;768&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;par&lt;/span&gt;(mar &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;V&lt;/span&gt;(g)&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;color &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;degree&lt;/span&gt;(g, mode &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;out&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot&lt;/span&gt;(g,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     layout &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; layout.auto,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;V&lt;/span&gt;(g)&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;color,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.frame.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     frame.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;white&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.label.cex &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1.5&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     vertex.label.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;black&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     edge.arrow.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.2&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     edge.color &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;grey&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     )
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;dev.off&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 13: Adding Very Large Integers</title>
      <link>https://lucidmanager.org/data-science/project-euler-13/</link>
      <pubDate>Thu, 23 Feb 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-13/</guid>
      <description>
	
&lt;p&gt;
Project Euler 13 asks to add one hundred numbers with fifty digits. This seems like a simple problem where it not that most computers are not designed to deal with numbers with a lot of integers. For example: 2&lt;sup&gt;64&lt;/sup&gt; = 18446744073709551616. When asking R to compute this value, we get 1.844674e+19, losing most of the digits and limiting the accuracy of the results. Computers solve this problem using &lt;a href=&#34;https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic&#34;&gt;Arbitrary-Precision Arithmetic&lt;/a&gt;. Many software libraries can process long integers without losing accuracy. Euler Problem 13 requires this type of approach.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 13 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Work out the first ten digits of the sum of the following one-hundred &lt;a href=&#34;https://projecteuler.net/problem=13&#34;&gt;50-digit numbers&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The easy way to solve this problem is to use the &lt;a href=&#34;https://cran.r-project.org/web/packages/gmp/index.html&#34;&gt;GMP package&lt;/a&gt; for working with huge integers. This package uses a special number types such as Big Rational and Big Integer. The number of digits in these number types is only limited by the size of your computer&amp;#39;s memory.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 13: Adding Very Large Numbers&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## GMP Library&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(gmp)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  numbers &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/p013_numbers.txt&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  gmp_method &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;() {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      digits &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.bigz&lt;/span&gt;(numbers))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;substr&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.character&lt;/span&gt;(digits),&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(answer)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gmp_method&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Using Base-R
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;To find the solution to this problem using only base R, I wrote a function to add numbers using strings instead of integers. The function adds leading zeros to the smallest number to make them both the same length. The function then proceeds to add numbers in the same way we were taught in primary school.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Base-R Solution&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  big.add &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(a, b) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;## Add leading zeros to smallest number&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(a)&lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(b)) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(b) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(a)), collapse &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;), a)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(a)&lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(b)) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      b &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste0&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(a) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(b)), collapse &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;), b)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    solution &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;vector&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    remainder &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(b)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      p &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;substr&lt;/span&gt;(a, i, i))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      q &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;substr&lt;/span&gt;(b, i, i))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      r &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; p &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; q &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; remainder
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (r &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        solution &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(solution, r &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        remainder &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (r &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; (r &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      } &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        solution &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(solution, r)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        remainder &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;paste&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rev&lt;/span&gt;(solution), collapse &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;With this function, the problem is easy to solve. The second part of the code runs this function over the one hundred numbers provided on the Euler Problem page and calculates the answer.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    base_method &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;() {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; numbers)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;big.add&lt;/span&gt;(answer, i)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;substr&lt;/span&gt;(answer, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(answer)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;base_method&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This solution for managing very large numbers is reused in &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-25/&#34;&gt;Project Euler 25&lt;/a&gt; which asks for a Fibonacci number with 1000 decimals.
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 12: Highly Divisible Triangular Number</title>
      <link>https://lucidmanager.org/data-science/project-euler-12/</link>
      <pubDate>Thu, 16 Feb 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-12/</guid>
      <description>
	
&lt;p&gt;
Project Euler 12 takes us to the realm of triangular numbers and proper divisors. The image below shows a hands-on method to visualise the number of divisors of ten. Cuisenaire rods are learning aids to explore mathematics. Each of the coloured rods has a different integer length, which allows students to explore basic arithmetic. In this article, I discuss a method to generate triangular numbers using the R language.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://upload.wikimedia.org/wikipedia/commons/6/67/Cuisenaire-Rods.jpg&#34; alt=&#34;Cuisenaire-rods (Source: Wikimedia user Celcom / CC BY).&#34; title=&#34;Cuisenaire-rods (Source: Wikimedia user Celcom / CC BY).&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Cuisenaire-rods (Source: Wikimedia user Celcom / CC BY).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 12 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be \(1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\). The first ten terms would be: \(1, 3, 6, 10, 15, 21, 28, 36, 45, 55, \ldots\)&lt;/p&gt;
&lt;p&gt;
Let us list the factors of the first seven triangle numbers:&lt;/p&gt;
&lt;div class=&#34;src src-text&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; 1: 1
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; 3: 1, 3
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; 6: 1, 2, 3,  6
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;10: 1, 2, 5, 10
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;15: 1, 3, 5, 15
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;21: 1, 3, 7, 21
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;28: 1, 2, 4,  7, 14, 28&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
We can see that 28 is the first triangle number to have over five divisors.&lt;/p&gt;
&lt;p&gt;
What is the value of the first triangle number to have over &lt;a href=&#34;https://projecteuler.net/problem=12&#34;&gt;five hundred divisors&lt;/a&gt;?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In the video below, Vishal Kataria explains a simple method to determine the number of divisors using prime factorization. The prime factorization of \(n\) is given by:&lt;/p&gt;
&lt;p&gt;
$$n = p^{\alpha_1}_1 \times p^{\alpha_2}_2 \times \ldots \times p^{\alpha_k}_k$$&lt;/p&gt;
&lt;p&gt;
Where \(p\) is a prime factor, and \(\alpha\) is the number of times the factor is repeated.&lt;/p&gt;
&lt;p&gt;
The number of proper divisors is for \(n\) is:&lt;/p&gt;
&lt;p&gt;
$$d = (\alpha_1 + 1) (\alpha_2 + 1) \times \ldots \times (\alpha_k + 1)$$&lt;/p&gt;
&lt;p&gt;
The code reuses the prime factorisation function developed for &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-3/&#34;&gt;Euler Problem 3&lt;/a&gt;. This function results in a vector of all prime factors, e.g. the prime factors of 28 are 2, 2 and 7.&lt;/p&gt;
&lt;p&gt;
The code to solve this problem determines the values for alpha using the run-length &lt;code class=&#34;verbatim&#34;&gt;rle()&lt;/code&gt; function. This function counts the number of times each element in a sequence is repeated. The outcome of this function is a vector of the values and the number of times each is repeated. The prime factors of 28 are 2, 2 and 7, and their run lengths are 2 and 1. The number of divisors can now be determined.&lt;/p&gt;
&lt;p&gt;
$$ 28 = 2^2 \times 7^1$$&lt;/p&gt;
&lt;p&gt;
$$ d = (2+1)(1+1) = 6$$&lt;/p&gt;
&lt;p&gt;
The six divisors of 28 are 1, 2, 4, 7, 14 and 28.&lt;/p&gt;
&lt;p&gt;
The code to solve Project Euler 12 is shown below. The loop continues until it finds a triangular number with 500 divisors. The first two lines increment the index and create the next triangular number. The third line in the loop determines the number of times each factor is repeated (the run lengths). The last line calculates the number of divisors using the above formula.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 12: Highly Divisible Triangular Number&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  divisors &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (divisors &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;500&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      triangle &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (i &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      pf &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;prime.factors&lt;/span&gt;(triangle)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      alpha &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rle&lt;/span&gt;(pf)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      divisors &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;prod&lt;/span&gt;(alpha&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lengths &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; triangle
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;p&gt;&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/_QIx_zmh9nU?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;figcaption&gt;
Vishal Kataria. Number Theory - Number of Divisors.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Percentile Calculations in Water Quality Regulations</title>
      <link>https://lucidmanager.org/data-science/percentile-calculations/</link>
      <pubDate>Fri, 10 Feb 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/percentile-calculations/</guid>
      <description>
	
&lt;p&gt;
Percentile calculations can be more tricky than at first meets the eye. A &lt;a href=&#34;https://en.wikipedia.org/wiki/Percentile&#34;&gt;percentile&lt;/a&gt; indicates the value below which a percentage of observations fall. Some percentiles have special names, such as the &lt;a href=&#34;https://en.wikipedia.org/wiki/Quartile&#34;&gt;quartile&lt;/a&gt; or the &lt;a href=&#34;https://en.wikipedia.org/wiki/Decile&#34;&gt;decile&lt;/a&gt;, both of which are &lt;a href=&#34;https://en.wikipedia.org/wiki/Quantile&#34;&gt;quantiles&lt;/a&gt;. This deceivingly simple definition hides the various ways to determine this number. Unfortunately, there is &lt;a href=&#34;https://www.amherst.edu/media/view/129116/original/Sample+Quantiles.pdf&#34;&gt;no standard definition for percentiles&lt;/a&gt;, so which method do you use? &lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://stat.ethz.ch/R-manual/R-devel/library/stats/html/quantile.html&#34;&gt;quantile&lt;/a&gt; function in R generates sample percentiles corresponding to the given probabilities. By default, the quantile function provides the quartiles and the minimum and maximum values. The code snippet below creates semi-random data, plots the histogram and visualises the third quartile.&lt;/p&gt;
&lt;p&gt;
The code for this page is available on GitHub in &lt;code class=&#34;verbatim&#34;&gt;case-studies/percentiles.R&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Percentile calculations&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Example&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;set.seed&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1969&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  test.data &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rnorm&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10000&lt;/span&gt;, mean &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, sd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.data.frame&lt;/span&gt;(test.data), &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(test.data)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_histogram&lt;/span&gt;(binwidth &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; ..density..), fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dodgerblue&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_line&lt;/span&gt;(stat &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;function&amp;#34;&lt;/span&gt;, fun &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; dnorm, args &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;list&lt;/span&gt;(mean &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, sd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;), colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_area&lt;/span&gt;(stat &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;function&amp;#34;&lt;/span&gt;, fun &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; dnorm, args &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;list&lt;/span&gt;(mean &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, sd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              colour &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, alpha &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.5&lt;/span&gt;, xlim &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;quantile&lt;/span&gt;(test.data, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.5&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.75&lt;/span&gt;))) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_bw&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;8&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/percentile-example.png&#34; alt=&#34;Percentile Calculations example&#34; title=&#34;Percentile Calculations example&#34; width=&#34;50%&#34;/&gt;
&lt;figcaption&gt;
Percentile Calculations example.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The quantile function with default settings and the 95&lt;sup&gt;th&lt;/sup&gt; percentile give the following results:&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;quantile&lt;/span&gt;(test.data)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&#34;example&#34;&gt;
       0%       25%       50%       75%      100% 
 39.91964  89.68041 100.16437 110.01910 153.50195
&lt;/pre&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;quantile&lt;/span&gt;(test.data, probs &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.95&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&#34;example&#34;&gt;
     95% 
124.7775
&lt;/pre&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Methods of percentile calculation
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The quantile function in R provides nine different ways to calculate percentiles. Each of these options uses another method to interpolate between observed values. I will not discuss the mathematical nuances between these methods. &lt;a href=&#34;https://www.amherst.edu/media/view/129116/original/Sample+Quantiles.pdf&#34;&gt;Hyndman and Fan&lt;/a&gt; (1996) provides a detailed discussion of these methods.&lt;/p&gt;
&lt;p&gt;
The differences between the nine available methods only matter in highly skewed distributions, such as water quality data. All methods provide the same outcome for the normal distribution simulated above, as illustrated by the following code.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;, &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(m) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;quantile&lt;/span&gt;(test.data, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.95&lt;/span&gt;, type &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; m))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&#34;example&#34;&gt;
     95%      95%      95%      95%      95%      95%      95% 
124.7775 124.7775 124.7775 124.7775 124.7775 124.7775 124.7775 
     95%      95% 
124.7775 124.7775
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Percentile calculations in water quality
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;a href=&#34;https://nhmrc.gov.au/about-us/publications/australian-drinking-water-guidelines&#34;&gt;Australian Drinking Water Quality Guidelines&lt;/a&gt; (November 2016) specify that: &amp;#34;based on aesthetic considerations, the turbidity should not exceed 5 NTU at the consumer&amp;#39;s tap&amp;#34;. The Victorian Safe Drinking Water Regulations(2015) relax this requirement and require that:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The 95&lt;sup&gt;th&lt;/sup&gt; percentile of results for samples in any 12 months must be less than or equal to 5.0 NTU.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The Victorian water quality regulator also specifies that the percentile should be calculated with the &lt;em&gt;Weibull Method&lt;/em&gt;. This requirement raises two questions: What is the Weibull method? How do you implement this requirement in R? &lt;/p&gt;
&lt;p&gt;
The term Weibull Method is confusing as this is not a name generally used by statisticians. In Hyndman &amp;amp; Fan (1996), this method has the less poetic name $\hat{Q}_8(p)$. The Victorian water quality regulator references &lt;a href=&#34;http://amzn.to/2k8shr8&#34;&gt;McBride (2005)&lt;/a&gt;, who calls it the Weibull method. &lt;a href=&#34;https://en.wikipedia.org/wiki/Waloddi_Weibull&#34;&gt;Waloddi Weibull&lt;/a&gt;, a Swedish engineer famous for his distribution, was one of the first to describe this method.&lt;/p&gt;
&lt;p&gt;
This theoretical interlude aside, how can we practically apply this to water quality data?&lt;/p&gt;
&lt;p&gt;
If you are interested in how the Weibull method works, the &lt;code class=&#34;verbatim&#34;&gt;weibull.quantile()&lt;/code&gt; function below calculates a quantile &lt;em&gt;p&lt;/em&gt; for a vector &lt;em&gt;x&lt;/em&gt; using this method. This function gives the same result as &lt;code class=&#34;verbatim&#34;&gt;quantile(x, p, type = 6)&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Weibull method&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  weibull.quantile &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x, p) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;# Order Samples from large to small&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; x&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[order&lt;/span&gt;(x, decreasing &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;# Determine the ranking of percentile according to Weibull (1939)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    r &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; p &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(x) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#888&#34;&gt;# Linear interpolation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    rfrac &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (r &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(r))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;((&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; rfrac) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; x&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[floor&lt;/span&gt;(r)] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; rfrac &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; x&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[floor&lt;/span&gt;(r) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;weibull.quantile&lt;/span&gt;(test.data, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.95&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;quantile&lt;/span&gt;(test.data, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.95&lt;/span&gt;, type &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&#34;example&#34;&gt;
124.777545386916
&lt;/pre&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Turbidity Data Example
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Turbidity data is not normally distributed as it is always greater than zero. In this example, we use simulated data from a fictional water system called Gormsey. This data is also used in book &lt;a href=&#34;https://lucidmanager.org/tags/r4h2o/&#34;&gt;Data Science for Water Utilities.&lt;/a&gt;&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Visualise Data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  gormsey &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read_csv&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;~/Documents/projects/r4h2o/data/water_quality.csv&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  turbidity &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(gormsey, Measure &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Turbidity&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                               Suburb &lt;span style=&#34;color:#333&#34;&gt;%in%&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Blancathey&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Tarnstead&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(turbidity, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(Result)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_density&lt;/span&gt;(fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;dodgerblue&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; ..density..)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_x_continuous&lt;/span&gt;(trans &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;log10&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;facet_wrap&lt;/span&gt;(&lt;span style=&#34;color:#333&#34;&gt;~&lt;/span&gt;Suburb) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_bw&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Turbidity Distribution&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         x&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;log Results&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/gormsey-turbidity.png&#34; alt=&#34;Turbidity at customer tap&#34; title=&#34;Turbidity at customer tap&#34; width=&#34;70%&#34;/&gt;
&lt;figcaption&gt;
Turbidity at customer tap in two towns in the fictional country of Gormsey.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
When we calculate the percentiles for all nine methods available in the base-R function, we see that the Weibull method generally provides the most conservative result for heavily skewed data.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Calculate all percentile methods&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tapply&lt;/span&gt;(turbidity&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Result, turbidity&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;Suburb,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;         &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(x) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;9&lt;/span&gt;, &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(m) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;quantile&lt;/span&gt;(x, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.95&lt;/span&gt;, type &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; m)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&#34;example&#34;&gt;
$Blancathey
   95%    95%    95%    95%    95%    95%    95%    95%    95% 
6.0200 6.0200 6.0200 5.8820 6.2720 6.6500 5.9165 6.3980 6.3665 

$Tarnstead
     95%      95%      95%      95%      95%      95%      95% 
4.480000 4.480000 4.480000 4.432500 4.607500 4.837000 4.442000 
     95%      95% 
4.684000 4.664875
&lt;/pre&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/descriptive-statistics-in-water-quality/&#34;&gt;Chapter 4&lt;/a&gt; of my book &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; discusses calculating descriptive statistics with R&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 11: Largest product in a grid</title>
      <link>https://lucidmanager.org/data-science/project-euler-11/</link>
      <pubDate>Thu, 09 Feb 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-11/</guid>
      <description>
	
&lt;p&gt;
Project Euler 11 is a relatively straightforward application of vector arithmetics in R. Just like &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-8/&#34;&gt;problem 8&lt;/a&gt;, it asks for the largest product.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 11 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In the 20×20 grid below, four numbers along a diagonal line have been marked in red. The product of these numbers is 26 × 63 × 78 × 14 = 1788696.&lt;/p&gt;
&lt;p&gt;
What is the &lt;a href=&#34;https://projecteuler.net/problem=11&#34;&gt;greatest product&lt;/a&gt; of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid?&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/project-euler/problem-011.png&#34; alt=&#34;Project Euler problem 11&#34; title=&#34;Project Euler problem 11&#34;/&gt;
&lt;figcaption&gt;
Project Euler 11.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The solution applies straightforward vector arithmetic to multiply the verticals, horizontals and diagonals. The product of all verticals is an array of the product of rows 1 to 4, rows 2 to 5 and so on. The code uses a similar logic for the horizontals and the diagonals. &lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 11: Largest product in a grid&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  square &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.matrix&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read.delim&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;data/p011_matrix.txt&amp;#34;&lt;/span&gt;, header &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;, sep &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  prod.vert &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; square[1&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;17&lt;/span&gt;, ] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; square[2&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;18&lt;/span&gt;, ] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; square[3&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;, ] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; square[4&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;, ]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  prod.hori &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; square[ ,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;17&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; square[ ,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;18&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; square[ ,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; square[ ,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  prod.dia1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; square[1&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;17&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;17&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; square[2&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;18&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;18&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; square[3&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; square[4&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  prod.dia2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; square[4&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;17&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; square[3&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;18&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; square[2&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;18&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;19&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; square[1&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;17&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(prod.vert, prod.hori, prod.dia1, prod.dia2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 10: Summation of Primes</title>
      <link>https://lucidmanager.org/data-science/project-euler-10/</link>
      <pubDate>Thu, 02 Feb 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-10/</guid>
      <description>
	
&lt;p&gt;
Project Euler 10 asks for the summation of primes. Computationally this is a simple problem because we can re-use the prime sieve developed for &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-3/&#34;&gt;Project Euler 3&lt;/a&gt;. Mathematicians consider primes the basic building blocks of number theory. No matter how hard we look, however, they do not seem to obey any logical sequence. There is thus no algorithm to create prime numbers, all we can do is mine them from the infinite field of integers. &lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 10 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the &lt;a href=&#34;https://projecteuler.net/problem=10&#34;&gt;sum of all the primes&lt;/a&gt; below two million.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The sieve of Eratosthenes function from Project Euler 3 generates the prime numbers between two and two million, which can then easily be summed.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 10: Summation of Primes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;source&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;problem003.R&amp;#34;&lt;/span&gt;, echo &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  primes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;esieve&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2e6&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(primes)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Goldbach&amp;#39;s Conjecture
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The summing of primes reveals an interesting problem in mathematics. Goldbach&amp;#39;s conjecture is one of the oldest and best-known unsolved problems in number theory. In 1742 Goldbach wrote a letter to Euler in which he states that:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Every even integer greater than 2 can be expressed as the sum of two primes.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
A Goldbach partition is the expression of a given even number as a sum of two primes, for example:&lt;/p&gt;
&lt;p&gt;
$$100 = 3 + 97 = 11 + 89 = 17 + 83 = 29 + 71 = 41 + 59 = 47 + 53$$&lt;/p&gt;
&lt;p&gt;
All even numbers greater than 12 can be written as the sum of two primes in more than two ways. &lt;a href=&#34;https://oeis.org/A045917/&#34;&gt;Sequence A045917&lt;/a&gt; in the Online Encyclopedia of Integer Sequences lists the number of ways in which \(2n\) can be written as the sum of two primes (\(n\geq1\)). This conjecture is as yet unproven and one of the most persistent problems in mathematics. &lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/MxiTG96QOxw?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Goldbach Conjecture - Numberphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
We can write some code to verify that every integer greater than two and less than \(n\) can be expressed as the sum of two primes. This code recreates sequence A045917 and visualises the first 1000 results. There does not seem to be a pattern in the number of ways to sum two primes. However, When visualising the sequence with a scatter plot, horizontal bands of points appear.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Goldbach&amp;#39;s Conjecture&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  goldbach &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (n&lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;This only works for even numbers&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      primes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rev&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;esieve&lt;/span&gt;(n)) &lt;span style=&#34;color:#888&#34;&gt;# All primes below n&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      k &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(primes)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      g &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;k) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (j &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; i&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;k) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt;((primes[i] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; primes[j]) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#888&#34;&gt;# print(paste(n, &amp;#34;=&amp;#34;, primes[i], &amp;#34;+&amp;#34;, primes[j]))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            g &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; g &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(g)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(from &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;, by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;, length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    A002375 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(n,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                          g &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(n, goldbach))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(A002375, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(n, g)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.5&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_minimal&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Goldbach&amp;#39;s Expressions&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           subtitle &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Number of ways to write an even number as the sum of two primes&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Even number&amp;#34;&lt;/span&gt;, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Number of prime sums&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggsave&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;images/problem-010.png&amp;#34;&lt;/span&gt;, width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;, height &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;p alt=&#34;Number of ways to write an even number n as the sum of two primes (4 ≤ n ≤ 1,000), (sequence A002375 in the OEIS)&#34; title=&#34;Number of ways to write an even number n as the sum of two primes (4 ≤ n ≤ 1,000), (sequence A002375 in the OEIS)&#34;&gt;&lt;img src=&#34;https://lucidmanager.org/images/project-euler/problem-010.png&#34; alt=&#34;/images/project-euler/problem-010.png&#34; title=&#34;/images/project-euler/problem-010.png&#34;/&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;figcaption&gt;
Number of ways to write an even number \(n\) as the sum of two primes \((2 \leq n \leq 1000)\), (sequence A002375 in the OEIS).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Spike Detection in Water Treatment Data in the R Language</title>
      <link>https://lucidmanager.org/data-science/spike-detection/</link>
      <pubDate>Mon, 30 Jan 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/spike-detection/</guid>
      <description>
	
&lt;p&gt;
Spike detection in time series is essential for controlling water treatment plants. Spikes in SCADA data are events in the data stream of water treatment plants or similar installations. These spikes can indicate problems with the process and may increase the risk to public health. The WSAA &lt;em&gt;Health-Based Targets Manual&lt;/em&gt; specifies a series of decision rules to assess the performance of filtration processes. For example, this rule evaluates the performance of conventional filtration:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Individual filter turbidity ≤ 0.2 NTU for 95% of the month and not &amp;gt; 0.5 NTU for ≥ 15 consecutive minutes.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/data-science/percentile-calculations/&#34;&gt;Turbidity&lt;/a&gt; is a measure of the cloudiness of fluid because of large numbers of individual particles otherwise invisible to the naked eye. Turbidity is an essential parameter in water treatment because a high level of cloudiness strongly correlates with the presence of microbes. This article uses the R language to show how to implement this specific decision rule.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Simulation
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;I first created a simulated SCADA feed for turbidity to create a minimum working example. The &lt;em&gt;turbidity&lt;/em&gt; data frame contains 24 hours of data. The &lt;a href=&#34;https://stat.ethz.ch/R-manual/R-devel/library/base/html/seq.POSIXt.html&#34;&gt;seq.POSIXt()&lt;/a&gt; function creates 24 hours of timestamps at a one-minute spacing. In addition, the &lt;a href=&#34;https://www.rdocumentation.org/search?q=rnorm&#34;&gt;rnorm()&lt;/a&gt; function creates 1440 turbidity readings with an average of 0.1 NTU and a standard deviation of 0.01 NTU. The image below visualises the simulated data. The next step is to assess this data following the decision rule.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/r4h2o/&#34; target=&#34;_blank&#34;
   title=&#34;Download r4h2o from GitHub&#34;
   alt=&#34;Download r4h2o from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;r4h2o&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Simulate turbidity data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# set.seed(1234)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  turbidity &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(timestamp &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq.POSIXt&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.POSIXct&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;2017-01-01 00:00:00&amp;#34;&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                                 by &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;min&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                                 length.out &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                          turbidity &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rnorm&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;24&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;60&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                            mean &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.1&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                                            sd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.01&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The second section simulates five spikes in the data. The first line randomly selects a start time for the spike. The second line in the for-loop picks a duration between 10 and 30 minutes. In addition, the third line simulates the spike&amp;#39;s value. The mean value of the spike is determined by the &lt;a href=&#34;https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/Binomial&#34;&gt;rbinom()&lt;/a&gt; function to create either a low or a high spike. The remainder of the spike simulation inserts the new data into the turbidity data frame.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Spike detection&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Simulate data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    duration &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;30&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    start_time &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sample&lt;/span&gt;(turbidity&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;timestamp[1&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(turbidity) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; duration)], &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    value &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rnorm&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.5&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rbinom&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.5&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.3&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.05&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    start_row &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(turbidity&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;timestamp &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; start_time)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    turbidity&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;turbidity[start_row&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(start_row &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; duration &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)] &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rnorm&lt;/span&gt;(duration, value, value &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(turbidity) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; timestamp, y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; turbidity) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_line&lt;/span&gt;(size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.2&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_hline&lt;/span&gt;(yintercept &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.5&lt;/span&gt;, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, linetype &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ylim&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(turbidity&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;turbidity)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_bw&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggtitle&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Simulated SCADA data&amp;#34;&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The image below visualises the simulated data using the mighty &lt;a href=&#34;https://ggplot2.tidyverse.org/&#34;&gt;ggplot2&lt;/a&gt; package. Only four spikes are visible because two of them overlap. The next step is to assess this data following the decision rule.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/hydroinformatics/spikes.png&#34; alt=&#34;Simulated turbidity spikes&#34; title=&#34;Simulated turbidity spikes&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Simulated turbidity spikes.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
SCADA Spike Detection
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The following code searches for all spikes over 0.50 NTU using the &lt;a href=&#34;https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/rle&#34;&gt;runlength function&lt;/a&gt;. This function transforms a vector into a vector of values and lengths. For example, the run length of the vector &lt;code class=&#34;verbatim&#34;&gt;c(1, 1, 2, 2, 2, 3, 3, 3, 3, 5, 5, 6)&lt;/code&gt; is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;lengths: int [1:5] 2 3 4 2 1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&#34;verbatim&#34;&gt;values : num [1:5] 1 2 3 5 6&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The value 1 has a length of 1. The value 2 has a length of 3, and so on. The spike detection code computes the run length for turbidity levels greater than 0.5, yielding a boolean vector. The &lt;a href=&#34;https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/cumsum&#34;&gt;cumsum&lt;/a&gt; function calculates the starting point of each spike, which allows us to calculate their duration.&lt;/p&gt;
&lt;p&gt;
The code produces a data frame containing all spikes above 0.50 NTU and lasting longer than 15 minutes. The spike at 11:29 exceeded 0.50 NTU and lasted 24 minutes. The other three spikes are either lower than 0.50 NTU. The first high spike lasted less than 15 minutes.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Spike Detection Function&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  spike.detect &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(timestamp, value, limit, duration) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    runlength &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rle&lt;/span&gt;(value &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; limit)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    spikes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;data.frame&lt;/span&gt;(spike &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; runlength&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;values,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                         times &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;cumsum&lt;/span&gt;(runlength&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lengths))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    spikes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;times &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; timestamp[spikes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;times]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    spikes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;event &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, spikes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;times[&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; spikes&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;times[&lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nrow&lt;/span&gt;(spikes)])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    spikes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;subset&lt;/span&gt;(spikes, spike &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;&amp;amp;&lt;/span&gt; event &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; duration)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(spikes)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;spike.detect&lt;/span&gt;(turbidity&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;timestamp, turbidity&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;turbidity, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.5&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This approach was used to prototype a &lt;a href=&#34;https://issuu.com/australianwater/docs/water_journal_november_2015/64&#34;&gt;software package&lt;/a&gt; to assess water treatment plant data in accordance with the Health-Based Targets Manual. The finished product has been written in SQL and is available under an free software license.&lt;/p&gt;
&lt;p&gt;
The book &lt;em&gt;Data Science for Water Utilities&lt;/em&gt; discusses &lt;a href=&#34;https://lucidmanager.org/data-science/detecting-outliers-and-anomalies/&#34;&gt;anomaly detection&lt;/a&gt; in more detail.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2023_ds4wu.jpg&#34; alt = &#34;Data Science for Water Utilities&#34; title = &#34;Data Science for Water Utilities&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Data Science for Water Utilities&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Data Science for Water Utilities published by CRC Press is an applied, practical guide that shows water professionals how to use data science to solve urban water management problems using the R language for statistical computing.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://routledge.com/9781032354545&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Routledge&lt;/span&gt;
            &lt;/a&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://www.amazon.com/Data-Science-Water-Utilities-Chapman/dp/1032354550&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;Amazon&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 9: Special Pythagorean Triplet</title>
      <link>https://lucidmanager.org/data-science/project-euler-9/</link>
      <pubDate>Thu, 26 Jan 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-9/</guid>
      <description>
	
&lt;p&gt;
Project Euler 9 is about the ancient problem or Pythagorean triples. My background is in carpentry and the essential Pythagorean triple 3:4:5 is a standard tool to check whether an angle is straight. When building a structure, simply mark 3 and 4 units of length on the two sides and check whether the diagonal is precisely five units to ensure your angles are straight. There are, however, an infinite number of triples that form right angles.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 9 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A Pythagorean triplet is a set of three natural numbers, \(a &amp;lt; b &amp;lt; c\), for which, \(a^2 + b^2 = c^2\).&lt;/p&gt;
&lt;p&gt;
For example, \(3^2 + 4^2 = 9 + 16 = 25 = 5^2\).&lt;/p&gt;
&lt;p&gt;
There exists exactly one Pythagorean triplet for which \(a + b + c = 1000\).&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://projecteuler.net/problem=9&#34;&gt;Find the product&lt;/a&gt; \(abc\).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Brute Force Solutions
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This solution uses brute force and checks all combinations of \(a\), \(b\) and \(c\). To limit the solution space, I used the fact that \(a &amp;lt; b &amp;lt; c\), which implies that \(a &amp;lt; s/3\),  and \(a &amp;lt; b &amp;lt; s/2\), where s is the sum of the three sides.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 9: Special Pythagorean Triplet&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  b &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  c &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  s &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  found &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (a &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;((s &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;))) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (b &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(s &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          c &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; s &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; a &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; b
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a^2 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; b^2 &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; c^2) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              found &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (found) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; a &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; b &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; c
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Alan Jordan provided a faster brute force method. Since \(min(a)=1\) and \(max(b)=499\), we can walk \(a\) and \(b\) towards each other. That way there’s a max of 498 possibilities instead of 292*497 in the first solution.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Improved Brute Force&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  b &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;499&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;repeat&lt;/span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      c &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(a^2 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; b^2) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; b &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; c &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;) {b &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; b &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; b &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; c &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;) {a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; a &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (a &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; b &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; c &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;) {&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;break&lt;/span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; a &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; b &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; c
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Euclid’s Method
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Euclid’s formula generates Pythagorean triples for an arbitrary pair of integers m and n with \(m &amp;gt; n &amp;gt; 0\). The formula states that the integers \(a = m^2 - n^2, b = 2mn, c = m^2 = n^2\) form a Pythagorean triple.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Euclid&amp;#39;s Method&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  abc_sum &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  x &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; abc_sum &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  min &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  max &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ceiling&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(x))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  m &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; min&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;max
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  m &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; m[x &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; m &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; ((x &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; m) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; m)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  a &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; m &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; n
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  b &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; m^2 &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; n^2
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  c &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; m^2 &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; n^2
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; a &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; b &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; c
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;p alt=&#34;Scatter plot of the legs (a, b) of the first Pythagorean triples with a and b less than 6000. Negative values are included to illustrate the parabolic patterns.&#34; title=&#34;Scatter plot of the legs (a, b) of the first Pythagorean triples with a and b less than 6000. Negative values are included to illustrate the parabolic patterns.&#34;&gt;&lt;img src=&#34;https://upload.wikimedia.org/wikipedia/commons/e/e2/Pythagorean_Triples_Scatter_Plot.png&#34; alt=&#34;https://upload.wikimedia.org/wikipedia/commons/e/e2/Pythagorean_Triples_Scatter_Plot.png&#34; title=&#34;https://upload.wikimedia.org/wikipedia/commons/e/e2/Pythagorean_Triples_Scatter_Plot.png&#34;/&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;figcaption&gt;
Scatter plot of the legs (a, b) of the first Pythagorean triples with a and b less than 6000. Negative values are included to illustrate the parabolic patterns. By Dearjean13 CC BY-SA 4.0.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Trumpworld Analysis: Ownership Relations in his Business Network</title>
      <link>https://lucidmanager.org/data-science/trumpworld-analysis/</link>
      <pubDate>Mon, 23 Jan 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/trumpworld-analysis/</guid>
      <description>
	
&lt;p&gt;
You do not need a machine learning algorithm to predict that the presidency of Donald Trump will be controversial. Judging by his pointed language in the campaign, we can rest assured that Trump will break many conventions of world politics. One of the most discussed aspects of his reign is the massive potential for conflicts of interest. Trump&amp;#39;s complex business empire is entangled with national and international politics. Buzzfeed has mapped many of the relationships between businesses and people in what they have dubbed &lt;a href=&#34;https://www.buzzfeed.com/johntemplon/help-us-map-trumpworld&#34;&gt;Trumpworld&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;
They provided the data to enable citizens data science into the wheeling and dealings of Donald J. Trump. The &lt;a href=&#34;https://docs.google.com/spreadsheets/d/1Z5Vo5pbvxKJ5XpfALZXvCzW26Cl4we3OaN73K9Ae5Ss/edit&#34;&gt;raw data set&lt;/a&gt; consists of three subsets of connections between: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Organisations&lt;/li&gt;
&lt;li&gt;People&lt;/li&gt;
&lt;li&gt;People and organisations&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This article presents a quick analysis of the data using the R language for statistical computing and the iGraph package for analysing networks.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Trumpworld Analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This article analyses the connections between organisations using the mighty &lt;a href=&#34;http://igraph.org/r/&#34;&gt;igraph package&lt;/a&gt;.The package implements social network analysis for the R language which can be used for many purposes, such as analysing &lt;a href=&#34;https://lucidmanager.org/data-science/analyse-enron-corpus/&#34;&gt;email traffic&lt;/a&gt; or &lt;a href=&#34;https://lucidmanager.org/data-science/pacific-island-hopping/&#34;&gt;flight paths&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The code snippet below reads the data and converts it to a graph that can be examined using social network analysis techniques. I have saved the raw data available on Google Sheets file as CSV files. This data is filtered to contain only ownership relationships and the names of the organisations.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/digital-humanities/&#34; target=&#34;_blank&#34;
   title=&#34;Download digital-humanities from GitHub&#34;
   alt=&#34;Download digital-humanities from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;digital-humanities&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Analysing Trumpworld&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(tidyverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(igraph)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  trumpworld.org &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;read_csv&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;trumpworld/TrumpWorld Data org-org.csv&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;filter&lt;/span&gt;(Connection &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Ownership&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;select&lt;/span&gt;(OrgA &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Organization A&amp;#34;&lt;/span&gt;, OrgB &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Organization B&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  org.ownership &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; trumpworld.org &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      as.matrix &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;graph.edgelist&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;par&lt;/span&gt;(mar&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;rep&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;,&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot&lt;/span&gt;(org.ownership,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  layout &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; layout.fruchterman.reingold,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      vertex.label &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NA&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      vertex.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      edge.arrow.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/trumpworld-org1.png&#34; alt=&#34;Trumpworld Analysis: Ownership Relations in his Business Network&#34; title=&#34;Trumpworld Analysis: Ownership Relations in his Business Network&#34;/&gt;
&lt;figcaption&gt;
Trumpworld Analysis: Ownership Relations in his Business Network
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Network Analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This network contains 309 ownership relationships between 322 distinct organisations. When we plot the data, we see that most connections are dyadic connections between two firms. The plot is organised with the &lt;a href=&#34;https://en.wikipedia.org/wiki/Force-directed_graph_drawing&#34;&gt;Fruchterman-Reingold&lt;/a&gt; algorithm to improve its clarity. We can also see a large cluster in the centre. The names have been removed for clarity. Our excursion into Trumpland continues by zooming in on the subnetwork. The second code section excises this connected subnetwork so we can analyse it in more detail.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Digging Deeper
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The node with the highest &lt;a href=&#34;https://en.wikipedia.org/wiki/Degree_(graph_theory)&#34;&gt;degree&lt;/a&gt; identifies the business with the most holdings. This analysis shows that DJT Holdings LLC owns 33 other organisations. These organisations hold other organisations. We can now use the cluster function to investigate this subnetwork using the decompose function, which splits the network into its unconnected subnetworks. The code then selects and visualises the largest of the subnetworks. &lt;/p&gt;
&lt;p&gt;
This Trumpworld analysis shows that the ownership network is a &lt;a href=&#34;https://en.wikipedia.org/wiki/Star_(graph_theory)&#34;&gt;star network&lt;/a&gt;. DJT Holdings LLC centrally controls all organisations. Perhaps this graph visualises the management style of the soon to be president Trump. Trump centrally controls his empire, which is typical of a family business. Does this chart visualise Trump&amp;#39;s leadership style? Is the star network an expression of his lack of trust and thus desire to oversee everything directly?&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which.max&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;degree&lt;/span&gt;(org.ownership))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  org.ownership.d &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;decompose&lt;/span&gt;(org.ownership)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  largest &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which.max&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(org.ownership.d, diameter))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;plot&lt;/span&gt;(org.ownership.d[[largest]],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       layout&lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt;layout.fruchterman.reingold,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.label.cex &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.5&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       vertex.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      edge.arrow.size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;.1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;img src=&#34;https://lucidmanager.org/images/digital-humanities/trump-holdings.jpg&#34; alt=&#34;/images/digital-humanities/trump-holdings.jpg&#34; title=&#34;/images/digital-humanities/trump-holdings.jpg&#34; /&gt;&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Mapping antipodes using the ggmap package</title>
      <link>https://lucidmanager.org/data-science/mapping-antipodes/</link>
      <pubDate>Fri, 20 Jan 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/mapping-antipodes/</guid>
      <description>
	
&lt;p&gt;
When I was much younger, growing-up in the Netherlands I was fascinated by the conundrum of what happens when you drill a hole straight through the centre of the earth. I always believed that I would turn up in Australia. Well, I did end up in Australia, but not by drilling a hole. But is this really the case? This article is about mapping antipodes using the &lt;a href=&#34;https://github.com/dkahle/ggmap&#34;&gt;ggmap package&lt;/a&gt; of the R language.&lt;/p&gt;
&lt;p&gt;
The antipodes of any place on earth is the place that is diametrically opposite to it. A pair of antipodes are connected by a straight line running through the centre of the Earth. These points are as far away from each other as is possible on this planet. Two people are antipodes when they live on opposite sides of the globe.&lt;/p&gt;
&lt;p&gt;
The term antipodes was first coined by the ancient Greeks. Antipodes are people whose feet (πούς/pouch in Ancient Greek) are directly opposite each other. This concept was a direct consequence the &lt;a href=&#34;https://lucidmanager.org/data-science/mapping-ptolemy-geography/&#34;&gt;Hellenistic understanding of geography&lt;/a&gt;, but the existence of such lands or peoples was often debated or outright denied.&lt;/p&gt;
&lt;p&gt;
How can we use coding in R to solve this conundrum?&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Mapping antipodes with ggmap
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;We can roughly recreate the antipodean map on Wikipedia with the &lt;a href=&#34;https://cran.r-project.org/web/packages/globe/&#34;&gt;globe package&lt;/a&gt;. This package, written by Adrian Baddeley, plots 2D and 3D views of the earth. The package contains a data file with major coastlines that can be used to create a flipped map of the world. The ggplot2 package uses the globe to visualise maps.&lt;/p&gt;
&lt;p&gt;
The package contains a data file with major coastlines that can be used to create a flipped map of the world. To turn a spatial location into its antipode you subtract 180 degrees from the longitude and reverse the sign of the latitude, shown below.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/geography/antipodes.png&#34; alt=&#34;Antipodean globe&#34; title=&#34;Antipodean globe&#34; width=&#34;500&#34;/&gt;
&lt;figcaption&gt;
Antipodean globe.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/geography/&#34; target=&#34;_blank&#34;
   title=&#34;Download geography from GitHub&#34;
   alt=&#34;Download geography from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;geography&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Antipodean globe&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  world &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;map_data&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;world&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  anti_world &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; world &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;mutate&lt;/span&gt;(long &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; long &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;180&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;             lat &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; lat)           
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_polygon&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; world,  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(long, lat, group &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; group), fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;grey&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_polygon&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; anti_world, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(long, lat, group &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; group),
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                   fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;blue&amp;#34;&lt;/span&gt;, alpha &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.2&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;coord_map&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;ortho&amp;#34;&lt;/span&gt;, orientation &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;00&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_void&lt;/span&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
We can also use the &lt;a href=&#34;https://cran.r-project.org/web/packages/ggmap/index.html&#34;&gt;ggmap package&lt;/a&gt; to visualise antipodes. This package, developed by David Kahle antipodean R-guru Hadley Wickham, has a neat geocoding function to obtain a spatial location. You will need a Google API to enable the &lt;a href=&#34;https://lucidmanager.org/data-science/geocoding-with-ggmap/&#34;&gt;geocoding function&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The antipode function takes the description of a location and a zoom level to plot a dot on the antipode location. The gridExtra package is used to create a faceted map, which is not otherwise possible in ggmap.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(gridExtra)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggmap)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  api &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;readLines&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;google.api&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# Text file with the API key&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;register_google&lt;/span&gt;(key &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; api)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Antipode function&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  antipode &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(location, zm &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Map location&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      lonlat &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geocode&lt;/span&gt;(location)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      loc1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;get_map&lt;/span&gt;(lonlat, zoom &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; zm)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      map1 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggmap&lt;/span&gt;(loc1) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lonlat, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(lon, lat, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme&lt;/span&gt;(legend.position &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;none&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;# Define antipode&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      lonlat&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; lonlat&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-180&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (lonlat&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;-180&lt;/span&gt;) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          lonlat&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;360&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; lonlat&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lon
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      lonlat&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lat &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt;lonlat&lt;span style=&#34;color:#333&#34;&gt;$&lt;/span&gt;lat
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      loc2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;get_map&lt;/span&gt;(lonlat, zoom &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; zm)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      map2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggmap&lt;/span&gt;(loc2) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_point&lt;/span&gt;(data &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; lonlat, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(lon, lat, col &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;red&amp;#34;&lt;/span&gt;, size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme&lt;/span&gt;(legend.position &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;none&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;grid.arrange&lt;/span&gt;(map1, map2, nrow &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;antipode&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Rector Nelissenstraat 47 Hoensbroek&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This code solves the problem I was thinking about as a child. Running the code shows that the antipodes location of the home I grew up in is not in Australia, but quite a way south of New Australia. Although I did end-up living in Australia withouth having to dig a hole in the earth.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/geography/antipode-hoensbroek.jpg&#34; alt=&#34;Antipode map of my birthplace, Hoensbroek, the Netherlands&#34; title=&#34;Antipode map of my birthplace, Hoensbroek, the Netherlands&#34;/&gt;
&lt;figcaption&gt;
Antipode map of my birthplace, Hoensbroek, the Netherlands.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 8: Largest product in a series</title>
      <link>https://lucidmanager.org/data-science/project-euler-8/</link>
      <pubDate>Thu, 19 Jan 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-8/</guid>
      <description>
	
&lt;p&gt;
Project Euler 8 combines mathematics with text analysis. Just like &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-11/&#34;&gt;problem 11&lt;/a&gt;, it asks for the largest product in a grid.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 8 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The four adjacent digits in the 1,000-digit number below with the greatest product are 9 × 9 × 8 × 9 = 5832.&lt;/p&gt;
&lt;div class=&#34;center-block&#34; style=&#34;text-align: center; margin-left: auto; margin-right: auto;&#34;&gt;
&lt;div class=&#34;src src-text&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;73167176531330624919225119674426574742355349194934
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;96983520312774506326239578318016984801869478851843
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;85861560789112949495459501737958331952853208805511
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;12540698747158523863050715693290963295227443043557
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;66896648950445244523161731856403098711121722383113
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;62229893423380308135336276614282806444486645238749
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;30358907296290491560440772390713810515859307960866
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;70172427121883998797908792274921901699720888093776
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;65727333001053367881220235421809751254540594752243
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;52584907711670556013604839586446706324415722155397
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;53697817977846174064955149290862569321978468622482
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;83972241375657056057490261407972968652414535100474
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;82166370484403199890008895243450658541227588666881
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;16427171479924442928230863465674813919123162824586
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;17866458359124566529476545682848912883142607690042
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;24219022671055626321111109370544217506941658960408
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;07198403850962455444362981230987879927244284909188
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;84580156166097919133875499200524063689912560717606
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;05886116467109405077541002256983155200055935729725
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;71636269561882670428252483600823257530420752963450&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Find the thirteen adjacent digits in the 1,000-digit number that have the greatest product. What is the &lt;a href=&#34;https://projecteuler.net/problem=8&#34;&gt;value of this product&lt;/a&gt;?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Euler Problem 8 Proposed Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The first step is to define the digits as a character string with the 1000 digits. The answer is found by cycling through all 13-character n-grams to find the highest product using the prod function. The next step strips the 13 numbers into separate digits and multiplies them with each other with the &lt;code class=&#34;verbatim&#34;&gt;prod()&lt;/code&gt; function.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 8: Largest product in a series&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  digits &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  ngram &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;13&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Define length&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Clycle through digits&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;nchar&lt;/span&gt;(digits) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; ngram &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      adjecent &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;substr&lt;/span&gt;(digits, i, i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; ngram &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#888&#34;&gt;# 13 consecutive digits&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      mult &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;prod&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;as.numeric&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;unlist&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;strsplit&lt;/span&gt;(adjecent, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;)))) &lt;span style=&#34;color:#888&#34;&gt;# Define product&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (mult &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; answer) &lt;span style=&#34;color:#888&#34;&gt;# Largest? &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; mult
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 7: 10,001st Prime Number</title>
      <link>https://lucidmanager.org/data-science/project-euler-7/</link>
      <pubDate>Thu, 12 Jan 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-7/</guid>
      <description>
	
&lt;p&gt;
Project Euler 7 delves into the wonderful world of prime numbers. These numbers are interesting because they don&amp;#39;t follow a predictable pattern. There is no algorithm to calculate primes, which is what makes them valuable in cryptography. &lt;/p&gt;
&lt;p&gt;
As the numbers get larger, the gaps between consecutive primes also increase. There are, however, some interesting patterns. There seem to be infinitely many &lt;a href=&#34;https://oeis.org/A077800&#34;&gt;twin primes&lt;/a&gt;, which are prime numbers that with a difference of two, such as (3, 5), (5, 7) and (11, 13). Another pattern in prime numbers are &lt;a href=&#34;https://oeis.org/A023201&#34;&gt;sexy primes&lt;/a&gt;, which differ by six: e.g. (5,11), (7, 13) and (11, 17). They are called sexy not because these primes are particularly attractive but because of the Latin word for six.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 7 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the &lt;a href=&#34;https://projecteuler.net/problem=7&#34;&gt;1,0001st prime number&lt;/a&gt;?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Finding the n&lt;sup&gt;th&lt;/sup&gt; prime number can only be solved using brute force because primes do not follow a predictable pattern. We don&amp;#39;t have to check whether a number is divisible by any number between 1 and itself. We only have to check whether a number is divisible by all primes between 2 and its square root. The &lt;code class=&#34;verbatim&#34;&gt;is.prime()&lt;/code&gt; function determines whether a number is a prime number by checking that it is not divisible by any prime number up to the square root of the number. The sieve of Eratosthenes used in &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-3/&#34;&gt;Euler Problem 3&lt;/a&gt; generates the prime numbers. The next step cycles through all odd numbers and increments a counter when we find a prime, stopping at 10001.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 7: 10,0001st Prime Number&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;source&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;problem003.R&amp;#34;&lt;/span&gt;, echo &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  is.prime &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      primes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;esieve&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ceiling&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(n)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;prod&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; primes &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Start counter&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10001&lt;/span&gt;) { &lt;span style=&#34;color:#888&#34;&gt;# Find 10001 prime numbers&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; answer &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Next number&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;is.prime&lt;/span&gt;(answer)) { 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Increment counter&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Sexy Primes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The largest gap between two primes for the first 10,001 is 72. Sexy primes with a gap of 6 are the most common, as shown in the figure below.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/project-euler/problem-007.png&#34; alt=&#34;Frequency or prime gaps for the first 10,001 prime numbers.&#34; title=&#34;Frequency or prime gaps for the first 10,001 prime numbers.&#34;/&gt;
&lt;figcaption&gt;
Frequency or prime gaps for the first 10,001 prime numbers.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Sexy Primes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(ggplot2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(dplyr)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  primes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;esieve&lt;/span&gt;(answer)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  p &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(primes)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  gaps &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;tibble&lt;/span&gt;(Gap &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; primes[2&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;p] &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; primes[1&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;(p &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)],
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                     Sexy &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; Gap &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%&amp;gt;%&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;count&lt;/span&gt;(Gap, Sexy)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggplot&lt;/span&gt;(gaps, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;aes&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;factor&lt;/span&gt;(Gap), n, fill &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; Sexy)) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;geom_col&lt;/span&gt;() &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;scale_fill_manual&lt;/span&gt;(values &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;( &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#7391AB&amp;#34;&lt;/span&gt;, &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;#A62102&amp;#34;&lt;/span&gt;), name &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Sexy Prime Gap&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;theme_minimal&lt;/span&gt;(base_size &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;labs&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Frequency of prime gaps for the first 10,000 primes&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          x &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Prime Gap&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          y &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Frequency&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;guide_legend&lt;/span&gt;(title &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;Sexy Primes&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ggsave&lt;/span&gt;(&lt;span style=&#34;background-color:#fff0f0&#34;&gt;&amp;#34;images/problem-007.png&amp;#34;&lt;/span&gt;, width &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;, height &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/WJ12DYBuazY?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Sexy Primes - Numberphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 6: Sum Square Difference</title>
      <link>https://lucidmanager.org/data-science/project-euler-6/</link>
      <pubDate>Thu, 05 Jan 2017 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-6/</guid>
      <description>
	
&lt;p&gt;
Project problem 6 is another trivial one that only requires a basic understanding of coding in R, but it does teach us something about computer science.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 6 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The sum of the squares of the first ten natural numbers is:&lt;/p&gt;
&lt;p&gt;
$$1^2 + 2^2 + \ldots + 10^2 = 385$$&lt;/p&gt;
&lt;p&gt;
The square of the sum of the first ten natural numbers is:&lt;/p&gt;
&lt;p&gt;
$$(1 + 2 + \ldots + 10)^2 = 552 = 3025$$&lt;/p&gt;
&lt;p&gt;
The difference between the sum of the squares of the first ten natural numbers and the square of the sum is \(3025 - 385 = 2640\). Find the &lt;a href=&#34;https://projecteuler.net/problem=6&#34;&gt;difference&lt;/a&gt; between the sum of the squares of the first one hundred natural numbers and the square of the sum.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This is a straightforward problem for vector processing capabilities in R.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#888&#34;&gt;## Project Euler 6: Sum square difference&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;)^2 &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;((&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;)^2)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This problem can also be solved arithmetically. When Carl Friedrich Gauss (1777–1855) when he was a child his teacher challenged his students to add all numbers from 1 to 100. All of his friends struggled to add all the 100 numbers one by one, but Carl completed the task in a few seconds. Gauss found that the sum of natural numbers 1 to \(n\) is:&lt;/p&gt;
&lt;p&gt;
$$\sum_{i=1}^{n} i = \frac{n(n + 1)}{2}$$&lt;/p&gt;
&lt;p&gt;
The code shown above does what Carl’s classmates would have done, using brute force to count the total. Gauss’ solution only required a straightforward step. Computer scientists use &lt;em&gt;Big O&lt;/em&gt; notation to describe the steps it takes to complete an algorithm. In Big-O Notation, the first solution is \(O(n)\) which means that the number of steps in the algorithm grows in direct proportion to the data set. In this case, we only look at 100 numbers. But solving this problem for many billions of numbers would pose some practical issues. The brute-force solution is notated as \(O(n)\) as it takes as many steps as there are elements. Gauss’ solution is \(O(1)\), which means that the solution only requires one step, regardless of the size of the data set.&lt;/p&gt;
&lt;p&gt;
The &lt;a href=&#34;https://brilliant.org/wiki/sum-of-n-n2-or-n3/&#34;&gt;sum of the squares&lt;/a&gt; of the first \(n\) natural numbers is:&lt;/p&gt;
&lt;p&gt;
$$\sum_{i=1}^{n} i^2 = \frac{n(n+1)(2n+1)}{6}$$&lt;/p&gt;
&lt;p&gt;
With these two formulas, a fast solution without having to use loops can be written.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;100&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; ((n &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)^2 &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; n &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;6&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 5: Smallest Multiple</title>
      <link>https://lucidmanager.org/data-science/project-euler-5/</link>
      <pubDate>Thu, 29 Dec 2016 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-5/</guid>
      <description>
	
&lt;p&gt;
Project Euler 5 relates to the divisibility of numbers and is an almost trivial problem that is included here only for completeness.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 5
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is &lt;a href=&#34;https://projecteuler.net/problem=5&#34;&gt;evenly divisible&lt;/a&gt; by all of the numbers from 1 to 20?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The solution will also be divisible by the numbers 1 to 10, so we can start at 2520 and increment by 2520. The loop checks whether the number is divisible by the numbers 1 to 20. &lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 5: Smallest Multiple&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2520&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(answer &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; answer &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2520&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;# Increase by smallest number divisible by 1:10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
David Radcliffe provided a more generalised way to derive the answer. To solve this problem, we need the Least Common Denominator, which is the smallest number that two or more numbers will divide into evenly. To find the LCD, we first need to know the Greatest Common Divisor \(gcd(x, y)\). The Lowest Common Denominator is the product two numbers, divided by the \(gcd\).&lt;/p&gt;
&lt;p&gt;
The first function calculates the Greatest Common Divisor of tho numbers, \(gcd(x, y)\), using the Euclidean Algorithm in a recursive function. The second function derives the \(lcm\).&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;Reduce()&lt;/code&gt; function takes a function, and a list of data items and recursively applies the function to the elements of the list. Reduce performs the function in the first parameter over the first two elements, then over that result and the third element, and so on. A nice way to see what &lt;code class=&#34;verbatim&#34;&gt;Reduce()&lt;/code&gt; does is to use &lt;code class=&#34;verbatim&#34;&gt;accumulate = TRUE&lt;/code&gt;. This option returns its state after processing the elements of the list.&lt;/p&gt;
&lt;p&gt;
This solution thus finds the Lowest Common Denominator for the numbers 1 to 20.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Generalised method &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  gcd &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt; (x, y) &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;ifelse&lt;/span&gt;(x &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;, y, &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gcd&lt;/span&gt;(y &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; x, x))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  lcm &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt; (x, y) x &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; y &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;gcd&lt;/span&gt;(x, y)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;Reduce&lt;/span&gt;(lcm, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;Reduce&lt;/span&gt;(lcm, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;20&lt;/span&gt;, accumulate &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;TRUE&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 4: Largest Palindromic Product</title>
      <link>https://lucidmanager.org/data-science/project-euler-4/</link>
      <pubDate>Thu, 22 Dec 2016 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-4/</guid>
      <description>
	
&lt;p&gt;
Project Euler 4 takes us to the palindromic numbers, a number that stays the same when reading it backwards. Palindromic numbers serve no practical purpose other than recreational mathematics.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 4 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the &lt;a href=&#34;https://projecteuler.net/problem=4&#34;&gt;largest palindrome&lt;/a&gt; made from the product of two 3-digit numbers.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The formal definition for Palindromic numbers in base-\(b\), with \(k\) digits \(a_i\) is:&lt;/p&gt;
&lt;p&gt;
$$\sum_{i=0}^ka_ib^i = \sum_{i=k}^0a_ib^i$$&lt;/p&gt;
&lt;p&gt;
The solution code uses a helper-function to reverse numbers. The &lt;code class=&#34;verbatim&#34;&gt;reverse()&lt;/code&gt; function takes the modulus of 10 to extract the last digit until all digits have been processed. The solution code searches for palindromic numbers, starting at the highest product of three-digit numbers.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 4: Largest Palindromic Product&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Reverse a number&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  reverse &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      reverse &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          reverse &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; reverse &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(reverse)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Euler problem 4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;999&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;900&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (j &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;990&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;900&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          p &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; j
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (p &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;reverse&lt;/span&gt;(p)) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (p &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;reverse&lt;/span&gt;(p)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; j
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Lychrel Numbers
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Lychrell process can convert almost all non-palindromic numbers to a palindromic number. The process reverses the non-palindromic number and adds the result to the original number. If the result is not a palindromic number, the process repeats until we reach a palindrome. For example, 59 becomes a palindrome after 3 iterations: 59 + 95 = 154, 154 + 451 = 605, 605 + 506 = 1111.&lt;/p&gt;
&lt;p&gt;
Any number that will never become a palindrome using the Lychrel process is a so-called Lychrel number. Most numbers will convert to a palindrome after a few iterations. However, the number 196 apparently never becomes a palindrome, even after hundreds of thousands of repetitions. There is no proof that Lychrel numbers actually exist. Any code to undertake the Lychrel process could run forever, which is the infamous halting problem in computer science. &lt;a href=&#34;https://oeis.org/A023108&#34;&gt;Sequence A023108&lt;/a&gt; of the Online Encyclopedia of Integers lists numbers that apparently never iterate to become a palindrome.&lt;/p&gt;
&lt;p&gt;
The &lt;code class=&#34;verbatim&#34;&gt;lychrel()&lt;/code&gt; function tests a number for Lychrel property by following the palindrome process. The output of this function is the resulting palindrome. As these numbers can be huge, we maximise the number of available digits. Unfortunately, there is no way of telling if it will ever stop for certain numbers. We know that the first 195 will terminate, but the number 196 &lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Lychrel Numbers&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  lychrel &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(l, verbose &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;FALSE&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt;(l &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;reverse&lt;/span&gt;(l)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;reverse&lt;/span&gt;(l)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(l)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  lychrel &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(l) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt;(l &lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;reverse&lt;/span&gt;(l))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;reverse&lt;/span&gt;(l)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(l)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## First 195 non-Lychrel numbers&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;options&lt;/span&gt;(digits &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;22&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sapply&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;195&lt;/span&gt;, lychrel)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## This function call apparently never halts - run at your own risk!&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;lychrel&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;196&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;figure&gt;
&lt;p&gt;&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/bN8PE3eljdA?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;figcaption&gt;
What&amp;#39;s special about 196? - Numberphile.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 3: Largest Prime Factor</title>
      <link>https://lucidmanager.org/data-science/project-euler-3/</link>
      <pubDate>Fri, 09 Dec 2016 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-3/</guid>
      <description>
	
&lt;p&gt;
Project Euler 3 is about prime factors, which are some of the most important numbers of the digital economy. RSA encryption is based on the fact that determining the prime factors of huge numbers takes a very long time. So much time in fact that the cost of breaking the encryption outweigh the benefits of obtaining the secret.&lt;/p&gt;
&lt;p&gt;
Prime numbers are the basic building blocks of the natural numbers as every number, except the primes themselves. Every natural number can be written as the product of a series of primes. The RSA encryption system uses large primes to keep electronic messages away from prying eyes, as explained in the Numberphile video below.&lt;/p&gt;
&lt;p&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/M7kEpw1tn50?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
Prime numbers are a favourite topic in Project Euler. &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-7/&#34;&gt;Problem 7&lt;/a&gt; asks for the first ten thousand primes, and &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-10/&#34;&gt;Problem 10&lt;/a&gt; looks at the sum of all the primes below two million.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 3 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The prime factors of 13195 are 5, 7, 13 and 29. What is the &lt;a href=&#34;https://projecteuler.net/problem=3&#34;&gt;largest prime factor&lt;/a&gt; of the number 600851475143?&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Generating Prime Numbers
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This solution relies on two functions that can be used for multiples problems. The Sieve of Eratosthenes generates prime numbers from 2 to &lt;em&gt;n&lt;/em&gt;. The code is commented to explain the sieve. The image shows how numbers from 1 to 100 are sieved to find the primes.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://upload.wikimedia.org/wikipedia/commons/b/b9/Sieve_of_Eratosthenes_animation.gif&#34; alt=&#34;Sieve of Eratosthenes (Source: SKopp at German Wikipedia / CC BY-SA).&#34; title=&#34;Sieve of Eratosthenes (Source: SKopp at German Wikipedia / CC BY-SA).&#34;/&gt;
&lt;figcaption&gt;
Sieve of Eratosthenes (Source: SKopp at German Wikipedia / CC BY-SA).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This problem uses two functions: &lt;code class=&#34;verbatim&#34;&gt;prime.factors()&lt;/code&gt; and &lt;code class=&#34;verbatim&#34;&gt;esieve()&lt;/code&gt;. The &lt;code class=&#34;verbatim&#34;&gt;prime.factors()&lt;/code&gt; function generates the list of unique prime divisors and then produces the factors. The factors are identified by dividing the number by the candidate prime factors until the result is 1.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Base R Solution
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;


&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 3: Largest Prime Factor&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Base R solution&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  esieve &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;NULL&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(n)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Create a list of consecutive integers {2,3,... n}.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;n
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Start counter&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Select p as the first prime number in the list, p = 2.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      p &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (p^2 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#888&#34;&gt;## Remove all multiples of p from the l.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          l &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l[l &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; p &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; l &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; p&lt;span style=&#34;color:#333&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#888&#34;&gt;## set p equal to the next integer in l which has not been removed.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#888&#34;&gt;## Repeat steps 3 and 4 until p^2 &amp;gt; n,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#888&#34;&gt;## all the remaining numbers in the list are primes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          p &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; l[i]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(l)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  prime.factors &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt; (n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Define list of factors&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      factors &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Define primes to be tested&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      primes &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;esieve&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(n)))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Idenitfy prime divisors&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      d &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;which&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; primes &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## No prime divisors&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(d) &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(n)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#888&#34;&gt;## Test candidate primes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (q &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; primes[d]) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#888&#34;&gt;## Generate list of factors&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; q &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              factors &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(factors, q)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; n&lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt;q } } 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) 
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  factors &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(factors, n)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(factors)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;prime.factors&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;600851475143&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Number package
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The solution can also be found by using the &lt;code class=&#34;verbatim&#34;&gt;primeFactors()&lt;/code&gt; function in the &lt;a href=&#34;https://cran.r-project.org/web/packages/numbers/index.html&#34;&gt;numbers package&lt;/a&gt;. This package provides a range of functions related to prime numbers and is much faster than the basic R code.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Numbers package&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(numbers)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;primeFactors&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;600851475143&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 2: Sum of Even Fibonacci Numbers</title>
      <link>https://lucidmanager.org/data-science/project-euler-2/</link>
      <pubDate>Thu, 08 Dec 2016 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-2/</guid>
      <description>
	
&lt;p&gt;
Project Euler 2 looks at Fibonacci numbers. This number sequence seems to describe our sense of natural beauty and aesthetics. The spiral staircase uses Fibonacci numbers as part of its geometry. Euler Problem 2 is a bit less poetic as it only asks to generate and sum even numbers. &lt;a href=&#34;https://lucidmanager.org/data-science/project-euler-25/&#34;&gt;Euler Problem 25&lt;/a&gt; also deals with Fibonacci numbers and asks to find the first such number with 1000 digits.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Project Euler 2 Definition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:&lt;/p&gt;
&lt;p&gt;
$1, 2, 3, 5, 8, 13, 21, 34, 55, 89, \ldots$&lt;/p&gt;
&lt;p&gt;
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the &lt;a href=&#34;https://projecteuler.net/problem=2&#34;&gt;sum of the even-valued terms&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Euler Problem 2 Solution in R
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The code generates Fibonacci numbers until it reaches the value of four million. The code then sums the even numbers in the sequence. &lt;/p&gt;
&lt;p&gt;
The intuitive way to calculate Fibonacci numbers is to use a recursive function. This function calls itself until it reaches the first two numbers.&lt;/p&gt;
&lt;p&gt;
&lt;a href = &#34;https://github.com/pprevos/ProjectEuler/&#34; target=&#34;_blank&#34;
   title=&#34;Download ProjectEuler from GitHub&#34;
   alt=&#34;Download ProjectEuler from GitHub&#34;&gt;
  &lt;button class=&#34;button is-medium is-primary&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-github&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span style=&#34;font-family: monospace&#34;&gt;ProjectEuler&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;

&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Project Euler 2: Sum of Even Fibonacci Numbers&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Recursive function&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  fib &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (n &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;) &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;fib&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;fib&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;fib&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This function calculates the \(n^{th}\) Fibonacci number by calling itself with a reduced index until it reaches 1. Recursive functions are, however, very memory hungry and not very fast. A much faster method is to create a vector of Fibonacci numbers and add the even ones. The code below generates Fibonacci numbers until it reaches the value of four million. The code then sums the even numbers in the sequence.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Sequential function&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  fib &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;max&lt;/span&gt;(fib) &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4E+06&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      len &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;length&lt;/span&gt;(fib)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      fib &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;c&lt;/span&gt;(fib, fib[len &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;] &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; fib[len])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(fib[fib &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Using the GMP Package
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A series of R packages exist to generate Fibonacci numbers. The &lt;a href=&#34;https://cran.r-project.org/web/packages/gmp/index.html&#34;&gt;GMP package&lt;/a&gt; for Multiple Precision Arithmetic provides the &lt;code class=&#34;verbatim&#34;&gt;fibnum()&lt;/code&gt; function to calculate the n^th Fibonacci number. This package is also able to work with huge numbers. Using this package is much faster than the base R code used above. Interestingly, the GMP library uses tables for Fibonacci numbers up to twelve quintillion (10&lt;sup&gt;18&lt;/sup&gt;).&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Using the GMP Package&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;library&lt;/span&gt;(gmp)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  fib &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;fibnum&lt;/span&gt;(i)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;while&lt;/span&gt; (fib &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4E6&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (fib &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; answer &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; fib
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    i &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    fib &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;fibnum&lt;/span&gt;(i)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Analytic Solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;An analytical solution prevents using recursion and a brute force method to find the answer. Binet&amp;#39;s formula for the n^th Fibonacci number lets us determine a Fibonacci number without recursion:&lt;/p&gt;
&lt;p&gt;
$$F_n=\frac{\varphi^n-\frac{1}{(-\varphi)^n}}{\sqrt{5}}$$&lt;/p&gt;
&lt;p&gt;
We know that $\varphi$ is the Golden Ratio, so we can simplify this formula:&lt;/p&gt;
&lt;p&gt;
$$F_n\sqrt{5}=\frac{(1+\sqrt{5})^n}{2^n}$$&lt;/p&gt;
&lt;p&gt;
This formula results in a simple function to generate a sequence of Fibonacci numbers:&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;## Analytical solution&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  binet &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;round&lt;/span&gt;((((&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;))^n) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;^n) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;binet&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;10&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
The &lt;a href=&#34;https://math.stackexchange.com/questions/374758/how-can-i-find-an-inverse-to-the-binet-formula&#34;&gt;inverse of the Binet formula&lt;/a&gt; gives us:&lt;/p&gt;
&lt;p&gt;
$n=\left[ \log_\phi \sqrt{5}(F_n-\frac{1}{2}) \right]$ holds for all $n\ge 3$&lt;/p&gt;
&lt;p&gt;
This formula allows us to work out which Fibonacci number is less than or equal to 4 million:&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  phi &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;)) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  n_4e6 &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;log&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sqrt&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;4E6&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0.5&lt;/span&gt;), base &lt;span style=&#34;color:#333&#34;&gt;=&lt;/span&gt; phi))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Using this formula, we find that the first 33 Fibonacci numbers are equal or less than four million. Next step is to sum all the even numbers.&lt;/p&gt;
&lt;p&gt;
According to the &lt;a href=&#34;https://oeis.org/A014445&#34;&gt;Online Encyclopedia of Integer Sequences&lt;/a&gt; (lemma A014445), every third Fibonacci number is even. We can now use Binet&amp;#39;s formula to sum every third Fibonacci number.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;binet&lt;/span&gt;(&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;seq&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, n_4e6, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;)))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Project Euler 1: Multiples of 3 and 5</title>
      <link>https://lucidmanager.org/data-science/project-euler-1/</link>
      <pubDate>Thu, 01 Dec 2016 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/project-euler-1/</guid>
      <description>
	
&lt;p&gt;
This &lt;a href=&#34;http://projecteuler.net/problem=001&#34;&gt;first Euler problem&lt;/a&gt; provides a gentle introduction to solving mathematical problems with code. This problem involves finding the sum of two related arithmetic sequences.&lt;/p&gt;
&lt;p&gt;
The natural numbers below 10 that are multiples of 3 or 5 results are 3, 5, 6 and 9. The sum of these numbers is $3+5+6+9=23$. Your assignment is to find the sum of all the multiples of 3 or 5 below 1000.&lt;/p&gt;
&lt;p&gt;
This problem is similar to one posed to a mathematics child prodigy that lived around the same time as Euler. When Carl Friedrich Gauss (1777–1855) was ten years old, his teacher gave his pupils a maths problem to ponder on. The teacher was perhaps seeking some quiet time for himself by giving the kids a hard problem. He asked them to sum all the numbers from 1 to 100, which surely would give him enough time to enjoy a cuppa.&lt;/p&gt;
&lt;p&gt;
Young Carl Gauss stood up after just a minute and confidently proudly raised his slate with 5050 written in large chalk letters to the teacher. All the other kids were still diligently adding numbers. How was Carl able to finish his task so quickly?  The &lt;a href=&#34;https://doi.org/10.1511/2006.59.200&#34;&gt;details and full truth of this story&lt;/a&gt; are lost in history. Perhaps Carl realised the solution while writing the series forwards and backwards:&lt;/p&gt;
&lt;p&gt;
$$1 + 2 + 3 + \ldots + 98 + 99 + 100$$&lt;/p&gt;
&lt;p&gt;
$$100 + 99 + 98 + \ldots + 3 + 2 + 1$$&lt;/p&gt;
&lt;p&gt;
Little Carl calculated the sum of some of the pairs and noticed a regularity:&lt;/p&gt;
&lt;p&gt;
$$1 + 100 = 2 + 99 = 3 + 98 = \ldots 100 + 1 = 99 + 2 = 98 + 3 = 101$$&lt;/p&gt;
&lt;p&gt;
Each of the pairs adds up to 101 and there are 50 pairs, therefore the sum of all numbers is half the sum of all pairs. Gauss was not the first to discover this method. Some thirteen hundred years earlier, Indian mathematician and astronomer Aryabhata had already discovered this method to sum a arithmetical sequence.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Proposed Solutions
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This anecdote shows that there are two ways to solve this first problem. The smart method that Gauss used or the slow brute force method that his fellow pupils used. The brute force solution requires many steps to find the answer. The smart solution uses a one-step formula, such as the young Gauss and Aryabhata had figured out.&lt;/p&gt;
&lt;p&gt;
The most inefficient solution is to test whether all numbers between 1 and 999 are divisible by 3 or 5 and then add all these number. The R language provides several ways to step through a sequence of numbers.&lt;/p&gt;
&lt;p&gt;
The code below loops trough the numbers between 1 and 999.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Project Euler 1: Multiples of 3 and 5&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Loop&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;for&lt;/span&gt; (i &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;999&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;if&lt;/span&gt; (i &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; i &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      answer &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; answer &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; i
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(i)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;print&lt;/span&gt;(answer)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This first solution is elaborate. Using for-loops in R should always be a last resort in R coding because they are the slowest way to compute over a series of steps. The next two solutions solve this problem by using vector arithmetic. These methods are much faster because they run the loop directly in machine code instead of having to compile each step.&lt;/p&gt;
&lt;p&gt;
The solution for the first problem only requires one line of code when using vector arithmetic.&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Vector aritmetic&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;sum&lt;/span&gt;((&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;999&lt;/span&gt;)&lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;[&lt;/span&gt;((&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;999&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;|&lt;/span&gt; ((&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt;&lt;span style=&#34;color:#333&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;999&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;%%&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;0&lt;/span&gt;)])&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Analytical solution
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Although the vector arithmetic is much faster than the for-loop, it is still not as fast as using the methods discovered by Aryabhata and Gauss. The two brute-force solutions are very fast because of the low number of steps to find a solution. An analytical solution reduces the processing time significantly, as it only requires one step.&lt;/p&gt;
&lt;p&gt;
The problem involves &lt;em&gt;arithmetic progressions&lt;/em&gt;, which are sequences of numbers with a constant difference. The sequence 1, 4, 7, 10, 13, … is an arithmetic progression with a common difference of three.&lt;/p&gt;
&lt;p&gt;
We can generalise the method discovered by Gauss. The sum of an arithmetic progression ($S_n$), where $n$ is the number of elements and $a_1$ and $a_n$ are the lowest and highest value, is:&lt;/p&gt;
&lt;p&gt;
$$S_n= \frac{n(a_{1} + a_n)}{2}$$&lt;/p&gt;
&lt;p&gt;
The numbers divisible by $n=3$ can be expressed as:&lt;/p&gt;
&lt;p&gt;
$$\mathrm{sum}_3(999)=3+6+9+12+ \ldots + 999 = 3(1+2+3+4+ \ldots + 333)$$&lt;/p&gt;
&lt;p&gt;
We can now calculate the sum of all divisors by combining the above progression with the formula for arithmetic progressions as expressed in the above code, where $m$ is the divisor and $n$ the extent of the sequence. $p$ is the highest number less than $n$ divisible by $m$. In the case of 5, this number is 995.&lt;/p&gt;
&lt;p&gt;
$$p = n \lfloor (m/n) \rfloor$$&lt;/p&gt;
&lt;p&gt;
Substitution gives:&lt;/p&gt;
&lt;p&gt;
$$\mathrm{sum}_m(n) =  p \frac{1+(p/m)}{2}$$&lt;/p&gt;
&lt;div class=&#34;src src-r&#34;&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#888&#34;&gt;# Analytical solution&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  SumDivBy &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;function&lt;/span&gt;(m, n) {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      p &lt;span style=&#34;color:#333&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;floor&lt;/span&gt;(n &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; m) &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; m &lt;span style=&#34;color:#888&#34;&gt;# Round to multiple of n&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#080;font-weight:bold&#34;&gt;return&lt;/span&gt; (p &lt;span style=&#34;color:#333&#34;&gt;*&lt;/span&gt; (&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; (p &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; m)) &lt;span style=&#34;color:#333&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;SumDivBy&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;999&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;SumDivBy&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;5&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;999&lt;/span&gt;) &lt;span style=&#34;color:#333&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#06b;font-weight:bold&#34;&gt;SumDivBy&lt;/span&gt;(&lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;15&lt;/span&gt;, &lt;span style=&#34;color:#60e;font-weight:bold&#34;&gt;999&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;a href = &#34;https://www.r-bloggers.com/&#34; target=&#34;_blank&#34; title=&#34;Proudly associated with R-Bloggers&#34;&gt;
  &lt;button class=&#34;button is-link is-medium&#34;&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;i class=&#34;fab fa-r-project&#34;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;span&gt;As seen on R Bloggers&lt;/span&gt;
  &lt;/button&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Towards Balanced Centricity: Moving Beyond Customer Focus</title>
      <link>https://lucidmanager.org/marketing/balanced-centricity/</link>
      <pubDate>Thu, 21 Apr 2016 09:54:37 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/balanced-centricity/</guid>
      <description>
	
&lt;p&gt;
It is an undisputed truism that service providers need to be customer-centric to be successful. This kernel of wisdom is more and more finding its way into the discourse on water utility marketing. While this statement is indisputable in a competitive environment, its application to public services such as water utilities is not beyond doubt. This article introduces the concept of balanced centricity to show the limits of focusing on customers alone.&lt;/p&gt;
&lt;p&gt;
Some contemporary marketing scholars, such as Evert Gummesson, are reconsidering the primacy of customer centricity have introduced the concept of Balanced Centricity. Total customer centricity is a limited foundation for service providers because full implementation risks the sustainability of the organisation.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Balanced Centricity
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Services are a dyadic (two-way) relationship between customers and service providers. Instead, a network of activities involving a range of diverse stakeholders creates the service. Each stakeholder within the network is a beneficiary of the actions of another stakeholder. The service provider and each of the beneficiaries in the network co-create value.&lt;/p&gt;
&lt;p&gt;
Customers are not the end-point, but actively maintain their part of the value chain. &lt;a href=&#34;https://lucidmanager.org/marketing/value-of-water/&#34;&gt;Water has no intrinsic value&lt;/a&gt; in itself. Customer realise its value proposition when they consume the water. The value chain for water utilities thus extends far beyond the customer tap. Most customer taps service multiple people, who use the water to achieve the 3Cs: &lt;em&gt;Comfort&lt;/em&gt;, &lt;em&gt;Cleanliness&lt;/em&gt; and &lt;em&gt;Convenience&lt;/em&gt;. It is, however, not the water that creates the value, it is the activities that people undertake with the water. The water utility is only a facilitator is value in a network of relationships.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/value-creation-network.png&#34; alt=&#34;Example of a value creation network for water utilities&#34; title=&#34;Example of a value creation network for water utilities&#34; width=&#34;400&#34;/&gt;
&lt;figcaption&gt;
Example of a value creation network for water utilities.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Multiple Stakeholders of Water Utilities
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;As public service providers, professional judgments, such as public health considerations dominate many aspects of service provision. These judgements are not the domain of the consumer experience but of the expert. Tap water is an undifferentiated service where natural monopoly provisions prevent utilities from providing individualised services. Customer centricity in public utilities is thus limited to those aspects that consumers are capable of influencing.&lt;/p&gt;
&lt;p&gt;
Balanced centricity is a situation where all beneficiaries in the value creation network have the right to the satisfaction of what customers need and want. Regulators are a principal beneficiary within the value creation network for utilities. Water utilities service them through information provision. The environment is also a significant beneficiary of water services, which in Australia is managed through environmental water allocations.&lt;/p&gt;
&lt;p&gt;
Water utilities are mediators between the natural environment and the value that customer create with this natural resource. Traditional customer centricity has limited application to water utilities because of our reliance on the natural environment. Being fully customer-centric could lead to a Tragedy of the Commons as the natural environment is depleted.&lt;/p&gt;
&lt;p&gt;
Water utilities have to balance their centricity between all stakeholders in the value-creation network, including the natural environment.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/water-utility-supply-chain.png&#34; alt=&#34;/images/water-marketing/water-utility-supply-chain.png&#34; title=&#34;/images/water-marketing/water-utility-supply-chain.png&#34; /&gt;&lt;figcaption&gt;
The water utility value chain.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This brief discussion shows that being customer-centric is not the sole focus of public service organisations. Public service has inherent limitations on the extent to which consumer judgement can be incorporated in service design. Also, the value creation network perspective shows that the consumer is only one of the many beneficiaries of the value creation process.&lt;/p&gt;
&lt;p&gt;
If you like to know more about this topic, they please read my book &lt;em&gt;Customer Experience Management for Water Utilities by IWA Publishing.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Service Quality Perception in Tap Water</title>
      <link>https://lucidmanager.org/marketing/service-quality-perception/</link>
      <pubDate>Tue, 12 May 2015 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/service-quality-perception/</guid>
      <description>
	
&lt;p&gt;
The concept that customer is always right is a controversial topic in service industries, including water utilities. There seems to be a &lt;a href=&#34;https://lucidmanager.org/marketing/tap-water-paradoxes/&#34;&gt;paradox&lt;/a&gt; between how water professionals interpret the service quality perception of tap water and the way customers see it. Providing &lt;a href=&#34;https://lucidmanager.org/marketing/water-quality-paradox/&#34;&gt;safe drinking water is not the same as providing good water.&lt;/a&gt; For example, water utilities add chlorine or fluoride to the water to protect public health. This article discuses the service quality perception that customers of water utilities hold.&lt;/p&gt;
&lt;p&gt;
In some communities, however, chlorine and fluoride are perceived as unwanted chemicals, leading to a reduction in the perception that customers have of the quality of service.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;  We can investigate the perceptions that customers have of tap water by analysing the sentiment of &lt;a href=&#34;https://lucidmanager.org/data-science/tap-water-sentiment-analysis/&#34;&gt;tweets about tap water&lt;/a&gt;. This analysis shows that approximately 60% of tweets express a negative sentiment.&lt;/p&gt;
&lt;p&gt;
We surveyed customers of two Australian and three American water utilities to investigate possible moderators of service quality in water services. The preliminary conclusion of this pilot study is that external factors such as financial hardship and service involvement influence service quality perception. This research has potential implications to how water utilities report service quality and how they relate to customers.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Summary
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;ul&gt;
&lt;li&gt;A sample of customers from two Australian water utilities reported
their perceptions of tap water&lt;/li&gt;
&lt;li&gt;Customers with a higher level of financial hardship rated the level of
service lower&lt;/li&gt;
&lt;li&gt;Customers with a higher level of involvement rated the level of
service higher&lt;/li&gt;
&lt;li&gt;External factors influence service quality perception of water utility
customers&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Methodology
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This article reports on a pilot of a research project investigating the relationship between organisational behaviour and customer perception. A sample of customers from two water utilities in Australia completed a survey about their perceptions of tap water. The survey asked customers their views on the following concepts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Involvement with tap water&lt;/li&gt;
&lt;li&gt;The frequency of contacting their water utility&lt;/li&gt;
&lt;li&gt;Level of experienced financial hardship&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Service quality perception&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The technical quality of the services provided by their water
utility&lt;/li&gt;
&lt;li&gt;The functional quality of the services provided by their water
utility&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Involvement with tap water was measured using the &lt;a href=&#34;https://lucidmanager.org/data-science/measuring-consumer-involvement/&#34;&gt;Personal Inventory Index&lt;/a&gt;. Consumer involvement is a person&amp;#39;s perceived relevance of something based on their needs, values, and interests.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-2&#34; href=&#34;#footnote-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
A Likert scale measured the frequency of contacting the utility and the level of perceived hardship. &lt;/p&gt;
&lt;p&gt;
The level of technical service was assessed using five questions about the physical services, i.e. availability, pressure, taste, safety, visual appeal. The level of functional service was evaluated using a scale consisting of 13 items, such as billing accuracy, friendliness of staff, availability of information and so on.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Service Quality Perception in Tap Water Services
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A total of 649 customers from six utilities in Australia and the United
States completed the survey, with the standard error of responses at
0.9%. The diagonal in figure 1 indicates the distribution of replies.
The scatter plots and large numbers show the correlations between
variables.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/correlations.jpg&#34; alt=&#34;Correlations between customer constructs&#34; title=&#34;Correlations between customer constructs&#34;/&gt;
&lt;figcaption&gt;
Figure 1: Correlations between customer constructs.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Analysis revealed statistically significant correlations between some of
the constructs. Financial hardship negatively influences service quality
perception. A high level of involvement relates to a high level of
service quality perception.&lt;/p&gt;
&lt;p&gt;
Most salient was a high negative correlation between the level of
financial hardship and perceptions of functional quality \((r(649)=-0.16, p&amp;lt;0.001)\) 
and technical quality \((r(649)=-0.19, p&amp;lt;0.001)\).&lt;/p&gt;
&lt;p&gt;
The level of involvement revealed a positive correlation with functional
quality \((r(649)=0.26, p&amp;lt;0.01)\) and with technical quality \((r(649)=0.35, p&amp;lt;0.01)\).&lt;/p&gt;
&lt;p&gt;
The data thus show that the more difficulty customers have with paying
their bills, the lower their perceptions of the level of service
provided by water utilities. The data also shows that customers with a
high level of involvement in tap water rate the level of service
provision higher than those with a low level of involvement.&lt;/p&gt;
&lt;p&gt;
The level of technical quality also shows a strong correlation between
the degree of functional quality \((r(649)=0.35, p&amp;lt;0.01)\). The
reason for this healthy relationship is unknown and is most likely
caused by confounding variables.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Discussion
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The idea that factors outside of the direct control of the service
provider moderate service quality is a well-known phenomenon in
marketing theory. &lt;a href=&#34;https://www.researchgate.net/publication/23547422_Does_Touch_Affect_Taste_The_Perceptual_Transfer_of_Product_Container_Haptic_Cues&#34;&gt;Research in food marketing&lt;/a&gt; shows that the taste of water can be influenced by
the firmness of the cup it was consumed from.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-3&#34; href=&#34;#footnote-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
This pilot study indicates that these types of effects may also exist in
the provision of urban water services.&lt;/p&gt;
&lt;p&gt;
Although improving operational effectiveness will improve the physical
quality of water services, many uncontrollable factors also influence
the perception that customers hold of the level of service. Utilities
can minimise the level of hardship through pricing controls and rebates.
Customer engagement and communication can influence involvement with tap
water. Involvement is important to water utilities as also relates to a
consumer&amp;#39;s willingness to pay for services.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Is the customer always right about their service quality perception?
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The axiom that the customer is always right needs to be nuanced. The
customer might not be right about the physical facts of water service.
However, they are always right about their service quality perception.
This research demonstrates that to provide a high level of service to
customers, a focus on excellent engineering will not necessarily lead to
increased customer satisfaction. Influencing customer perceptions
requires a deep understanding of customers.&lt;/p&gt;
&lt;p&gt;
If you like to find out more about using marketing theory to manage the experience of water utility customers, then please consider reading &lt;em&gt;Customer Experience Management for Water Utilities&lt;/em&gt; by Peter Prevos. &lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
Notes
&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Kot, M., Castleden, H., &amp;amp; Gagnon, G. A. (2011). Unintended consequences of regulating drinking water in rural Canadian communities: Examples from Atlantic Canada. &lt;em&gt;Health &amp;amp; Place&lt;/em&gt;, /17/(5), 1030–1037.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-2&#34;&gt;&lt;a href=&#34;#footnote-reference-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Zaichkowsky, J. L. (1994). The personal involvement inventory: Reduction, revision, and application to advertising. &lt;em&gt;Journal of Advertising&lt;/em&gt;, 23(4), 59.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-3&#34;&gt;&lt;a href=&#34;#footnote-reference-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Krishna, A., &amp;amp; Morrin, M. (2008). Does touch affect taste? The perceptual transfer of product container haptic cues. &lt;em&gt;Journal of Consumer Research&lt;/em&gt;, 34(6), 807–818.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Water Utility Branding: What is your Utility&#39;s Personality?</title>
      <link>https://lucidmanager.org/marketing/water-utility-branding/</link>
      <pubDate>Tue, 07 Apr 2015 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/water-utility-branding/</guid>
      <description>
	
&lt;p&gt;
Water utilities are generally invisible to their customers. You open the tap, water comes out and ones in a while you receive a bill. Customers tend to only contact water utilities when they need to undertake mundane tasks, such as changing payment arrangements, or when they experience a service failure. Neither of these activities are conducive to a string brand for water utilities.&lt;/p&gt;
&lt;p&gt;
How can a water utility create a strong brand when they provide a service at arm&amp;#39;s length from the customer? This article reflects on some branding opportunities&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Water Utility Branding
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The biggest problem with branding a water utility is that the average consumer only spends a few minutes every year in direct contact with utility staff. The number of touch points between the service provider and customer, beyond the bill and the physical server, are minimal. While water utilities manage millions of customer experiences every day, they occur in the privacy of the customer&amp;#39;s home without any opportunity for branding.&lt;/p&gt;
&lt;p&gt;
A few years ago I lectured &lt;a href=&#34;https://horizonofreason.com/culture/first-law-of-consumer-behaviour/&#34;&gt;consumer behaviour&lt;/a&gt; for masters students at La Trobe University. I asked students to view a website of a water utility and describe the brand personality of these utilities. One student asked: &amp;#34;Where is the emotion?&amp;#34;. The site was filled with images of excavators laying pipe, treatment plants and even a diver swimming in sewage.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Where is the emotion?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Water utilities can improve brand personality by emphasising the intangible aspects of the value they provide. Water utilities are not technology companies, but they deliver a substance that mediates emotional experiences, such as bathing your child.&lt;/p&gt;
&lt;p&gt;
These mock advertisements express this idea that the value of water lies beyond it being vital to sustain life. Water plays an important social role and most of water consumed in developed countries is not for survival, but for social reasons. Even our daily shower is not a biological necessity, but a ritual that we follow to make ourselves presentable to the outside world.&lt;/p&gt;
&lt;p&gt;
Water&amp;#39;s biggest role is thus to facilitate social life, while only a small amount is consumed each day for biological survival.&lt;/p&gt;
&lt;figure&gt;


&lt;div class=&#34;slideshow-container&#34;&gt;
  &lt;div class=&#34;mySlides fade&#34;&gt;
    &lt;div class=&#34;numbertext&#34;&gt;1 / 3&lt;/div&gt;
    &lt;img src=&#34;https://lucidmanager.org/images/water-marketing/advertising/tap-water-advertisement-2.jpg&#34; /&gt;
  &lt;/div&gt;
  &lt;div class=&#34;mySlides fade&#34;&gt;
    &lt;div class=&#34;numbertext&#34;&gt;2 / 3&lt;/div&gt;
    &lt;img src=&#34;https://lucidmanager.org/images/water-marketing/advertising/tap-water-advertisement-3.jpg&#34; /&gt;
  &lt;/div&gt;
  &lt;div class=&#34;mySlides fade&#34;&gt;
    &lt;div class=&#34;numbertext&#34;&gt;3 / 3&lt;/div&gt;
    &lt;img src=&#34;https://lucidmanager.org/images/water-marketing/advertising/tap-water-advertisement-4.jpg&#34; /&gt;
  &lt;/div&gt;
  
  &lt;a class=&#34;prev&#34; onclick=&#34;plusSlides(-1)&#34;&gt;&amp;#10094;&lt;/a&gt;
  &lt;a class=&#34;next&#34; onclick=&#34;plusSlides(1)&#34;&gt;&amp;#10095;&lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;

&lt;div style=&#34;text-align:center&#34;&gt;
  &lt;span class=&#34;dot&#34; onclick=&#34;currentSlide( 1 )&#34;&gt;&lt;/span&gt;
  &lt;span class=&#34;dot&#34; onclick=&#34;currentSlide( 2 )&#34;&gt;&lt;/span&gt;
  &lt;span class=&#34;dot&#34; onclick=&#34;currentSlide( 3 )&#34;&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;script&gt;
  var slideIndex = 1;
  showSlides(slideIndex);
  function plusSlides(n) {
      showSlides(slideIndex += n);
  }
  function currentSlide(n) {
      showSlides(slideIndex = n);
  }
  function showSlides(n) {
      var i;
      var slides = document.getElementsByClassName(&#34;mySlides&#34;);
      var dots = document.getElementsByClassName(&#34;dot&#34;);
      if (n &gt; slides.length) {slideIndex = 1}    
      if (n &lt; 1) {slideIndex = slides.length}
      for (i = 0; i &lt; slides.length; i++) {
	  slides[i].style.display = &#34;none&#34;;  
      }
      for (i = 0; i &lt; dots.length; i++) {
	  dots[i].className = dots[i].className.replace(&#34; active&#34;, &#34;&#34;);
      }
      slides[slideIndex-1].style.display = &#34;block&#34;;  
      dots[slideIndex-1].className += &#34; active&#34;;
  }
&lt;/script&gt;

&lt;figcaption&gt;
Mock-advertisements for a utility that express the value of water.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Branding beyond the logo
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A brand is so much more than a logo and extends into everything the utility does and communicates. An example of where branding meets core service delivery are the assets that are visible in public space.&lt;/p&gt;
&lt;p&gt;
Engineers design most water utility assets with a utilitarian purpose. Most pump stations, pipework and other public assets are more often than not an eyesore. The design of these assets, beyond their functional use, influences the image that people have of the local utility. This idea does not mean that we need to slap a logo on assets visible in public space — it requires a bit more thought.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/newzeal_mhc01.jpg&#34; alt=&#34;Wellington sewer access chamber&#34; title=&#34;Wellington sewer access chamber&#34;/&gt;
&lt;figcaption&gt;
Wellington sewer access chamber.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The photograph shows a sewer access chamber in the city of Wellington. This design is an prime example of utility branding as it provides a talking point in the street. There is no logo and this cover goes beyond the typical dull lids used around the world. A local Maori artist created this symbolic work of art. The design represents the water and sewage that flows above and below the land. The &lt;em&gt;koru&lt;/em&gt;, the spiral shape, represents the people who live on the land and who need the water and sewage to flow.&lt;/p&gt;
&lt;p&gt;
Denver Water used to run a guerilla marketing campaign to increase awareness of the need to save water. Their creative expressions not only draw attention, they also subliminally improve brand awareness.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/denver-water.jpg&#34; alt=&#34;Denver Water Guerilla Marketing campaign example&#34; title=&#34;Denver Water Guerilla Marketing campaign example&#34;/&gt;
&lt;figcaption&gt;
Denver Water Guerilla Marketing campaign example.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Branding an Invisible Water Utility
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The &lt;em&gt;invisibility principle&lt;/em&gt; still holds but it needs to be enhanced through using the theory of brand personality. If your water utility was a person, who would it be?&lt;/p&gt;
&lt;p&gt;
Water utilities work in the background to make sure society runs smooth, without needing to take the credit. They are like the chef or the stagehand that make a performance go smoothly, without being seen by the customers.&lt;/p&gt;
&lt;p&gt;
The core services of water utilities need to remain invisible. But this invisibility does not imply that water utilities have no brand. There is still a need to engage with the community to develop a relationship with customers. Rather than speaking to customers about core services, which is usually a conversation about service failures, utilities can build a positive brand by proactively engaging with communities.&lt;/p&gt;
&lt;p&gt;
If you like to find out more about using marketing theory to manage the experience of water utility customers, then please consider reading &lt;em&gt;Customer Experience Management for Water Utilities&lt;/em&gt; by Peter Prevos.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Communicating Water&#39;s Value by Melanie Goetz: Book Review</title>
      <link>https://lucidmanager.org/marketing/communicating-waters-value/</link>
      <pubDate>Wed, 17 Dec 2014 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/communicating-waters-value/</guid>
      <description>
	
&lt;p&gt;
Technical texts on the latest engineering developments to improve services dominate the literature on managing water utilities. &lt;a href=&#34;https://lucidmanager.org/marketing/engineering-marketing-interface/&#34;&gt;Engineers&lt;/a&gt; often see marketing as peripheral to their quest to provide a reliable and safe water supply. It is therefore a delight to read a book on how to improve services in water utilities using the human dimension.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Communicating Water&amp;#39;s Value
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://amzn.to/2Uakma0&#34;&gt;Communicating Water&amp;#39;s Value: Talking Points,Tips &amp;amp; Strategies&lt;/a&gt; by Melanie Goetz is based on a sound basis of years of experience, backed by the latest scientific findings in behavioural economics, neuromarketing and related disciplines. This book is by no means a nerdy academic treatise. The countless vivid examples from Melanie&amp;#39;s experience in working with utilities will appeal to water utility professionals.&lt;/p&gt;
&lt;p&gt;
The book delves into the non-rational (a term I prefer above &amp;#39;irrational&amp;#39;) aspects of human psychology. Melanie clearly explains how the techniques used in competitive commercial organisations can also enhance the value proposition of water utilities.&lt;/p&gt;
&lt;p&gt;
Marketing has earned itself a bad name for being deceptive and manipulative. This negative image is one of the reasons public services often don&amp;#39; t use marketing. Melanie&amp;#39;s book shows, however, that good marketing can tap into the forces of psychology and be used for good instead of evil.&lt;/p&gt;
&lt;p&gt;
Melanie recognised in the book that her work is &amp;#34;preaching to the choir&amp;#34;. Engineers, economists and accountants and other professional that operate at a distance from customers should read this book. As pointed out in the latter part of the book, innovation can only arise from positive deviance. Daring to be different and breaking the shackles of tradition is difficult in an industry where tradition dominates thinking.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/atkipef0zXg?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Melanie Goetz about her book.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Value of Water
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Reading this book, I latched on to one little phrase: &amp;#34;We do not sell water, we sell status—we sell a solution for thirst&amp;#34;. When a utility recognises that they do not sell water, but the benefits that water provides, they are on their way to maximise the value perception held by their customers. Thinking of water as merely the product they supply, instead of the benefits it provides is an example of &lt;a href=&#34;https://lucidmanager.org/marketing/marketing-myopia/&#34;&gt;marketing myopia&lt;/a&gt;, a form of short-sightedness that can only be fixed by using marketing glasses.&lt;/p&gt;
&lt;p&gt;
My version of this idea is: &amp;#34;We don&amp;#39;t sell water, we sell &lt;a href=&#34;https://lucidmanager.org/marketing/value-of-water/&#34;&gt;experiences&lt;/a&gt;&amp;#34;. We sell good ideas (in the shower), we sell initiate moments (having a bath with someone you love), we sell personal fulfilment (gardening) and so on. Status comes into play only with conspicuous purchases, such as a pool.&lt;/p&gt;
&lt;p&gt;
When looking at a water utility using marketing lenses we see the service as the customers perceive it. Not the way customers might consciously understand water, but subconsciously. In &lt;em&gt;Communicating Water&amp;#39;s Value&lt;/em&gt;, demonstrates the psychological subtleties involved in managing the attitudes and behaviours of customers.&lt;/p&gt;
&lt;p&gt;
This book is a great read for every water utility professional who wants to practice some &lt;a href=&#34;https://lucidmanager.org/management/positive-workplace-deviance/&#34;&gt;positive organisational deviance&lt;/a&gt;. Melanie Goetz&amp;#39;s work will help you to think differently and increase the value proposition of customers. Not by investing millions in new gadgets, but by levering human psychology.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Dissolve the Three Tap Water Paradoxes or Manage Ambiguity?</title>
      <link>https://lucidmanager.org/marketing/tap-water-paradoxes/</link>
      <pubDate>Sun, 14 Sep 2014 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/tap-water-paradoxes/</guid>
      <description>
	
&lt;p&gt;
Through my review of tap water marketing, I have stumbled on three paradoxes: statements that apparently contradict themselves and yet might be correct. Most paradoxes can be resolved. Can we also dissolve the tap water paradoxes?&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Water-Diamond Paradox
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The oldest known water paradox is the &lt;a href=&#34;https://lucidmanager.org/marketing/value-of-water/&#34;&gt;paradox of value&lt;/a&gt;. Ancient Greek philosopher Plato wrote more than two millennia ago that water, which is the most essential of things, only commands a low price. This paradox was formalised by Adam Smith, the father of modern economics. Smith compared to water with diamonds and observed that although nothing is more useful than water and nothing more useless than diamonds, however, water is cheap and diamonds are expensive.&lt;/p&gt;
&lt;p&gt;
Is this a paradox? Economists will tell you that this is because Plato nor Smith knew about &lt;a href=&#34;https://en.wikipedia.org/wiki/Marginal_value&#34;&gt;marginal value&lt;/a&gt;. The marketing solution is to point out the difference between value and price. The price we are willing to pay is related to the relative value we attach to the purchase. Water comes out of our tap, without effort and without having to think about it—it has a low level of involvement. People are, however, highly involved with diamonds. Owning a diamond provides social status, owning tap water doesn&amp;#39;t. The reason water demand a low price is because as an essential product it does not give us social benefits. But, when water is sparse, this paradox dissolves completely. In the words of Benjamin Franklin:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When the well is dry, we know the worth of water.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Involvement Paradox
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Consumer involvement is defined as “a person&amp;#39;s perceived relevance of the object based on inherent needs, values, and interests”. The fact that water is essential to life suggests that consumers of tap water have a high level of involvement with the service. Contrary to this sensible intuition, practitioner experience and literature states that tap water is a low-involvement service.&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://www.researchgate.net/publication/326533830_We_Care_About_Water_Even_If_You_Don&amp;#39;t_Water_As_a_Low_Involvement_Service&#34;&gt;This paradox can be resolved&lt;/a&gt; by looking at involvement from two different angles. Tap water as an essential product will logically attract a very high level of cognitive involvement because life in the developed world without it is unthinkable. However, as a non-branded, undifferentiated, monopolistic service, the level of affective involvement it attracts will be significantly lower.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
The Water Quality Paradox
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Although in well-managed systems, the chances that somebody does not receive excellent service through their tap are minimal, consumer perception of these services is often not as good as engineers would hope for. The &lt;a href=&#34;https://lucidmanager.org/marketing/water-quality-paradox/&#34;&gt;water quality paradox&lt;/a&gt; holds that although water might be safe to drink, customers will not necessarily value it.&lt;/p&gt;
&lt;p&gt;
Operators of drinking water systems are required to comply with regulations. Meeting these legal requirements can, however, lead to a reduction in service quality. For example, adding chlorine is essential to ensure public health in that it destroys micro-organisms. In some communities, however, chlorine is perceived as an unwanted chemical, leading to a reduction in service quality.&lt;/p&gt;
&lt;p&gt;
This tension between safe water and good water is only a paradox when we believe that one or the other side view of water quality dominates the other. The sometimes contradictory views are both equally valid and cannot be resolved easily—just like light can be viewed as a wave and a particle at the same time, so are both safe water and good water equally valid views.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Tap Water Paradoxes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;How are we to deal with these paradoxes, do we need to resolve them or do we need to learn to live with the ambiguity?&lt;/p&gt;
&lt;p&gt;
If you like to find out more about using marketing theory to manage the experience of water utility customers, then please consider reading &lt;em&gt;Customer Experience Management for Water Utilities&lt;/em&gt; by Peter Prevos.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Positive Workplace Deviance and the Governance Chastity Belt</title>
      <link>https://lucidmanager.org/management/positive-workplace-deviance/</link>
      <pubDate>Mon, 17 Mar 2014 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/positive-workplace-deviance/</guid>
      <description>
	
&lt;p&gt;
According to popular history, when European knights left for the holy land during the crusades, they fitted their wives with a nasty iron &lt;a href=&#34;https://en.wikipedia.org/wiki/Chastity_belt&#34;&gt;chastity belt&lt;/a&gt; to guarantee their fidelity. These devices were a crude method to enforce chaste behaviour because the Knights did not trust their wives while on their holy tour of duty. It is unlikely that chastity belts actually prevented any lonely woman from expressing natural desires. We can apply this lesson from history also to contemporary management and the rise of governance.&lt;/p&gt;
&lt;p&gt;
The paper chastity belt is a device to prevent deviant behaviour in the workplace. While necessary, such a device also stifles innovation. Lucid Managers practice positive deviance to enable their natural desire to innovate.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Organisational Chastity Belt
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The chastity belt is making a comeback—and not only with contemporary connoisseurs of erotic bondage. The Global Financial Crisis has driven an increased focus on governance in organisations. Therefore, we have more &lt;a href=&#34;https://lucidmanager.org/management/alternative-risk-matrix-template/&#34;&gt;risk management&lt;/a&gt;, more red tape, more creativity stifling procedures—more paper chastity belts. &lt;/p&gt;
&lt;p&gt;
These procedural chastity belts serve the same purpose as the medieval metal contraptions. A lack of trust in the ability of people to make the right decisions on your behalf often leads to a perceived need for corporate chastity belts. Chastity belts replace trust with a power dynamic.&lt;/p&gt;
&lt;p&gt;
Procedural chastity belts, just like their physical counterparts, are not foolproof methods to ensure chaste behaviour of wives nor of managers. Employees will circumvent any device that replaces trust when the motivation and the reward for deviance outweigh the risks.&lt;/p&gt;
&lt;p&gt;
The key to unlocking the regulatory chastity belt is to look at your processes and unravel them. Procedures should &lt;em&gt;enable&lt;/em&gt; people to achieve objectives. They should not be the final word on how employees do their job. The people that write these procedures are after-all not all-knowing gods of management.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Positive Workplace Deviance
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Lucid managers allow for positive workplace deviance, and they enable the employees to make their judgement on how to best achieve goals, instead of using red-tape.&lt;/p&gt;
&lt;p&gt;
Deviant Behaviour has a bad name for obvious reasons. We all know people who behave negatively in the workplace, even resorting to bullying or harassment. Positive workplace deviance is not about embracing your Machiavellian tendencies but more about breaking unwritten rules to progress organisational objectives. To think outside the box, to use a cheesy metaphor, requires you to bend the rules to shift reality. &lt;/p&gt;
&lt;p&gt;
A popular meme to express this idea is &amp;#34;&lt;a href=&#34;https://horizonofreason.com/magic/not-giving-a-fuck/&#34;&gt;not to give a fuck&lt;/a&gt;&amp;#34;. Some authors censor one of these words with asterisks, but that goes against the spirit of the term. This somewhat crude popular wisdom does not imply that you can rampage your way through the workplace without caring about the consequences. Positive workplace deviance is the subtle art of crafting your niche within your organisation or your industry.&lt;/p&gt;
&lt;p&gt;
A Lucid Manager always asks why unwritten business rules exist and seek inspiration in playing little thought experiments to test the boundaries of the traditions within an organisation. Those trying to use positive workplace deviance to can find inspiration from the great Frank Zappa who famously said:&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/deviance/frank-zappa-deviance.jpg&#34; alt=&#34;Without deviance from normality, there can be no progress&#34; title=&#34;Without deviance from normality, there can be no progress&#34;/&gt;
&lt;figcaption&gt;
Without deviance from normality, there can be no progress.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Importance of Useless Knowledge in Management</title>
      <link>https://lucidmanager.org/management/useless-knowledge/</link>
      <pubDate>Sat, 25 Jan 2014 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/useless-knowledge/</guid>
      <description>
	
&lt;p&gt;
Although managing a business, or even a small part thereof, is a complex task, the solutions for solving problems often seem deceivingly simple. Managers resolve even the most complex issues with a &lt;a href=&#34;https://lucidmanager.org/management/alternative-risk-matrix-template/&#34;&gt;two-by-two matrix&lt;/a&gt; or simple lists of steps. Most management books simplify the complicated world of business by providing attractive solutions with a high level of perceived usefulness. This article praises the value of the arts, perceived by some as useless knowledge. This article closes with some views of Steve Jobs about the Humanities.&lt;/p&gt;
&lt;p&gt;
In that goal-directed behaviour, managers often lose purpose and forget about what their mission is. Within my industry, many professionals are obsessed with engineering and forget about the true &lt;a href=&#34;https://lucidmanager.org/marketing/value-of-water/&#34;&gt;value of tap water&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
I draw inspiration from knowledge outside my profession as an engineer to gain new perspectives. My inspiration lies in learning &amp;#39;useless&amp;#39; subjects such as philosophy, ancient Greek or anthropology. My degree in the humanities has enhanced my engineering and management qualifications, and it has resulted in many publications and conference presentations.&lt;/p&gt;
&lt;p&gt;
This article shows how managers can improve their work by obtaining useless knowledge. What might seem useless and without purpose at first, will in fact become a powerful tool to become a more creative professional.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Importance of Useless Knowledge
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To become the best possible manager, you should invest time in acquiring ‘useless knowledge&amp;#39;. The type of knowledge that does not directly enhance the bottom line, but enlightens the individual.&lt;/p&gt;
&lt;p&gt;
British philosopher Bertrand Russell once beautifully expressed the importance of useless knowledge in an ode to the humble peach and apricot:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I have enjoyed peaches and apricots more since I have known that they were first cultivated in China in the early days of Han Dynasty; that Chinese hostages held by the great King Kaniska introduced them to India, whence they spread to Persia, reaching the Roman Empire in the first century of our era … All this makes the fruit taste much sweeter.&lt;/p&gt;
&lt;p&gt;
Bertrand Russell, &lt;em&gt;In Priase of Idleness and Other Essays&lt;/em&gt; (1935).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
To enlarge and sweeten the fruits of management, professionals need to embrace so-called useless knowledge. This knowledge is not the type of information you get from reading the trivialities on Twitter feeds or Facebook. The canon of useless knowledge is more profound and includes philosophy and its continuous questioning of everything, the lessons of history and appreciation of the arts—the humanities of the liberal arts.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Nothing more practical than a good theory
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The words &amp;#34;useless knowledge&amp;#34; is problematic because it is a contradiction. There is no such thing as useless knowledge. A more suitable term would be &lt;em&gt;indirect knowledge&lt;/em&gt;. This the type of knowledge that solves problems by introducing new perspectives from outside the world of business. Wielded correctly, understanding the humanities will make you a better manager by understanding new perspectives.&lt;/p&gt;
&lt;p&gt;
Managers often equate useful with being practical. There is, however, nothing more practical than a good theory. Besides doing something, managers also need to think. The humanities teach you how to think, how to take a new perspective, think about meaning and purpose, without falling into the platitudes of popular management books.&lt;/p&gt;
&lt;p&gt;
Knowing some basic philosophy of science helps managers to comprehend what &amp;#39;evidence-based management&amp;#39; actually entails. Reading about ethical dilemmas and the solutions proposed by philosophers might prevent managers from making morally wrong decisions. Visiting an art gallery during lunch will reset your brain and provides new inspiration to solve your mundane work problems. Reading literature will help you to understand your customers better.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Steve Jobs and the Humanities
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A well-grounded appreciation of the arts beyond economic value helps in creating beautiful products loved by your customers. A textbook example of an organisation that has integrated both business utilitarianism and the humanities is Apple. In one of his last public performances, &lt;a href=&#34;https://www.newyorker.com/news/news-desk/steve-jobs-technology-alone-is-not-enough&#34;&gt;Steve Jobs&lt;/a&gt; said:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It&amp;#39;s in Apple&amp;#39;s DNA that technology alone is not enough — it&amp;#39;s technology married with liberal arts, married with the humanities, that yields us the result that makes our heart sing.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Useless knowledge makes you question the certainties of life; it creates a thoughtful and reflective mind, protected against impulsive decision making. Knowledge of the humanities literally humanises technology because, as Jobs put it: &amp;#34;technology alone is not enough&amp;#34;.&lt;/p&gt;
&lt;p&gt;
For this reason, managers should embrace useless knowledge and study the classics, and the understand the humanities. Read some of Plato&amp;#39;s dialogues and learn from &lt;a href=&#34;https://lucidmanager.org/management/socratic-management/&#34;&gt;Socrates&lt;/a&gt; how &lt;a href=&#34;https://lucidmanager.org/management/positive-workplace-deviance/&#34;&gt;deviant behaviour leads to innovation&lt;/a&gt;. Finally, the next time you visit a bookshop, ignore the management section and pick a topic you know nothing about.&lt;/p&gt;
&lt;p&gt;
The video below is an extract from &lt;em&gt;The Lost Interview&lt;/em&gt; (1995) in which Jobs discusses the early days of Apple and how the liberal arts made this company great.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/KgHkAwaW_lk?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Steve Jobs about the humanities.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Notes
&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;This article is inspired by an article in Dutch newspaper &lt;a href=&#34;https://www.trouw.nl/nieuws/we-snakken-naar-nutteloosheid~bf7507a5/&#34;&gt;Trouw&lt;/a&gt; by Jonah Kahn.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Social Gadfly: The Benefits of Socratic Management</title>
      <link>https://lucidmanager.org/management/socratic-management/</link>
      <pubDate>Sat, 18 Jan 2014 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/socratic-management/</guid>
      <description>
	
&lt;p&gt;
When studying business, there is little time for critical reflection on what has you have learnt. Universities arm newly minted MBAs with &lt;a href=&#34;https://lucidmanager.org/tags/management-tools/&#34;&gt;management tools&lt;/a&gt; such as Maslow&amp;#39;s Hierarchy of Needs, the BGC Matrix, Porter&amp;#39;s Five Forces and
other devices to solve business problems. Their acceptance as valid tools is, however, often not based on critical reflection or solid empirical research but on mythical stories of how they were used successfully in the past.&lt;/p&gt;
&lt;p&gt;
The study of business and most of writing about business is based on the &lt;a href=&#34;https://en.wikipedia.org/wiki/Case_method&#34;&gt;case method&lt;/a&gt;. In this system, students are presented with a business problem and placed in the shoes of the decision maker charged with solving the problem. This article briefly discusses what we can learn from ancient Greek philosophers and why we should practice Socratic management.&lt;/p&gt;
&lt;p&gt;
In the &lt;a href=&#34;https://www.coursera.org/learn/critical-management&#34;&gt;Critical Perspectives on Management&lt;/a&gt; course, Rolf Strom-Olsen advocates an approach that deviates from the standard case methods and draws from the more critical humanities. He sees the life of the ancient Greek philosopher &lt;a href=&#34;https://en.wikipedia.org/wiki/Socrates&#34;&gt;Socrates&lt;/a&gt; as a signpost for a different way to think about business.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Socrates: “I know nothing except the fact of my ignorance”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The benefits of Socratic management
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;We know about Socrates from the vivid writings of Plato who was one of his followers. His books form the foundation of European philosophy and profoundly influenced Western civilisation as we know it. Socrates spent his time meeting people in the marketplace in Athens and questioned their opinions and cherished beliefs. &lt;/p&gt;
&lt;p&gt;
Socrates was a bit like an annoying toddler that keeps asking &amp;#34;Why?&amp;#34; to find the foundations of what we hold to be true. The Athenians themselves compared him with a gadfly, a fly that annoys horses and other livestock. A lifetime annoying people by questioning everything they know is not a way to &lt;a href=&#34;https://en.wikipedia.org/wiki/How_to_Win_Friends_and_Influence_People&#34;&gt;Win Friends and Influence People&lt;/a&gt;. Socrates thus paid the highest price for his life as a social gadfly—he was convicted of drinking a cup of poisonous hemlock and died.&lt;/p&gt;
&lt;p&gt;
From my experience, it is clear that being the social gadfly in business can be a dangerous activity which could lead to career suicide. For me, following the Socratic path has helped me to be very successful in solving business problems. Only by daring to ask the hard questions and draw from disciplines outside business we can see perspectives on issues that a case method cannot provide.&lt;/p&gt;
&lt;p&gt;
The traditional case method of solving business problems looks backwards at past experiences. Using the analytical method from the humanities allows us to draw from entirely different perspectives and analyse issues in creative ways. Business is an applied social science, and it seems only reasonable that the methods of social science should be used to understand the problems of humans.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Socratic Management: philosophical deviance to improve performance.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The Lucid Manager is courageous and not afraid to be a social gadfly and practices Socratic management. The Lucid Manager stops asking &amp;#34;Why?&amp;#34; and goes beyond &lt;a href=&#34;https://en.wikipedia.org/wiki/5_Whys&#34;&gt;The Five Whys&lt;/a&gt; if needed. View your problem from all angles—including disciplines that are not traditionally used in business. Reading about the life of Socrates teaches the way of philosophical deviance as a path to business success. Following the path of Socrates will help you to develop those cherished innovative solutions.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>It is not rocket science. Managing people is more complex</title>
      <link>https://lucidmanager.org/management/not-rocket-science/</link>
      <pubDate>Fri, 16 Aug 2013 21:12:34 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/not-rocket-science/</guid>
      <description>
	
&lt;p&gt;
Space exploration is the crowning glory of human achievement. Anyone working in this industry—astronauts flying the spaceships and rocket scientists building them are the heroes of contemporary society.&lt;/p&gt;
&lt;p&gt;
Ever since the start of the space race in the 1960s, rocket engineering has been perceived as the most complex human activity. Rocket scientists became the ultimate symbol of human intelligence and the phrase “It is not rocket science” has been heard in offices around the English-speaking world.&lt;/p&gt;
&lt;p&gt;
Does this statement make sense? Is rocket science so much more complicated than management? I think that rocket science is grossly overrated and that the science of management is a lot more complicated than the science of building rockets.&lt;/p&gt;
&lt;p&gt;
The science of space exploration has been a lot more successful than the science of management. Robots &lt;a href=&#34;https://mars.jpl.nasa.gov/&#34;&gt;explore Mars&lt;/a&gt;; one spaceship has &lt;a href=&#34;https://voyager.jpl.nasa.gov/&#34;&gt;left the solar system&lt;/a&gt;; people have &lt;a href=&#34;https://www.nasa.gov/podcasts/houston-we-have-a-podcast/apollo-and-the-moon/&#34;&gt;walked on the moon&lt;/a&gt;, and much more exciting exploration is yet to come. Management as a science has not achieved much compared to rocket science. There is, for example, no generally accepted theory for motivation or effective decision making.&lt;/p&gt;
&lt;p&gt;
Rocket science is an extension of physics, and therefore all processes are entirely predictable. The more research scientists do, the better they understand the physical processes, the more predictable technology becomes. Management is not a physical science but a social science. Human behaviour is not like a physical process that can be predicted with high accuracy. Individual behaviour is unpredictable and more controlled by emotion than by reason.&lt;/p&gt;
&lt;p&gt;
Some might argue that human behaviour is, in essence, a physical process. It is, however, so complicated that it becomes inherently unpredictable as we are unable to model human behaviour in physical terms. There are no computer programs to help managers deal with people; there are no simple rules to make correct decisions—a lot of management is based on unsubstantiated rules of thumb and intuition.&lt;/p&gt;
&lt;p&gt;
That leaves me to conclude that management is not rocket science, it is a lot more complicated.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Literature
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;ul&gt;
&lt;li&gt;Abbott, D. (2003). It&amp;#39;s not rocket science. &lt;em&gt;The Safety &amp;amp; Health Practitioner&lt;/em&gt;, 21(8), 40–41.&lt;/li&gt;
&lt;li&gt;Call, D. (2005). Knowledge management—not rocket science. &lt;em&gt;Journal of Knowledge Management&lt;/em&gt;, 9(2), 19–30. &lt;a href=&#34;https://dx.doi.org/10.1108/13673270510590191&#34;&gt;doi:10.1108/13673270510590191&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Dentzer, S. (2011). Innovation: Needed, but not rocket science. &lt;em&gt;Health Affairs&lt;/em&gt;, 30(3), 378.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Engineering-Marketing Interface in Water Utilities</title>
      <link>https://lucidmanager.org/marketing/engineering-marketing-interface/</link>
      <pubDate>Wed, 17 Jul 2013 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/engineering-marketing-interface/</guid>
      <description>
	
&lt;p&gt;
Judging by the available publications and conference papers, engineers, scientists and economists dominate the water industry. This industry gives much less attention to research into customer service than to technical issues. The &lt;a href=&#34;https://lucidmanager.org/tags/invisible-water-utility/&#34;&gt;application of marketing theories&lt;/a&gt; to provide value to customers of water utilities has not received a lot of attention, given the monopoly status of service providers. The purpose of this article is to share some thoughts about the relationship between engineering and customer satisfaction. This article introduces the concept of the Engineering-Marketing Interface to help understand these relationships.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Water Utility Paradox
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A &lt;a href=&#34;https://lucidmanager.org/marketing/tap-water-paradoxes/&#34;&gt;paradox&lt;/a&gt; appears to exist in the provision of reticulated water services. Providing service at a high level of technical proficiency is a necessary, but not a sufficient condition to ensure customer satisfaction. To further research this problem, we interviewed several stakeholder organisations of reticulated water customers. These interviews investigated the factors determining customer-centric service provision. These interviews revealed that a ‘professional orientation&amp;#39; could exist, obstructing the creation of positive customer experience. Focusing on the technical aspects of service delivery carries the risk of losing sight of the
human dimension.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Technology is predictable; consumer behaviour is unpredictable&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Providing reticulated water services requires a high level of investment in technology to be able to provide a safe and reliable supply. As such, engineers dominate the industry. These professionals develop and maintain the infrastructure required to deliver core services. Non-technical people often wrap engineers in stereotypes, highly focused on the technical task at hand but lacking marketing skills. However, in its purest essence engineering and marketing complement each other. In the words of marketing professors Philip Kotler and Sidney Levy:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Marketing is customer satisfaction engineering.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Attitudes of Engineers
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;In the delivery of water services, the attitudes and actions of engineers towards customer service are important as this directly impacts on the experience of customers. Engineers mainly undertake ‘back-stage&amp;#39; roles to determine how to deliver core services to customers. The ‘front-stage&amp;#39; customer service staff manage support services, such as complaints handling and billing.&lt;/p&gt;
&lt;p&gt;
A water utility is in this respect much like an amusement park: invisible staff members make all the rides happen, while the staff that interact with customers enhance the experience. The biggest difference between an amusement park and a water utility is that most customers never meet their service provider in person.&lt;/p&gt;
&lt;p&gt;
The development of an effective engineering-marketing interface between engineering and customer functions within an organisation is vital for providing customers a high level of service. Both marketing and engineering literature acknowledges the importance of good relationships between customer service and engineering personnel. Researchers have identified several sources of potential conflict between these two functions. The most common causes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Polarisation of behaviour through a tension between standardisation and customisation.&lt;/li&gt;
&lt;li&gt;Stereotyping of personality traits of the two professional fields&lt;/li&gt;
&lt;li&gt;Engineers and marketers have different educational backgrounds and occupy different ‘thought-worlds&amp;#39;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I conducted a pilot study to test whether such differences between customer service and engineering employees exists in water utilities. Employees were asked a series of questions about the relationship between engineering and service functions.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
The Engineering-Marketing Interface
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The results of this pilot into the Engineering-Marketing Interface study reveal a small, but statistically significant difference between the views of employees with engineering education and those without engineering education. Engineers viewed the potential for tension between customer service and engineering functions as lower than those without engineering qualification. &lt;/p&gt;
&lt;p&gt;
This effect was found to be the case for all items in the survey, except for the statement that “all engineers should know something about customer service”, which found strong agreement among all respondents. In other words, engineers perceived the tension between customer service and engineering functions as less important than other employees did. Another part of the survey revealed engineers having a lower level of empathy with customers than other staff. Analysis indicated that this finding corroborated the other results.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Marketing for Engineers
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The core of the issue is that technology and science are predictable―engineering problems can be solved in neat equations. Human behaviour is more complicated and cannot be captured in models and equations. Academics have extensively researched tensions between marketing and engineering employees in the manufacturing industry, but not in service provision. My dissertation describes the results of detailed research into this issue. The research found a small but significant tension exists between the two professional groups in Australian Water utilities.&lt;/p&gt;
&lt;p&gt;
Finally, one way to minimise these tensions is by teaching engineers the principles of marketing. If you are interested in &lt;a href=&#34;https://lucidmanager.org/marketing/marketing-for-engineers/&#34;&gt;marketing for engineers&lt;/a&gt;, then view my guest lecture on this topic.&lt;/p&gt;
&lt;p&gt;
If you like to find out more about using marketing theory to manage the experience of water utility customers, then please consider reading &lt;em&gt;Customer Experience Management for Water Utilities&lt;/em&gt; by Peter Prevos.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Corporate Jester: The Teller of Organisational Truth</title>
      <link>https://lucidmanager.org/management/corporate-jester/</link>
      <pubDate>Sun, 14 Jul 2013 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/corporate-jester/</guid>
      <description>
	
&lt;p&gt;
In medieval times, the jester played a significant role in influential circles. Jesters, a precursor to the modern-day clown, wore bright, motley-patterned costumes and entertained the rich and powerful with their antics. Their role was not only to amuse but also to challenge their master and guests in their thinking. Jesters used to be a mirror of society, using satire to provoke the current status. This article discusses how a corporate jester can accelerate innovation by challenging the &lt;em&gt;status quo&lt;/em&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Historical Jester
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The jester played an essential role in society because he was able to provide a unique perspective on current affairs. They were able to be critical without being concerned about internal politics and personal sensitivities. In doing so, they walked a fine line, because not being severe enough or being too critical could land them in serious trouble.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Corporate Jester
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Court jesters have disappeared from our cultural landscape, but it is time to bring this character back to the boardroom. I propose that major organisations hire a boardroom jester. The jester is allowed to attend all proceedings, say anything without punishment and use satire to hold a mirror to the people in power. The Boardroom Jester helps management to think “outside the box” by being an intellectual Jack-in-the-Box. An effective boardroom jester practices philosophical cynicism, rejecting social conventions and using humour to reveal the naked truth.&lt;/p&gt;
&lt;p&gt;
Unfortunately, most managers take themselves far too seriously. People in senior management positions—these days referred to as leaders—are often disconnected from what happens in their organisations. Staff are reluctant to speak about the details because of the fear the repercussions. Officially sanctioned jesters can hide behind their silly costumes and foolishness to ask the questions that others are afraid to ask. The Boardroom Jester does not form part of the illusion of hierarchy, so there is never any fear of damaging career prospects.&lt;/p&gt;
&lt;p&gt;
The idea of hiring people that can challenge current thinking is being frustrated by contemporary recruitment practices. Organisations seek people to fit into their carefully chose set of values, rather than people that deviate from normality.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Psychology of the Recycled Water Yuck Factor</title>
      <link>https://lucidmanager.org/marketing/recycled-water-yuck-factor/</link>
      <pubDate>Mon, 27 May 2013 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/recycled-water-yuck-factor/</guid>
      <description>
	
&lt;p&gt;
Using sewage to create drinking water, or recycled water is a controversial topic in many parts of the world, especially in places where drought has forced utilities to develop alternative sources of tap water. In 2006 the Australian city of Toowoomba faced an extreme water supply problem and held a &lt;a href=&#34;http://www.smh.com.au/news/national/toowoomba-says-no-to-recycled-water/2006/07/29/1153816419568.html&#34;&gt;referendum&lt;/a&gt; asking its citizens whether recycled water should be added to the potable supply. This referendum led to emotional outbursts, and the proposal was eventually rejected. Some commentators on this event referred to the so-called ‘recycled water yuck factor&amp;#39;, which is an emotional reaction of repugnance towards certain foods and medicines. This article explores a psychological mechanism that causes this response and provides some suggestions on how to effectively promote the idea of using sewage to create drinking water.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/rg_sewage_wideweb__470x3350.jpg&#34; alt=&#34;Brendan Walsh diving in a sea of human waste&#34; title=&#34;Brendan Walsh diving in a sea of human waste&#34;/&gt;
&lt;figcaption&gt;
Brendan Walsh diving in a sea of human waste.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The importance of origin
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;From a marketing point of view, using treated sewage to create drinking water is a proposition that &amp;#39;s hard to sell to customers. The &lt;a href=&#34;https://lucidmanager.org/marketing/bottled-water-marketing/&#34;&gt;origin of water&lt;/a&gt; is the most important aspect of the marketing of water, a concept masterfully used by bottled water companies. The importance of the (perceived) source of water was illustrated in a study which investigated whether there is a difference in willingness to pay depending on the name of water service. &lt;/p&gt;
&lt;p&gt;
The research found that customers had a higher willingness to pay for “recycled water” than for “treated wastewater”.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; Although the study indicates that there are differences in valuation based on the perceived origin of the water, no explanation was provided for this phenomenon.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The psychology of disgust and the recycled water Yuck Factor
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;There is no rational reason to oppose using sewage to create tap water. Regardless of technology, the natural water cycle ensures that all sewage will eventually become fresh water and most likely will find its way to somebody&amp;#39;s tap. Human psychology is, however, more complicated than this simple rational line of thought.&lt;/p&gt;
&lt;p&gt;
Our deep-seated negative overall attitude towards faeces leads us to maintain a negative attitude towards anything that is related to it, including recycled water. Rationally speaking, this is a fallacy and known as the &lt;em&gt;Wisdom of Repugnance&lt;/em&gt;, or the yuck factor. People arguing against recycled water use a non-rational ‘appeal to disgust&amp;#39;. They believe that a natural negative response to something should be interpreted as evidence for the intrinsically dangerous character of that thing. Although this is not considered a rational argument, it is nevertheless valid because we cannot ignore our innate psychological drives.&lt;/p&gt;
&lt;p&gt;
The psychological mechanism at work is the well-known principle of &lt;a href=&#34;http://en.wikipedia.org/wiki/Classical_conditioning&#34;&gt;classical conditioning&lt;/a&gt;, also known as the &lt;em&gt;Pavlov Reflex&lt;/em&gt;. Our cultural surroundings largely condition our tastes. Psychologists have researched these issues in detail. Faeces are a universal disgust substance that is deeply seated within our psychological make-up. This disgust is, however, not innate—we develop this feeling of disgust through conditioning.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-2&#34; href=&#34;#footnote-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Yuck Factor Laboratory
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Psychologist Paul Rozin has undertaken several experiments to test aversion to a range of stimuli. The slides below show the questionnaire the researchers used in groundbreaking research in 1988. They asked people to rate how much they desire a certain item of food. In some cases, they combined the food with another stimulus, such as a cockroach and asked the same question.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-3&#34; href=&#34;#footnote-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt; Flick through the slides by clicking on the arrow on the side. Answer each question on a scale from 1 to 9 of how much you like what is presented in the question.&lt;/p&gt;
&lt;figure&gt;


&lt;div class=&#34;slideshow-container&#34;&gt;
  &lt;div class=&#34;mySlides fade&#34;&gt;
    &lt;div class=&#34;numbertext&#34;&gt;1 / 5&lt;/div&gt;
    &lt;img src=&#34;https://lucidmanager.org/images/water-marketing/yuck-survey/Yuck_Factor_Survey_1.png&#34; /&gt;
  &lt;/div&gt;
  &lt;div class=&#34;mySlides fade&#34;&gt;
    &lt;div class=&#34;numbertext&#34;&gt;2 / 5&lt;/div&gt;
    &lt;img src=&#34;https://lucidmanager.org/images/water-marketing/yuck-survey/Yuck_Factor_Survey_2.png&#34; /&gt;
  &lt;/div&gt;
  &lt;div class=&#34;mySlides fade&#34;&gt;
    &lt;div class=&#34;numbertext&#34;&gt;3 / 5&lt;/div&gt;
    &lt;img src=&#34;https://lucidmanager.org/images/water-marketing/yuck-survey/Yuck_Factor_Survey_3.png&#34; /&gt;
  &lt;/div&gt;
  &lt;div class=&#34;mySlides fade&#34;&gt;
    &lt;div class=&#34;numbertext&#34;&gt;4 / 5&lt;/div&gt;
    &lt;img src=&#34;https://lucidmanager.org/images/water-marketing/yuck-survey/Yuck_Factor_Survey_4.png&#34; /&gt;
  &lt;/div&gt;
  &lt;div class=&#34;mySlides fade&#34;&gt;
    &lt;div class=&#34;numbertext&#34;&gt;5 / 5&lt;/div&gt;
    &lt;img src=&#34;https://lucidmanager.org/images/water-marketing/yuck-survey/Yuck_Factor_Survey_5.png&#34; /&gt;
  &lt;/div&gt;
  
  &lt;a class=&#34;prev&#34; onclick=&#34;plusSlides(-1)&#34;&gt;&amp;#10094;&lt;/a&gt;
  &lt;a class=&#34;next&#34; onclick=&#34;plusSlides(1)&#34;&gt;&amp;#10095;&lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;

&lt;div style=&#34;text-align:center&#34;&gt;
  &lt;span class=&#34;dot&#34; onclick=&#34;currentSlide( 1 )&#34;&gt;&lt;/span&gt;
  &lt;span class=&#34;dot&#34; onclick=&#34;currentSlide( 2 )&#34;&gt;&lt;/span&gt;
  &lt;span class=&#34;dot&#34; onclick=&#34;currentSlide( 3 )&#34;&gt;&lt;/span&gt;
  &lt;span class=&#34;dot&#34; onclick=&#34;currentSlide( 4 )&#34;&gt;&lt;/span&gt;
  &lt;span class=&#34;dot&#34; onclick=&#34;currentSlide( 5 )&#34;&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;script&gt;
  var slideIndex = 1;
  showSlides(slideIndex);
  function plusSlides(n) {
      showSlides(slideIndex += n);
  }
  function currentSlide(n) {
      showSlides(slideIndex = n);
  }
  function showSlides(n) {
      var i;
      var slides = document.getElementsByClassName(&#34;mySlides&#34;);
      var dots = document.getElementsByClassName(&#34;dot&#34;);
      if (n &gt; slides.length) {slideIndex = 1}    
      if (n &lt; 1) {slideIndex = slides.length}
      for (i = 0; i &lt; slides.length; i++) {
	  slides[i].style.display = &#34;none&#34;;  
      }
      for (i = 0; i &lt; dots.length; i++) {
	  dots[i].className = dots[i].className.replace(&#34; active&#34;, &#34;&#34;);
      }
      slides[slideIndex-1].style.display = &#34;block&#34;;  
      dots[slideIndex-1].className += &#34; active&#34;;
  }
&lt;/script&gt;

&lt;figcaption&gt;
Yuck Factor survey. How do you score these stimuli?
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
What we see in this experiment is that the context in which the bowl is placed influences the attractiveness of the soup. None of the changes to the soup did, however, rationally modify the soup in any way. This experiment is based on the same principle behind the idea to use a special spoon to serve food to your pet—there is no rational reason to do so, but the perception of disgust is strong enough to motivate people to buy special spoons for their pets.&lt;/p&gt;
&lt;p&gt;
This experiment can be repeated using different water scenarios: straight from a spring, from a treatment plant, sourced from sewerage, downstream of a sewerage treatment plant and so on. This type of research should be conducted as it would assist utilities to sell better the proposition of using purified sewerage as drinking water.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Cultural Differences in Promoting Recycled Water
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Direct Potable Reuse is a hot topic in areas where alternative sources of water are becoming scarce. There is a lot of fear in the industry because customers are not likely to accept this solution readily, due to our learnt attitude towards faecal matter, also known as the Yuck Factor.&lt;/p&gt;
&lt;p&gt;
Water utilities have tried a wide range of strategies to convince communities to encourage drinking recycled water. The general advice is to educate customers about the process. One of the rules of social marketing is, however, that rational appeals to change attitudes are not very useful. Clear examples of this practice are the many anti-smoking or anti-speeding ads that use emotional appeals to modify the viewer&amp;#39;s attitude towards smoking or speeding.&lt;/p&gt;
&lt;p&gt;
Some commentators recommend using euphemisms for recycled sewerage such as &amp;#39;impaired water&amp;#39; instead of polluted water. Some of these are weasel words and should not be used as people see through the ruse.&lt;/p&gt;
&lt;p&gt;
Singapore is one country which effectively implemented Direct Potable Reuse (DPR). However, comparisons with Singapore are not straightforward since due to cultural differences between this country and Anglo-Saxon countries. Salient differences in culture can be identified using the system defined by &lt;a href=&#34;https://geerthofstede.com/landing-page/&#34;&gt;Geert Hofstede.&lt;/a&gt;&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/singapore.png&#34; alt=&#34;Cultural differences between Singapore, Australia and the United States&#34; title=&#34;Cultural differences between Singapore, Australia and the United States&#34;/&gt;
&lt;figcaption&gt;
Cultural differences between Singapore, Australia and the United States.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Power Distance&lt;/em&gt;: the extent to which the less powerful members of institutions and organisations within a country expect and accept that power is distributed unequally.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Individualism&lt;/em&gt;: the degree of interdependence a society maintains among its members&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Masculinity:&lt;/em&gt; the level of interdependence a society maintains among its members.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Uncertainty Avoidance:&lt;/em&gt; The extent to which the members of a culture feel threatened by ambiguous or unknown situations and have created beliefs and institutions that try to avoid these.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Pragmatism:&lt;/em&gt; the extent to which people attach more importance to the future, fostering pragmatic values towards rewards, including saving and capacity for adaptation.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Indulgence:&lt;/em&gt; the extent to which people try to control their desires and impulses.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The data shows that the cultural profile of Australia and the USA are very similar. There are, however, notable differences between the cultures of Singapore and Australia/USA that need to be taken into consideration when comparing Direct Potable Reuse acceptance in these countries.&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;Power Distance&lt;/em&gt; level for Singapore is almost double that in the other countries. Power distance influences the acceptance of government initiatives, such as DPR. The higher the level of Power Distance, the more likely a proposal is accepted.&lt;/p&gt;
&lt;p&gt;
The level of &lt;em&gt;Individualism&lt;/em&gt; in Singapore is much lower than in Western countries in general. A small degree of individualism would make acceptance of initiatives such as DPR easier to implement because of the perceived public benefits. In Western countries, the high level of individualism complicates social marketing due to a large number of segments that need to be targeted to obtain coverage over a whole population.&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;Masculinity&lt;/em&gt; dimension is almost the same in all three countries, which has thus no impact on differences in acceptance.&lt;/p&gt;
&lt;p&gt;
The low level of &lt;em&gt;Uncertainty Avoidance&lt;/em&gt; predicts that people in Singapore feel much less threatened by the novelty of DPR than in countries with a high level.&lt;/p&gt;
&lt;p&gt;
The high degree of pragmatism in Singaporean society points towards a future-oriented view of water resources that includes thrift and a sense of saving for the future. This dimension is much less in Australia and the USA.&lt;/p&gt;
&lt;p&gt;
Finally, the &lt;em&gt;Indulgence&lt;/em&gt; dimension is not very different between the countries&lt;/p&gt;
&lt;p&gt;
This comparison shows that firstly, understanding the value system of the consumers in the service area is essential to be able to craft an effective campaign for the acceptance of Direct Potable Reuse. Secondly, it shows that we cannot use an example used in one location and transpose that approach to another location.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Marketing Recycled Water
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Although repugnance is a deep-seated psychological mechanism, the precise nature of the disgust mechanism is culturally determined. Just because a psychological mechanism is at work does not mean that it is hard-wired in our brain. Classically conditioned responses can be extinguished and reprogrammed. This change can, however, not be achieved by appealing to reason, as some industry experts proclaim.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-4&#34; href=&#34;#footnote-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Marketing recycled water is a delicate art. The repugnance against faeces is too deeply seated to be extinguished by reason alone. The most effective advertising to change 
attitudes does not appeal to reason—don&amp;#39;t try to convince your customers by telling them how great your treatment plants are. The best analogies to this problem are anti-smoking or safe driving campaigns. The most effective campaigns are those that appeal to non-rational aspects of smoking or speeding.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Sanitising public language
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Weasel words are often used by demagogues, politicians and marketers to disguise what they are saying. A tax becomes a levy, we no longer live, we have a lifestyle and sacking people becomes downsizing. They are weasel words because they suck the meaning out of language, just like a weasel sucks eggs.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-5&#34; href=&#34;#footnote-5&#34;&gt;5&lt;/a&gt;&lt;/sup&gt; Some weasel words, or buzzwords, are so common that they appear on special &lt;a href=&#34;https://lucidmanager.org/management/buzzword-bingo/&#34;&gt;bingo cards&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
This type of language is, unfortunately also familiar with water utilities. What used to be a sewage treatment plant is now a water reclamation facility, removing any reference to its origins. Sewerage Sludge is magically transformed to a &amp;#39;biosolid&amp;#39;, ensuring that the average person has no idea what its provenance is. These new terms suck all meaning from the original words.&lt;/p&gt;
&lt;p&gt;
In a recent article in &lt;em&gt;Water21&lt;/em&gt;, the magazine for the International Water Association, John Baten proposed to take &amp;#39;evolve&amp;#39; the language used by water professionals to even deeper levels of befuddlement, as evidenced by the table below.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-6&#34; href=&#34;#footnote-6&#34;&gt;6&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/weaselwords.jpg&#34; alt=&#34;Weasel words in the water utility sector&#34; title=&#34;Weasel words in the water utility sector&#34;/&gt;
&lt;figcaption&gt;
Weasel words in the water utility sector.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Some of these suggestions are even sucking the life out of the existing weasel words. To call a sewage treatment plant a &amp;#39;renew enterprise&amp;#39; is confusing and deceptive. The regeneration—excuse me for using one of these terms—of treated effluent to Star-rated water is a total obfuscation of reality and removes water users even further away from the problems in our water supply chain.&lt;/p&gt;
&lt;p&gt;
Having said this, a careful choice of words is important. Empirical research demonstrated that framing &amp;#39;treated wastewater&amp;#39; as &amp;#39;recycled water&amp;#39; changed perceptions of the product by consumers and increased their willingness to use and to pay for the service.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-7&#34; href=&#34;#footnote-7&#34;&gt;7&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
The removal of any reference to poo in the case of treated sewage circumvents the Yuck Factor—the psychological mechanism that prevents people from accepting treated sewage as drinking water. But this is nothing more than a cheap magic trick that will not be able to deceive water users into accepting what they know to be the truth. An example of direct communication about sewerage is the &lt;a href=&#34;https://twitter.com/danielgerling&#34;&gt;Twitter feed&lt;/a&gt; of Daniel Gerling, who is preparing a book on the cultural history of excrement. His language is clear and straightforward, and the impact of his word choice forces people to face the issue.&lt;/p&gt;
&lt;p&gt;
This type of language will be more harmful than helpful in our industry. Only by calling things by their proper name can we educate consumers  about the water cycle and move forward in securing water for the future.&lt;/p&gt;
&lt;p&gt;
Given the intense disgust related to sewerage, telling people that they should drink and shower in recycled water will immediately activate the Pavlovian disgust reflex. The most effective way to sell the idea of using sewerage to create potable is to increase the level of trust customers have in the organisation, using origin strategies.&lt;/p&gt;
&lt;p&gt;
Don&amp;#39;t emphasise the sewerage aspect of the water or the high-tech treatment facilities—emphasise the natural water cycle by using emotive images of pristine water flows. Focusing on the non-rational aspects of water consumption will increase customers&amp;#39; involvement with utilities and ultimately have a positive influence on their perceptions of quality and trust in the organisation.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-8&#34; href=&#34;#footnote-8&#34;&gt;8&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
What do you think? How can we negate the Yuck Factor and make using recycled water as potable water acceptable?&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Menegaki, A. N., Mellon, R. C., Vrentzou, A., Koumakis, G., &amp;amp; Tsagarakis, K. P. (2009). What&amp;#39;s in a name: Framing treated wastewater as recycled water increases willingness to use and willingness to pay. &lt;em&gt;Journal of Economic Psychology&lt;/em&gt;, 30(3), 285–292. &lt;a href=&#34;http://dx.doi.org/10.1016/j.joep.2008.08.007&#34;&gt;doi:10.1016/j.joep.2008.08.007&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-2&#34;&gt;&lt;a href=&#34;#footnote-reference-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Rozin, P., Haidt, J., &amp;amp; McCauley, C.R. (2008). Disgust in M. Lewis, J.M. Haviland-Jones &amp;amp; L.F. Barrett (eds.), &lt;em&gt;Handbook of emotions&lt;/em&gt;, 3rd ed. (pp. 755–776). New York: Guilford Press.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-3&#34;&gt;&lt;a href=&#34;#footnote-reference-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Rozin, P., Fallon, A., &amp;amp; Mandell, R. (1984). Family resemblance in attitudes to foods. &lt;em&gt;Developmental Psychology&lt;/em&gt;, 20(2), 309–314.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-4&#34;&gt;&lt;a href=&#34;#footnote-reference-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Russell, S., &amp;amp; Lux, C. (2009). Getting over yuck: moving from psychological to cultural and sociotechnical analyses of responses to water recycling.
&lt;em&gt;Water Policy&lt;/em&gt;, /11/(1), 21. &lt;a href=&#34;http://dx.doi.org/doi:10.2166/wp.2009.007&#34;&gt;doi:10.2166/wp.2009.007&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-5&#34;&gt;&lt;a href=&#34;#footnote-reference-5&#34;&gt;5&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Don Watson, &lt;a href=&#34;https://www.penguin.com.au/books/watsons-dictionary-of-weasel-words-9781740513661&#34;&gt;Watson&amp;#39;s Dictionary of Weasel Words&lt;/a&gt;, Knopf, 2004&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-6&#34;&gt;&lt;a href=&#34;#footnote-reference-6&#34;&gt;6&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Baten III, J. (2014). One Water: Uniting around a new water language. Water 21, (February), 12–16.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-7&#34;&gt;&lt;a href=&#34;#footnote-reference-7&#34;&gt;7&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Menegaki, A. N., Mellon, R. C., Vrentzou, A., Koumakis, G., &amp;amp; Tsagarakis, K. P. (2009). What&amp;#39;s in a name: Framing treated wastewater as recycled water increases willingness to use and willingness to pay. &lt;em&gt;Journal of Economic Psychology&lt;/em&gt;, /30/(3), 285–292. doi:&lt;a href=&#34;https://www.academia.edu/3305802/Whats_in_a_name_Framing_treated_wastewater_as_recycled_water_increases_willingness_to_use_and_willingness_to_pay&#34;&gt;10.1016/j.joep.2008.08.007&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-8&#34;&gt;&lt;a href=&#34;#footnote-reference-8&#34;&gt;8&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Cohen (2000). Consumer involvement–driving up the cost. Consumer Policy Review, 10(4), 122–125; Espejel, Fandos &amp;amp; Flavián (2009). The influence of consumer involvement on quality signals perception: An empirical investigation in the food sector. British Food Journal, 111(11), 1212–1236.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Evil Leadership: Management Lessons From Mr Spock</title>
      <link>https://lucidmanager.org/management/evil-leadership/</link>
      <pubDate>Sun, 26 May 2013 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/evil-leadership/</guid>
      <description>
	
&lt;p&gt;
Leadership is the magic word spoken around board tables everywhere on the globe. Consequently, being an excellent manager is no longer sufficient, we have to be a good leader. Nobody can provide a definitive definition of leadership. An army of leadership gurus is, however, more than happy to provide their personal perspective. Being a leader has become a value judgement. Nobody wants to be a good manager anymore; everybody wants to be a &lt;em&gt;leader.&lt;/em&gt; A vast industry providing leadership training has developed in the wake of the movement away from management. Leadership coaches promise to transform average hard-working managers into great leaders. This article briefly explores the concept of evil or Machiavellian leadership.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Evil Leadership according to Spock
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;At Lucid Manager we don&amp;#39;t get inspiration from management books or leadership programs. Lucid managers are &lt;a href=&#34;https://lucidmanager.org/management/useless-knowledge/&#34;&gt;inspired by the arts&lt;/a&gt;, and there is nothing more inspiring than the epic television series &lt;em&gt;Star Trek&lt;/em&gt;. The inimitable Spock has a very different view of leadership in the mythic 1966 episode &lt;a href=&#34;https://en.wikipedia.org/wiki/The_Enemy_Within_(Star_Trek:_The_Original_Series)&#34;&gt;The Enemy Within&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;What is it that makes one man an exceptional leader? We see indications that it&amp;#39;s his negative side which makes him strong, that his evil side, if you will, properly controlled and disciplined, is vital to his strength. Your negative side removed from you, the power of command begins to elude you.&lt;/p&gt;
&lt;p&gt;
Lieutenant Spock (Stardate 1672.1).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
In some management books, this evil side of management is innocently referred to as Machiavellian. Leaders with this trait are people who are willing to sacrifice ethics to achieve goals. Some people believe that this is a necessary condition of being successful. There is, however, no evidence that individuals with a high level of Machiavellianism perform better.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Psychopath Leader: &lt;em&gt;Snakes in Suits&lt;/em&gt;
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Paul Babiak, an industrial and organisational psychologist, and Robert Hare, the creator of the standard tool for diagnosing psychopathy, wrote a fascinating book about psychopaths in the workplace, which he called snaked in suits. By the way, you can play our &lt;a href=&#34;https://lucidmanager.org/management/corporate-snakes-and-ladders-career-simulator/&#34;&gt;Corporate Snakes and Ladders&lt;/a&gt; career simulation if you like some free career lessons.&lt;/p&gt;
&lt;p&gt;
Babiak and Hare explored the prominence of people with destructive personality characteristics who could be classified as psychopaths. A psychopath does not have to be a knife-wielding mass-murdering maniac. Most of them are charming and intelligent, but lack empathy and are willing to sacrifice ethics to achieve personal goals. They can impress in interviews, but their lack of understanding creates tension in organisations, which in the long run leads to reduced performance.&lt;/p&gt;
&lt;p&gt;
So it seems that Spock was wrong. Being either good or evil bears no relationship to the level of performance. If there is no real difference, then leadership can easily digress into its evil counterpart. We should once again focus on good management instead of leadership. The leadership experiment has failed and has not created better organisations. Management is the key to good organisations. Management can be defined, and its outcomes can be measured, while leadership will forever be contested and its effects are unable to be measured.&lt;/p&gt;
&lt;p&gt;
Live long and prosper!&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Notes
&lt;/h3&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Gable, M., &amp;amp; Topol, M. T. (1991). Machiavellian managers: Do they perform better? &lt;em&gt;Journal of Business and Psychology&lt;/em&gt;, /5/(3), 355–365. &lt;a href=&#34;https://dx.doi.org/10.1007/BF01017707&#34;&gt;doi:10.1007/BF01017707&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Water Quality Paradox and Perceptions of Service Quality</title>
      <link>https://lucidmanager.org/marketing/water-quality-paradox/</link>
      <pubDate>Sat, 20 Apr 2013 16:09:08 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/water-quality-paradox/</guid>
      <description>
	
&lt;p&gt;
Every day, thousands of engineers around the world work hard every day to provide potable water quality to their customers thereby keeping cities liveable and preventing disease. They do this work invisible to most people as customers have very simple, but very high expectations of service. Nevertheless, regularly often complain. This article discusses the water quality paradox at the heart of many of these complaints.&lt;/p&gt;
&lt;p&gt;
Although in well-managed systems, the chances that somebody does not receive an excellent service through their tap are extremely low, consumer perception of these services is often not as good as engineers would hope for. The reason for this is because there is a &lt;a href=&#34;https://lucidmanager.org/marketing/tap-water-paradoxes/&#34;&gt;paradox&lt;/a&gt; in the provision of water services. Operators of drinking water systems need to comply with local regulatory requirements. Meeting these requirements can, however, lead to a reduction in service quality. For example, adding chlorine is essential to ensure public health in that it destroys micro-organisms. In some communities, however, chlorine is perceived as an unwanted chemical, leading to a reduction in service quality. &lt;/p&gt;
&lt;p&gt;
The water quality paradox is one of the main issues faced by water utilities. A case in point is the resistance against adding fluoride to water, such as explained in this video.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Water Quality Paradox
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The water quality paradox implies that we can not influence the total experience of the service enjoyed by customers because there are always aspects outside the control of the service provider. What at first seems like a paradox is, however, not paradoxical. Water services are like internet services, as they are provided at the customer&amp;#39;s premises and they use their equipment to consume the service. The cause of the paradox in water quality is the fact that we cannot control all variables that make up the customer experience. To the customer, however, this is not important, and any service failure will reflect negatively on the service provider.&lt;/p&gt;
&lt;p&gt;
Providing safe water is the most important task of &lt;a href=&#34;https://lucidmanager.org/marketing/engineering-marketing-interface/&#34;&gt;engineers&lt;/a&gt; in a water utility. Operators of drinking water systems comply with local regulations to meet this objective. Meeting these requirements
can, however, lead to a reduction in the perception of quality by the consumer. For example, adding chlorine is essential to ensure public health in that it destroys micro-organisms, but in some communities chlorine is perceived as an unwanted chemical.&lt;/p&gt;
&lt;p&gt;
Providing safe water is a &lt;a href=&#34;http://en.wikipedia.org/wiki/Necessity_and_sufficiency&#34;&gt;necessary condition. but not a sufficient condition&lt;/a&gt; to achieve customer satisfaction.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Safe Water Versus Good Water
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A search on &amp;#34;tap water&amp;#34; on &lt;a href=&#34;https://lucidmanager.org/data-science/tap-water-sentiment-analysis/&#34;&gt;Twitter&lt;/a&gt; shows that taste is the main concern. The taste of water is, however, influenced not only by the chemical and biological quality of the water itself but also by other circumstances, such as the cup people drink it from. The researchers found that the firmness of a cup from which you drink water can influence our judgments of the taste of water.&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/marketing/service-quality-perception/&#34;&gt;Service quality&lt;/a&gt; is the overall assessment of quality by the customer. In reticulated water, it has two perspectives: that of the customer and that of the service provider. The customer extrinsically assesses the experienced quality attributes concerning what they perceive. From the service provider&amp;#39;s perspective, quality resides intrinsically within the service itself. The service provider is interested in providing &lt;em&gt;safe water&lt;/em&gt; by meeting the relevant regulations—the customer is interested in &lt;em&gt;good water&lt;/em&gt; through a positive consumption experience.&lt;/p&gt;
&lt;p&gt;
The intrinsic perspective of the water engineer is predictable and rational. Water safety expresses itself in e-Coli counts, electrical conductivity and other scientific parameters. However, the extrinsic perspective of the consumer&amp;#39;s individual perception is non-rational. This non-rationality does not imply that consumers are irrational. A non-rational perspective is one that includes emotional assessments that numbers cannot describe. How users of water systems view their service (&lt;em&gt;good water&lt;/em&gt;) only partially overlaps with how engineers and scientists see the service (&lt;em&gt;safe water&lt;/em&gt;). Customers are thus interested in good water and take safe water for granted. This aspect of water quality is for marketers to assess.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Experience and Credence Qualities
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;In marketing jargon, good water is determined by &lt;em&gt;experience qualities&lt;/em&gt; while safe water is determined by the &lt;em&gt;credence qualities&lt;/em&gt; of water. Experience qualities are attributes such as taste, that can only be discerned after purchase or during consumption, and credence qualities are attributes which consumers find impossible to evaluate because they do not have the knowledge or skill to do so and because many aspects of safe water are not immediately perceivable. This idea implies that as customers cannot experience the safety aspects of water directly, trust is one of the most important parameters in the provision of water services.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/safe-good-water.jpg&#34; alt=&#34;Service quality in tap water: the difference between safe water and good water&#34; title=&#34;Service quality in tap water: the difference between safe water and good water&#34;/&gt;
&lt;figcaption&gt;
Service quality in tap water: the difference between safe water and good water.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
To provide a complete picture of service quality in water, it is important not to focus only on the intrinsic scientific aspects of service provision. A complete measurement system will include the non-rational dimensions of human perception. Scientists and engineers responsible for water safety need to work together with marketers to provide a complete understanding of water quality.&lt;/p&gt;
&lt;p&gt;
If you like to find out more about using marketing theory to manage the experience of water utility customers, then please consider reading &lt;em&gt;Customer Experience Management for Water Utilities&lt;/em&gt; by Peter Prevos.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;blockquote class=&#34;twitter-tweet&#34;&gt;&lt;p lang=&#34;en&#34; dir=&#34;ltr&#34;&gt;&lt;a href=&#34;https://x.com/InvisibleH2O?ref_src=twsrc%5Etfw&#34;&gt;@InvisibleH2O&lt;/a&gt; &lt;a href=&#34;https://x.com/lsimas17?ref_src=twsrc%5Etfw&#34;&gt;@lsimas17&lt;/a&gt;: &lt;a href=&#34;https://x.com/InvisibleH2O?ref_src=twsrc%5Etfw&#34;&gt;@InvisibleH2O&lt;/a&gt; Great article. As a Portuguese tap water quality regulator, I am going to take it into account&lt;/p&gt;&amp;mdash; Luís Simas (@lsimas17) &lt;a href=&#34;https://x.com/lsimas17/status/357484641130790913?ref_src=twsrc%5Etfw&#34;&gt;July 17, 2013&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async src=&#34;https://platform.x.com/widgets.js&#34; charset=&#34;utf-8&#34;&gt;&lt;/script&gt;

&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Value of Water — A Marketing Perspective on Tap Water</title>
      <link>https://lucidmanager.org/marketing/value-of-water/</link>
      <pubDate>Tue, 26 Mar 2013 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/value-of-water/</guid>
      <description>
	
&lt;p&gt;
The value of water has been a topic of interest since the start of modern economic. Father of economics Adam Smith identified the so-called &lt;a href=&#34;https://lucidmanager.org/marketing/tap-water-paradoxes/&#34;&gt;diamond-water paradox&lt;/a&gt; in &lt;em&gt;The Wealth of Nations&lt;/em&gt;. The basic question he asked is what are useless diamonds so valuable, while the price of water is so low. This article discusses a model for the value of water and a method to describe the water value proposition.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Value of Water in History
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Thoughts about the value of water as as old as human culture itself. The Bible (&lt;a href=&#34;http://www.biblegateway.com/passage/?search=Isaiah+55%3A1&amp;amp;version=NIV&#34;&gt;Isaiah 55:1&lt;/a&gt;) sees water as a human right. A point of view that many people seem to have in debates about water prices:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Come, all you who are thirsty, come to the waters; and you who have no money, come, buy and eat! Come, buy wine and milk without money and without cost.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
This invitation to the thirsty shows the importance of water in semi-arid cultures. This quote positions water as a human right to be shared by all without having to pay for it. Some have argued that water is a God-given right and should not have a price. The counter-argument is that the water might fall free from the sky, but the pumps and pipes needed to deliver it to customers is not.&lt;/p&gt;
&lt;p&gt;
Plato (&lt;a href=&#34;http://classics.mit.edu/Plato/euthydemus.1b.txt&#34;&gt;Euthydemus&lt;/a&gt; 304B), refers to the Ancient Greek lyric poet from Thebes:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;For only what is rare is valuable; and &amp;#34;water,&amp;#34; which, as Pindar says, is the &amp;#34;best of all things,&amp;#34; is also the cheapest.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Adam Smith, in his book &lt;a href=&#34;http://www.econlib.org/library/Smith/smWN1.html#B.I,%20Ch.4,%20Of%20the%20Origin%20and%20Use%20of%20Money&#34;&gt;Wealth of Nations&lt;/a&gt; (Book I: 4.13) described what has become known as the Diamond—Water Paradox.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Nothing is more useful than water: but it will purchase scarce any thing; scarce any thing can be had in exchange for it. A diamond, on the contrary, has scarce any value in use; but a very great quantity of other goods may frequently be had in exchange for it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
A more mundane example comes from the quiz show &lt;em&gt;Family Feud&lt;/em&gt;. In an episode of the Australian version, they asked contestants what they though people answered when asked what should be free. Water was, perhaps unsurprisingly, the top answer.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/family-feud-water.jpg&#34; alt=&#34;Question on Family Feud Australia&#34; title=&#34;Question on Family Feud Australia&#34;/&gt;
&lt;figcaption&gt;
Question on Family Feud Australia.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Value of Water
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The value of water is not the same as the price of water. Price is an absolute concept, but value is an inherently subjective construct that only customers can define. It is often said that &lt;a href=&#34;https://lucidmanager.org/marketing/fly-in-my-soup/&#34;&gt;the customer is always right&lt;/a&gt;. Although customers might be wrong about facts, they are always right about how they feel about something. In order to use the concept of value in marketing we need to view it from the perspective of the customer, which relates to how they feel about the service. Following this line of reasoning, the definition of value is the difference between the &lt;em&gt;perceived benefits&lt;/em&gt; and &lt;em&gt;perceived&lt;/em&gt; &lt;em&gt;cost&lt;/em&gt;. We should, however, not view benefits and cost only from a monetary perspective. The value of water is a multi-dimensional construct.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
The Benefits of Water
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
The Hierarchy of Needs
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Not all water use is, however, a matter of life and death. Customer use water for many purposes and in the case of reticulated water supply, they use the same water for drinking, hygiene, gardens, swimming and other recreational activities and as a transport medium for waste.&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;http://en.wikipedia.org/wiki/Maslow%27s_hierarchy_of_needs&#34;&gt;Maslow&amp;#39;s Hierarchy of Needs&lt;/a&gt; can be evoked to illustrate the multidimensional nature of the value of water. At the
physiological level, we need water for hygiene and hydration. Water does, however, also fulfil social and psychological needs. A mundane activity such as gardening, which requires a lot of water, serves to meet the full spectrum of human needs, e.g. physical exercise, expressing creativity and creating a space to socialise.&lt;/p&gt;
&lt;figure&gt;
&lt;a title=&#34;Hamish.croker, CC BY-SA 4.0 &amp;lt;https://creativecommons.org/licenses/by-sa/4.0&amp;gt;, via Wikimedia Commons&#34; href=&#34;https://commons.wikimedia.org/wiki/File:Maslow%27s_Hierarchy_of_Needs_Pyramid_(original_five-level_model).png&#34;&gt;&lt;img width=&#34;960&#34; alt=&#34;Diagram of Maslow&amp;#039;s Hierarchy of Needs.&#34; src=&#34;https://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Maslow%27s_Hierarchy_of_Needs_Pyramid_%28original_five-level_model%29.png/960px-Maslow%27s_Hierarchy_of_Needs_Pyramid_%28original_five-level_model%29.png?utm_source=commons.wikimedia.org&amp;utm_campaign=index&amp;utm_content=thumbnail&#34;&gt;&lt;/a&gt;
&lt;figcaption&gt;
Maslow&amp;#39;s Hierarchy of Needs illustrated (Source: Wikimedia. Saul McLeod / CC BY-SA).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Needs and Wants
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;To understand the value of water we need to define its benefits and distinguish between needs and wants for water. The marketing definition of needs and wants is very different from the common sense understanding of need as a necessity. Many publications on tap water distinguish between the water we &lt;em&gt;need&lt;/em&gt; and the water we &lt;em&gt;want&lt;/em&gt;, the so called discretionary use. This distinction is the a common-sense concept between needs and wants, whereby needs are of a higher order than wants. The common sense understanding of the difference between needs and wants is, however, incorrect as it denies the importance of higher order needs.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Needs
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Maslow, as a &lt;a href=&#34;http://en.wikipedia.org/wiki/Humanistic_psychology&#34;&gt;humanist psychologist&lt;/a&gt;, believed that all human beings have a need for self-actualisation as much as they need food and water—the so called hierarchy of needs is not really a hierarchy. Physiological needs are just as important as the need for a sense of safety, a sense of belonging, self-esteem and self-actualisation. Therefore, the need for water includes uses other that hygiene and consumption. Recognising that sociological and psychological needs are just as important as physiological needs is paramount to be able to define the value proposition of water.&lt;/p&gt;
&lt;p&gt;
Evoking on Mallow&amp;#39;s humanistic psychology, human beings need a lot more than just a minimal amount to survive. Human beings have sociological needs and psychological needs, and they all have to be met. They are all necessary to be a complete human being. To say that water used for gardening is not a need but &amp;#34;only a want&amp;#34; is wrong.&lt;/p&gt;
&lt;p&gt;
People need water to grow their gardens because they have a sociological need or psychological need. People have a garden because they want to invite friends and have a good time. Gardening also provides a sense of achievement, a significant psychological need. Needs are a mental state of felt deprivation. There is no threshold whether something does or does not classify as a need. Needs are psychologically innate within us. We cannot change of create these needs.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Wants
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Hand in hand with psychological needs, customers have &amp;#39;wants&amp;#39;, which is the manner in which a need is satisfied. If somebody needs self-fulfilment, some people might do a PhD in marketing, other people might enjoy working in their garden, for which they need water. Everybody fulfils their psychological needs differently. The core task
of a service provider is to understand these needs and wants and create a value proposition that matches customer expectations.&lt;/p&gt;
&lt;p&gt;
Marketing can not change or create needs, but it can influence what people want. Wants are culturally determined and can be shaped through communication, and education. The traditional Aussie backyard is disappearing because customer&amp;#39;s values are changing. People are no longer interested in expressing themselves through their garden. The younger generation has experienced the prolonged drought and they have developed alternative ways to satisfy their needs.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
The Cost of Water
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The discourse about the price of water predominately discusses money. However, the cost of water is multi-dimensional. Besides money, people pay a psychological price a sociological price and a time price for water.&lt;/p&gt;
&lt;p&gt;
On the cost side of the value equation, dimensions other than financial cost, such as time cost should be taken into
consideration. Additional to the money a customer pays for service, they also pay with their time. Using time to enjoy a service is an opportunity cost to the customer—any time expenditure reduces discretionary time. A service provider can increase the value perceived by the customer by minimising the amount of time required to enjoy the service.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
Time Cost
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The time cost concept forms the foundation of a method to measure quality of &lt;a href=&#34;https://lucidmanager.org/marketing/service-quality-perception/&#34;&gt;service delivery&lt;/a&gt;. The worst level of service occurs in countries women walk for hours to obtain their family&amp;#39;s daily amount of water. In developed reticulated water systems, the time investment by consumers is marginal and only becomes noticeable in the case of service failures or with inefficient facilitating services such as billing. The value perceived by customers can be maximised by minimising their perceived cost, minimising the amount of time they need to invest in enjoying a water service.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-10&#34;&gt;
Psychological Cost
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The psychological price encompasses the mental effort customers need to expense in purchasing or consuming the service. With water, the psychological cost is generally marginal, but as soon as the service fails, the psychological price increases dramatically, thereby decreasing the perceived value and leading to unhappy customers.&lt;/p&gt;
&lt;p&gt;
Another aspect is the sociological price, which relates to how the purchase impacts how other people view us. Sociological cost is relevant to water users in that, for example owning a lovely garden or swimming pool enhances the customer&amp;#39;s prestige in their social network.&lt;/p&gt;
&lt;p&gt;
The type of price that I want to focus a bit more on is time. People need to spend their time to obtain water, and around the world, things are very different. The worst possible water service imaginable you would find, for example, in arid parts of Africa where women spend hours every day to get their daily ration of water.&lt;/p&gt;
&lt;p&gt;
There are some estimates that &lt;a href=&#34;https://www.npr.org/sections/goatsandsoda/2016/07/07/484793736/millions-of-women-take-a-long-walk-with-a-40-pound-water-can&#34;&gt;women around the&lt;/a&gt; world, you never see men carrying water, spend about 200 million hours every day to obtain water. In developed countries, customers use a negligible amount of time on obtaining water. Customers only get actively involved with the service when it s unavailable or unsafe. In worst cases, they might need to boil the water before they can use it.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-11&#34;&gt;
The Value of Water and the Tap Water Value Proposition
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Understanding how your customers assess the value of a service is the first step in developing a water value proposition enhances customer experience. The price of water, monetary, psychological, sociological and time, is so low that any disturbance in the value equation will lead to dissatisfaction. This thought leads to a previous proposition I made on this blog; the best possible water utility is invisible to the customer. An invisible water utility provides services that are so seamless that customers pay a negligible time price.&lt;/p&gt;
&lt;p&gt;
Deliberations about the value water seem at first instance to be a foregone conclusion. Water is of infinite value because we need water just like we need air and food to stay alive. This is, however, a simplistic view as we only need a relatively small amount to sustain life, anything beyond that is discretionary. In this article I will describe the complexities of the the value of water as a construct and propose an alternative perspective to define it. From this layered definition of value we can start defining the value proposition of water to improve customer engagement in tap water.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/WeihJRcgiLU?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Tap Water Value Proposition: Theory and Practice.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-12&#34;&gt;
Tap Water Value Proposition
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;With this multi-layered concept of the value of water we can define a meaningful tap water value proposition—a promise to the customer regarding the value of the provided service. The value proposition is not merely a slogan or a branding exercise. A meaningful value proposition is communicated in everything a service provider writes says and more importantly, does—within the tap water context, customer service stretches from catchment to tap and to the water bill.&lt;/p&gt;
&lt;p&gt;
There are only two ways to maximise the value perceived by the customer: increase the perceived benefits or decrease the perceived cost. To maximise the perceived benefits of the service offering, water companies should focus their communication on the higher order needs water use satisfies. Many water utilities highlight the technological aspects of service provision, instead of the higher order benefits it provides. &lt;/p&gt;
&lt;p&gt;
The other side of the value equation involves lowering perceived cost. To lower the perceived cost of water services it is important to provide a high level of service in order to minimise the time price paid by customers. Water companies can focus on finding the root cause of customer communications and seeking to eradicate these causes so that there is no more need for consumers to contact the organisation. The perfect water utility is invisible to the customer.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-13&#34;&gt;
Tap Water Advertising
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Water utilities should use their value proposition to guide how they position themselves within the community. Water utility &lt;a href=&#34;https://lucidmanager.org/marketing/water-utility-branding/&#34;&gt;branding&lt;/a&gt; should closely follow the value proposition. &lt;/p&gt;
&lt;p&gt;
Marketing wisdom dictates that communication for services that are highly tangible, like water, should focus on the intangible aspects.&lt;/p&gt;
&lt;p&gt;
So instead of focusing on technology or emphasising on the physical qualities of the water, tell customers what intangible benefits they get from their tap water. Most discussions about water focus on its life-sustaining properties, but tap water is so much more. Using tap water is an essential part of modern life and maintains the lifestyle we have come accustomed to.&lt;/p&gt;
&lt;p&gt;
Having a shower is a perfect place for generating inspiring ideas; water is an essential ingredient in virtually every single recipe; water performs a crucial role in some of the most intimate moments in our lives.&lt;/p&gt;
&lt;p&gt;
The slide show below provides some examples on how the intangible value of water can be communicated, beyond the pipes, pumps and plants. These ads &lt;a href=&#34;https://lucidmanager.org/marketing/communicating-waters-value/&#34;&gt;communicate the intangible dimensions of water&lt;/a&gt; and show that using water is not
about the water itself, but about the value that water adds to our life. Advertising is not about
convincing people with logical arguments but about communicating the value proposition that the utility provides beyond plants, pumps and pipes.&lt;/p&gt;
&lt;p&gt;


&lt;div class=&#34;slideshow-container&#34;&gt;
  &lt;div class=&#34;mySlides fade&#34;&gt;
    &lt;div class=&#34;numbertext&#34;&gt;1 / 3&lt;/div&gt;
    &lt;img src=&#34;https://lucidmanager.org/images/water-marketing/advertising/tap-water-advertisement-2.jpg&#34; /&gt;
  &lt;/div&gt;
  &lt;div class=&#34;mySlides fade&#34;&gt;
    &lt;div class=&#34;numbertext&#34;&gt;2 / 3&lt;/div&gt;
    &lt;img src=&#34;https://lucidmanager.org/images/water-marketing/advertising/tap-water-advertisement-3.jpg&#34; /&gt;
  &lt;/div&gt;
  &lt;div class=&#34;mySlides fade&#34;&gt;
    &lt;div class=&#34;numbertext&#34;&gt;3 / 3&lt;/div&gt;
    &lt;img src=&#34;https://lucidmanager.org/images/water-marketing/advertising/tap-water-advertisement-4.jpg&#34; /&gt;
  &lt;/div&gt;
  
  &lt;a class=&#34;prev&#34; onclick=&#34;plusSlides(-1)&#34;&gt;&amp;#10094;&lt;/a&gt;
  &lt;a class=&#34;next&#34; onclick=&#34;plusSlides(1)&#34;&gt;&amp;#10095;&lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;

&lt;div style=&#34;text-align:center&#34;&gt;
  &lt;span class=&#34;dot&#34; onclick=&#34;currentSlide( 1 )&#34;&gt;&lt;/span&gt;
  &lt;span class=&#34;dot&#34; onclick=&#34;currentSlide( 2 )&#34;&gt;&lt;/span&gt;
  &lt;span class=&#34;dot&#34; onclick=&#34;currentSlide( 3 )&#34;&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;script&gt;
  var slideIndex = 1;
  showSlides(slideIndex);
  function plusSlides(n) {
      showSlides(slideIndex += n);
  }
  function currentSlide(n) {
      showSlides(slideIndex = n);
  }
  function showSlides(n) {
      var i;
      var slides = document.getElementsByClassName(&#34;mySlides&#34;);
      var dots = document.getElementsByClassName(&#34;dot&#34;);
      if (n &gt; slides.length) {slideIndex = 1}    
      if (n &lt; 1) {slideIndex = slides.length}
      for (i = 0; i &lt; slides.length; i++) {
	  slides[i].style.display = &#34;none&#34;;  
      }
      for (i = 0; i &lt; dots.length; i++) {
	  dots[i].className = dots[i].className.replace(&#34; active&#34;, &#34;&#34;);
      }
      slides[slideIndex-1].style.display = &#34;block&#34;;  
      dots[slideIndex-1].className += &#34; active&#34;;
  }
&lt;/script&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-14&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-14&#34;&gt;
Water Utility marketing
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-14&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to find out more about using marketing theory to manage the experience of water utility customers, then please consider reading &lt;em&gt;Customer Experience Management for Water Utilities&lt;/em&gt; by Peter Prevos.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Organisational culture and the risks of normality</title>
      <link>https://lucidmanager.org/management/organisational-culture/</link>
      <pubDate>Sun, 24 Mar 2013 15:24:47 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/organisational-culture/</guid>
      <description>
	
&lt;p&gt;
&amp;#34;We need to change our organisational culture!&amp;#34; one of the board members said, &amp;#34;we have &lt;a href=&#34;https://lucidmanager.org/management/functional-silos/&#34;&gt;too many silos&lt;/a&gt;!&amp;#34;. Everybody around the table nodded. The secretary noted another action in the board minutes and instructed the CEO to change the culture of the organisation.&lt;/p&gt;
&lt;p&gt;
Nobody knew what they wanted, all they knew was that something had to change. Because nobody knew what had to change, blaming the culture of the organisation for whatever was going wrong seemed like the best way forward. Not that anyone had any idea what organisational culture is. Judging by some of the inspiring articles in &lt;em&gt;Harvard Business Review&lt;/em&gt; it seemed the best way to go.&lt;/p&gt;
&lt;p&gt;
Soon enough a &lt;a href=&#34;https://lucidmanager.org/management/consultant-shaman/&#34;&gt;consultant&lt;/a&gt; was hired and the work to &lt;a href=&#34;https://lucidmanager.org/management/culture-change/&#34;&gt;transform the organisation&lt;/a&gt; began. The management team held meetings and defined a range of new values, based on a concise list of &lt;a href=&#34;https://lucidmanager.org/management/value-based-management/&#34;&gt;abstract nouns&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
Paraphrasing George Bush after the 9/11 attacks: You either are with us and subscribe to these values, or you are an enemy of the organisation. Employees that criticise the new approach become the axis of evil. The consultant even drew a Bell Curve on a whiteboard to visualise that &lt;a href=&#34;https://lucidmanager.org/management/positive-workplace-deviance/&#34;&gt;deviance from normality&lt;/a&gt; was from now on scorned upon. Thus began the new world order.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;forcing normality destroys excellence and innovation&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
What the consultant didn&amp;#39;t realise was that forcing people to normality within strict standard deviations represses spontaneity. The very act of improving culture can destroy sources of excellence and innovation. When organisations force their employees into the same value pattern. When managers no longer accept any deviance, they kill a significant source of improvement and innovation. Cultural programs can become an organisational chastity belt that constricts any creative naughtiness.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Positive deviance to change organisational culture
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The link between organisational culture and business performance is strong. nevertheless, both researchers and practitioners struggle to describe what a healthy culture is. A culture of obedience to a norm might be pleasant, but it will lead to organisational mediocrity.&lt;/p&gt;
&lt;p&gt;
Positive corporate deviance is a necessary condition for innovation and improvement to thrive. Only by nurturing those that think differently are organisations able to become remarkable.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Do water utilities need to have customer focus?</title>
      <link>https://lucidmanager.org/marketing/water-utility-customer-focus/</link>
      <pubDate>Mon, 04 Feb 2013 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/water-utility-customer-focus/</guid>
      <description>
	
&lt;p&gt;
Customer focus is the prime purpose of all organisations, or so you would think. Many engineers in water companies believe that legislation and technical standards only govern the level of service quality experienced by customers. Engineers and scientists are the experts, and there is thus no need to ask the lay-customer what they want. One engineer expressed this view succinctly on &lt;a href=&#34;http://linkedin.com&#34;&gt;LinkedIn&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You have to deliver good quality services, but I don&amp;#39;t get the concept that the customer is best placed to decide what those services are. They know they need pressure and they know if they don&amp;#39;t have water out of their tap, but beyond that, they have only a small understanding of the what is required to run a safe and efficient water supply system.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Service Quality Perception
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The many engineers and scientists in water utilities that hold this view are wrong. Perhaps they need to follow a course in &lt;a href=&#34;https://lucidmanager.org/marketing/marketing-for-engineers/&#34;&gt;marketing for engineers&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
These engineers assume that if the technical quality of service is sufficient, then customers will be happy. This assumption is not correct—the Grönroos model of service quality shows that technical quality is only one aspect of the total customer experience.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; To influence the total perceived quality, many non-technical parameters,
such as public image and functional quality, need to be managed.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/gronroos-service-quality-model.jpg&#34; alt=&#34;Grönroos (1990) model of service quality&#34; title=&#34;Grönroos (1990) model of service quality&#34;/&gt;
&lt;figcaption&gt;
Grönroos (1990) model of service quality.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Engineering and Marketing
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;There is a significant paradigmatic difference between engineering and marketing. Engineering is based on predictable physical systems, while marketing builds on the inexact science of consumer behaviour and is predominately about managing perceptions. There are many examples where, even though technical quality is almost perfect, the understanding of consumers of the level of service is still small. This problem exists because the human dimension is not part of the equations that govern water systems.&lt;/p&gt;
&lt;p&gt;
One perfect example is the aesthetics of water. Although it makes no difference towards the actual safety of the water, consumer perception is that drinking water is colourless. Taste is another variable that is not easily controlled or measured through engineering. Research shows that water does not only influence the taste of water but moderated by environmental variables, such as the material of the cup.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-2&#34; href=&#34;#footnote-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Perception is everything in marketing. This concept is also important in monopolies because publicly owned businesses are controlled by politicians who want to keep the voters happy. Having said this, a good friend of mine &lt;a href=&#34;https://lucidmanager.org/marketing/water-privatisation/&#34;&gt;once stated&lt;/a&gt; that “voter satisfaction is not a good proxy for customer satisfaction”. It could also be argued that all customers in a publicly owned system are all shareholders, and their views should be taken into consideration—any other opinion could be considered arrogant.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Marketers should manage water companies.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Water Utility Customer Focus
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In my interviews with customer stakeholders in reticulated water, the voice of the customer indicates that they want to improve the focus on their needs. A clear theme in the data is the occasional disconnect between engineering and service staff. One respondent told me (paraphrasing): “Engineers used to run water companies, now accountants manage them. In the future, marketers should control them”. In other words, we should account for the non-rationality of consumer behaviour.&lt;/p&gt;
&lt;p&gt;
The concept of bringing engineers and marketers together was beautifully expressed by Philip Kotler and Sidney Levy who writes that: &amp;#34;Marketing is customer satisfaction &lt;a href=&#34;https://lucidmanager.org/marketing/engineering-marketing-interface/&#34;&gt;engineering&lt;/a&gt;&amp;#34;.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-3&#34; href=&#34;#footnote-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Water Utility Marketing
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to learn more about water utility marketing, then please consider reading &lt;em&gt;Customer Experience Management for Water Utilities&lt;/em&gt; by Peter Prevos.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Grönroos, C. (1984). A service quality model and its marketing implications. &lt;em&gt;European Journal of Marketing&lt;/em&gt;, 18(4), 36–44. doi:&lt;a href=&#34;http://dx.doi.org/10.1108/EUM0000000004784&#34;&gt;10.1108/EUM0000000004784&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-2&#34;&gt;&lt;a href=&#34;#footnote-reference-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Krishna, A., &amp;amp; Morrin, M. (2008). Does touch affect the taste? The perceptual transfer of product container haptic cues. &lt;em&gt;Journal of Consumer Research&lt;/em&gt;, 34(6), 807–818.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-3&#34;&gt;&lt;a href=&#34;#footnote-reference-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Kotler, P., &amp;amp; Levy, S. J. (1969). Broadening the concept of marketing. &lt;em&gt;Journal of Marketing&lt;/em&gt;, &lt;em&gt;33&lt;/em&gt;, 10–15.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Cynical Manager: The Organisation&#39;s Guard Dog</title>
      <link>https://lucidmanager.org/management/cynical-manager/</link>
      <pubDate>Thu, 24 Jan 2013 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/cynical-manager/</guid>
      <description>
	
&lt;p&gt;
The cynical manager has a bad reputation in business, and some even call them a “&lt;a href=&#34;https://web.archive.org/web/20180731113529/http://winthecustomer.com/the-cynic-is-a-cancer/&#34;&gt;cancer in your organisation&lt;/a&gt;”. In my view, most people are a bit too cynical about cynicism. Cynics are often valuable assets in corporations because they expose the &amp;#39;new clothes&amp;#39; of management.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
The word Cynic stems from the ancient Greek word for dog. The cynic might be a dog but is not a lapdog. The cynical manager can be the guard dog for organisations, protecting them from nonsense. Philosophical cynicism rejects conventional social values, such as business hierarchies. The cynic reflects on business practices from an external perspective and positively contributes by pointing out issues that might not be visible to their superiors. Being cynical is not necessarily a focus on negativity; it allows a view of the organisation outside of office politics.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The value of a cynical manager
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Every manager should prefer a cynic over the pseudo-expert who is armed with uses &lt;a href=&#34;https://lucidmanager.org/management/buzzword-bingo/&#34;&gt;buzzwords&lt;/a&gt; without substance. Cynics often exasperate upper management by &lt;a href=&#34;https://lucidmanager.org/management/socratic-management/&#34;&gt;questioning everything&lt;/a&gt;, like a child they keep asking &amp;#34;why&amp;#34;. More often than not, however, they know what is going on and see through the veil of ignorance.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-2&#34; href=&#34;#footnote-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Cynicism helps people to ensure that others don&amp;#39;t take advantage of them and it benefits organisations through resistance to potentially dangerous decisions.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-3&#34; href=&#34;#footnote-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
In one experiment, participants that were cynical towards their organisation were less likely to comply with unethical requests than those who were less cynical.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-4&#34; href=&#34;#footnote-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Types of cynicism
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Not all cynical behaviour is, however, of equal value. Researchers have defined three types of cynics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Affective&lt;/li&gt;
&lt;li&gt;Cognitive&lt;/li&gt;
&lt;li&gt;Behavioural&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In other words, you can be cynical as an emotional reaction, such as irritation, tension and anxiety. When you are cognitively cynical, you think that self-interest runs your organisation. When you are behaviourally cynical, you display that attitude in how you perform at work.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-5&#34; href=&#34;#footnote-5&#34;&gt;5&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
The most productive type of cynicism is the cognitive type—the cynic as the devil&amp;#39;s advocate.&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;Lucid Manager&lt;/em&gt; listens to cynics in their organisation to find out what is bothering them and learn from these experiences. You can cultivate your &lt;a href=&#34;https://lucidmanager.org/management/positive-workplace-deviance/&#34;&gt;positive deviance&lt;/a&gt; by becoming the &lt;a href=&#34;https://lucidmanager.org/management/corporate-jester/&#34;&gt;coorporate jester&lt;/a&gt; and use humour to make people think.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Notes
&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Dean Jr, J.W., Brandes, P. &amp;amp; Dharwadkar, R. (1998). Organizational cynicism. &lt;em&gt;Academy of Management Review&lt;/em&gt; (23) 341–52.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-2&#34;&gt;&lt;a href=&#34;#footnote-reference-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Carlini, J. (1996). A trustworthy cynic. &lt;em&gt;Network World,&lt;/em&gt; 13(42), 70–70.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-3&#34;&gt;&lt;a href=&#34;#footnote-reference-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Naus, F., van Iterson, A. &amp;amp; Roe, R. Value incongruence, job autonomy, organisation-based self-esteem: A self-based perspective on organisational cynicism. &lt;em&gt;European Journal of Work and Organizational Psychology&lt;/em&gt;, 2007b, 16, 195–219.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-4&#34;&gt;&lt;a href=&#34;#footnote-reference-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Andersson, L.M. &amp;amp; Bateman, T.S. (1997). Cynicism in the workplace: Some causes and effects. &lt;em&gt;Journal of Organizational Behavior&lt;/em&gt; 18, 449–469.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-5&#34;&gt;&lt;a href=&#34;#footnote-reference-5&#34;&gt;5&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Kim, Tae-Yeol, Bateman, Thomas S., Gilbreath Brad and Andserson, Lynne M. (2009). Top management credibility and employee cynicism: A comprehensive model. &lt;em&gt;Human Relations&lt;/em&gt; 62(10), 1435–1458. DOI: &lt;a href=&#34;http://dx.doi.org/10.1177/0018726709340822&#34;&gt;10.1177/0018726709340822&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Bottled Water Marketing: The Importance of the Place of Origin</title>
      <link>https://lucidmanager.org/marketing/bottled-water-marketing/</link>
      <pubDate>Fri, 04 Jan 2013 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/bottled-water-marketing/</guid>
      <description>
	
&lt;p&gt;
Water is like air—a naturally occurring substance without which life is not possible. But unlike air, tap water is a commercial commodity that is only available at a price from water utilities. Bottled water marketing is one of the greatest commercial successes of the last century. &lt;a href=&#34;https://lucidmanager.org/tags/invisible-water-utility/&#34;&gt;Water utilities&lt;/a&gt; in many countries sell water that is perfectly drinkable, however, bottled water companies convinced the public that their &lt;a href=&#34;https://lucidmanager.org/marketing/value-of-water/&#34;&gt;value proposition&lt;/a&gt; is better than tap water.&lt;/p&gt;
&lt;p&gt;
In an early episode of the Australian comedy show &lt;em&gt;Gruen Transfer&lt;/em&gt;, panellists discussed why people are willing to pay so much more for bottled water than for tap water. Even though tap water provides the same benefits as bottled water, the price difference is gigantic. Marketing executive Russel Howcroft argued that this difference in price exists because water utilities are &amp;#34;lazy marketers&amp;#34;.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/Cg9YH4bm2Sk?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
The Gruen Transfer (2009).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Water Utilities generally have a weak &lt;a href=&#34;https://lucidmanager.org/marketing/water-utility-branding/&#34;&gt;brand&lt;/a&gt; and judging by the opinions published on &lt;a href=&#34;https://lucidmanager.org/data-science/tap-water-sentiment-analysis/&#34;&gt;Twitter&lt;/a&gt;, people hold a negative sentiment towards tap water. This article discusses a core ingredient of bottled water marketing to explain the high willingness to pay.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Origin as Bottled Water Marketing Strategy
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;One of the strategies often used in bottled water marketing is by emphasising the natural origins of their product. While bottled water advertising often shows beautiful mountains and pristine springs, water utilities prefer to advertise the technology they use to treat water. Whether these origin stories are true is doubtful. A Chicago business has &lt;a href=&#34;https://www.forbes.com/sites/nadiaarumugam/2012/10/19/nestle-sued-again-for-falsely-representing-bottled-tap-water-as-naturally-spring-sourced/#426b09161109&#34;&gt;sued Nestle&lt;/a&gt; for falsely promoting the origin of bottled water. Researchers have repeatedly published findings that tap water is inherently safer than bottled water. But yet, the sales of bottled water keep increasing.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/evian.jpg&#34; alt=&#34;Evian advertising&#34; title=&#34;Evian advertising&#34;/&gt;
&lt;figcaption&gt;
Bottled water companies focus on increasing affective involvement and the pristine origin or the product.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Nestlé is in trouble because its “spring water” source is municipal tap water. Nestlé&amp;#39;s advertising campaign claims that &lt;a href=&#34;http://www.icemountainwater.com/&#34;&gt;Ice Mountain&lt;/a&gt; is spring water, while it is distinctly referred to as “drinking water”, which is defined as “municipal water and well water…” in their documents. Nestle simply processes the tap water and branded with images of pristine glacial lakes and mountains.&lt;/p&gt;
&lt;p&gt;
This strategy is standard for bottled water companies. Bottled water is identical to tap water, but at one thousand times the price. Bottled water companies increase the value proposition of their offering by emphasising how their product is different to tap water. A common strategy used by bottled water companies is to highlight the origin of the water and link it to increased benefits, such as health. Just look at &lt;a href=&#34;http://www.fijiwater.com/&#34;&gt;Fiji Water&lt;/a&gt;, &lt;a href=&#34;http://www.evian.com/&#34;&gt;Evian&lt;/a&gt; and any other bottled water brand to see how they connect their water to a pristine natural environment.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/fiji-water.jpg&#34; alt=&#34;/images/water-marketing/fiji-water.jpg&#34; title=&#34;/images/water-marketing/fiji-water.jpg&#34; /&gt;&lt;figcaption&gt;
Fiji water does not suffer from marketing myopia.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Creating emotional connections
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;This strategy is very similar to the way toilet paper is sold. Advertising for &lt;a href=&#34;https://lucidmanager.org/marketing/marketing-toilet-paper/&#34;&gt;toilet paper&lt;/a&gt; creates an emotional connection with the product by emphasising a perfect lifestyle. Bottled water establishes this emotional connection by highlighting the health benefits of water through a connection with pristine natural surroundings.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Water Utility Marketing
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In developed countries, tap water is provided through reticulated systems. Pipes in your street deliver water directly to your house, and you pay the price, depending on the amount of water used. Even though tap water pricing is a controversial topic, it is very cheap. With prices of less than one cent per litre, filling a bottle of water costs practically nothing. But, not all water is the same. Purveyors of bottled water charge hundreds of times the price people pay for tap water, even though the core product is the same.&lt;/p&gt;
&lt;p&gt;
Many water utilities don&amp;#39;t implement origin strategies very well. Municipal water utilities are often focusing on treatment processes instead of the natural origin of their tap water. &lt;a href=&#34;https://lucidmanager.org/marketing/marketing-for-engineers/&#34;&gt;Utility engineers&lt;/a&gt; are proud of their achievement and love to tell their community about the technology needed to deliver drinkable water to each house. &lt;/p&gt;
&lt;p&gt;
This strategy is set for failure because it emphasises the production process without any emotional attachment. Problems with the &lt;a href=&#34;https://lucidmanager.org/marketing/recycled-water-yuck-factor/&#34;&gt;acceptance of recycled sewage as drinking water&lt;/a&gt; forcefully illustrate this point.&lt;/p&gt;
&lt;p&gt;
Water utilities could become less lazy by showing customers the natural
origins of their water. In the end, all water comes from nature and tap
water is as good, if not better, than bottled water.&lt;/p&gt;
&lt;p&gt;
If you like to learn more about &lt;a href=&#34;https://lucidmanager.org/tags/invisible-water-utility/&#34;&gt;water utility marketing&lt;/a&gt;, then please consider reading &lt;em&gt;Customer Experience
Management for Water Utilities&lt;/em&gt; by Peter Prevos.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Value of Value-Based Management</title>
      <link>https://lucidmanager.org/management/value-based-management/</link>
      <pubDate>Thu, 27 Dec 2012 12:30:18 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/value-based-management/</guid>
      <description>
	
&lt;p&gt;
Many organisations espouse to implement value-based management. Scholars have proposed many &lt;a href=&#34;http://www.valuebasedmanagement.net/faq_what_is_value_based_management.html&#34;&gt;definitions&lt;/a&gt; of what value-based management is, but most are not very illuminating. The consensus is that value-based management is a tool to achieve organisational consistency, or from a more cynical perspective, values are a device to control behaviour.&lt;/p&gt;
&lt;p&gt;
Philosophers refer to words such as value an ‘essentially contested concept&amp;#39;, which means that there is no agreement on the definition of value, which has espoused a complex branch of philosophy called &lt;a href=&#34;http://en.wikipedia.org/wiki/Axiology&#34;&gt;axiology&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
In practice, value-based management leads to a list of &lt;a href=&#34;http://grammar.yourdictionary.com/parts-of-speech/nouns/Abstract-Nouns.html&#34;&gt;abstract nouns&lt;/a&gt; that the organisation advocates. But, which of the many hundreds of positively interpreted abstract nouns in the English language do you choose?&lt;/p&gt;
&lt;p&gt;
Which value is critical to your organisation? Do you prefer creativity over punctuality? Or should we have pride in our work or is it dedication we are after? Any word that has positive connotations and ends in -tion, -ism, -ity, -ment, -acy and so on will do. Defining a list of value, which usually is no longer than four, is restrictive and leads to the implicit exclusion of other positive values.&lt;/p&gt;
&lt;p&gt;
Value-based management is primarily a crude implementation of &lt;a href=&#34;http://en.wikipedia.org/wiki/Virtue_ethics&#34;&gt;virtue-based ethics&lt;/a&gt;. This approach leads to tensions because most organisations don&amp;#39;t work according to virtues but follow a &lt;em&gt;consequentialist&lt;/em&gt; approach; valuing those behaviours that lead to positive outcomes. Consequentialism can be problematic because not all activities that lead to the desired results are necessarily ethical. I have argued in an &lt;a href=&#34;https://lucidmanager.org/management/environmental-ethics-for-managers-deontic-constraints/&#34;&gt;earlier paper&lt;/a&gt; that deontic constraints maintain the goal-oriented nature of business in an ethical environment.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Value-based management is of little value
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In value-based management, it is assumed that following an arbitrary list of abstract nouns will lead to good business outcomes. These lists of abstract nouns are a cheat-sheet for employees on how to behave and a way for management or colleagues to assess the behaviour of others. &lt;/p&gt;
&lt;p&gt;
The values chosen from the multitude of available abstract nouns are usually decided democratically, without systematic examination of all available options. I prefer to stick to the list defined by &lt;a href=&#34;http://en.wikipedia.org/wiki/Aristotelian_ethics&#34;&gt;Aristotle&lt;/a&gt;, more than 2000 years ago: wisdom; prudence; justice; fortitude; courage; liberality; magnificence; kindness and temperance.&lt;/p&gt;
&lt;p&gt;
Most businesses are not honest in their chosen values, &lt;a href=&#34;https://lucidmanager.org/data-science/analyse-enron-corpus/&#34;&gt;Enron being an excellent case in point&lt;/a&gt;. The never list greed any of the other deadly sins as their real core values. And those so-called deadly sins are not always wrong. Peter Nowak argued convincingly that the seven deadly sins propelled humanity more for good than bad.&lt;/p&gt;
&lt;p&gt;
Value-based management is of little value as it ignores the practical outcomes of behaviours. It is also flawed because it arbitrarily highlights some values of others. Surely to be ethical, we should behave in accordance with positive values and not just those printed on our coffee mugs.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Evolution of Marketing Toilet Paper</title>
      <link>https://lucidmanager.org/marketing/marketing-toilet-paper/</link>
      <pubDate>Tue, 11 Dec 2012 10:44:13 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/marketing-toilet-paper/</guid>
      <description>
	
&lt;p&gt;
Toilet paper is an essential product and a symbol of a comfortable life. This statement might seem obvious, but the current status of toilet paper is quite recent. Humanity reached dizzying heights of cultural achievement before we were bestowed with the luxury of soft tissue to clean our bottoms. In the late 19th-century, toilet paper was marketed as a luxury product. The soft tissue quickly became embedded in the cultural landscape of the Western world through effective marketing.&lt;/p&gt;
&lt;p&gt;
The amount of options for a product that is merely used to keep our behinds clean is bewildering. At the supermarket, we grab our favourite brand without any giving it much thought. How do we decide what toilet paper to use? Single, double or triple ply, scented, unscented, unbleached, the choice is yours. This article briefly reviews how marketing toilet paper and how advertising helps us to select your daily need for tissue.&lt;/p&gt;
&lt;p&gt;
My interest in toilet paper is closely related to my work as a &lt;a href=&#34;https://lucidmanager.org/marketing/engineering-marketing-interface/&#34;&gt;water engineer&lt;/a&gt; and marketing scholar. Water utilities transport and &lt;a href=&#34;https://lucidmanager.org/marketing/recycled-water-yuck-factor/&#34;&gt;process sewage&lt;/a&gt;, and toilet paper is one of the substances that our pipes, pumps and plants process to ensure human waste does not endanger public health or the natural environment.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Consumer Involvement and Toilet Paper Marketing
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The amount of energy we are willing to invest in a decision depends on the level of involvement we have with the product. Consumer involvement is a measure of the importance a consumer places on a product or service. Commodities such as toilet paper and tap water are &lt;a href=&#34;https://lucidmanager.org/marketing/tap-water-paradoxes/&#34;&gt;low involvement products&lt;/a&gt; because they require little thought in their purchase.&lt;/p&gt;
&lt;p&gt;
Low involvement products are hard to sell because, by definition, consumers don&amp;#39;t pay much attention to them. This low involvement is why marketers developed techniques to increase the level of involvement and in effect create a market where one previously did not exist. This practice &lt;a href=&#34;http://www.slate.com/articles/news_and_politics/explainer/2011/09/what_do_bears_have_to_do_with_toilet_paper.html&#34;&gt;started in the 1890s&lt;/a&gt; when the &lt;em&gt;Scott Paper Company&lt;/em&gt; became the first to offer toilet paper on a roll and advertise it with a range of images positioning it as a luxury product.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Evolution of Toilet Paper Advertising
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Toilet paper marketing has evolved over the years. The 1980s advertisement below emphasises the material properties of the toilet paper. The ad shows images of the factory and talks about the production process to convince the consumer that this is the best possible paper on the market. This communication tries to increase the involvement consumers have with toilet paper by emphasising the features of the product.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/1ypWFKvWsC8?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Advertising toilet paper in the 1980s.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
A recent advertisement for the same product uses a different strategy. This ad is not trying to communicate that dogs should use toilet paper. This advertising and similar toilet paper marketing communications appeal to an ideal lifestyle to sell products.&lt;/p&gt;
&lt;p&gt;
The ad below barely mentions the physical benefits of the Kleenex product, but it shows an enviable home setting. This purpose of this piece of communication is to associate the Kleenex brand with the perfect life depicted in the images. Who would not want to live in a house with shiny polished floorboard and a Labrador? All you have to do is use Kleenex and you are on your way to be part of this fashionable group of people.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/mg6qPVA3_HY?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Recent toilet paper advertisement.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Marketing Toilet Paper and the Ideal Self
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The products we purchase are an extension of our self; a means to construct an identity. Toilet paper manufacturers have used this psychological construct to capture the market. Supermarket aisles bombarded us with a plethora of types of toilet paper to choose from. The bewildering array of choices ranges from one, two or even three-ply, scented, non-scented, hypo-allergenic, recycled, non-bleached, rain forest certified and so on, and so on. There is a type of toilet paper for every segment of the market. Because we are subjected to this wide range of choices, we are forced to make one. The basic principle of marketing is to increase the likelihood that a consumer will choose your product.&lt;/p&gt;
&lt;p&gt;
The primary reason toilet paper manufacturers spend so much money on developing new types of toilet paper and advertising their product is that they want us to care about toilet paper. Not only by developing a product variant for every imaginable preference, but also by adding emotion to an otherwise dull product. Toilet paper advertising features cute puppy dogs, babies and other images that trigger emotions. When consumers are involved, they are hesitant to choose lower price alternatives and suppliers of toilet paper use this by creating a high level of involvement and charging higher prices than they otherwise could.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Manufacturing Demand
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In this respect, marketing toilet paper is very similar to marketing &lt;a href=&#34;https://lucidmanager.org/marketing/bottled-water-marketing/&#34;&gt;bottled water&lt;/a&gt;. The only way to convince consumers to purchase bottled water instead of using the 1000 times cheaper tap water is by manufacturing involvement with the product. Just like toilet paper, bottled water marketing creates an emotional connection with the customers with lifestyle imagery.&lt;/p&gt;
&lt;p&gt;
The high willingness to pay for toilet paper is no better illustrated than by what I observed during a recent visit to a supermarket in Kangaroo Flat in Australia. They sell rolls of specially printed Christmas toilet paper for $4.49 each, almost ten times as much as ordinary toilet paper. Cleaning your bottom with jolly messages and images makes life just that much more worth living. Christmas is a time when people are prepared to spend money on silly items, and a roll of special toilet paper can provide a lot of value because it becomes an instant conversation starter, as evidenced by this article.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Buddhist Management: Organisations Do Not Exist</title>
      <link>https://lucidmanager.org/management/buddhist-management/</link>
      <pubDate>Sat, 08 Dec 2012 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/buddhist-management/</guid>
      <description>
	
&lt;p&gt;
Yesterday, &lt;a href=&#34;https://www.guidetogreatness.com/&#34;&gt;Cyndi Laurin&lt;/a&gt; presented at the 2012 &lt;em&gt;World Business Capability Conference&lt;/em&gt; in Auckland about &lt;em&gt;The Four Pillars of Organizational Greatness&lt;/em&gt;. Cyndi discussed one analogy that stuck in my mind as it took me back to my days as a &lt;a href=&#34;https://horizonofreason.com/&#34;&gt;philosophy student&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
Cyndi asked which part of a car is the most essential. The audience mentioned several options, and then it dawned on me that this analogy is much like a famous line of reasoning in Buddhist philosophy about the self, which I will use to show that there is no such thing as an organisation and that no one part of an organisation is essential or more important than another.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/humanities/cyndi-laurin.jpg&#34; alt=&#34;Slide at the World Capability Congress in 2012&#34; title=&#34;Slide at the World Capability Congress in 2012&#34;/&gt;
&lt;figcaption&gt;
One of Cyndi&amp;#39;s slides at the World Capability Congress in 2012.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The idea of the firm in Buddhist management
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Buddhist management view of the firm would be that there is no such entity, illustrated by a debate between King Milinda and the Buddhist monk Nagasena.&lt;/p&gt;
&lt;p&gt;
Following the analogy used by the monk, we can compare a firm with a chariot, or in more modern terms a car. None of the individual parts of the car (the wheels, the engine, the radio and so on), &lt;em&gt;are&lt;/em&gt; the car. Nor can you say that the combination of the parts is the car. We can not discover a firm at all, only the word that denotes the idea of the business. &lt;/p&gt;
&lt;p&gt;
A business consists of its parts, just like a car does. None of the components of the firm, however, &lt;em&gt;are&lt;/em&gt; the firm. No part is less important than the other—although followers of the Lean philosophy will disagree on this one.&lt;/p&gt;
&lt;p&gt;
The Buddhist management argument extends to management in that a firm is not about its constituent parts, but a firm is a cycle of cause and effect, or in Buddhist terms, &lt;a href=&#34;https://horizonofreason.com/culture/karma-dharma-moksa/&#34;&gt;Karma&lt;/a&gt;. A firm is not about its CEO, the share price, employees, customers or fancy headquarters. A company, just like a person, is defined by the actions it takes and their results.&lt;/p&gt;
&lt;p&gt;
Following the Buddhist view to its conclusion, there is only one pillar of organisational greatness: the actions taken by the organisation and the impact these actions have on the beneficiaries.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/yJjvUmE7Ibo?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Questions of King Milinda.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Are SMART objectives smart? Introducing DUMB objectives</title>
      <link>https://lucidmanager.org/management/dumb-objectives/</link>
      <pubDate>Tue, 04 Dec 2012 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/dumb-objectives/</guid>
      <description>
	
&lt;p&gt;
SMART objectives are a seemingly immutable law in management, formulated initially by George Doran in 1981.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; We are told in management seminars that objectives should be, in the words of Doran, Specific, Measurable, Assignable, Realistic and Time-related. &lt;/p&gt;
&lt;p&gt;
Many varieties have spawned from the minds of managers across geography and time, each focusing on slightly different aspects of the meme. There is no science behind this, as is the case with most &lt;a href=&#34;https://lucidmanager.org/management/management-tools/&#34;&gt;popular management tools&lt;/a&gt;. The original meme has evolved through successive mutations. &lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
DUMB Objectives
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;blockquote&gt;
&lt;p&gt;“What you measure is what you get…”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The term Specific can also be written as: ‘stretching&amp;#39; or ‘simple&amp;#39;; measurable has mutated into ‘meaningful&amp;#39;, ‘motivational&amp;#39; and ‘manageable&amp;#39;, Assignable is in most cases turned into ‘achievable&amp;#39;, which is the same as being realistic. Realistic in turn has morphed into ‘relevant&amp;#39; or ‘resource-based&amp;#39; and lastly ‘time-related&amp;#39; has stood the test of time and has not changed much in the various mutations of the original definition. Some have even extended the mnemonic and defined SMARTER objectives.&lt;/p&gt;
&lt;p&gt;
Many managers seem to struggle with defining SMART objectives, evidenced by the multitude of websites and magazine articles devoted to this topic. The meme—I dare not call it a theory as there is no real research into the effectiveness of this popular business tool—is driven by the idea that we can only manage what we can measure. This approach is driven by the often cited words of former General Electric CEO Jack Welch: “What you measure is what you get…”.&lt;/p&gt;
&lt;p&gt;
I propose that organisations start using DUMB objectives:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Devious&lt;/li&gt;
&lt;li&gt;Unfair&lt;/li&gt;
&lt;li&gt;Manipulative&lt;/li&gt;
&lt;li&gt;Bizarre&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Evan Carmichael has defined &lt;a href=&#34;https://www.michaeldpollock.com/dumb-goals-smart-goals/&#34;&gt;DUMB Goals&lt;/a&gt; in a more useful and less satirical way.&lt;/p&gt;
&lt;p&gt;
Any list of adjectives that can remotely be related to management will do. Just Google “adjectives starting with …” and create your acronym.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Are SMART Objectives smart?
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;blockquote&gt;
&lt;p&gt;“Too often we measure everything and understand nothing”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Not everything activity in an organisation is measurable and using SMART targets often obfuscates the fact that business is about human interaction and can not always be placed into a quantitative straight-jacket.&lt;/p&gt;
&lt;p&gt;
How can you specify a SMART target for having empathy for customers? How do you define a measurable objective for having a genuine smile?&lt;/p&gt;
&lt;p&gt;
There is an inherent incompleteness in relying on quantitative measures when managing an organisation that deals with people and people are the very cornerstone of every organisation. It is undeniable that measurement is essential in business. &lt;/p&gt;
&lt;p&gt;
Although quantitative performance measurement is a &lt;em&gt;necessary condition,&lt;/em&gt; it is not a &lt;em&gt;sufficient condition&lt;/em&gt; for holistic performance measurement. To understand their business, managers must take the responsibility of venturing beyond the figures and dashboard displays. Perhaps DUMB targets can help to break the mould by deviating from the norm as a pathway to open innovation.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Doran, G. T. (1981). There&amp;#39;s a S.M.A.R.T. way to write managements&amp;#39; goals and objectives. &lt;em&gt;Management Review&lt;/em&gt;, 70(11), 35–36.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Marketing Myopia in Tap Water Services</title>
      <link>https://lucidmanager.org/marketing/marketing-myopia/</link>
      <pubDate>Wed, 21 Nov 2012 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/marketing-myopia/</guid>
      <description>
	
&lt;p&gt;
A few weeks ago I ran a workshop for a group of senior managers of a tap water supplier. The workshop consisted of a series of rhetorical questions designed to spawn discussion about the meaning of customer service in tap water. When asking the question: “What service do you provide?” the answers were mainly based on the physical aspects: physically providing water to customers. The water managers suffered from marketing myopia. A tap water company is, paradoxically, &lt;a href=&#34;https://lucidmanager.org/marketing/engineering-marketing-interface/&#34;&gt;not about selling tap water&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Marketing myopia
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Managers of water utilities who believe that they merely sell water suffer from so-called ‘marketing myopia&amp;#39;, a term coined in 1960 by &lt;a href=&#34;http://en.wikipedia.org/wiki/Theodore_Levitt&#34;&gt;Theodore Levitt&lt;/a&gt;. This is a situation where an organisation focuses on selling products or services instead of focusing on satisfying customer needs.&lt;/p&gt;
&lt;p&gt;
There is a lot of confusion about the difference between needs and wants. In marketing, the common sense definition—needs are obligatory and wants are discriminatory—&lt;a href=&#34;https://lucidmanager.org/marketing/value-of-water/&#34;&gt;does not apply&lt;/a&gt;. Needs are a state of felt deprivation which is either physical, social or psychological.&lt;/p&gt;
&lt;p&gt;
Looking at water as a service, we need some water to physically survive and for hygiene. Al significant amount of the water we use for hygiene is, however, driven by sociological needs because of western values towards cleanliness. People also &lt;em&gt;need&lt;/em&gt; water for their gardens because it gives them a sense of accomplishment. People &lt;em&gt;need&lt;/em&gt; water for their swimming pool, because it provides them an outlet for social belonging. Nobody buys water just for the pleasure of owning it, water has a purpose.&lt;/p&gt;
&lt;p&gt;
One of the main rules in consumer behaviour is that we do not buy products for what they do, but for what they mean.  So as marketers we do not judge the consumer&amp;#39;s needs or wants. Consumers need water for social and psychological reasons, as much as they need it for physiological reasons.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Avoiding marketing myopia
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Good marketing is about satisfying the needs of the customers, which means you need to &lt;a href=&#34;https://lucidmanager.org/marketing/sociological-imagination-in-marketing/&#34;&gt;understand them&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
In the context of water it is important to understand what your customers do with the water. Looking at websites of water utilities shows a large focus on the technology to deliver the product. There seems to be a need to tell consumers how much effort is required to give them their daily tap water instead of showing the benefits of using the water. &lt;/p&gt;
&lt;p&gt;
Some marketer have even claimed in this context that water utilities are lazy marketers.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/Cg9YH4bm2Sk?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Gruen Transfer (2009).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/marketing/bottled-water-marketing/&#34;&gt;Bottled water companies&lt;/a&gt; have a different view on this issue. Their communication material never shows the production process, they show the origin of the water or the benefits it provides. This ad from Fiji water emphasises the purity of the water by using the word ‘untouched&amp;#39;. Bottled water companies connect their product not with technology, but with nature and beautiful healthy people. &lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/fiji-water.jpg&#34; alt=&#34;Fiji water advertising.&#34; title=&#34;Fiji water advertising.&#34;/&gt;
&lt;figcaption&gt;
Bottled water companies focus on the experience and image, not on the product.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
We need a paradigm shift in the way tap water is marketed by utilities. Not because &lt;a href=&#34;https://lucidmanager.org/marketing/water-privatisation/&#34;&gt;customers might defect to the competition&lt;/a&gt;, but to create goodwill. Many water companies try to do this by rationally explaining how hard it is to
create drinking water. Well, I am sorry to say that your customers don&amp;#39;t care about water as much as you do.&lt;/p&gt;
&lt;p&gt;
A much more effective way is to tap into the emotions of your customers and link your product to the benefits it provides them, or the pristine origins of the water. A water utility is not about selling water, it is about promoting health, providing water to have fun, grow your own vegetables or relax in a bubble bath. To illustrate this example, I have create an advertisement for a water utility that uses the same techniques as bottled water companies.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/great-ideas.jpg&#34; alt=&#34;Water utility advertisment&#34; title=&#34;Water utility advertisment&#34;/&gt;
&lt;figcaption&gt;
Water utilities don&amp;#39;t sell water, they sell innovation and great ideas
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Water Utility Marketing
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If you like to learn more about water utility marketing, then please consider reading &lt;em&gt;Customer Experience Management for Water Utilities&lt;/em&gt; by Peter Prevos.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Functional Silos to Deliver Business Objectives</title>
      <link>https://lucidmanager.org/management/functional-silos/</link>
      <pubDate>Sun, 18 Nov 2012 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/functional-silos/</guid>
      <description>
	
&lt;p&gt;
Functional silos are among the evilest things that can happen to a manager. Well, that is what you are lead to believe when attending the average management workshop.&lt;/p&gt;
&lt;p&gt;
One of the first things people mention when asked what is wrong with their work is having a “silo mentality”. Organisational silos are evil, and everybody who tries to build one runs the risk of becoming a pariah. I think silos are inevitable and valuable—I designed some early in my career as shown in the picture above.&lt;/p&gt;
&lt;p&gt;
A silo mentality is so prevalent that a small vocabulary has built up around this phenomenon: ‘information silo&amp;#39;, ‘silo thinking&amp;#39;, ‘the silo effect&amp;#39;, ‘functional silo&amp;#39; and so on. The language around removing silos is quite physical and evocative: silos need to be ‘demolished&amp;#39;, ‘blown up&amp;#39; or ‘torn down&amp;#39;. Surely, any manager using this type of language is serious about his job!&lt;/p&gt;
&lt;p&gt;
This article proposes a more &lt;a href=&#34;https://lucidmanager.org/management/socratic-management/&#34;&gt;philosophical approach&lt;/a&gt; and gently deconstructs, not demolish or blow up, the concept of silo mentality to show that they are not as evil as many managers
believe.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Embrace functional silos mentality to deliver value
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;There is no proper definition of what a silo mentality is. A recent paper goes to the extreme and suggests that people who display a silo mentality are mentally ill.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Psychodynamically, silos represent the phallic characteristics of male dominance, submission and persecution. They are characterised by intra- and intergroup anxiety followed by the infantile and regressive defensive structures&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
On a positive side, functional silos are vertically aligned teams with experts in their respective fields. Silos shape expert knowledge communities that can reach consensus, make decisions and act efficiently and effectively. By embracing and nurturing functional silos, an agency&amp;#39;s expertise can flourish.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-2&#34; href=&#34;#footnote-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Pointing at silos to identify why an organisation is not optimally functioning is a way to blame somebody else for your problems. Instead of wielding the silo, managers should practice some introspection and think about how they can improve communication with other experts in their organisation. Don&amp;#39;t blame somebody else for not wanting to cooperate with you, think of ways you can motivate them instead of using strong language and start demolishing, tearing down and blasting their silos.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Cilliers, F., &amp;amp; Greyvenstein, H. (2012). &lt;a href=&#34;http://www.sajip.co.za/index.php/sajip/article/view/993&#34;&gt;The impact of silo mentality on team identity&lt;/a&gt;: An organisational case study. &lt;em&gt;SA Journal of Industrial Psychology&lt;/em&gt;, 38(2), 1–9.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-2&#34;&gt;&lt;a href=&#34;#footnote-reference-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Paulson, J. (2010). &lt;a href=&#34;https://web.archive.org/web/20150515173103/http://www.dmnews.com/agency/embrace-silos-to-deliver-value/article/179026/&#34;&gt;Embrace silos to deliver value&lt;/a&gt;. &lt;em&gt;DM News&lt;/em&gt;, 32(17), 32–32.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Clear Your head — The Key to Getting Things Done</title>
      <link>https://lucidmanager.org/productivity/clear-your-head/</link>
      <pubDate>Wed, 25 Jan 2012 00:00:00 +0000</pubDate>
      <author>Arjan Zuidhof</author>
      <guid>https://lucidmanager.org/productivity/clear-your-head/</guid>
      <description>
	
&lt;p&gt;
Do you feel overwhelmed with a head full of thoughts without time to think about useful things? It is time to clear your head.&lt;/p&gt;
&lt;p&gt;
Preparation:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Have pencil and paper ready.&lt;/li&gt;
&lt;li&gt;Make sure you&amp;#39;re in a quiet place without danger to be disturbed before reading on.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is a simple yet powerful way to get all those plans and ideas that are buzzing around in your brain all day long under control. These thoughts are constantly distracting you, preventing you from making short- and long-term plans.&lt;/p&gt;
&lt;p&gt;
The truth is: they can&amp;#39;t help it, it&amp;#39;s you that haven&amp;#39;t decided anything about them that will make them keep nagging you. What you need is a reliable external system to get them out of your head.&lt;/p&gt;
&lt;p&gt;
One of these systems is David Allen&amp;#39;s &lt;a href=&#34;https://en.wikipedia.org/wiki/Getting_Things_Done&#34;&gt;Getting Things Done&lt;/a&gt; (GTD) system. But it takes at least a month to read the book and start making this method our own. We don&amp;#39;t have that long right now.&lt;/p&gt;
&lt;p&gt;
There a huge issues with all those loose ends circling both in your head and heading your direction from the outside world. You will be reminded of the stupidest things at the least expected moment. Even worse: don&amp;#39;t do anything about them, and they will finally just disappear. Too bad, because while most ideas have no future value, some of them are real gems. One of them might even change the world. &lt;/p&gt;
&lt;p&gt;
So make sure you do something with those gems! How? Read on!&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Clear Your head: Start Writing
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Grab that pen and paper that have so patiently been waiting next to you (or even better, use &lt;a href=&#34;https://lucidmanager.org/productivity/getting-things-done-with-emacs/&#34;&gt;Emacs Org Mode&lt;/a&gt;). During the next ten minutes, you will start to write down everything that&amp;#39;s in your head. Try not to &lt;a href=&#34;https://lucidmanager.org/management/myth-of-multitasking/&#34;&gt;multitask&lt;/a&gt; but fully focus your attention non the list.&lt;/p&gt;
&lt;p&gt;
This exercise will range from small actions that need immediate attention up to big future projects whose impact you cannot yet even fathom. It doesn&amp;#39;t matter what it is, once it&amp;#39;s written down it will be out of your head. Things you might encounter:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Cleaning up the backyard&lt;/li&gt;
&lt;li&gt;Find a good school for my kid&lt;/li&gt;
&lt;li&gt;Improve my job skills&lt;/li&gt;
&lt;li&gt;Learn how to use &lt;a href=&#34;https://lucidmanager.org/productivity/publishing-with-org-mode-export/&#34;&gt;Emacs instead of Word for writing ebooks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Write an ebook about … (fill in your speciality)&lt;/li&gt;
&lt;li&gt;Update your daily administration&lt;/li&gt;
&lt;li&gt;Empty your e-mail inbox&lt;/li&gt;
&lt;li&gt;Prepare presentation for quarterly meeting next week&lt;/li&gt;
&lt;li&gt;Get XYZ project back on track with Isaac and Charlie&lt;/li&gt;
&lt;li&gt;And so on, and so on.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Don&amp;#39;t spend any time thinking about those weird things you&amp;#39;re jotting down. What you&amp;#39;re going to do with them later is irrelevant now. By the way, did you notice that most things on the list above, apart from items 6 and 7, are bigger things than just one action? In GTD-speak they&amp;#39;re called projects, all “desired outcomes that take more than one action to complete” or goals. Goals are good, but can not be acted on immediately. They need to be made more specific and normally follow the route from defining projects first and actions later.&lt;/p&gt;
&lt;p&gt;
Now start writing. Take your time and keep writing, until your head is empty. If ten minutes of frantic writing is not enough, hold on. Later you&amp;#39;ll thank yourself! OK, there we go, I&amp;#39;m waiting for you …&lt;/p&gt;
&lt;p&gt;
Ready? When everything went according to plan, you now have an impressive list in front of you. Full of actionable items, projects and the more fuzzy goals. With less than 30 points you either have an extremely laid back life or cheated. In the latter case: maybe write a little more? Until the number approaches 50 or even 100 you&amp;#39;re probably not done yet. This only works if your head is clear of every loose end you will know when you&amp;#39;re done.&lt;/p&gt;
&lt;p&gt;
What you have achieved now is that everything is in a trusted system outside your head. Now it comes down to the most important thing: &lt;em&gt;doing&lt;/em&gt; something with this information. First look at things that can be done in one step: your actions. These go on an action list, to be done the moment you are ready for them. The rest of your items are either projects or goals. Put them on two separate lists, and keep them current. In the future, these lists make it easier for you to focus on what&amp;#39;s requiring your attention now (projects) and to check whether your actions are in line with where you&amp;#39;re heading in life and work.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Getting Things Done—Bonus Tip
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Overwhelmed by a huge project list? Do not shoot the messenger! ;-) this is all your stuff. Who says you are required to complete the entire list? Take a critical look at the projects that don&amp;#39;t give energy and that you can eliminate without risk of getting in trouble. Be honest, there&amp;#39;s more to be deleted than you think. You are your judge.&lt;/p&gt;
&lt;p&gt;
A waste of time, all this list making? On the contrary! You have found a way to get those loose ends out of your head. This will give a tremendous amount of energy and focus. From now on you&amp;#39;re doing only things that are important to YOU. It&amp;#39;s hard to come up with a better time saver than that, I&amp;#39;d say.&lt;/p&gt;
&lt;p&gt;
Good luck clearing your head. Did it work? Share your experiences below.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Corporate Snakes and Ladders: A Career Simulator Board Game</title>
      <link>https://lucidmanager.org/management/corporate-snakes-and-ladders-career-simulator/</link>
      <pubDate>Fri, 20 Jan 2012 15:18:05 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/corporate-snakes-and-ladders-career-simulator/</guid>
      <description>
	
&lt;p&gt;
The career path of a manager from graduation on her way to the boardroom is full of unexpected surprises. It might sometimes even feel like you are playing the ancient Indian board game of &lt;a href=&#34;https://en.wikipedia.org/wiki/Snakes_and_Ladders&#34;&gt;Snakes &amp;amp; Ladders&lt;/a&gt;, known to Americans as &lt;em&gt;Chutes &amp;amp; Ladders&lt;/em&gt;. &lt;/p&gt;
&lt;p&gt;
At the Lucid Manager, we have created the ultimate career simulation with &lt;em&gt;Corporate Snakes and Ladders&lt;/em&gt; to express the trials and tribulations of a professional career. Who will get to the boardroom first?&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Career Simulator
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The objective of the &lt;em&gt;Corporate Snakes &amp;amp; Ladders&lt;/em&gt; is to navigate by rolling a die, from your graduation (the bottom-left square) to the boardroom (top-right square). On your career journey you are either helped or hindered by ladders or corporate snakes. This game is based on the articles on the Half-Hour MBA, which help you to become a Lucid Manager.&lt;/p&gt;
&lt;p&gt;
Studying to obtain an MBA and buying a &lt;a href=&#34;https://lucidmanager.org/management/managers-new-clothes/&#34;&gt;new suit&lt;/a&gt; will certainly help you in your career. Be careful though of &lt;a href=&#34;https://lucidmanager.org/management/self-knowledge-for-managers/&#34;&gt;personality tests&lt;/a&gt;, you might give the wrong answers! As your career progresses you are expected to start &lt;a href=&#34;https://lucidmanager.org/management/myth-of-multitasking/&#34;&gt;multitasking&lt;/a&gt; but alas it does not make you more productive.&lt;/p&gt;
&lt;p&gt;
The secrets behind the corporate veil are lifted once you realise that &lt;a href=&#34;https://lucidmanager.org/management/magician-manager/&#34;&gt;perception is reality&lt;/a&gt; and that &lt;a href=&#34;https://lucidmanager.org/management/generation-y/&#34;&gt;Generation Y does not exist&lt;/a&gt;, which helps you to manage your middle management stress, for which you are grateful.&lt;/p&gt;
&lt;p&gt;
At the end of the game, you might or might not enter the board room. The main purpose of this career simulator is to help you recognise the illusions of management. A business or any other organsiation is &lt;a href=&#34;https://lucidmanager.org/management/buddhist-management/&#34;&gt;merely a human construct&lt;/a&gt; that has no objective reality.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Corporate Snakes and Ladders
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Click on the image below to print the game and play our Corporate Snakes &amp;amp; Ladders career simulator to find out whether you will make it all the way to the board room.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/management-tools/snakes-ladders.jpg&#34; alt=&#34;Corporate Snakes and Ladders&#34; title=&#34;Corporate Snakes and Ladders&#34;/&gt;
&lt;figcaption&gt;
Corporate Snakes and Ladders - a career simulator.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>All the World&#39;s a Stage — Deception in Management</title>
      <link>https://lucidmanager.org/management/deception-in-management/</link>
      <pubDate>Sun, 18 Dec 2011 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/deception-in-management/</guid>
      <description>
	
&lt;p&gt;
Deception in management is more common than we care to admit. Shakespeare already understood this more than four centuries ago:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;All the world&amp;#39;s a stage, And all the men and women merely players:
  They have their exits and their entrances; And one man in his time
  plays many parts.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Professional social network site LinkedIn has surveyed to &lt;a href=&#34;https://lucidmanager.org/management/buzzword-bingo/&#34;&gt;analyse buzzwords&lt;/a&gt; in user profiles. It seems that almost &lt;a href=&#34;http://blog.linkedin.com/2011/12/13/buzzwords-redux/&#34;&gt;everybody on LinkedIn is creative&lt;/a&gt; and effective. These are, however, vague statements as &lt;em&gt;creativity&lt;/em&gt; and &lt;em&gt;effectiveness&lt;/em&gt; are not fixed states of mind but variables on a sliding scale.&lt;/p&gt;
&lt;p&gt;
The use of meaningless buzzwords is pandemic across the globe, although there are regional differences. Professionals from countries with a high level of individualism prefer to be creative, i.e. have individual and original ideas. While in Spain, a country with a high tendency towards uncertainty avoidance, prefer to be perceived as &amp;#39;managerial&amp;#39;. Most Italians are problem solvers, which is not surprising given the perpetual state of seeming disorder.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Deception in Management
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Deception in management forms an integral part of being human. All the Deception in Management is as common as deception in the world outside the office. Our self is not an innate property of the person; it is carefully constructed. Sociologist Erving Goffman uses a theatrical metaphor, inspired by Shakespeare&amp;#39;s lines opening this post. We use scripts, buy props and create backdrops for the roles we lay in society. &lt;/p&gt;
&lt;p&gt;
Professional life is, however, a particular case as the selves we create in the workplace are mostly very different from that which we are in personal experience. Sociologist &lt;a href=&#34;https://lucidmanager.org/management/managers-new-clothes/&#34;&gt;Erving Goffman&lt;/a&gt; once wrote that deception is common among executives:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;… blinding themselves and others to the fact that they hold their jobs partly because they look like executives, not because they can work like executives.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The prevalence of deception in our daily lives and at work implies that managers can learn from magicians about how to best &lt;a href=&#34;https://lucidmanager.org/management/misdirection-in-presentations/&#34;&gt;present themselves&lt;/a&gt;. Work is, after all, merely a play.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Subservient Manager and the Illusion of Hierarchy</title>
      <link>https://lucidmanager.org/management/subservient-manager/</link>
      <pubDate>Wed, 09 Nov 2011 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/subservient-manager/</guid>
      <description>
	
&lt;p&gt;
One evening at the dining table (Based on a true story. The names have been changed to protect the innocent):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Hannah: &amp;#34;What is your job mum?&amp;#34;&lt;/p&gt;
&lt;p&gt;
  Olyvia: &amp;#34;I manage a team of dentists.&amp;#34;&lt;/p&gt;
&lt;p&gt;
  Hannah: &amp;#34;So you drill holes in people&amp;#39;s teeth?&amp;#34;&lt;/p&gt;
&lt;p&gt;
  Olyvia: &amp;#34;No, I am a manager&amp;#34;&lt;/p&gt;
&lt;p&gt;
  Hannah: &amp;#34;What is that?&amp;#34;&lt;/p&gt;
&lt;p&gt;
  Olyvia: &amp;#34;I make sure my coworkers have everything they need to do their best possible work.&amp;#34;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Management is the craft of achieving objectives vicariously, achievement through other people. The manager-employee relationship is &lt;em&gt;de facto&lt;/em&gt; hierarchical. The idea of the manager to control workers was popularised by the Lucid Manager&amp;#39;s mortal enemy, &lt;a href=&#34;https://lucidmanager.org/management/frederick-taylor-management-fundamentalism/&#34;&gt;Freddy Taylor&lt;/a&gt;. Simply put, the manager controls resources and staff follow instructions. This obvious fact is, however, a great misconception of the true nature of the manager-employee relationship.&lt;/p&gt;
&lt;p&gt;
When President Nixon met Premier Zhou Enlai in 1972, he asked his thoughts about the French revolution of 1789. Zhou Enlai reportedly considered the question for quite some time before finally answering:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;#34;It&amp;#39;s too soon to tell.&amp;#34;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Zhou Enlai was right. The &lt;a href=&#34;https://en.wikipedia.org/wiki/Age_of_Enlightenment&#34;&gt;ideals of the enlightenment&lt;/a&gt; of people as independent thinkers have after over two hundred years still not been fully realised. The struggle between the ideals of the &lt;em&gt;Ancien Régime&lt;/em&gt; and the Enlightenment can also be seen in management theory. The Taylor inspired scientific view of management versus a more human-centred view is a recurring theme in management literature. At the Lucid Manager, we believe in the ideals of the enlightenment and proclaim a humanistic view on management.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Subservient Manager
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Managers are subservient to their employees. It is the subservient manager&amp;#39;s task to select the right people, make sure they are provided with sufficient resources, have the proper knowledge and provide a safe working environment. The manager is also responsible for maintaining networks with external stakeholders. Every activity of the manager is aimed at enabling employees to get the work done effectively and efficiently. The manager makes sure that staff can provide value to customers. To refer to Chinese wisdom, Lao-Tzu wrote 2500 year ago:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The highest type of ruler is one of whose existence the people are barely aware.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Management Alchemy: The Philosopher&#39;s Stone of Management</title>
      <link>https://lucidmanager.org/management/management-alchemy/</link>
      <pubDate>Fri, 07 Oct 2011 10:00:55 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/management-alchemy/</guid>
      <description>
	
&lt;p&gt;
Managers and alchemists have a lot in common. Alchemists look for the philosopher&amp;#39;s stone to find wisdom, while managers seek their inspiration in theories. Much of business literature presents a form of management alchemy.&lt;/p&gt;
&lt;p&gt;
In management, there is a vast disconnect between the popularity of theories and their empirical evidence. Popular theories usually suffer from a lack of empirical validation, while empirically supported theories published in peer-reviewed management journals remain obscure and unknown.&lt;/p&gt;
&lt;p&gt;
In a recent paper, Mata Alvesson and Jörgen Sandberg lament the field of management studies is stronger in producing rigour than in creating exciting and influential theories.&lt;/p&gt;
&lt;p&gt;
The infamous &lt;em&gt;Boston Consulting Group Matrix&lt;/em&gt;, which is taught to business students worldwide, has been called the &amp;#34;philosopher&amp;#39;s stone of the consulting business&amp;#34;. The BCG matrix has been used as a rationalisation to fire people or undertake a merger. The matrix legitimises action through symbolic references to the mystique of strategy.&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/management/theory-and-practice-of-management/&#34;&gt;Humbug in management&lt;/a&gt; is, however, not a recent development. Management guru Chester Barnard expressed it in 1938 as such:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I believe that a good deal of conflicting bunk is taught in these fields. This argues for improvement and development, not against teaching what can be taught. In the time of Newton, or even much later, a great deal of modern physics, and much that is fundamental in it, was not known, and for this reason perhaps a good deal of bunk was then taught in the field.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Management is historically speaking a very young field of endeavour. Formal studies of how people behave in a professional environment only started when &lt;a href=&#34;https://lucidmanager.org/management/frederick-taylor-management-fundamentalism/&#34;&gt;Frederick Taylor&lt;/a&gt; analysed labourers logging pig-iron.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Management Alchemy and the philosopher&amp;#39;s stone of management
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The natural sciences are much older and have developed a rigorous method that ensures their success. However, in the early days of the physical sciences, even prominent figures such as Isaac Newton spent a considerable amount of time on alchemy and other &lt;a href=&#34;http://en.wikipedia.org/wiki/Isaac_Newton&amp;#39;s_occult_studies&#34;&gt;occult studies&lt;/a&gt; in an attempt to find the Philosopher&amp;#39;s Stone. &lt;/p&gt;
&lt;p&gt;
Whether this means that, several centuries from now, management theory is as successful as physics in controlling reality, remains to be seen. Management, strategy and marketing are inherently social sciences, and people are not billiard balls whose trajectories can be predicted and controlled.&lt;/p&gt;
&lt;p&gt;
The Philosopher&amp;#39;s Stone of management is the art of &lt;em&gt;understanding&lt;/em&gt; people. The key to &lt;a href=&#34;https://lucidmanager.org/management/self-knowledge-for-managers/&#34;&gt;understanding people&lt;/a&gt; lies not in the rigorous statistical analysis of questionnaires, but in the life experience of the manager.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Literature
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;ul&gt;
&lt;li&gt;Alvesson, M. and Sandberg, J., 2011. Generating research questions through problematization. &lt;em&gt;Academy of Management Review&lt;/em&gt;, 36, 247–271.&lt;/li&gt;
&lt;li&gt;Astley, W.G., 1985. Administrative science as socially constructed truth. &lt;em&gt;Administrative Science Quarterly&lt;/em&gt;, 30(4), pp.497–513.&lt;/li&gt;
&lt;li&gt;Chester Barnard (1938) &lt;em&gt;The Functions of the Executive&lt;/em&gt;. Harvard University Press.&lt;/li&gt;
&lt;li&gt;Owen, D., 1982. Those who can&amp;#39;t, consult. &lt;em&gt;Harper&amp;#39;s&lt;/em&gt;, 265(1590), 8–17.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Magician Manager: The Role of Deception in Business</title>
      <link>https://lucidmanager.org/management/magician-manager/</link>
      <pubDate>Mon, 26 Sep 2011 10:00:32 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/magician-manager/</guid>
      <description>
	
&lt;p&gt;
Every manager would love to have a wand and make things happen magically. Although this vision is only a dream, managers do have a lot in common with magicians. Both the manager and the magician aim to create the world different from the one we know. Both the manager and the magician construct a new reality; the magician uses the stage, and the manager uses the workplace to frame their performance. &lt;/p&gt;
&lt;p&gt;
Another similarity is that many magicians carved out a market in the corporate sector by providing entertainment at Christmas parties and similar occasions. But the similarities don&amp;#39;t stop here.&lt;/p&gt;
&lt;p&gt;
As an amateur magician, I collect academic &lt;a href=&#34;https://horizonofreason.com/magic/magic-bibliography/&#34;&gt;journal articles about conjuring&lt;/a&gt; and found two interesting papers exploring the similarities between management and magic.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Magician Manager
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;David Pollitt described how the management team of a large retailer was invited for a magic show as part of their professional development. Magicians follow rigid &lt;a href=&#34;https://lucidmanager.org/management/positive-workplace-deviance/&#34;&gt;procedures&lt;/a&gt; to create the illusion of magic, and the management team were encouraged to do the same to achieve results. Magician Richard Pinner performed a Russian Roulette inspired trick to illustrate that in customer contact there is only one chance to get it right.&lt;/p&gt;
&lt;p&gt;
Professor&amp;#39;s of management Joe Dobson and Terence Krell published a paper on how to use magic tricks to teach organisational behaviour. They use magic tricks in the classroom to show that withholding information, like a magician withholds the methods from spectators, can create a power difference. So-called forcing techniques commonly used by magicians are an illustration of the fact that our free will is more often than not bound and limited by the context in which we operate.&lt;/p&gt;
&lt;p&gt;
Although a magic wand is not a reliable management tool, these examples from the academic literature show that professionals can learn from magic as it provides valuable lessons in psychology.&lt;/p&gt;
&lt;p&gt;
Most importantly the magician&amp;#39;s ability to distort reality is a reminder that our perception is fragile and that we should always find out the facts, rather than rely on perception. The biggest difference between a manager and a magician is that a magician manages perception to create the illusion of a new reality. Managers focusing on perception, in reality, will find that they are creating an illusion.&lt;/p&gt;
&lt;p&gt;
If you like to know more about magic tricks and how they relate to the normal world, including management, read my book &lt;a href=&#34;https://horizonofreason.com/shop/perspectives-on-magic/&#34;&gt;Perspectives on Magic&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Myth of Multitasking</title>
      <link>https://lucidmanager.org/management/myth-of-multitasking/</link>
      <pubDate>Mon, 12 Sep 2011 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/myth-of-multitasking/</guid>
      <description>
	
&lt;p&gt;
A favourite &lt;a href=&#34;https://lucidmanager.org/management/buzzword-bingo/&#34;&gt;buzzword&lt;/a&gt; heard around water coolers in offices spanning the globe is multitasking. Employers see the presumed ability to do more than one thing simultaneously as the hallmark of a great employee. This short article looks at the myth of multitasking.&lt;/p&gt;
&lt;p&gt;
People imagine themselves as multi-armed Hindu goddesses or gods of efficiency, aiming to manage their time better by doing many things simultaneously.&lt;/p&gt;
&lt;p&gt;
Unfortunately, multitasking is self-deception. In the words of psychiatrist Edward Hallowell,&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; multitasking is a mythical activity in that people believe they can do two or more tasks simultaneously, just as effectively as one.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Myth of Multitasking
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Neuroscientific research supports this practical knowledge. A neural network in the frontal lobe acts as a bottleneck of information processing that severely limits our ability to multitask. Not only do tasks take longer, but the quality is also reduced.&lt;/p&gt;
&lt;p&gt;
Multitasking introduces a &lt;a href=&#34;https://www.apa.org/topics/research/multitasking&#34;&gt;switching cost&lt;/a&gt; which means that the brain has to adapt to the new task every time it switches. The switching time can be low, but can amount to as much as 40% of your productive time.&lt;/p&gt;
&lt;p&gt;
The switching cost depends on the cognitive load f the task. We are very adept at having a dep discussion while doing menial tasks like doing the dishes. But, watching a movie while also scrolling your phone will not do either task justice.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Multitasking in a Magic Show
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;What managers can learn from magicians and &lt;a href=&#34;http://dx.doi.org/10.1016/j.neuron.2006.11.009&#34;&gt;cognitive scientists&lt;/a&gt; is that we should focus on only one task at a time. Magicians are very adept at controlling our attention by running a dual narrative. &lt;/p&gt;
&lt;p&gt;
In this video, the late Dutch magic genius Tommy Wonder shows how people are easily deceived because their minds can only focus on one thing at a time.&lt;/p&gt;
&lt;figure&gt;
&lt;p alt=&#34;Two Cups Routine By Tommy Wonder&#34; title=&#34;Two Cups Routine By Tommy Wonder&#34;&gt;&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/UzFu_IuK8-k?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;
&lt;/p&gt;
&lt;figcaption&gt;
Two Cups Routine By Tommy Wonder.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;ol&gt;
&lt;li&gt;Hallowell, “CrazyBusy: Overstretched, Overbooked, and About to Snap!” (Ballantine, 2006).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Unfortunately, the feeble human mind cannot focus on more than one thing simultaneously. The myth of multitasking is no better illustrated than a magician’s ability to deceive people, wonderfully demonstrated by Tommy Wonder in the video below. Magicians use techniques based on our limitations in attending to multiple things simultaneously to create the illusion of magic.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Golden Rule of Recruitment: You get the employees you deserve</title>
      <link>https://lucidmanager.org/management/golden-rule-of-recruitment/</link>
      <pubDate>Mon, 05 Sep 2011 06:30:53 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/golden-rule-of-recruitment/</guid>
      <description>
	
&lt;p&gt;
Recruitment of new people or can be a stressful experience. Many organisations maintain extensive procedures to try to find the right person for the right job or even hire specialised &lt;a href=&#34;https://lucidmanager.org/management/consultant-shaman/&#34;&gt;consultants&lt;/a&gt; to do the job for them. Why go through these troubles if there was a golden rule of recruitment?&lt;/p&gt;
&lt;p&gt;
They ask strange questions that no reasonable person would ever dare to entertain: &amp;#34;What are your three trademarks?&amp;#34;, &amp;#34;What are your biggest mistakes?&amp;#34; or &amp;#34;What is the meaning of life&amp;#34; and &amp;#34;What is the airspeed velocity of a laden swallow?&amp;#34;. Some even resort to pseudo-scientific &lt;a href=&#34;https://lucidmanager.org/management/free-personality-test/&#34;&gt;personality testing&lt;/a&gt; to throw some insights into these strangers across the table.&lt;/p&gt;
&lt;p&gt;
The problem recruiters have is that it is a lot easier not to hire someone than to fire them later, which leads to complicated processes to reduce this risk. &lt;a href=&#34;https://lucidmanager.org/management/deception-in-recruitment/&#34;&gt;Job interviews are thus a bizarre environment&lt;/a&gt; that often bears no resemblance to a real professional situation. The fear of taking a risk with a person and a lack of self-confidence in their people skills motivates recruiters to resort to pseudo-scientific tools and hiding behind bizarre interviewing techniques.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Golden Rule of Recruitment
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Particularly in a customer service related position a person&amp;#39;s ability to &lt;a href=&#34;https://lucidmanager.org/marketing/sociological-imagination-in-marketing/&#34;&gt;understand customers&lt;/a&gt; is more important than the results of a personality test or the answer to weird questioning. Asking irrelevant questions only motivates the applicant to bend the truth.&lt;/p&gt;
&lt;p&gt;
Recruitment methods should as much as possible be normal human interaction as ultimately every company gets the
&lt;a href=&#34;https://lucidmanager.org/management/recruitment/&#34;&gt;employees they deserve&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;
No matter how ritualised the interview process, the Golden Rule of Recruitment remains: You get the employees you deserve.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>“there is a fly in my soup”: Customer Service Goes Wrong</title>
      <link>https://lucidmanager.org/marketing/fly-in-my-soup/</link>
      <pubDate>Wed, 24 Aug 2011 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/fly-in-my-soup/</guid>
      <description>
	
&lt;p&gt;
&lt;em&gt;Customers are always right&lt;/em&gt; is one of the adages often proclaimed in marketing. This well-worn phrase was coined by Harry Gordon Selfridge, Sr. (1864–1947), a retail magnate and founder of the British department store Selfridges. Lucid managers object against this presumed absolute truth because &lt;a href=&#34;https://lucidmanager.org/marketing/balanced-centricity/&#34;&gt;bowing to every whim&lt;/a&gt; of customers would make it very hard to achieve organisational goals, i.e. to provide a return to shareholders or help as many people as possible in the case of social marketing.&lt;/p&gt;
&lt;p&gt;
Some might hold that the customer is always right about their perception, but that is a far too simplistic view of this problem. This statement needs to be unpacked and analysed to find it what it means. There are three aspects to this: customers, the qualifier always and the idea of being right.&lt;/p&gt;
&lt;p&gt;
For this statement to make sense, the term &amp;#34;customers&amp;#34; should be demarcated, or in marketing jargon, segmented. Market segmentation is, however, an artificial construct used to simplify soup.&amp;#34; groups of people. &lt;a href=&#34;https://lucidmanager.org/marketing/sociological-imagination-in-marketing/&#34;&gt;Understanding&lt;/a&gt; customers does, however, go beyond quantified constructs and focuses on customers as individuals. Furthermore, demographic variables are poor predictors of behaviour as they rely on descriptive, rather than causal factors.&lt;/p&gt;
&lt;p&gt;
Customers are individuals that can only be understood within a specific context. This context implies that the statement should be &amp;#34;&lt;em&gt;the customer&lt;/em&gt; is always right&amp;#34;, narrowing it down to individuals, rather than all or some customers.&lt;/p&gt;
&lt;p&gt;
The second part of the statement, &amp;#34;always right&amp;#34;, infers a universality. Whatever the customer says, the truth is on their side. However, truth is a tricky concept, specially when combined with a universal statement. Absolute universal truth is mostly proclaimed by religions and not in marketing. The &amp;#34;always right&amp;#34; component should be understood as an ethical marker. &lt;/p&gt;
&lt;p&gt;
The term always implies that an organisation should do whatever a customer wants because they are presumed to be always right. However, an organisation serves customers, but can never become the slave of customers as it will undermine economic sustainability. This can be corrected by narrowing the statement down to: &amp;#34;The customer is sometimes right&amp;#34;. But this is not enlightening and practically tautological.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Fly in my soup
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The way out of this conundrum is to find out what a customer can be right or wrong about. The easy way out is to say that the customer is always right about their experience, but that is too much of a simplification as two planes of
reality are at work in customer service:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Fact: &amp;#34;waiter, &lt;a href=&#34;https://www.theguardian.com/notesandqueries/query/0,,-1418,00.html&#34;&gt;there is a fly in my soup&lt;/a&gt;.&amp;#34;&lt;/li&gt;
&lt;li&gt;Feeling: &amp;#34;I am angry because there is a fly in my soup.&amp;#34;&lt;/li&gt;
&lt;/ul&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/FBig5p0yBNE?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Spike Milligan: There is a fly in my soup.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Customers can indeed be wrong about facts because they are by their very nature &lt;a href=&#34;http://en.wikipedia.org/wiki/Verificationism&#34;&gt;verifiable&lt;/a&gt;. A waiter can confirm whether there is a fly in the soup or whether it is an oddly shaped crouton. Perception is not reality, and where possible, every claim customers should be verified.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The customer is always right about their state of mind
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The second type of statement is much harder to verify because it is, in the words of Bernard Williams, &lt;a href=&#34;http://en.wikipedia.org/wiki/Incorrigibility&#34;&gt;incorrigible&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
A proposition &lt;em&gt;p&lt;/em&gt; is incorrigible when it satisfies this description: &amp;#34;if I believe that p, then p&amp;#34;. These statements can neither be verified nor denied, and they assume that the customer is sincere, and they thus have to be true. Customers are logically always right about when it comes to incorrigible propositions about how they feel about the level of service. &lt;/p&gt;
&lt;p&gt;
The incorrigibility is problematic because of the implied sincerity. Some customers might exaggerate their feelings to obtain preferential treatment. Some &lt;a href=&#34;http://en.wikipedia.org/wiki/Subconscious_mind&#34;&gt;psychologists&lt;/a&gt; would argue, however, that nobody can indeed be sincere about their internal state of mind because of subconscious drives. Although customers might not always know or able to express their state of mind, incorrigible statements are absolute truths to those who utter them.&lt;/p&gt;
&lt;p&gt;
The original statement can be corrected by saying that &amp;#34;the customer is always right about their state of mind&amp;#34;. The customer is always right about how they feel about the level of service, and the marketer has to accept these statements as absolute truths.&lt;/p&gt;
&lt;p&gt;
When managing negative observations from customers, make sure you have empathy for their point of view. Embrace complaints because they are a &lt;a href=&#34;https://lucidmanager.org/marketing/complaints-are-a-gift/&#34;&gt;gift to the organisation&lt;/a&gt; from the customer.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Customer Complaints Are a Gift: Value from Customer Feedback</title>
      <link>https://lucidmanager.org/marketing/complaints-are-a-gift/</link>
      <pubDate>Sat, 13 Aug 2011 14:30:08 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/complaints-are-a-gift/</guid>
      <description>
	
&lt;p&gt;
One Monday morning, Jeff dragged himself back to work, preparing for a new week on the phone and helping customers. However, his day was rudely interrupted when his manager scolded him about a customer complaint that had come to his attention. Jeff went back to his workstation and, angry and disenchanted, screamed to himself: &amp;#34;bloody customers!&amp;#34; This article explains why complaints are a gift to the organisation to improve performance and not a mere nuisance.&lt;/p&gt;
&lt;p&gt;
Complaints are difficult to process with dealing with an angry customer. People who feel aggrieved by their service provider don&amp;#39;t hold back and provide a raw insight. The natural response of a service provider is to be defensive. Some managers dismiss complaints as subjective feedback, while others seek to blame and use them punitively.&lt;/p&gt;
&lt;p&gt;
Many organisations use complaint statistics as a performance indicator that aims for zero. However, using complaints as a performance measure is not productive because they become a negative measure of performance rather than a mechanism to improve the level of service. So the counterintuitive logic is that a service provider should maximise the number of complaints.&lt;/p&gt;
&lt;p&gt;
McDonald&amp;#39;s seemed to have grasped the concept that complaints are a gift and has created this beautiful piece of advertising to motivate people to voice their opinion.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/vzLPlCwXMes?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
McCafe &amp;#34;It&amp;#39;s good to complain&amp;#34;.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
This article is part of a series in &lt;a href=&#34;https://lucidmanager.org/marketing/marketing-for-engineers/&#34;&gt;marketing for engineers&lt;/a&gt;, based on my research and experience with analysing the customer experience in water utilities.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Are complaints subjective?
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The customer is always right about their perception of the &lt;a href=&#34;https://lucidmanager.org/marketing/value-of-water/&#34;&gt;value they receive&lt;/a&gt; and complaints provide insight into how customers perceive what you do. Unfortunately, in many organisations, complaints are a negative performance indicator. When a customer lodges a formal expression of dissatisfaction, managers run around in blind panic and blame somebody for this negative feedback. A more productive approach is to view a complaint as a measurement. &lt;/p&gt;
&lt;p&gt;
One often-heard defence against complaints is that they merely provide a subjective view of performance. For example, the customer might think that their &lt;a href=&#34;https://lucidmanager.org/marketing/water-quality-paradox/&#34;&gt;tap water is unacceptable&lt;/a&gt;, but the utility repeatedly states that it is safe to drink. In organisations that provide technical services, engineers can easily dismiss a complaint by pointing at statistics that disprove the customer&amp;#39;s view of the world.&lt;/p&gt;
&lt;p&gt;
Marketing gurus point out that the customer is always right. This statement is correct but needs a subtle change. The customer is always right about how they &lt;em&gt;feel&lt;/em&gt; about the service they receive. They might not be correct about the facts, but their feelings are accurate and verifiable. Therefore, when somebody tells you how they feel, this is not subjective data but an objective statement.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The customer is always right about their perception of the value they receive.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
How customers feel about factual aspects of a service, such as how long it takes to respond to requests, is subjective, but how they feel about this is an objectively measurable variable. Thus, customer complaints are perspectives on service delivery as much as technical measurements are. Technical measures tell a story about the physical reality, but complaints provide insight into a psychological fact. And in marketing, customer perception is reality.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
The Complaint Process
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The idea that a service provider always perfectly meets the expectations of customers is unreasonable. Nevertheless, a certain level of complaints is unavoidable and even preferable. Complaints are the background radiation of service provision. Too much is dangerous, but at most levels, they are a natural fact of life.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Complaints are like radioactivity; there is always a natural background level.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Complaints are not a product of the modern world. The video below presents a translation of the oldest surviving letter of complaint, written in ancient Sumeria 3,700 years ago. Archaeologist found the letter in the ruins of the ancient city of Ur, in modern-day Iraq. This letter shows that society has not changed as much as we think it has.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/gkoaHFMjYJg?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
World&amp;#39;s Oldest Complaint Letter (Ancient Sumeria) from 2nd Millennium BCE.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
But what causes a customer to take the effort of picking up a clay tablet and spend much time expressing their discontent. Customers have several options when they experience dissatisfaction.&lt;/p&gt;
&lt;p&gt;
They can decide not to take action. However, doing so will erode trust in the organisation and eventually lead to more significant problems in the future.&lt;/p&gt;
&lt;p&gt;
Customers can take private action by seeking an alternative service provider or by badmouthing the organisation. In commercial settings, this option will erode revenue. Negative word of mouth implies that the negative experience spreads like a virus and will be much more challenging to contain.&lt;/p&gt;
&lt;p&gt;
Lastly, grieved customers can take public action by complaining to a regulator or the service provider directly. &lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/marketing/complaint-model.png&#34; alt=&#34;/images/marketing/complaint-model.png&#34; title=&#34;/images/marketing/complaint-model.png&#34; /&gt;&lt;figcaption&gt;
Post-satisfaction behaviour model.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The likelihood that a customer complains after a negative experience is relatively low. Estimates vary that only between 1% and 5% of unhappy customers make an effort to contact their service provider. Most negative experiences lead to private or no action.&lt;/p&gt;
&lt;p&gt;
A low level of complaints can this counter-intuitively lead to problems. The best possible outcome in this simplified decision model is that a customer complains about the utility. Once a customer takes the time and effort to contact the utility, you have an opportunity to influence their perception. Any of the other outcomes will lead to adverse effects.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
The Service Recovery Paradox
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Once a customer complains to an organisation, then you have an opportunity to turn their perceptions around. The &lt;a href=&#34;https://en.wikipedia.org/wiki/Service_recovery_paradox&#34;&gt;service recovery paradox&lt;/a&gt; is the phenomenon that aggrieved customer who complains will be more satisfied than those who never complain in the first place. This mechanism only applies in cases where the organisation has a well-designed service recovery process. &lt;/p&gt;
&lt;p&gt;
This fact is an apparent paradox because it does not imply that you should purposely make customers unhappy so you can ride the service recovery wave.&lt;/p&gt;
&lt;p&gt;
Motivating customer to complain also requires an excellent complaint management process to ensure that the organisation can benefit from the service recovery paradox.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Customer complaints are a gift
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;McDonald&amp;#39;s are not the only fast-food company performing a &lt;em&gt;mea culpa&lt;/em&gt; on television. Also, pizza purveyor Domino&amp;#39;s recently admitted having changed its recipe after customer feedback. Patrick Doyle, president of Dominoes, summarised their journey succinctly: &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You can either use negative comments to get you down, or you can use them to excite and energise you.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/AH5R56jILag?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Domino&amp;#39;s Pizza Turnaround.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
To embrace complaints as an organisation, you need to lower the threshold for customers to provide their feedback. Don&amp;#39;t hide behind formal processes, lengthy complex forms and other techniques to &lt;/p&gt;
&lt;p&gt;
The moral of this story is to embrace customer complaints. If a customer complains about a &lt;a href=&#34;https://lucidmanager.org/marketing/fly-in-my-soup/&#34;&gt;fly in their soup&lt;/a&gt;, perhaps it might be a crouton, but it is the job of the service provider to manage these perceptions. A lucid manager removes emotion from the process and rationally reviews every complaint, seeking ways to make the customer feel better and improve the organisation.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Retail Theatre: The Magic of Brick and Mortar Shops</title>
      <link>https://lucidmanager.org/marketing/retail-theatre/</link>
      <pubDate>Fri, 15 Jul 2011 00:51:30 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/retail-theatre/</guid>
      <description>
	
&lt;p&gt;
Retailers around the world are scratching their heads how to seduce customers to come back into their shops. Competition from online stores have seen a decline in retail turnover. This article describes how physical shops can enhance their value proposition by realising the concept of retail theatre.&lt;/p&gt;
&lt;p&gt;
In Australia, some shopkeepers criticised their customers because they prefer to purchase their stuff online. Online retailers indeed have a price advantage over local retailers because of the lower overhead. Interestingly, in a physical shop, customers pay the price of delivering the goods by physically visiting the place. In online shopping customers pay for the delivery. The real cause of why people prefer to shop online lies, however, more profound than price alone. All retail experiences are a small piece of theatre.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
My Favourite Cigar Shop
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Since my undergraduate days, I enjoy smoking the occasional cigar. Retailing tobacco has its complexities, given the health implications of excessive smoking. My justification is that smoking cigars is good for my metal health. The marketing principles governing their sales are, however, the same. My favourite cigar shop is Wum Otten in my former hometown of Maastricht in the Netherlands.&lt;/p&gt;
&lt;p&gt;
At my first visit to his shop, the thousands of boxes and smoking paraphernalia lining the walls fascinated me. I asked Wum for my favourite brand, but he quickly persuaded me to try something different. He shuffled around the boxes and produced a single cigar for me to try. Ever since that first visit, I have faithfully bought almost all my
cigars from his shop, until I moved to Australia.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/business-magic/wum-otten.jpg&#34; alt=&#34;Wum Otten&amp;#39;s cigar shop in Maastricht&#34; title=&#34;Wum Otten&amp;#39;s cigar shop in Maastricht&#34;/&gt;
&lt;figcaption&gt;
Wum Otten&amp;#39;s cigar shop in Maastricht.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Being thousands of kilometres away from my favourite cigar store, I am faced with the boring tobacco shops in Australia. Alas, I purchase my cigars online as the places available to me do not know the product and do not provide a compelling experience. The shops are dull - only partially caused by strict anti-smoking legislation - and staff are unmotivated. Buying cigars is no longer an enjoyable experience, so I prefer the utility of online shopping.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Retail Theatre as a Metaphor and as a Reality
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The idea of providing an &lt;em&gt;experience&lt;/em&gt; is a modern development of marketing. Kim Harris, Richard Harris and Steve Baron (2001) have compared retail with a theatrical experience.&lt;/p&gt;
&lt;p&gt;
Retail theatre relies on correspondences between shopping and the stage: the backdrop and props formed by retail displays and merchandise with sales people as actors, customers as spectators and the shop floor is the stage. A salient difference between a shop and a theatre is that there is no &lt;a href=&#34;http://en.wikipedia.org/wiki/Fourth_wall&#34;&gt;fourth wall&lt;/a&gt;, no imaginary sheet of glass between the actors and the spectators and no &lt;a href=&#34;http://en.wikipedia.org/wiki/Proscenium&#34;&gt;proscenium&lt;/a&gt;. The customers are not just passive spectators but are active and integral components of the play.&lt;/p&gt;
&lt;p&gt;
Therein also lies the most significant difference between online retailing and brick-and-mortar shops. Online retailing engages the eyes and maybe the ears, but physical retailing provides a full sensory and social experience. Online stores have no smell; you can not touch the goods. There are also no people, which is negative but is often considered a positive.&lt;/p&gt;
&lt;p&gt;
Well designed physical shops with motivated staff provide a holistic experience that can only be beaten by online retailers on price and many case studies in marketing show that price is only one factor in purchase decisions. Recent research indicates that a positive mood, influenced by motivated retail staff and a vibrant environment, have a positive impact on shopping behaviour.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
All the more reason for retail managers to look at their shop as a theatre and positively influence the customer experience.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Paul M. Herr, Christine M. Page, Bruce E. Pfeiffer and Derick F. Davis (2012) Affective Influences on Evaluative Processing, &lt;em&gt;Journal of Consumer Research&lt;/em&gt; (Published online 13 June 2011).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Magic of Marketing</title>
      <link>https://lucidmanager.org/marketing/marketing-magic/</link>
      <pubDate>Mon, 20 Jun 2011 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/marketing-magic/</guid>
      <description>
	
&lt;p&gt;
What do marketing and conjuring have in common? Some might say that both fields of human endeavour use deception to reach their objectives. Marketers promise a world in which consumers can be beautiful and live the life of the rich and famous. Magicians deceive by presenting a world in which spectators are asked to believe that the laws of nature can be suspended. &lt;/p&gt;
&lt;p&gt;
Marketers and magicians have, however, more in common than the creation of impossible worlds of universal beauty and magic. There are in fact four areas where magic shows and marketing overlap. I got this insight when watching Australian magician Simon Coronel and his show Manipulations.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Magic Techniques in Marketing
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Special techniques
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Firstly, to be able to create the illusion of perfect or enchanted worlds, both marketers and conjurers need to use special techniques, hidden from consumers and spectators. Magicians spend many hours developing manual dexterity to create the illusion of magic. Marketers use special techniques to, for example, create the illusion that food looks fresh, even after ours in the spotlight of a photo studio.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Perception Psychology
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The use of perception psychology is the second correspondence. Most stage illusions are, just like advertisements, based on the fact that our mind makes inferences based on perceptual clues. We are led to believe that beautiful girls can be cut in half and restored just like we are led to believe that using the right deodorant will make you more attractive.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Attention Management
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Penultimate, both marketers and magicians, use attention management. These are psychological tools to ensure that consumers remember advertisements or that spectators only looks at the narrative aspects of the performance. In conjuring, this is mostly called misdirection, which is the technique to ensure viewers do not perceive the mechanical workings of a trick. In marketing, this is important because in a hyper-competitive world attracting attention from consumers is tough.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Entertainment
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Finally, presentation and entertainment are essential in both conjuring and marketing. Both are forms of theatre. A well-designed shop, website, supermarket and so on are similar to a stage. The most successful brands in the world understand and excel at this. The most important aspect of a magic performance or a marketing exchange is that the consumer has a positive experience.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-6&#34;&gt;
The Magic of Marketing and Deception
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Theatrical magic is based on deception, using the four principles outlined above. Using deception in marketing is considered unethical while using deception in a magic show is accepted. There exists a social contract between the magician and the audience that deception will be used to entertain them. But also in marketing, there is an implicit understanding by consumers that communication paints a positive picture and does not provide the whole truth. Just like a magician does not reveal the secrets, neither does a marketer point out the negative aspects of their offering.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Selling Magic
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The art of retail has one of the strongest links between theatre ad marketing. All retail is deceptive theatre in its core. Not only as a metaphor but as a means to sell more product. One of the most visible connections between magic and marketing are the many brand names with the word magic in it. As I aimlessly walked around a shopping centre, I came across the Magic Mop Set, a mop so good that it will clean the floors like magic.&lt;/p&gt;
&lt;p&gt;
A search in the &lt;a href=&#34;https://search.uspto.gov/search?query=magic&#34;&gt;American trademark register&lt;/a&gt; reveals more than three thousand entries that use the word magic. A company producing herbal nutritional supplements uses Jungle Magic to communicate the idea that their herbs have properties beyond the natural garden herbs. Prepaid telephone cards are marketed as It’s Magic to express their ease of use, and a series of cooking appliances sell under the name of Cook Magic which seems to suggest that cooking with these products becomes an effortless activity.&lt;/p&gt;
&lt;p&gt;
Using the word magic in the branding of goods and services taps directly into the almost universal human desire for a magical world where mundane activities can be undertaken virtually effortlessly. Marketing, just like a magic show, delivers the promise of a world where the bonds of the laws of nature have been broken.&lt;/p&gt;
&lt;p&gt;
Buying magical products taps into a sincere desire for a world where we control reality, instead of being controlled by it.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Misdirection in Presentations: Magic Shows in the Boardroom</title>
      <link>https://lucidmanager.org/management/misdirection-in-presentations/</link>
      <pubDate>Thu, 09 Jun 2011 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/misdirection-in-presentations/</guid>
      <description>
	
&lt;p&gt;
In a blog entry for &lt;em&gt;Harvard Business Review&lt;/em&gt;, Jerry Weissman argued that &lt;a href=&#34;https://hbr.org/2011/06/misdirection-is-for-magicians&#34;&gt;misdirection is for magicians, not for presenters&lt;/a&gt;. Weissman writes that misdirection has no place in business presentations because a presenter needs to direct the attention of the audience to the screen, not distract them.&lt;/p&gt;
&lt;p&gt;
While distracting your audience is indeed not a good presentation technique, managers can learn from magicians to perform better presentations. Business people that perform magic have been found to be better public speakers than other presenters.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; This article shows how managers can use misdirection for presentations.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Misdirection in the Office
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Misdirection is one of the few words of the specialist magician’s vocabulary that have made it into everyday speech.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-2&#34; href=&#34;#footnote-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Misdirection is an essential technique in sleight of hand conjuring used to ensure that the audience cannot identify the causes of the actions of the magician. While the magician hides a ball in her left hand, she focuses the attention of the audience on her right hand so that the ball remains outside the field of awareness of the spectator. Some magicians no longer use the term misdirection but prefer ‘attention management’ to indicate that that the audience is directed towards the narrative of the magic trick instead of the technique.&lt;/p&gt;
&lt;p&gt;
Techniques to distract people from the real cause of things is not only used by magicians but in all forms of the performing arts. Some scholars even argue that misdirection is an essential skill in everyday human interaction.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-3&#34; href=&#34;#footnote-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Erving Goffman described the interaction between humans as a theatrical metaphor and emphasised the importance of managing the impressions that people have of each other.&lt;/p&gt;
&lt;p&gt;
Goffman writes that we are all actors in a play of our own making; we have scripts, props and costumes to portray how we want the outside world to perceive us. We require misdirection in our daily and professional lives to construct who we are by our ideal self. One of the ways professionals communicate their corporate positions communicate is through clothing and managers are, according to Goffman:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;… blinding themselves and others to the fact that they hold their jobs partly because they look like executives, not because they can work like executives.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Misdirection is as such a normal aspect of our lives and probably more so in the office. Working life is an artificial reality where people wear uncomfortable clothes to misdirect the attention away from their true self. Goffman’s ideas might seem a pessimistic interpretation of human interaction, but deception is part of life because social reality is subjective.&lt;/p&gt;
&lt;p&gt;
The manager has become an archetype of contemporary society. The manager is the prime example of homo economicus, the rational thinking problem solver that always seeks to maximise benefit, independent of social reality. This thought is, however, only an ideal that many of us strive to and we all play a role in the great theatre of life.
Misdirection in Presentations&lt;/p&gt;
&lt;p&gt;
Business presentations are a form of theatre even more so. Brief monologues designed to convince the listener that the presenter’s ideas should be implemented. Misdirection is a valid and natural way to create the ideal self of the lucid manager and persuade people with your presentations. This post is, however, not an invitation to deceive in business presentations. Misdirection only works when it is subtle and skillfully applied.&lt;/p&gt;
&lt;p&gt;
Public speaking fills many people with fear. Jerry Seinfeld once joked that:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“… people’s number one fear is public speaking. Number two is death. This strong statement means to the average person that if you have to go to a funeral, you are better off in the casket than doing the eulogy”.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/yQ6giVKp9ec?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Seinfeld on public speaking.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
A good presenter needs to manage the attention of the audience away from the unimportant aspects of their presentation and focuses the listener on on the narrative.&lt;/p&gt;
&lt;p&gt;
In the Powerpoint era, beautifully designed slides can be used to give credence to an otherwise weak argument. The summarised and seemingly well-flowing information hides gaps in knowledge and insecurities of the presenter.&lt;/p&gt;
&lt;p&gt;
For professionals, public speaking is an essential skill which unfortunately not many of them excel at. We all have sat through death by Powerpoint; bombarded with slides and poorly presented disjointed information.
What Managers can learn from Magicians&lt;/p&gt;
&lt;p&gt;
In my opinion, presentation skills are essential to succeed in any organisation—business presentations are a form of theatre. In this post, I will explain how a book favorite among magicians, &lt;em&gt;The Five Points of Magic&lt;/em&gt; by Spanish performer Juan Tamariz—can be used to teach professionals about presentation skills.&lt;/p&gt;
&lt;p&gt;
Below are some tips from the book that apply to both magicians and public speaking.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
The Eyes
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Eye contact is the most vital tool to connect with the audience. Don’t only look at the first row. Sweep your gaze like a fan across the spectators, giving everybody some personal attention.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/business-magic/tamariz-eyes.png&#34; alt=&#34;Eye contact in public speaking.&#34; title=&#34;Eye contact in public speaking.&#34;/&gt;
&lt;figcaption&gt;
Eye contact in public speaking.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
The Hands
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The hands are the most critical tool of the magician, and in business presentations, they usually perceived get in the way. But the hands can communicate almost anything. We should use our hands to point out things, present objects and emphasise the communication. Think about how you use your hands other than a means to hold your laser pointer.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
The Voice
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Imagine an elderly lady, who is hard of hearing, sitting at the back of the room. Dedicate the performance to her and project your voice to the last row.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/business-magic/tamariz-mouth.png&#34; alt=&#34;Public speaking - project your speech.&#34; title=&#34;Public speaking - project your speech.&#34;/&gt;
&lt;figcaption&gt;
Public speaking - project your speech
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
The Feet
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The best place to stand is centre stage, facing the audience. Don’t hide behind the lectern or turn your back to the audience. This positioning is essential to be able to make good eye contact.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
The Body
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Body language is our subconscious means of communication. In theatre, and thus also in public speaking, we need to be aware of this type of communication.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
In Conclusion
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This post is only a glimpse into the vast array of literature on theatrical performances that can be applied to public speaking.&lt;/p&gt;
&lt;p&gt;
Next time you need to do a presentation, view it as a theatrical performance and follow the five points of public speaking.&lt;/p&gt;
&lt;p&gt;
One last tip: whatever you do, never imagine your audience naked, at best it will get you distracted.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Endnotes
&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Davids, Meryl. Tricks of the Trade. &lt;em&gt;The Journal of Business Strategy&lt;/em&gt; 15, no. 3 (1994): 67.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-2&#34;&gt;&lt;a href=&#34;#footnote-reference-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;A.S. Fleischman (1949), Words in modern magic, &lt;em&gt;American Speech&lt;/em&gt; (24)1, pp. 38–42.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-3&#34;&gt;&lt;a href=&#34;#footnote-reference-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Erving Goffman (1959), &lt;em&gt;The performance of self in everyday life&lt;/em&gt;. Anchor Books.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Buzzword Bingo! Play this game at your next meeting</title>
      <link>https://lucidmanager.org/management/buzzword-bingo/</link>
      <pubDate>Fri, 13 May 2011 18:37:26 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/buzzword-bingo/</guid>
      <description>
	
&lt;p&gt;
Managers use an &lt;a href=&#34;https://lucidmanager.org/management/theory-and-practice-of-management/&#34;&gt;esoteric language&lt;/a&gt; to describe very common activities. Anyone who works in an office will have heard some of the weasel words and buzzwords around the meeting table. Some of these words use evocative metaphors to express something quite mundane. &lt;/p&gt;
&lt;p&gt;
A helicopter view means that you are viewing the whole topic, and blue-sky thinking is just another word for daydreaming. Some of these words are used to give concept different meanings. A restructure is called a realignment or water utilities that use exotic words to describe &lt;a href=&#34;https://lucidmanager.org/marketing/recycled-water-yuck-factor/&#34;&gt;recycled sewage&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Introducing Buzzword Bingo
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Some of the more grounded people in the office, the lucid managers, devised a hypothetical games called Buzzword Bingo, also called Bullshit Bingo as perhaps the word buzzword is itself a buzzword that does not say it like it is. I have never met anyone who has actually played the game but is surely is a nice thought to sit in a boring meeting and shout BINGO as soon as your card with buzzwords is full.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-2&#34;&gt;
Play Buzzword Bing
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;Play Buzzword Bingo, the most popular past time during boring meetings. The list of words you could use is endless. We hope to one day develop an application that can automatically detect buzzwords and shout &amp;#34;Bingo&amp;#34; n the middle of a meeting. The image below is an example of a card.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/management-tools/buzzword-bingo.jpg&#34; alt=&#34;Buzzword Bingo!&#34; title=&#34;Buzzword Bingo!&#34;/&gt;
&lt;figcaption&gt;
Buzword Bingo!
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>An Alternative Risk Matrix Template: Welcome to the Matrix</title>
      <link>https://lucidmanager.org/management/alternative-risk-matrix-template/</link>
      <pubDate>Wed, 20 Apr 2011 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/alternative-risk-matrix-template/</guid>
      <description>
	
&lt;p&gt;
If Einstein were a management guru, he perhaps would have said that managers don&amp;#39;t play dice, but how wrong he was! All of management is about controlling risk. If there were no risk, there would be no need to manage anything because positive outcomes would be guaranteed. This article presents an alternative risk matrix template.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;God doesn&amp;#39;t play dice but managers do.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Risk management is a complex topic that is all about the dreaded concept of statistics. Most managers don&amp;#39;t understand statistics and need something simple to help them through the necessary risk management sessions. They use a risk management template to make the topic understandable for the not so mathematically inclined.&lt;/p&gt;
&lt;p&gt;
Around the world, businesses are using simple matrices to manage risk. People gather around a table and argue whether a risk is low, medium or high. In most cases without proper consideration of the actual statistical issues.&lt;/p&gt;
&lt;p&gt;
Risk matrices are a poor proxy for real risk management and suck up a lot of resources to &amp;#39;manage&amp;#39; trivial risk.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; Risk matrices provide false confidence in the actual risk profile and, more often than not, produce outcomes that do not add any information to the situation other than the ability to provide colourful overviews. The best outcome of any risk matrix exercise is that at least all risks have been discussed and acknowledged. The actual outcome of the matrix rarely has any bearing on the way the risk is managed; it is merely a category.&lt;/p&gt;
&lt;p&gt;
A risk matrix is a security blanket for higher management and the board to feel secure that the rest of the organisation knows what they are doing and will not expose the organisation to unacceptable risks.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Alternative Risk Matrix Template
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;At the Lucid Manager, we have created an alternative risk matrix that you can use to inform your management decisions. We bring risk management to life without boring and meaningless numbers, but practical device. Download this picture, assess the likelihood and consequence of your risk and act by this schedule. Success at your next risk management session is guaranteed!&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/management-tools/risk-matrix-template.png&#34; alt=&#34;Lucid Manager Risk Matrix&#34; title=&#34;Lucid Manager Risk Matrix&#34;/&gt;
&lt;figcaption&gt;
Lucid Manager Risk Matrix.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Cox, L.A. (2008), &lt;a href=&#34;https://dx.doi.org/10.1111/j.1539-6924.2008.01030.x&#34;&gt;What&amp;#39;s Wrong with Risk Matrices?&lt;/a&gt;, &lt;em&gt;Risk Analysis&lt;/em&gt;, (28)2: 497–512.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Manager&#39;s New Clothes: The Magic of the Business Suite</title>
      <link>https://lucidmanager.org/management/managers-new-clothes/</link>
      <pubDate>Sat, 19 Feb 2011 18:03:52 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/managers-new-clothes/</guid>
      <description>
	
&lt;p&gt;
The manager in his or her suit has become an archetype in professional life around the globe. Even at international meetings, where people of various cultures gather, managers all wear the same type of clothing, only displaying minor variations in style and colour. &lt;/p&gt;
&lt;p&gt;
Business suits have of course no practical purpose but instead, convey social meaning. The suit has become a symbol of power, and a means to demarcate the white from the blue collars. Using clothes and other objects to communicate meaning to other people is a natural aspect of being human. An immutable law of marketing is that we don&amp;#39;t buy stuff for what it does, but for what it means.&lt;/p&gt;
&lt;p&gt;
Early in my career, I was working on a dredging site in Bangladesh, wearing my comfy heavy metal t-shirt and jeans. I was unexpectedly asked to present to head office executives visiting from the Netherlands. Blissfully unaware of my lack of appropriate attire and ignoring their visible scepticism towards my expertise I was able to convince them of my recommendation.&lt;/p&gt;
&lt;p&gt;
It is of course not a secret that the relationship between the clothes we wear and our actual ability to be a good manager is not a necessary one. Sociologists Erving Goffman, who analysed human interaction from a theatrical perspective, wrote more than half a century ago:&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;People holding corporate positions are blinding themselves and others to the fact that they hold their jobs partly because they look like executives, not because they can work like executives.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
In the field of &lt;a href=&#34;https://horizonofreason.com/culture/first-law-of-consumer-behaviour/&#34;&gt;consumer behaviour&lt;/a&gt;, the clothes we buy are often seen as the &lt;em&gt;result&lt;/em&gt; of our lifestyle, demographics and other variables. Sociologists, however, have a reverse logic and look at the clothes we wear as the &lt;em&gt;cause&lt;/em&gt; of the behaviour. Research has confirmed that we use objects such as clothing to compensate for actual ability to act in a particular role. &lt;/p&gt;
&lt;p&gt;
It has been found that MBA students less likely to be successful in professional life (based on grade averages) are more likely to look the part.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-2&#34; href=&#34;#footnote-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Manager&amp;#39;s New Clothes
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;With this in mind, it is interesting to note that quite often the smartest people are portrayed in movies as eccentric, deviating from the expectations, but accepted because of their abilities.&lt;/p&gt;
&lt;p&gt;
Clothing as a means to communicate actual and aspired social status is part of what makes us human, and after my experience, I quickly learnt to adapt to the expectations of professional life. The best way to end this post is with the
&lt;a href=&#34;https://lucidmanager.org/management/deception-in-management/&#34;&gt;words of the bard&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;All the world&amp;#39;s a stage, And all the men and women merely players; They have their exits and their entrances; And one man in his time plays many parts … [note]Shakespeare, As You Like it).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Erving Goffman (1959) &lt;em&gt;The presentation of self in everyday life&lt;/em&gt;, Penguin, London.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-2&#34;&gt;&lt;a href=&#34;#footnote-reference-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Solomon, Michael R.: The Role of Products as Social Stimuli: A Symbolic Interactionism Perspective, &lt;em&gt;The Journal of Consumer Research&lt;/em&gt; 10(3), volume 10, 319–329, 1983.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Do You Know Customers? Sociological Imagination in Marketing</title>
      <link>https://lucidmanager.org/marketing/sociological-imagination-in-marketing/</link>
      <pubDate>Sun, 30 Jan 2011 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/marketing/sociological-imagination-in-marketing/</guid>
      <description>
	
&lt;p&gt;
Customers are the lifeblood of any organisation. Marketing is, very simply put, the process of creating customer satisfaction or in the words of Philip Kotler, &amp;#34;customer satisfaction engineering&amp;#34;.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
To be able to market well it is as such important to know who this other person is and understand their needs and wants. In the words of my former marketing professor Rhett Walker, you need to find out what &amp;#34;rattles their cage&amp;#34;.&lt;/p&gt;
&lt;p&gt;
Marketers mainly do this by using simplified quantitative models of social reality. They like to know where customers live, who their customers are, how they purchase and use stuff and why they buy stuff in the first place. Like a baby playing with blocks, they match the segments with their products and services, making sure not to put a square peg in a round hole. Selling ice to Eskimos is clearly a case of segmentation gone horribly wrong.&lt;/p&gt;
&lt;p&gt;
It is tough to make sense out of the myriad of variables available within the four broad types of segmentation. But people&amp;#39;s drive to simplify the complexity of social reality knows no bounds. Some companies have developed insightful tools to help marketers to segment their market in easy to understand chunks, such as the &lt;em&gt;Roy Morgan Values Segments&lt;/em&gt; and the VALS (Values, Attitudes and LifeStyles) system. Unfortunately, these systems are propriety, and it is difficult to assess their validity, but that does not diminish their &lt;a href=&#34;https://lucidmanager.org/management/free-personality-test/&#34;&gt;popularity&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Sociological imagination in marketing
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;These systems certainly serve a purpose, but they can be no replacement for a real understanding of human beings. To be a successful marketer requires &lt;a href=&#34;http://en.wikipedia.org/wiki/The_Sociological_Imagination&#34;&gt;sociological imagination&lt;/a&gt; which is the ability to recognise relationships between patterns in society and the actions of individual people. The quantitative sociology of segmentation cannot lead to an understanding of people, it can only describe them. Understanding is much harder to obtain. In the words of C. Wright Mills:&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-2&#34; href=&#34;#footnote-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Neither the life of an individual nor the history of a society can be understood without understanding both.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Sociological imagination in marketing is a quality of mind, rather than analysing a set of data. Unfortunately, this type of knowledge cannot be summarised in beautiful diagrams nor can it be scientifically tested with statistical models. Sociological imagination in marketing is a narrative that grows through debate and life experience.&lt;/p&gt;
&lt;p&gt;
To truly understand customers you need to look beyond the source of revenue with a multitude of labels, but understand them in a qualitative sense. You need to find out what rattles their cage.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Kotler, P., &amp;amp; Levy, S. J. (1969). Broadening the concept of marketing. &lt;em&gt;Journal of Marketing&lt;/em&gt;, &lt;em&gt;33&lt;/em&gt;, 10–15.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-2&#34;&gt;&lt;a href=&#34;#footnote-reference-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Mills, C. Wright (1959) &lt;em&gt;Sociological Imagination&lt;/em&gt;. Oxford University Press, London.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>A new Methodology to Assess Management Tools</title>
      <link>https://lucidmanager.org/management/management-tools/</link>
      <pubDate>Thu, 20 Jan 2011 20:32:04 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/management-tools/</guid>
      <description>
	
&lt;p&gt;
The science of business, just like any other academic field of endeavour, seeks to understand the nature of reality. Scientists judge a theory not only on its ability to predict the future but also on whether it can be considered elegant. In the physical sciences, for example, Stephen Hawking admits that he longs for the day when nerds can wear t-shirts with a straightforward formula that explains everything in the universe.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Science of Business
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Business theorists are also drawn towards the aesthetics of their thoughts. The textbooks slaved over by MBA students all over the world are littered with two-dimensional matrices that purportedly explain everything from what business strategy to use or whether the divest whole business units. Famous examples are the &lt;a href=&#34;http://www.quickmba.com/strategy/matrix/bcg/&#34;&gt;BCG Matrix&lt;/a&gt;, Igor Ansoff&amp;#39;s &lt;a href=&#34;http://www.quickmba.com/strategy/matrix/ansoff/&#34;&gt;strategy matrix&lt;/a&gt;, the ubiquitous &lt;a href=&#34;http://www.quickmba.com/strategy/swot/&#34;&gt;SWOT analysis&lt;/a&gt;, &lt;a href=&#34;http://www.quickmba.com/strategy/generic.shtml&#34;&gt;Porter&amp;#39;s Generic Strategies&lt;/a&gt; and so on. Some more adventurous thinkers take it a step further and postulate slightly more complicated diagrams, such as the &lt;a href=&#34;http://www.quickmba.com/strategy/matrix/ge-mckinsey/&#34;&gt;GE-McKinsey Matrix&lt;/a&gt; or Porter&amp;#39;s Five Forces and of course his &lt;a href=&#34;http://www.quickmba.com/strategy/global/diamond/&#34;&gt;Diamond&lt;/a&gt; of national competitive advantage. &lt;/p&gt;
&lt;p&gt;
It is a comforting thought that the unpredictable nature of business reality can be expressed in simple two-dimensional diagrams that even the least intelligent manager can reproduce to impress his peers and superiors with.&lt;/p&gt;
&lt;p&gt;
Since I started my journey into business theory several years ago, it surprised me how much academic literature on business is separated from the popular books that managers read and apply in their daily work. A great moat surrounds the ivory tower of academic business schools. Most managers spend considerable time chewing the fat with academics when they attend university. But, as soon as they leave, there is little further interaction. The word academic is mostly used in a negative sense as an indication of something being of no practical use.&lt;/p&gt;
&lt;p&gt;
The Lucid Manager would not be a real business blog if we did not introduce our meta-matrix or ‘über-matrix&amp;#39; of the business sciences and management tools. So, let&amp;#39;s take the blue pill and enter the world of the Management Theory Matrix, henceforth known as the LM (Lucid Manager) Matrix.&lt;/p&gt;
&lt;p&gt;
The first dimension of the LM Matrix is the extent to which theory is corroborated in reality. In other words, how much empirical evidence is available to support the theory. The second dimension to consider in the LM Matrix is the popularity of the theory. The popularity of a model can be easily tested by reviewing the best-sellers lists of internet bookshops and reviews in popular management magazines. To visualise the matrix and provide some metaphors, a zoological approach is used in the LM Matrix.&lt;/p&gt;
&lt;p&gt;
This method is inspired by the ubiquitous BCG Matrix and &lt;a href=&#34;http://www.thediscpersonalitytest.com&#34;&gt;DiSC personality profiling&lt;/a&gt;. In the bestiary of business theories, we can distinguish four animal kingdoms, dodos, owls, rabbits and unicorns, each with their unique characteristics.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/management-tools/HTCMatrix.jpg&#34; alt=&#34;Management Theory Matrix (HTC Matrix)&#34; title=&#34;Management Theory Matrix (HTC Matrix)&#34;/&gt;
&lt;figcaption&gt;
Management Theory Matrix (HTC Matrix).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Management Tools Matrix
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-3&#34;&gt;
Dodos
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;When a management theory has a shallow empirical foundation and is neither very popular, it can be called a dodo. Just like the now extinct ugly flightless bird from the island nation of Mauritius was hunted to extinction by Dutch sailors in the seventeenth century, these theories are not able to withstand the evolutionary forces of social selection by managers and scholars. &lt;/p&gt;
&lt;p&gt;
Although the father of what we now call management science, &lt;a href=&#34;https://lucidmanager.org/management/frederick-taylor-management-fundamentalism/&#34;&gt;Freddy Taylor&lt;/a&gt;, who himself was killing the dodos of his time, proclaimed to base his work on rigorous measurements of reality. More recent research of his private notes shows that this is more myth than reality. See Matthew Stewart&amp;#39;s excellent book &lt;em&gt;&lt;a href=&#34;http://mwstewart.com/the-management-myth/&#34;&gt;The Management Myth&lt;/a&gt;&lt;/em&gt;, which inspired to write this post. Taylorism and Scientific Management is thus an example of a dodo. Although it has spawned many modern theories, Taylor&amp;#39;s original thought has fortunately perished.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-4&#34;&gt;
Owls
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;Academic journals of management theory are brimming with valuable research, carefully undertaken and analysed using deep thought and sophisticated mathematical models. Prestigious journals rigorously select papers that can demonstrate a high level of empirical validation and predictive power. &lt;/p&gt;
&lt;p&gt;
The complexity of academic thinking is, however, not popular with managers. Most people in business are not comfortable with convoluted mathematics and abstract structures proposed by scholars. The ancient Greek goddess of wisdom Athena is often depicted with an owl perched on her head. These theories are as such called owls because of their great wisdom. Alas, owls are shy creatures that prefer the darkness of the night and are rarely seen in boardrooms and management workshops.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-5&#34;&gt;
Bunnies
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;Most theories that win the popularity contest in the business ideas market dramatically lacking in empirical validation. Managers blindly accept Maslow&amp;#39;s Hierarchy of Needs as a psychological truth and try to emulate the &lt;a href=&#34;http://www.quickmba.com/mgmt/7hab/&#34;&gt;7 Habits of Highly Effective People&lt;/a&gt;. They are called bunnies because they are cute and cuddly on the outside, but breed uncontrollably and can cause irreparable damage to the environment; burrowing holes and undermining the foundations of organisations. &lt;/p&gt;
&lt;p&gt;
Some authors, such as Jim Collins and his immensely popular book &lt;em&gt;Good to Great&lt;/em&gt;, hide behind a veil of pseudoscience and undertake shallow research without the statistical rigour required in science. But his work is littered with tautologies and is lacking in critical analysis.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-4&#34;&gt;
&lt;h4 id=&#34;headline-6&#34;&gt;
Unicorns
&lt;/h4&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-4&#34;&gt;
&lt;p&gt;What would be expected the Cash Cow of management theory are those ideas that are corroborated with actual business practice and are indeed practised widely, are unfortunately as elusive as the mythical unicorn. But the unicorn stands for a hope of better times ahead. &lt;/p&gt;
&lt;p&gt;
Maybe one day a new age in business will e heralded, as was initially proclaimed by Taylor, and millions of workers around the world can sigh of relief when they are liberated from the dodos and owls, instead of riding unicorns towards the rainbow.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Epilogue
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;But what does this all mean you might ask yourself. The simple message that the LM Matrix proclaims is, in the words of Immanuel Kant: &amp;#34;&lt;em&gt;Sapere Aude&lt;/em&gt;!&amp;#34;, or in everyday language, dare to think. &lt;/p&gt;
&lt;p&gt;
A business theory is, in essence, social theory, and no aspect of reality is so difficult to capture in theory as the behaviour of human beings. Good business science is complicated and often requires deep thought and self-knowledge to be able to understand business. As a social science, a business can not be explained away in simple theories and matrices. Understanding comes with wisdom and insight that can just not be drawn in two-dimensional diagrams.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Pitfalls of Culture Change: Why most programs fail</title>
      <link>https://lucidmanager.org/management/culture-change/</link>
      <pubDate>Mon, 27 Sep 2010 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/culture-change/</guid>
      <description>
	
&lt;p&gt;
Culture change is a favourite past-time among contemporary managers. The promise that many management books make is that changing your organisation&amp;#39;s culture will lead to organisational success.&lt;/p&gt;
&lt;p&gt;
Managers eager to impress their directors will invariably implement a &lt;a href=&#34;https://lucidmanager.org/management/esoteric-change-management/&#34;&gt;cultural change program&lt;/a&gt; with the anticipation that it will increase &lt;em&gt;productivity&lt;/em&gt;, &lt;em&gt;profitability&lt;/em&gt; or any other noun ending in -ty. This promise first to change themselves on the premise that successful organisations all have a &amp;#39;good&amp;#39; culture.&lt;/p&gt;
&lt;p&gt;
The idea that a good or healthy culture will improve business results is also logically nonsensical. The claim that a healthy organisational culture will improve performance is tautological. Any qualifier of the word culture will inevitably be self-referential. &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Interestingly enough, most culture change programs fail!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The reason most cultural change programs fail is that culture is an epiphenomenon of human interaction, which means that culture as such does not exist. Culture is a mental construct; it is the &lt;em&gt;effect&lt;/em&gt; of something and can not be the &lt;em&gt;cause&lt;/em&gt; of anything. The only place where culture changes are always successful is in microbiological laboratories, where nerdy scientists in lab coats poke around in Petri-dishes and conical flasks to develop medicine, biological warfare
or just because they need a job. Back to human cultures. &lt;/p&gt;
&lt;p&gt;
Culture is the result of a whole range of phenomena, such as people&amp;#39;s values and beliefs. Managers more often than not focus on these aspects of culture. They try to change the values and beliefs of their staff by spouting &amp;#39;inspiring&amp;#39; rhetoric and professional development programs.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Culture is an epiphenomenon&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Corporations are not democratic organisations and rely on hierarchical structures. Culture is thus driven from top to bottom and can therefore only change to the limit of the values and beliefs of the managers in charge. It is because of this that most textbooks on cultural change fail. To change a culture, managers need first to change themselves!&lt;/p&gt;
&lt;p&gt;
Because culture is the effect of phenomena, it can not be the cause of anything - including corporate success.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
How to implement culture change
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;There are aspects of culture that can be modified quite easily. Other phenomena that cause culture are &lt;a href=&#34;https://lucidmanager.org/management/consultant-shaman/&#34;&gt;rituals and ceremonies&lt;/a&gt;, stories and legends and material objects. This description might sound like things that you only find in tribal societies, but all corporations have them.&lt;/p&gt;
&lt;p&gt;
Rituals and ceremonies are expressed in the way meetings are conducted, and birthdays are celebrated and everything in between. Stories and legends relate to the history of the corporation, and material objects are the tools we use and the office we work in.&lt;/p&gt;
&lt;p&gt;
If a manager wants to change a &amp;#39;culture&amp;#39;, then these phenomena are the starting point. Change these, and the culture will follow. The best example to illustrate this is the often discussed Google offices. By placing people in the right environment, they will display the proper behaviour. &lt;a href=&#34;http://tribalinsight.wordpress.com/2008/08/19/supermarket-psychology/&#34;&gt;Supermarket designers&lt;/a&gt; use these principles very successfully. Telling appropriate stories will create a sense of collective and conduct the corporate rituals in the right way will act as an example of the desired behaviour.&lt;/p&gt;
&lt;p&gt;
The simple message is: don&amp;#39;t try to change a culture, try to modify the phenomena that cause the culture. Also, when implementing culture change, make sure you don&amp;#39;t erase the creativejuices of the organisation by promoting &lt;a href=&#34;https://lucidmanager.org/management/organisational-culture/&#34;&gt;normality&lt;/a&gt; and fighting against &lt;a href=&#34;https://lucidmanager.org/management/positive-workplace-deviance/&#34;&gt;positive deviance&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Free Personality Test for Professionals: Forer Workstyle Analysis</title>
      <link>https://lucidmanager.org/management/free-personality-test/</link>
      <pubDate>Mon, 30 Aug 2010 00:00:00 +0000</pubDate>
      <author>Ian Watson &amp; Prevos</author>
      <guid>https://lucidmanager.org/management/free-personality-test/</guid>
      <description>
	
&lt;p&gt;
Welcome to the &lt;em&gt;Forer Workstyle Inventory&lt;/em&gt;, a free personality test designed for professionals. Please take place on our virtual divan and answer the twenty-two questions below to find out what your Forer Workstyle Inventory is.&lt;/p&gt;
&lt;p&gt;
Many companies use personality testing in their &lt;a href=&#34;https://lucidmanager.org/management/recruitment/&#34;&gt;recruitment processes&lt;/a&gt;. Rather than relying on unreliable human intuition, personalty testing adds a scientific certainty to recruitment. A well-designed personality test inreases your &lt;a href=&#34;https://lucidmanager.org/management/self-knowledge-for-managers/&#34;&gt;self-knowledge&lt;/a&gt; because the questions help with introspection about your patterns of behaviour.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Free Personality Test
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Many personality tests are protected intellectual property and can cost a lot of money to do. The &lt;em&gt;Forer Workstyle Inventory&lt;/em&gt; is fully open source and you can read all about how it is designed and statistically validated. Our analysis proves that this test is as good as commercially available tests.&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;Forer Workstyle Inventory&lt;/em&gt; helps professionals to better understand their personality by asking 22 seemingly unrelated questions. This test is specially designed and our objective is that this will be the last personality test you will ever need to take.&lt;/p&gt;
&lt;p&gt;
Remember, there are no wrong answers, we don&amp;#39;t collect any identifiable information, so what are you waiting for?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;center&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;a href=&#34;https://prevos.shinyapps.io/Personality_Test/&#34; target=&#34;_blank&#34;&gt;&lt;i class=&#34;fa-3x fa fa-clipboard&#34;&gt;&lt;/i&gt;&lt;/a&gt;
    &lt;/span&gt;
      &lt;div class=&#34;content&#34;&gt;Click on the icon to go to the test.&lt;/div&gt;
&lt;/center&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Esoteric Change Management: Marketing to change employees</title>
      <link>https://lucidmanager.org/management/esoteric-change-management/</link>
      <pubDate>Fri, 20 Aug 2010 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/esoteric-change-management/</guid>
      <description>
	
&lt;p&gt;
Just as a new house owner likes to change the paint colour, new businesses practice change management. The literature shows that most change management processes do not achieve the objectives they seek and a whole library of books has been written about the best ways to create and sustain change.&lt;/p&gt;
&lt;p&gt;
Managing change is more often than not about changing the behaviour of people. Management speak uses words such as alignment, creating buy-in and other &lt;a href=&#34;http://www.abc.net.au/rn/breakfast/stories/2009/2706771.htm&#34;&gt;bendable learnings&lt;/a&gt;. However, as soon as the word &amp;#39;change&amp;#39; is mentioned in a workplace, people will raise their defensive shutters and try hard to keep doing what they have always been doing.&lt;/p&gt;
&lt;p&gt;
One aspect of management where attempts to change behaviour is very successful is marketing. Good companies can manipulate the attitudes and &lt;a href=&#34;https://horizonofreason.com/culture/first-law-of-consumer-behaviour/&#34;&gt;behaviour of consumers&lt;/a&gt; so that they buy their product. Why does it work in marketing but not so much in management?&lt;/p&gt;
&lt;p&gt;
Change management strategy is more often than not &lt;a href=&#34;http://en.wiktionary.org/wiki/exoteric&#34;&gt;exoteric&lt;/a&gt;. This perspective means that all details of the approach are revealed to the subjects of the change. Change managers, and more often than not &lt;a href=&#34;https://lucidmanager.org/management/consultant-shaman/&#34;&gt;consultants&lt;/a&gt;, openly explain how they will change behaviour.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Esoteric change management
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Marketing managers are a bit more devious about their motives and use &lt;a href=&#34;http://en.wiktionary.org/wiki/esoteric&#34;&gt;esoteric&lt;/a&gt; change management techniques to change the behaviour of consumers. Some advertisements openly admit to the methods they use to change the behaviour of consumers - the best example is a Molson beer ad from some years ago:&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/deviance/molson-beer-advertising.jpg&#34; alt=&#34;Molson beer advertising&#34; title=&#34;Molson beer advertising&#34;/&gt;
&lt;figcaption&gt;
Molson beer advertising.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Maybe change managers should take a leaf from the book of marketing and use the sophisticated sociological and psychological techniques employed to convince people to change their buying behaviour.&lt;/p&gt;
&lt;p&gt;
This might raise the question whether it is ethical to change people&amp;#39;s behaviour esoterically. But all I have to say to that is that we change our behaviour based on our interaction with other people all the time. The anti-marketing crowd often underestimate the intelligence of consumers, which they portray as will-less victims. Creating change, whether in marketing or management is about creating an environment in which people feel comfortable to change, can identify with the proposed changes and believe that the change will provide them with benefits.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Deviant Behaviour as a Key Selection Criterion</title>
      <link>https://lucidmanager.org/management/deviant-behaviour/</link>
      <pubDate>Fri, 16 Jul 2010 12:00:35 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/deviant-behaviour/</guid>
      <description>
	
&lt;p&gt;
Would you like to work on the front lines of contemporary management?&lt;/p&gt;
&lt;p&gt;
The Lucid Manager is hiring, and we are looking for people that &lt;strong&gt;don&amp;#39;t fit&lt;/strong&gt; the culture of their current work and have difficulty being aligned with corporate goals. At the Lucid Manager, we believe that the only thing you have to be brought into line with is yourself.&lt;/p&gt;
&lt;p&gt;
We acknowledge that deviant behaviour and taking calculated risks is the foundation of innovation. We, therefore, look for independent critical thinkers who can add value. &lt;/p&gt;
&lt;p&gt;
If this were a genuine recruitment add, it would have been a very odd one indeed. Most companies are looking for so-called alignment and matching cultural values. At The Lucid Manager, we believe that this will lead to a
&lt;a href=&#34;https://lucidmanager.org/management/positive-workplace-deviance/&#34;&gt;severe lack of innovation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
The major corporate collapses and scandals of the recent years have caused a tightening of corporate governance, and many organisations have moved away from open models of leadership that value self-initiative to more regimented models of management.&lt;/p&gt;
&lt;p&gt;
Even though the western world is waging war to spread democracy around the globe, the one aspect that dominates most people&amp;#39;s lives, their workplaces, are ideally &lt;a href=&#34;http://en.wikipedia.org/wiki/Meritocracy&#34;&gt;meritocracies&lt;/a&gt; but are mostly more like &lt;a href=&#34;http://en.wikipedia.org/wiki/Dictatorship&#34;&gt;dictatorships&lt;/a&gt;. Most organisations are managed through clear hierarchical lines, and people are not very likely to go against the grain.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Deviant Behaviour is neccesary
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Research shows that employees do not only remain silent because of a fear of retribution but also because it is perceived as a &lt;a href=&#34;http://hbr.org/2010/06/debunking-four-myths-about-employee-silence/ar/1&#34;&gt;waste of their time&lt;/a&gt;. This silence creates psychological tension and cognitive dissonance and eventually less commitment to organisational goals.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Organisational deviance is, however, a significant source of innovation. Without the freedom to make mistakes, there can be no learning. The current wave of tightened corporate governance leads to the silencing of dissenting voices and pruning of innovative actions. The ultimate consequence of this is the impoverishment of management practices.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Notes
&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Detert, James R., Burris, E. R., &amp;amp; Harrison, D. A. (n.d.). Debunking four myths about employee silence. &lt;em&gt;Harvard Business Review&lt;/em&gt;, 88(6), 26.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Virtues of Nepotism: Building strong organisations</title>
      <link>https://lucidmanager.org/management/nepotism-in-the-workplace/</link>
      <pubDate>Fri, 09 Jul 2010 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/nepotism-in-the-workplace/</guid>
      <description>
	
&lt;p&gt;
Nepotism in the workplace is considered by many to be one of the great sins of Western culture. Over the past century, Western society has been levelled by removing class distinctions and shaped to create equal opportunities for everybody, regardless of race, religion, gender. Family relationships are not supposed to play a role in any one&amp;#39;s
chances of success. The Wikipedia definition of &lt;a href=&#34;http://en.wikipedia.org/wiki/Nepotism&#34;&gt;nepotism&lt;/a&gt; is:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Favouritism granted to relatives or friends, without regard to their merit.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
When Ian and I researched &lt;a href=&#34;https://lucidmanager.org/management/human-resource-management-in-hanoi/&#34;&gt;HR practices in Vietnam&lt;/a&gt;, we came across thought-provoking recruitment practices. From our interviews with local managers, it became clear that using family networks is an accepted recruitment source for staff.&lt;/p&gt;
&lt;p&gt;
From our data, we formed the hypothesis that recruitment in countries with a collective nature, such as Vietnam, is primarily conducted through traditional social networks, not the electronic type. This collectivism contrasts with the developed world, with a high level of individualism, where, especially in the government sector, a level playing field is created by publicly advertising positions. Companies in Hanoi use family networks as a primary recruitment pool.&lt;/p&gt;
&lt;p&gt;
Although Vietnamese practices are very much like the dreaded nepotism in the workplace, some interviewees clarified that although they use family networks as a primary recruitment source, within that pool of people, the selection is nevertheless based on merit.&lt;/p&gt;
&lt;p&gt;
The benefit of this nepotism in the workplace is a strong organisational culture. A training manager of a large company told us that they have many teams in which several generations of one family work together and that this creates strong culture bonds and a sense of common purpose within the organisation.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Nepotism in the workplace
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This sense of shared purpose is considered a holy grail by most organisations in the developed, individualistic, world. Many activities are aimed at &amp;#39;aligning&amp;#39; people with the common objectives of the organisation. But given that most businesses are a grab bag of people, working together more by change than by common purpose, this has proven to be an elusive goal.&lt;/p&gt;
&lt;p&gt;
Research in Australia has shown that people recruited through anonymous sources such as newspaper advertisements missed almost twice as many days as those hired through other sources, such as employee referrals.&lt;/p&gt;
&lt;p&gt;
[note]Breaugh, James A. (1981) Rela­tion­ship between recruiting sources and employee per­form­ance, absent­ee­ism, and work attitudes. &lt;em&gt;Academy of Man­age­ment Journal&lt;/em&gt; 24(1): 142–147.[/note]&lt;/p&gt;
&lt;p&gt;
This research underwrites the importance of using traditional social networks as a source of recruitment.&lt;/p&gt;
&lt;p&gt;
Human beings are inherently social creatures, and we like to spend our time with people we enjoy spending time with. Within that frame of reference, we are biased towards relatives. One of the primary reasons many people don&amp;#39;t enjoy work is not because of the work itself but because of the people they are forced to socialise with.&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/management/deception-in-recruitment/&#34;&gt;Open recruitment processes&lt;/a&gt; aimed at creating a level playing field are problematic, and many organisations use abstract tools, such as &lt;a href=&#34;https://lucidmanager.org/management/free-personality-test/&#34;&gt;personality tests&lt;/a&gt;, and &lt;a href=&#34;https://lucidmanager.org/management/predicting-behaviour/&#34;&gt;reference checks&lt;/a&gt; to create the illusion that recruitment is a stoic rational process.&lt;/p&gt;
&lt;p&gt;
Next time when hiring people, look around your immediate and extended social circle and see if there is anybody you would like to work with that can potentially do the job. The moral of the story is: nepotism in the workplace is not inherently evil, as long as the final selection is based on merit.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Becoming an Entrepreneur: Walking Through the Valley of Darkness</title>
      <link>https://lucidmanager.org/management/becoming-an-entrepreneur/</link>
      <pubDate>Sat, 03 Jul 2010 00:00:00 +0000</pubDate>
      <author>Ian Watson</author>
      <guid>https://lucidmanager.org/management/becoming-an-entrepreneur/</guid>
      <description>
	
&lt;p&gt;
In Australia, the term ‘&lt;a href=&#34;https://lucidmanager.org/management/essence-of-entrepreneurship/&#34;&gt;entrepreneur&lt;/a&gt;&amp;#39; has a very mixed heritage that may be responsible for discouraging others from embarking on a new enterprise. Bond and Skase are central to many Australians&amp;#39; view of an entrepreneur and they, Bond, Skase and Entrepreneurs are often cited with venomous derision; so much so that it has even generated the straight-to-video release of equally dubious movies such as &lt;a href=&#34;https://www.imdb.com/title/tt0264792/&#34;&gt;Let&amp;#39;s Get Skase&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
Additionally, many Australians experience a sense of &lt;a href=&#34;https://en.wikipedia.org/wiki/Schadenfreude&#34;&gt;schadenfreude&lt;/a&gt; in watching successful public figures fall from grace, even going so far, at times, to assist their fall, in a cultural phenomenon known as the Tall Poppy Syndrome. The Tall Poppy Syndrome is a social levelling phenomenon, related to envy, that is well-known in Australia and New Zealand (Feather, 1989; Mouly and Sankaran, 2002).&lt;/p&gt;
&lt;p&gt;
Against the backdrop of failed entrepreneur pariahs and a social phenomenon acting to drag the successful toward mediocrity, it can be daunting for the inspired would-be Australian entrepreneur to act on their ideas; particularly because entrepreneurism, despite the bad press entrepreneurs may have received, is often a force for positive change within society.&lt;/p&gt;
&lt;figure&gt;

			&lt;div
					style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
				&lt;iframe
					src=&#34;https://player.vimeo.com/video/186226156?dnt=0&#34;
						style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; allow=&#34;fullscreen&#34;&gt;
				&lt;/iframe&gt;
			&lt;/div&gt;

&lt;figcaption&gt;
Let&amp;#39;s Get Skase.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Entrepreneurs as contributors
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Understanding whether or not you would like to become an entrepreneur
greatly depends on what being an entrepreneur means to the individual.
The scholarly definition of entrepreneur and entrepreneurism has seen a
significant evolution over time. Daniel Wren, in his excellent
examination of the &lt;em&gt;History of Management Thought&lt;/em&gt; (Wren, 2005: 42),
describes the use of entrepreneur, or more literally the word
&amp;#39;undertaker&amp;#39; by Richard Cantillon in 1755 as anyone that bought or made
a product at a certain cost to sell at an uncertain price. This
definition encompasses almost all those engaged in any commercial
enterprise.&lt;/p&gt;
&lt;p&gt;
Since Cantillon&amp;#39;s definition, the &lt;a href=&#34;https://lucidmanager.org/management/essence-of-entrepreneurship/&#34;&gt;distinction between the entrepreneur and the manager&lt;/a&gt; has further evolved, possibly
as part of the academic drive to develop conceptual dichotomies. Entrepreneurs are seen as those that drive innovation whereas the
manager is primarily engaged in imitation (White, 2004).&lt;/p&gt;
&lt;p&gt;
The view that the entrepreneur is a source of innovation is one
presented and supported by the often-quoted and well-regarded Austrian
economist Joseph Schumpeter, that the role of the entrepreneur is to
drive creative destruction; that is, to reform or revolutionise
(Petrakis, 2005; Turner, 2009). The necessity for entrepreneurial
activity to be creative or innovative has also led to the conclusion
that small business, previously thought to be synonymous with
entrepreneurism, need not be entrepreneurial (Carland et al., 1984).&lt;/p&gt;
&lt;p&gt;
The role of the entrepreneur in creating jobs and consumer value has
also been described in great detail, particularly by Peter Drucker who
goes on to describe the activity of the entrepreneur as someone that
always searches for change, responds to it, and exploits it as an
opportunity (Drucker, 1985: 28).&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Entrepreneurs take on risks
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;When the activities of entrepreneurs are watched from afar though media
reports it may appear that entrepreneurs are people that take on very
large risks. This apparent propensity for taking on risk has been
extensively described in the literature (for a summary see Petrakis,
2005). However, studies have not conclusively confirmed that
entrepreneurs engage in greater levels of risk-taking behaviour than
non-entrepreneurs (Brockhaus, 1980) and for a review and summary of
other studies see Busenitz, 1999).&lt;/p&gt;
&lt;p&gt;
If entrepreneurs, successful or otherwise, make the decision to act upon
their innovative ideas despite the prevailing depressed economic
conditions, what can the non-entrepreneur learn from the experiences of
entrepreneurs to gain the audacity to transition from
non-entrepreneurship to entrepreneurship?&lt;/p&gt;
&lt;p&gt;
This essay seeks to examine two Australian entrepreneurs; Sidney Myer
and William McPherson to argue that the prevailing economic conditions,
boom or bust, provides an opportunity for the astute entrepreneur.&lt;/p&gt;
&lt;p&gt;
Additionally, it will be argued that lessons may be learnt from the two
examples of entrepreneurs so that the non-entrepreneur may take that
walk through the ‘valley of darkness&amp;#39; to emerge a successful
entrepreneur on the other side.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Simcha Baevski (Sidney) Myer (1878–1934)
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Simcha Baevski was born in Kritchev, Belarus, in 1878, the last of 11
siblings, his mother Koona Dubrusha who ran the family&amp;#39;s drapery
business and his Father, Israel, a scholarly Talmudist (Lifiman, 1999).
After arriving in Australia in 1899, he adopted the name Sidney Myer
and, with his brother Elcon, opened a small store in Bendigo, Victoria
and began door-to-door sales of fabric and clothes to country housewives
(Lifiman, 1999). His attitude, charm and enthusiasm, despite the initial
language barrier, led to relatively rapid success and he moved his
business to a larger store in Bendigo where he worked on building and
improving the Myer Emporium.&lt;/p&gt;
&lt;p&gt;
He committed himself to world travel to make business contacts,
understand emerging fashion trends and marketing methods and eventually
took a large, but calculated risk in buying Moffat&amp;#39;s Drapery in
Melbourne (Anonymous, 1922). Sidney, coming from a background in which
scholarly pursuits were valued, became a benefactor of educational and
health facilities during the Great Depression and, being an amateur
actor, he also became a great supporter of the arts (Lifiman, 1999). He
was equally generous to his staff, providing paid holidays, staff share
offerings and even providing an elaborate in-store hospital (Hyslop,
1986). He also established the Myer Woollen Mills in Ballarat to deal
with difficulties with imports of some of his lines of products (Neil,
1920).&lt;/p&gt;
&lt;p&gt;
Following his untimely death in 1934 (Anonymous, 1934), Sidney Myer&amp;#39;s
legacy is one of courage and philanthropy and would most suitably fit
within the Great Person school of entrepreneurism described by
Cunningham and Lischeron (1991).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
William Murray McPherson (1865–1932)
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;William McPherson was the son of an iron merchant who inherited his
business concerns after his father&amp;#39;s death in 1888 and his brother&amp;#39;s
death in 1896 (Patrick and Hamer, 1986). William received a six-year
apprenticeship to a metal merchant and machinery import company prior to
his inheritance, giving him a good understanding of that business. In
later years he, among others, established the Acme Bolt Company which he
owned outright by 1905 (Patrick and Hamer, 1986) which eventually became
McPherson&amp;#39;s Pty Ltd.&lt;/p&gt;
&lt;p&gt;
His educational and family background provided the basis for his
entrepreneurial activities maintaining and growing the business during
the Great Depression he did this through a shrewd business manner and an
aversion to debt. Throughout his role as a businessman, he interviewed
every job applicant and, after going on to serve as Treasurer, and
subsequently Premier of Victoria. He ensured that his staff were treated
well; providing them with lunch facilities, share offerings and bonuses
at a time when this was uncommon (Patrick and Hamer, 1986). William
McPherson&amp;#39;s profile fits best with the Managerial School of
entrepreneurism (Cunningham and Lischeron, 1991).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Defining Characteristics of Entrepreneurs
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;From the two case studies, and the observations of Peter Drucker
(Drucker, 1985), it appears that change is the fuel of entrepreneurs.
Though change is all surrounds us all of the time, it takes skill to
identify the opportunities offered by that change. To be able to
identify change, the above case study examples constantly searched it
out. They believed in intellectual improvement and pursuits often
travelling around the country or around the world to find new ideas and
fresh perspectives.&lt;/p&gt;
&lt;p&gt;
It may be argued that being politically connected may also foster
entrepreneurial activity, as William McPherson certainly had a very
close affiliation with politics. This may provide the appearance that
it&amp;#39;s not what you know but who you know, it could be argued that
politics is a profound source of change and being near to and in
constant communication with the agents of change means that the
entrepreneur is more likely to be able to identify a change in the
general environment.&lt;/p&gt;
&lt;p&gt;
To respond to and exploit an opportunity, it is essential to have a
great deal of support. The entrepreneurs above sought out that support
from several sources to achieve their goals. They required a support
network of families and friends to help guide their values, provide them
with initial skills, give them encouragement during times of stress and
to cheer them on when they were winning. They required the support of
their customers, which they achieved by identifying their needs and
meeting them with innovative or more efficient goods and services. They
also depended on their staff to ensure that their customers are well
looked after, and both Myer and McPherson demonstrated this example in
their innovative approaches to valuing their staff. They also needed the
support of the community in which they operate, and the aforementioned
entrepreneurs are exemplars of not only corporate social responsibility
but corporate social benevolence.&lt;/p&gt;
&lt;p&gt;
It is also possible that entrepreneurs identify and diagnose opportunity
differently. While the research for two of the case studies cannot
definitively provide an answer to how they identified an opportunity, in
each case the next step was to be willing and able to act upon the
findings of an opportunity diagnosis (Pech and Cameron, 2006). It is
this willingness to take that leap of faith that requires the
convergence of a number of factors based on personal attributes of the
entrepreneur such as abilities, attitudes, skills and knowledge. It also
required an understanding of the environmental obstacles and opportunity
factors affecting the new venture such as cultural and community
acceptance, social, political and environmental shifts, and resource
availability (Pech, 2009).&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Key differences between entrepreneurs
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The two entrepreneurs cited above came from different educational
backgrounds. One started his own enterprises while the other modified
the activity of existing enterprises that was inherited. In one case
there is a clear example of where the entrepreneur had a good
understanding of the need for someone that complemented their own
business skills; such as Lee Neil&amp;#39;s management skills supporting Sidney
Myer. It would appear that the differences outnumber the similarities,
which may be of comfort to the non-entrepreneur looking toward embarking
on an entrepreneurial enterprise.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Becoming an Entrepreneur
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The decision to take the leap and become an entrepreneur is a daunting
one, a walk through the valley of darkness as suggested in the title,
but each successful entrepreneur has made this journey by being prepared
with a map and a torch (a good understanding of their industry and
customers), taking each small step at a time, surrounded by supportive
family and friends, with enthusiasm for the journey itself.&lt;/p&gt;
&lt;p&gt;
For a non-entrepreneur to make the transition to entrepreneur, based on
the case studies and literature cited in this essay, it is recommended
that you start learning to think what no-one has thought yet to identify
opportunities but then develop the decision-making skills to evaluate
and then map out a way to bring ideas to life. This may be achieved by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Finding an opportunity that you are passionate about or develop a passion for the opportunity you find.&lt;/li&gt;
&lt;li&gt;Developing the abilities skills and knowledge necessary to run a business.&lt;/li&gt;
&lt;li&gt;Maintaining a high awareness of change and remain in frequent communication with change agents.&lt;/li&gt;
&lt;li&gt;Being aware of the actions of potential competitors.&lt;/li&gt;
&lt;li&gt;Enlisting the support of your loved ones and friends.&lt;/li&gt;
&lt;li&gt;Understanding your skills and limitations and partner with those that complement your skills.&lt;/li&gt;
&lt;li&gt;Planning and mapping out how you will develop the idea and then start the business; a business plan may assist this (Stutley, 2007).&lt;/li&gt;
&lt;li&gt;Starting small but plan to grow.&lt;/li&gt;
&lt;li&gt;Maintaining a lookout for new opportunities while remaining wary of new threats.&lt;/li&gt;
&lt;li&gt;Committing yourself to self-improvement and education and&lt;/li&gt;
&lt;li&gt;Being mindful of the support, you receive from your customers, staff and the community and ensuring that you provide support in return.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
References
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;ul&gt;
&lt;li&gt;Anderson, F. (2001) Entrepreneurism is not a dirty word. &lt;em&gt;The Courier Mail&lt;/em&gt; : 29.&lt;/li&gt;
&lt;li&gt;Anonymous (1922) Large Drapery Merger. &lt;em&gt;Argus&lt;/em&gt;: 32.&lt;/li&gt;
&lt;li&gt;Anonymous (1934) Sidney Myer: Sudden death in Melbourne. &lt;em&gt;The Canberra Times&lt;/em&gt;: 1.&lt;/li&gt;
&lt;li&gt;Brockhaus, R. H. (1980) Risk taking propensity of entrepreneurs. &lt;em&gt;Academy of Management Journal&lt;/em&gt; 23(3): 509-520.&lt;/li&gt;
&lt;li&gt;Busenitz, L. W. (1999) Entrepreneurial risk and strategic decision making: It&amp;#39;s a matter of perspective. &lt;em&gt;The Journal of Applied Behavioral Science&lt;/em&gt; 35(3): 325–340.&lt;/li&gt;
&lt;li&gt;Carland, J. W. et al. (1984) Differentiating entrepreneurs from small business owners: A conceptualization. &lt;em&gt;The Academy of Management Review&lt;/em&gt; 9(2): 354–359.&lt;/li&gt;
&lt;li&gt;Cassrels, D. (2000) Sharing the benefits. &lt;em&gt;The Courier Mail&lt;/em&gt;: 28.&lt;/li&gt;
&lt;li&gt;Cunningham, J. B. and Lischeron, J. (1991) Defining entrepreneurship. &lt;em&gt;Journal of Small Business Management&lt;/em&gt; 29(1): 45–61.&lt;/li&gt;
&lt;li&gt;Drucker, P. F. (1985) &lt;em&gt;Innovation and Entrepreneurship.&lt;/em&gt; New York: HarperCollins.&lt;/li&gt;
&lt;li&gt;Feather, N. (1989) Attitudes towards the high achiever: The fall of the tall poppy. &lt;em&gt;Australian Journal of Psychology&lt;/em&gt; 41: 239–267.&lt;/li&gt;
&lt;li&gt;Hyslop, A. (1986) &lt;em&gt;Australian Dictionary of Biography&lt;/em&gt; vol. 10, chap. Myer, Simcha Baevski (Sidney) (1878-1934). Melbourne University Press, 657–660.&lt;/li&gt;
&lt;li&gt;Lewis, S. (2008) Portrait of a First Lady. &lt;em&gt;The Daily Telegraph&lt;/em&gt;: 123.&lt;/li&gt;
&lt;li&gt;Lifiman, M. (1999) A &lt;em&gt;century of Myer Philanthropy&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Mouly, V. S. and Sankaran, J. K. (2002) The enactment of envy within organizations. &lt;em&gt;The Journal of Applied Behavioral Science&lt;/em&gt; 38(1): 36–56.&lt;/li&gt;
&lt;li&gt;Neil, E. L. (1920) Important pronouncement by Myer&amp;#39;s. &lt;em&gt;Argus&lt;/em&gt;: 18.&lt;/li&gt;
&lt;li&gt;Patrick, A. and Hamer, B. (1986) &lt;em&gt;Australian Dictionary of Biography&lt;/em&gt;, vol. 10, chap. McPherson, Sir William Murray (1865 - 1932). Melbourne University Press, 359–360.&lt;/li&gt;
&lt;li&gt;Pech, R. J. (2009) &lt;em&gt;Entrepreneurial Courage, Audacity and Genius&lt;/em&gt; Chapter 15: Our Conclusions. Frenchs Forest, Australia: Pearson Education Australia.&lt;/li&gt;
&lt;li&gt;Pech, R. J. and Cameron, A. (2006) An entrepreneurial decision process model describing opportunity recognition. &lt;em&gt;European Journal of Innovation Management&lt;/em&gt; 9(1): 61–78.&lt;/li&gt;
&lt;li&gt;Petrakis, P. E. (2005) Risk perception, risk propensity and entrepreneurial behaviour: The Greek case. &lt;em&gt;Journal of American Academy of Business&lt;/em&gt; 7(1): 233–242.&lt;/li&gt;
&lt;li&gt;Stutley, R. (2007) &lt;em&gt;The Definitive Business Plan&lt;/em&gt;. 2nd ed. Harlow, UK: Pearson Education.&lt;/li&gt;
&lt;li&gt;White, C. (2004) &lt;em&gt;Strategic Management&lt;/em&gt;. Palgrave Macmillan, Houndmills, Basingstoke, England.&lt;/li&gt;
&lt;li&gt;Wren, D. (2005) &lt;em&gt;The History of Management Thought&lt;/em&gt;. 5th ed. Hoboken: John Wiley and Sons Inc.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Consultant Shaman: Contemporary Rituals in Business</title>
      <link>https://lucidmanager.org/management/consultant-shaman/</link>
      <pubDate>Fri, 02 Jul 2010 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/consultant-shaman/</guid>
      <description>
	
&lt;p&gt;
Imagine you are an anthropologist, posted in a remote village in Papua New Guinea to study how people solve problems. The recent tornado has reduced the village’s yam crops dramatically, and the people are on the brink of famine. Nobody knows what has caused the crop failures—the yams refuse to grow. One village elder says he has heard about a powerful shaman from a remote village in the mountains and wants to hire her to make sure they will not go hungry.&lt;/p&gt;
&lt;p&gt;
The shaman arrives, and everybody rejoices. She walks around the village, making strange noises, sniffing everything and dancing mysteriously. She announces to have found the cause and organises a long ritual that will remove the evil that creates crop failures. All the villagers gather and sing and dance all night. Everybody feels great. The next day they go back to working the fields, knowing that the cause for the crop failures has been neutralised. The following crop is plentiful, and the famine that was nearly upon them has been magically averted. Some years later you return to the village to revisit them. Most houses are gone, and people have moved away—recent crops failed, and everybody went to the city to look for work.
The Consultant Shaman&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Consultant Shaman
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Now imagine you are a management scientist, posted in a random corporation to study how they solve problems. The company’s revenue stream has been reduced dramatically, and they are on the brink of insolvency. Nobody knows what caused the reduction in revenue, and customers seem to ignore their products. One of the executives says that she has heard about a management consultant from England and proposes to engage him in making sure they avoid insolvency.&lt;/p&gt;
&lt;p&gt;
The consultant arrives, and everybody is very confident. He goes to the organisation, asking questions and studies piles of documents. He announces to have found the cause of the reduced revenue and organises motivational sessions that will make things better. All employees gather, and they share many great ideas with each other. Everybody feels elated, and the next day they go back to work, knowing that the cause for potential financial disaster has been neutralised. Pretty soon, cash flow is positive again, and even a small profit is made. Some years later you return to the same building only to find a great “For Rent” sign on the door. The company recently went bankrupt after all.&lt;/p&gt;
&lt;p&gt;
These stories are based on what happens in tribal societies and corporations around the world. Only the names have been changed to protect the innocent.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
These stories are not a judgement about either shamans or management consultants. They both perform essential functions within their social universes.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Anthropology and Business
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Medical anthropologists distinguish between sickness and disease. A disease is the physical aspect of a problem whereas illness is a psychological dimension.&lt;/p&gt;
&lt;p&gt;
Both consultants and shamans are good at healing sickness but are in most cases not able to heal disease. Just like scientific medicine is required to cure disease, a scientific approach is needed to improve companies.&lt;/p&gt;
&lt;p&gt;
Many managers believe that organising motivational team building sessions are sufficient to solve managerial problems. Employees are on the receiving end of an avalanche of management fads and short-lived initiatives. A positive consequence of these types of sessions is that they can build strong personal relationships, which are essential for running an excellent organisation.&lt;/p&gt;
&lt;p&gt;
At the Lucid Manager, we believe in a rational approach, based on data, to solving the hard issues. Good quality data and statistical analysis, combined with strong human relationships are the only way to find solutions to hard problems. Having said this, acknowledging that human beings are not entirely rational, is paradoxically a sensible idea. A Lucid Manager can embrace ambiguity and accept the limitations of reason.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Schuyt, T.N.M., and J.J.M. Schuijt. Rituals and Rules: About Magic in Consultancy. &lt;em&gt;Journal of Organizational Change Management&lt;/em&gt; 11, no. 5 (1998): 399–406.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Predicting Behaviour in Recruitment: A Magician’s View</title>
      <link>https://lucidmanager.org/management/predicting-behaviour/</link>
      <pubDate>Fri, 25 Jun 2010 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/predicting-behaviour/</guid>
      <description>
	
&lt;p&gt;
A used golden rule of recruitment is that past behaviour is an indication of future conduct. Businesses rely on reference checks or even Google searches to find out as much as they can about their potential new staff. But, is past behaviour a good proxy for predicting future behaviour?&lt;/p&gt;
&lt;p&gt;
Knowledge of the past is the foundation of all science and human understanding. We try to predict the future by drawing from our experience. Philosophers call this inductive process reasoning – drawing a general conclusion from a range of observations. But when you think profoundly about this, we can never know for sure that our past observations can be used to predict the future. Scottish philosopher David Hume did precisely this more than two centuries years ago when he found that it is not logical to think that past behaviour is an indication of future action.&lt;/p&gt;
&lt;p&gt;
For millennia people in Europe thought that all swans are white. This little kernel of absolute knowledge was rudely destroyed when in 1697 Dutch explorer Willem de Vlamingh was the first European to see a black swan in what is now Western Australia.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Predicting behaviour: A magician’s view
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The silent part of the American magician’s duo Penn &amp;amp; Teller broke his usual silence and vow of secrecy when he explained a classic magic trick to a gathering of consciousness scholars. Teller showed that magicians could use the propensity of the human mind to seek patterns by skilfully changing the method during the routine. Teller beautifully illustrates what Hume philosophically argued: in human behaviour, the past is in no way a reliable approach to predicting the future.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/J5x14AwElOk?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Teller Speaks!
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Predicting behaviour in recruitment
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;We have to be careful when judging a person through second-hand information gained from referees, Facebook searches and other forms of overt espionage. People are not billiard balls that operate by laws of physics. People have free will and can change their behaviour depending on the circumstances they find themselves in.&lt;/p&gt;
&lt;p&gt;
Most importantly, we can learn from our mistakes and grow as people by learning from them. Not hiring somebody who has made an error in the past could mean that you miss out on hiring an individual with a high level of maturity and ability to adapt. Therefore, when judging a person, keep in mind the words of Roman poet Horace: “Non sum quals eram“—I am not who I once was.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Lies We Tell — Double Deception in Recruitment</title>
      <link>https://lucidmanager.org/management/deception-in-recruitment/</link>
      <pubDate>Fri, 04 Jun 2010 00:00:00 +0000</pubDate>
      <author>Ian Watson</author>
      <guid>https://lucidmanager.org/management/deception-in-recruitment/</guid>
      <description>
	
&lt;p&gt;
Matt was nervous. Most people are under the circumstances. Matt sat in front of the recruitment specialist, hoping that he&amp;#39;d end up with the job that was on offer. It was a step up from what he had done in the past—in pay, responsibility and influence.&lt;/p&gt;
&lt;p&gt;
Daniel, the Recruitment Manager, pushed a folded piece of paper and a pencil across the table to Matt and then did something appalling. He lied.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“Please answer the questions for this &lt;a href=&#34;https://lucidmanager.org/management/free-personality-test/&#34;&gt;personality test&lt;/a&gt; there are no right or wrong answers”, Daniel reassured Matt.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Mind you, Daniel had no intention of lying nor did he even realise that he had, at the time. &amp;#34;There are no right or wrongs answers&amp;#34;, is a lie that many managers and human resources professionals use from time to time. The personality tests that are conducted in workplaces throughout the world in job interviews have no answer that is intrinsically correct—as you might find in a high school mathematics exam. &lt;/p&gt;
&lt;p&gt;
However, the presence of a series of questions that are included as part of the selection process for an employment role makes a lie of Daniel&amp;#39;s reassurance.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Deception in Recruitment
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If a recruitment test of any kind is used in the context of an employee selection process, there is an intention to use it to justify the selection of a particular candidate and to exclude others. It has already been decided by the interviewer, recruitment expert or organisation that a specific personality is required for the role (or, conversely, that particular personality profiles are to be avoided). This simple truth means that for the organisation, responses on the personality test &lt;em&gt;are&lt;/em&gt;, in fact, right or wrong.&lt;/p&gt;
&lt;p&gt;
Looking at personality tests from the candidate experiencing the job interview process, there are also right and wrong answers. In our example, Matt desperately wants the job but does not necessarily know what personality profile Daniel is looking for, nor does Matt know what responses he needs to give to present the &amp;#39;right&amp;#39; personality profile for the job. Additionally, he knows that he should be honest during a job interview. When nervous, the tension created by the need, to be frank, and also the desire to meet the needs of the interviewer is unlikely to help Matt through the selection process nor help Daniel find the right candidate.&lt;/p&gt;
&lt;p&gt;
Set aside for now whether there is any validity in using Myers-Briggs, Keirsey, DISC or any other personality test or temperament sorter in a job interview, the simple message is that there are lies in the workplace that we use to smooth the path or appease people, but they are still lies.&lt;/p&gt;
&lt;p&gt;
A Lucid Manager will make every effort to assist Matt through the interview process and would also be aware that there is a right or wrong answer to every question in a job interview—the solution that demonstrates suitability for the job.&lt;/p&gt;
&lt;p&gt;
A formalised job interview is counter-productive human interaction with limited predictive quality when it comes to getting to know a person. The artificial nature of the job interview does, however, prevent this process from being rational. Useful job interviews should be based on the presumption of equality between the recruiter and the applicant to espouse genuine conversations between the parties. It is the task of the recruiter to make the candidate feel comfortable and treat them as an equal conversation partner. Only this way will you be able to get to know the person on the other side of the table.&lt;/p&gt;
&lt;p&gt;
For more information and critique of personality profiles, confirmation bias and the Forer effect check out Peter&amp;#39;s essay, &lt;a href=&#34;https://lucidmanager.org/management/self-knowledge-for-managers/&#34;&gt;Know Thyself&lt;/a&gt;. Also check out Peter&amp;#39;s article on recruitment, arguing that every business gets the employees they deserve.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Generation Y Does not Exist</title>
      <link>https://lucidmanager.org/management/generation-y/</link>
      <pubDate>Fri, 28 May 2010 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/generation-y/</guid>
      <description>
	
&lt;p&gt;
Many articles about management discuss the so-called Generation Y. Authors analyse their motivations, lament their supposed high expectations and so on. This arbitrary dividing of people into generational cohorts is, however, counterproductive.&lt;/p&gt;
&lt;p&gt;
In my spare time, I occasionally perform &lt;a href=&#34;https://horizonofreason.com/categories/magic/&#34;&gt;magic shows&lt;/a&gt; for adults and children. Recently I was reading a booklet by David Kaye, who performs for children under the name &lt;a href=&#34;http://www.sillybillymagic.com/&#34;&gt;Silly Billy&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Through the so-called benefits of science—the impossible exploits of movie heroes, blood-curdling action stories in video games – the child is thrilled to such an extent that a magician’s bag of tricks becomes a poor substitute. All this has brought about another more malicious change. Fifteen or twenty years ago the average child was well-mannered, quiet and attentive. The magician had very little difficulty keeping them under control. Today it appears that those few exceptions have become the rule. Children are more ill-mannered. They have less respect for their elders and the conduct in public places is often far from commendable.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
This quote illustrates an often heard complaint about the younger generations. But there is more to this quote that meets the eye. Just like in a magic show, I have deceived you a little.&lt;/p&gt;
&lt;p&gt;
Eddie Clever wrote this paragraph in 1939! Kaye only changed “radio shows” to “video games” and all of a sudden the text looks as if it was written yesterday. We can go even further back to find similar concerns about the younger generations. There are records of Dutch priests in the 18th century lamenting the lewd and drunken behaviour of the young people in his parish. Have young people changed? People have not changed, it is us our perception of them that changes as we grow older.
Generation Y does not exist!&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Generation Y does not exist
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;This finding has a direct bearing on a concept that is frequently used in our cultural landscape and contemporary management: Baby Boomers, Generation X, Generation Y and other broad sweeping categorisations. In much of the management literature on this topic, authors proclaim that the young professionals of today are different from the way the authors themselves once were and should thus be treated differently.&lt;/p&gt;
&lt;p&gt;
There are distinct differences between age cohorts. As we go through the stages of life, we mature, and our priorities change. There are, however, no psychological differences between age groups in the past, present or future. Our psychological make-up does not evolve fast enough for us to notice any differences.&lt;/p&gt;
&lt;p&gt;
Sure, you can classify people by the era in which they were born, but to think that they are in any way psychologically different to the way Generation X or Baby Boomers were when they were at the same age as any evidence does not support generation Y. The perceived generational problem is only caused by a lack of the older generations to be able to understand the others.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Passive Aggressive Battle of the Disappearing Teaspoons</title>
      <link>https://lucidmanager.org/management/disappearing-teaspoons/</link>
      <pubDate>Fri, 21 May 2010 00:00:00 +0000</pubDate>
      <author>Ian Watson</author>
      <guid>https://lucidmanager.org/management/disappearing-teaspoons/</guid>
      <description>
	
&lt;p&gt;
It doesn&amp;#39;t matter how well-designed, functional or beautiful your office tea-room or kitchen is, it almost seems utterly useless if you can&amp;#39;t find a teaspoon. From time-to-time, someone will snap, and there will be a call to arms. The indignant party who leads the charge will usually be well-meaning and genuinely concerned about standing up for the rights of others needing to create a vortex in their hot beverage of choice.&lt;/p&gt;
&lt;p&gt;
Emails go out; complaints are lodged and, if the workplace culture is entirely wrong, painfully polite and hilariously, hostile passive aggressive notes will adorn the tearoom. After some weeks of torment, the intractable problem will be solved by buying some more spoons, but not before several people have walked around feeling guilty while the spoon crusaders end up muttering about never being listened to. All of this is avoidable once you understand the science behind spoon migration.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/EaKektjDIqE?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
30 Hillarous Passive Agressive Notes.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Science? Spoon Migration? Yes, it has been studied and published in the &lt;a href=&#34;http://www.bmj.com/&#34;&gt;British Medical Journal&lt;/a&gt;. A research study at the &lt;em&gt;Centre for Epidemiology and Population Health Research&lt;/em&gt; at the Macfarlane Burnet Institute for Medical Research and Public Health in Melbourne, Australia found that the half-life of teaspoons in their common tea room was 42 days.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
That&amp;#39;s right; it&amp;#39;s been studied by a group of epidemiologists and, to paraphrase and butcher their results, the conclusion is: communal teaspoons will eventually disappear. This research has sparked a range of possible management interventions, including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Don&amp;#39;t provide spoons&lt;/li&gt;
&lt;li&gt;Provide disposable stirrers&lt;/li&gt;
&lt;li&gt;Provide spoons on a heavy chain&lt;/li&gt;
&lt;li&gt;Just accept that people are going to take them and buy more spoons&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Do we defend the practice of stealing office property, regardless of how small, shiny and valueless it is? Of course not! We should, however, understand which fights are worth fighting. Or in the wise words of &lt;a href=&#34;https://lucidmanager.org/management/approaches-to-strategic-management/&#34;&gt;Sun Tzu&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;He will win who knows when to fight and when not to fight.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Priority of disappearing teaspoons
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;To provide a simple guide to where disappearing teaspoons fit into the scheme of things, consider the following list:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Occupational Health and Safety issues&lt;/li&gt;
&lt;li&gt;Working to gain multi-million dollar revenue streams&lt;/li&gt;
&lt;li&gt;Teaspoons&lt;/li&gt;
&lt;li&gt;Ensuring you&amp;#39;ve employed &lt;a href=&#34;https://lucidmanager.org/management/golden-rule-of-recruitment/&#34;&gt;the right people for the job&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Making sure your telecommunication systems are running effectively&lt;/li&gt;
&lt;li&gt;Ensuring your corporate image is one that &lt;a href=&#34;https://lucidmanager.org/marketing/sociological-imagination-in-marketing/&#34;&gt;appeals to consumers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that the list above could have been written in any order and the addition of teaspoons will always appear unworthy and unwelcome. The Battle of the Disappearing Teaspoons is not an important issue.&lt;/p&gt;
&lt;p&gt;
For the amount of time and effort, people will spend badgering other staff members about disappearing teaspoons, complaining, writing nasty notes and disrupting the workplace, based on epidemiological science, if you have a tearoom it is best to accept that you will regularly need to buy spoons. This one simple tip will help avoid a lot of the angst and pain of not being able to measure your morning caffeine dose accurately.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;He who knows when he can fight and when he cannot be victorious. He who knows when he can fight and when he cannot be victorious.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Lim, Megan S C and Hellard, Margaret E and Aitken, Campbell K (2005) The case of the disappearing teaspoons: longitudinal cohort study of the displacement of teaspoons in an Australian research institute. &lt;em&gt;BMJ&lt;/em&gt; (331)7531: p. 1498–1500. doi: &lt;a href=&#34;https://doi.org/10.1136/bmj.331.7531.1498&#34;&gt;10.1136/bmj.331.7531.1498&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Make Time Poverty History! The Cult Busy and the Time Poor</title>
      <link>https://lucidmanager.org/productivity/time-poverty/</link>
      <pubDate>Fri, 14 May 2010 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/productivity/time-poverty/</guid>
      <description>
	
&lt;blockquote&gt;
&lt;p&gt;Good morning Agnes, how are you? You know how it is, busy, busy, busy … Have you read my latest proposal? No sorry, I am very time poor.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
As affluence has spread across Australia and parts of the rest of the world, time seems to be the new frontier of poverty. When asking the average professional what is happening in their life, the word &amp;#39;busy&amp;#39; is frequently uttered. If they seek your sympathy, they use the superlative neologism &amp;#34;&lt;em&gt;Time Poor&lt;/em&gt;&amp;#34;. This article discusses how we can make time poverty history.&lt;/p&gt;
&lt;p&gt;
The underlying message is that, although these time poor people are financially wealthy, we should feel sorry for them as they equate themselves with the poor people of the world. They are, however, not poor cash poor, but time poor. We need to establish a charity and sell white sympathy &lt;a href=&#34;https://en.wikipedia.org/wiki/Make_Poverty_History&#34;&gt;wristbands&lt;/a&gt;.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Make Time Poverty History!
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Time Poverty is, however, more often than not a self-induced state of mind and not an actual state of affairs. It is not about a factual lack of available time, but the perception of a lack of available time. Being time poor and being busy has almost become a status symbol in what Scott Berkun describes as the &lt;em&gt;Cult of Busy&lt;/em&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;#34;That simply by always seeming to have something to do, we all assume you must be important or successful. It explains the behaviour of many people at work. By appearing busy, people bother them less, and simultaneously believe they &amp;#39;re doing well at their job.&amp;#34;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
For some strange reason, as Berkin points out, a manager with a long line of people at her door will command respect, but a long line at a supermarket register breeds frustration.&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;Cult of Busy&lt;/em&gt; has a large following and has spawned numerous courses and books for managers seeking to squeeze more productive minutes out of a day. A manager I worked with some years ago suffered from extreme time poverty. He was always busy but never seemed to achieve much. He decided to sign up for a time management course. Unfortunately, he was so busy that he forgot to attend the class! &lt;/p&gt;
&lt;p&gt;
Being busy is a status symbol for the ostensibly successful manager. If you are not busy or if you have enough spare time to speak to people, you are obviously not very good at what you do, is the subconscious reasoning.&lt;/p&gt;
&lt;p&gt;
Some people attempt to alleviate their time poverty by trying to &lt;a href=&#34;https://lucidmanager.org/management/myth-of-multitasking/&#34;&gt;multi-task&lt;/a&gt;, but that only leads to suboptimal outcomes because our brains are just not wired to project our attention to more than one thing simultaneously. Yes, you can do something physical and mental at the same time, but you cannot spread your psychological attention across two mental tasks. So leave your laptops closed at meetings unless you take notes about the proceedings.&lt;/p&gt;
&lt;p&gt;
Sadly, accompanying the new Cult of Busy is also an abundance of guides available to support this hyperactive charade. &lt;a href=&#34;http://www.wikihow.com/Look-Busy-at-Work-Without-Really-Working&#34;&gt;WikiHow&lt;/a&gt; even provides a comprehensive program for those who want to join the ranks of the apparent time poor:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Know what the standards are (so you meet them).&lt;/li&gt;
&lt;li&gt;Create the illusion of furious activity (somewhat messy desk, lots of
windows open on your computer, post-it notes around the monitor).&lt;/li&gt;
&lt;li&gt;Ask lots of intelligent questions to make each task appear more
complicated than it is.&lt;/li&gt;
&lt;li&gt;Be alert and watch out for &amp;#39;big brother&amp;#39;.&lt;/li&gt;
&lt;li&gt;Carry a backup prop or document and make sure you have a cover story
ready.&lt;/li&gt;
&lt;li&gt;Send packages to yourself with documents to &amp;#39;review&amp;#39;.&lt;/li&gt;
&lt;li&gt;Have personal conversations and phone calls away from your workspace.&lt;/li&gt;
&lt;li&gt;Don&amp;#39;t brag to anyone that you&amp;#39;re doing any of the above.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In contrast, a lucid manager is never time poor but takes control over the available time to them. A Lucid Manager might have a lot to do but rarely says &amp;#34;I don&amp;#39;t have time&amp;#34; or &amp;#34;I am busy&amp;#34;. A Lucid Manager &lt;a href=&#34;https://lucidmanager.org/productivity/clear-your-head/&#34;&gt;works efficiently&lt;/a&gt; and does not choose to live in false poverty but leads a productive life full of achievement.&lt;/p&gt;
&lt;p&gt;
Next time when you are very busy, and somebody asks a question, don&amp;#39;t brush them off by saying your busy but listen to their needs.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Blood, Sun Tzu and the Four Approaches to Strategic Management</title>
      <link>https://lucidmanager.org/management/approaches-to-strategic-management/</link>
      <pubDate>Wed, 12 May 2010 13:56:03 +0000</pubDate>
      <author>Ian Watson</author>
      <guid>https://lucidmanager.org/management/approaches-to-strategic-management/</guid>
      <description>
	
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/management/strategic-management-and-business-performance/&#34;&gt;Strategic management&lt;/a&gt; is often compared with warfare. Humans have had, and sadly still appear to have, a profoundly disturbing need to settle conflict using armed warfare. While stories of the battle abound in prose, poem, song and cinema, there is usually only a glib allusion to the thought and preparation made before the slaughter itself. Though premeditation before the wholesale murder is an unsavoury concept, it is from this conscious anticipation of brutality that the art of strategy was born; to save oneself and one&amp;#39;s friends at the expense of foes.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Sun Tzu and Strategy
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;An often translated and studied treatise on strategy is that of a Chinese General from around 2600 years ago named Sun Tzu.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; Though this is one of the earliest known documented manuals on the topic of strategy, it is likely that military strategy pre-dated Sun Tzu. Initially, mainly when applied to the military, the desired outcome of a well-executed strategy was to gain an advantage over others at their expense. As applied to business in the modern era, strategy is becoming more often used to gain competitive advantage while benefiting all involved in the value chain. A positive outcome may also be obtained for one&amp;#39;s competitors as long as a sustainable competitive advantage is maintained for oneself.&lt;/p&gt;
&lt;p&gt;
A single definition of strategy simply doesn&amp;#39;t exist. With each commentator on the topic of strategy, there appears to be an accompanying definition. An excellent definition described by Colin White (2004) and de Wit and Meyer (1998) is any course of action for achieving an organisation&amp;#39;s purpose(s).&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-2&#34; href=&#34;#footnote-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; This is an all-encompassing definition that includes all of a businesses&amp;#39; productive activity, and it is this definition that will be used for this essay.&lt;/p&gt;
&lt;p&gt;
Having provided the general purpose and definition of strategy, this essay will describe four approaches that may be taken to making strategy. Additionally, it will be argued that without a healthy workplace culture, elements of the four approaches are likely to be used within a single organisation.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/mba/paris-hilton-art-of-war.jpg&#34; alt=&#34;Paris Hilton reading Sun Tzu and learning about Strategic Management&#34; title=&#34;Paris Hilton reading Sun Tzu and learning about Strategic Management&#34;/&gt;
&lt;figcaption&gt;
Paris Hilton reading Sun Tzu and learning about Strategic Management.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Approaches to Strategic Management
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Developing a strategy is described most commonly in literature as being based on the way in which the process of strategy is developed and the desired outcome of that strategy. The process of &lt;a href=&#34;https://lucidmanager.org/management/strategic-management-and-serendipity/&#34;&gt;strategy development&lt;/a&gt; is either deliberate or emergent (or adaptive) while the desired outcome is to maximise profit or to achieve multiple purposes (plural).&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-3&#34; href=&#34;#footnote-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
These form a matrix of four basic approaches to strategic management that may be taken to make a strategy. The four approaches to strategic management are Classical, Evolutionary, Systemic and Processual, each of which is described in detail below.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Classical
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The classical approach to strategy making is the deliberate process of developing a strategy to maximise profit. This approach, though described as classical, was mainly developed and propounded by management strategists in the 1960s such as Igor Ansoff and Alfred Sloan. Sloan, the former chief of General Motors, was credited with much of the organisation&amp;#39;s early success predominantly due to his approach of thoughtful examination of the internal and external environment and then developing a strategy to direct resources to meet the company&amp;#39;s long-term goals. The long-term aim of the classical approach to strategy is precisely to make a profit, and this is best summed up in Sloan&amp;#39;s words from his biography;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The strategic aim of a business is to earn a return on capital, and if in any particular case the return in the long run is not satisfactory, the deficiency should be corrected or the activity abandoned. (Richard Whittington, 2001).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
This very rational approach has advantages where a change in markets and the industry move relatively slowly and where reasonable confidence can be achieved in long-term financial modelling. The classical approach relies on the strategic capability being concentrated in the organisational leader and his or her ability to suitably commanding the organisation. For this reason, particularly due to cognitive limitations in decision making by individuals, many organisations are adopting an approach that, while focusing on business profitability, acknowledges the dynamic processes acting upon and within the organisation.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Evolutionary
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The evolutionary approach to strategy is based on the view that the organisation is operating within an economic environment that is ever changing. The role of strategy, in this case, is to respond to the environment for survival and profit. The main reason that this process is known as evolutionary is that it is similar to Darwinian theory in biology where only those individuals, or in this case strategies, best equipped to survive environmental or economic pressures do so (Colin White, 2004). An example of this is the strategy of Sony during the 1980s where they released well over 100 different versions of their portable cassette player, the Walkman, and allowed the market to decide which would survive and which would be removed from the market through failure.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Processual
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The processual view is that the business environment is messy and largely unpredictable (Richard Whittington, 2001). Additionally, with this approach, there is an acknowledgement that decision-makers cannot act with pure reason and that only a few factors affecting a decision can be dealt with. This limitation of human cognition is known as bounded rationality (Simon, 1982).&lt;/p&gt;
&lt;p&gt;
To make sense of the &lt;a href=&#34;https://lucidmanager.org/management/strategic-management-and-serendipity/&#34;&gt;chaos of the world&lt;/a&gt; in which the organisation operates, managers develop models, or processes, to help make decisions. These models are known to be imperfect representations of the complicated world but the help the strategist to identify and quickly respond to forces acting upon the organisation. The models that are used for decision-making may be explicit and documented or cognitive.&lt;/p&gt;
&lt;p&gt;
Ultimately, because there is an acceptance that the world is messy and unpredictable, it is accepted that maximising profit is not within the control of the strategist and sufficient profit becomes the goal. To achieve this, there is also a  prevalence of satisficing in environments which are tolerant of under-performance (Colin White, 2004) where the decision maker looks for a satisfactory, rather than an optimal, alternative.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-4&#34; href=&#34;#footnote-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Systemic
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The systemic approach is taken by those that understand the need to play by the local rules (Richard Whittington, 2001). The cultural context is key to the development of the strategy. This may be a function of the way that a family culture influences a business or may also be influenced by the local cultures with different levels of uncertainty avoidance, power distance, collectivism, masculinity (Hofstede, 1983) and long-term vs short-term orientation. The systemic approach toward strategy is the deliberate development of a strategy to meet cultural and societal needs while maintaining sufficient profit.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Inevitable co-existence of multiple approaches
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In determining which approach to strategy-making will be taken within an organisation, it is important first to understand who the strategist or strategists are within the organisation. The classical approach commonly has the organisational leader as the source of strategy development and the driver of strategy implementation. The more modern approach is not
only the acceptance but the goal of engaging everybody in an organisation as a strategist.&lt;/p&gt;
&lt;p&gt;
An organisation is not a single entity but is instead made up of numerous individuals that hold different views of labour, economics, planning and the organisation&amp;#39;s goals. Though it is the role of the strategists within an organisation to align their activities to achieve the organisation&amp;#39;s goals, even under optimal conditions, this will be incomplete.&lt;/p&gt;
&lt;p&gt;
It may also be possible that this may not be in the best interests of the organisation to have all of the strategists of one mind. While a managing director or president or chief executive may propound to deliberately and methodically plan a long-term strategy to deliver profits to the organisation, it is the line managers that will usually develop decision-making models that will help respond to the changing environment. It may also be the case that a work-group is operating within a different society or culture and though they do deliberately plan but also understand that they need to play by local rules. Throughout this, each strategy that develops either succeeds or fails and the strategy of the organisation evolves.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Conclusion
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;It is because an organisation has many working within it that opinions and approaches will differ towards strategy. Co-existence of multiple approaches to strategic management is inevitable without the development of either a powerful organisational culture, a human resource monoculture or extremely prescriptive management, such as in the armed forces. For this reason, it is likely that a single approach will never occur, but within an organisation, it is likely that more than one approach to strategy will be represented.&lt;/p&gt;
&lt;p&gt;
Regardless of the approach taken, the judgement of the success of a strategy is measured by whether the desired outcomes have been achieved. In examining and using strategy within the business, we may consider ourselves fortunate that these outcomes require no bloodshed; the original reason that strategy was first developed.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
Notes
&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Wing, R.L. (1997) &lt;em&gt;The Art of Strategy: The Leading Modern Translation of Sun Tzu&amp;#39;s Classic The Art of War.&lt;/em&gt; Thorsons.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-2&#34;&gt;&lt;a href=&#34;#footnote-reference-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;White, C (2004) &lt;em&gt;Strategic Management&lt;/em&gt;. Palgrave Macmillan; De Wit, B. and Meyer, R. (1994) &lt;em&gt;Strategy: Process, Content, Context&lt;/em&gt;, West Publishing, New York.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-3&#34;&gt;&lt;a href=&#34;#footnote-reference-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Whittington, R (2001) &lt;em&gt;What is Strategy and Does it Matter&lt;/em&gt; Cengage Learning.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-4&#34;&gt;&lt;a href=&#34;#footnote-reference-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Simon, H. A. (1982) &lt;em&gt;Models of Bounded Rationality&lt;/em&gt;. The MIT Press, Cambridge, MA.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Theory and Practice of Management Humbug, Buzzwords and Fads</title>
      <link>https://lucidmanager.org/management/theory-and-practice-of-management/</link>
      <pubDate>Fri, 29 Jan 2010 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/theory-and-practice-of-management/</guid>
      <description>
	
&lt;p&gt;
One of the grave problems in the theory and practice of management is the dominance of buzzwords, fads and humbug. Just a quick look at the management section in the local bookshop will prove this point. &lt;a href=&#34;https://horizonofreason.com/culture/management-philosophy/&#34;&gt;Management thinkers&lt;/a&gt; are possibly some of the most influential people of the current age. They influence, for better or worse, the lives of millions of people and have even spawned a separate language, flushed with &lt;a href=&#34;https://lucidmanager.org/management/buzzword-bingo/&#34;&gt;buzzwords&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
Management thinking is, due to its very nature, entrepreneurial and everybody who has an idea wants to ensure that as many people as possible read it and perhaps make a few bucks in the process. More than any other science, management ideas are primarily developed to make money, and people are willing to pay good money for them, as innovative ideas can significantly impact the bottom line.&lt;/p&gt;
&lt;p&gt;
This article briefly reviews the relationship between theory and practice in management in light of the dominance of pseudoscience in business.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Theory and Practice of Management
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;A problem with the theory and practice of management is that solid scientific research does not underpin many management theories. As a working manager, you need to be equipped with a pretty good &amp;#39;bullshit radar&amp;#39;. Looking around the management section of the average bookshop the volumes on sale do not seem to meet the rigour of academic research. Popular management books give you &amp;#39;simple solutions&amp;#39; to success. &lt;em&gt;Good to Great&lt;/em&gt; by Jim Collins is one of the best selling volumes in this genre.&lt;/p&gt;
&lt;p&gt;
The Business Pundit blog provides an excellent critique of Collins&amp;#39; pseudo-scientific writing. The book is touted to be based on solid scientific analysis of data, but in fact, relies mostly on Jim&amp;#39;s intuition (p. 11):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;#34;We all have a strength or two in life, and I suppose mine is the ability to take a lump of unorganized information, see patterns, and extract order from the mess - to go from chaos to concept.&amp;#34;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Collins did not use any advanced statistical analysis of the data, and there are no indications of the validity of his findings. Although he repeatedly emphasises the data, his interpretation of the data is not scientific but based on intuition. There is nothing wrong with using intuition to make &lt;em&gt;specific&lt;/em&gt; &lt;em&gt;decisions&lt;/em&gt;, but you can not call it science and generate &lt;em&gt;general rules&lt;/em&gt; for good business management unless findings have a solid foundation. &lt;a href=&#34;https://lucidmanager.org/data-science/analyse-enron-corpus/&#34;&gt;Enron&lt;/a&gt;, one of the
companies that according to Collins went from Good to Great, but after the Global Financial Crisis, it quickly became apparent that Enron&amp;#39;s success was just smoke and mirrors.&lt;/p&gt;
&lt;p&gt;
The reason pseudo-scientific books like &lt;em&gt;Good to Great&lt;/em&gt; are bestsellers is that our brains are not naturally wired to be critical thinkers. The success of a lot of business literature is based on &lt;a href=&#34;http://en.wikipedia.org/wiki/Confirmation_bias&#34;&gt;confirmation bias&lt;/a&gt;. We prefer information that confirms our preconceptions. Also, most popular management theory does not go beyond self-fulfilling prophecy, and broad sweeping general statements and its popularity is in essence based on the same psychological principle that explains the success of astrology and other forms of divination.&lt;/p&gt;
&lt;p&gt;
Another problem is that the average manager does not have the capability or motivation to understand elaborate theories that underpin human behaviour fully. Managers don&amp;#39;t want to read complicated scientific theories. Good advice to those who seek to write a management best seller is to stay away from using any sophisticated analysis.&lt;/p&gt;
&lt;p&gt;
Management is, in essence, a social science that aims to influence human behaviour to achieve a collective goal, whether that be increasing profit or creating a great piece of orchestral music. Management seeks to change the behaviour of customers to convince them to purchase goods or services. Management tries to influence employees to ensure goal-oriented behaviour. Management theory is also about influencing or anticipating the behaviour of the external world, i.e. the stakeholders and possible competitors.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Nothing More Practical than a Good Theory
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;As a social science, management does not follow the strict rules of the natural sciences. There are no simple formulas to ensure staff motivation, increases sales volumes or assuring customer satisfaction. Management is about human behaviour, which is intrinsically unpredictable. Collins and other popular management writers do not use scientific methods, but there are natural limits to what the scientific method can achieve in management. All we can hope to achieve is to develop statistical models. These models do, however, not produce simple statements about friendly concepts such as &amp;#39;Level 5 Leadership&amp;#39; and the &amp;#39;Hedgehog principle&amp;#39;. At best, the scientific analysis provides partial insights into a very specific phenomenon instead of the organisation as a whole.&lt;/p&gt;
&lt;p&gt;
There are also too many practical and ethical issues with undertaking full-scale management experiments that would be required to make the sort of claims that Collins promoted in &lt;em&gt;Good to Great&lt;/em&gt;. Merely looking at sets of data from the past can not generate such claims because there are too many confounding variables that are not covered by the data. In other words: the principles distilled by Collins might not be the only reasons these hand-picked companies were successful.&lt;/p&gt;
&lt;p&gt;
Scientific theories do, however, remain an essential tool to regulate our intuition. Before we had a consistent theory of gravity, architects were very limited by the size of buildings they could create. As our theoretical and practical knowledge of physics increased, so did the size and complexity of structures. A theory is required to propel human knowledge and even though management is many times more complicated than skyscrapers, using only intuition will not improve our understanding of managing organisations.&lt;/p&gt;
&lt;p&gt;
In conclusion, because management is a social science, we can not rely on theoretical models alone. Working with people requires insight and intuition that can only be obtained by life experience. However, theory underpins our intuition, and in the end, there is nothing more practical than a good theory.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Water Privatisation and its effects on Customer Satisfaction</title>
      <link>https://lucidmanager.org/marketing/water-privatisation/</link>
      <pubDate>Thu, 05 Nov 2009 00:00:00 +0000</pubDate>
      <author>Peter Prevos &amp; Ian Watson</author>
      <guid>https://lucidmanager.org/marketing/water-privatisation/</guid>
      <description>
	
&lt;p&gt;
The supply of water and sanitation in urban areas has historically been dominated by public investments. Aqueducts in ancient Rome and other major cities in the empire we funded by public money. Nineteenth-century London started water privatisation made a significant public investment in a sewer system to rid the city of the 200,000 cesspools that caused many diseases that plagued the city (Cadbury 2003).&lt;/p&gt;
&lt;p&gt;
These developments eventually led to the establishment of fully vertically integrated government-owned monopolies in water and sanitation services. These monopolistic service providers have repeatedly been criticised for being inefficient and lacking &lt;a href=&#34;https://lucidmanager.org/marketing/balanced-centricity/&#34;&gt;customer focus&lt;/a&gt; (Deichmann and Lall 2007). The past two decades, there has been a gradual transition of ownership of utility companies from public to private ownership. Private corporations are now actors in about half the countries of the world in some fundamental dimension of service delivery in the utility sector. This trend is increasing and is currently extending to the water and sanitation sectors (Estache et al. 2005).&lt;/p&gt;
&lt;p&gt;
This paper discusses the rationale behind the recent wave of water privatisation in water and sanitation service provision. This is done with specific reference to service quality. The water and sanitation supply chain are examined to determine likely points of entry for competitive privatisation. It is proposed that the provision of retail services is an area in which market forces can be used to improve service to customers. A review of effects of privatisation on service quality is presented, based on extant literature on the topic and literature on service marketing theory.&lt;/p&gt;
&lt;p&gt;
A conceptual model is presented to facilitate further research on the mechanisms that influence customer satisfaction due to ownership structure. It is argued that &lt;em&gt;managerial behaviour&lt;/em&gt; is dependent upon ownership structure and a major determinant of the level of service quality.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
The Case for Water Privatisation
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;One of the often cited reasons that water distribution networks are in public control is because they are considered a natural monopoly (DiLorenzo 1996). A natural monopoly occurs when, &amp;#34;due to the economies of scale of a particular industry, the maximum efficiency of production and distribution is realised through a single supplier&amp;#34; (DiLorenzo 1996:
43).&lt;/p&gt;
&lt;p&gt;
The high level of investment required to construct water distribution and sanitation networks creates a natural barrier to entry for more than one firm to operate in the same geographic area. Natural monopolies are considered unsuitable for a competitive market because of the duplication of facilities required to service individual customers in the same area (Hart et al. 1997). Natural monopolies exist in most markets for networked services, such as telecommunication, transport (particularly rail and harbours), electricity, gas and water supply (DiLorenzo 1996).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;#34;The most important single central fact about a free market is that no exchange takes place unless both parties benefit.&amp;#34;&lt;/p&gt;
&lt;p&gt;
&lt;a href=&#34;https://lucidmanager.org/management/milton-friedman-corporate-social-responsibility/&#34;&gt;Milton Friedman&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Natural monopolies in water and sanitation services are also widespread because of the so-called diamond-water paradox, expressed by Adam Smith as the &lt;em&gt;Paradox of Value&lt;/em&gt; (Robertson and Taylor 1957). This is the assertion that some commodities without value in use, such as diamonds, have a high value in exchange and vice versa, water has a high use value, but demands a low price (Levy 1982). Although water is more critical to survival than diamonds, this is not reflected in pricing.&lt;/p&gt;
&lt;p&gt;
Water is used for many purposes and in the case of reticulated water
supply, the same water is used for drinking, hygiene, gardens and as a
transport medium for waste. Economic theory suggests that the price of a
product is determined by its marginal utility, i.e. its least important
use to a person (Levy 1982). In the case of water, this is reflected in
the difference in price between tap water and bottled water. Consumers
in Australia are willing to pay more than 1000 times the price of tap
water for a bottle of drinking water, although the quality is
essentially the same.&lt;/p&gt;
&lt;p&gt;
The low value of reticulated water implies that providing this type of
service generates very low margins for the investor. Significant amounts
of assets are required to deliver this service to a customer, but the
price that can be commanded is very little. This makes reticulated water
and sanitation supply particularly economically uninteresting for
private suppliers and is thus dominated by monopolistic publicly owned
service providers.&lt;/p&gt;
&lt;p&gt;
Because of the natural monopoly characteristics of water and sanitation
services, privatisation has seen some monopolistic segments in the
industry transferred to private operators (Estache et al. 2005). One
means by which governments attempt to negate the disadvantages of
monopolised state-owned service providers is through regulation.
Regulation usually takes the form of market mimicking regimes in which
service providers compete with each other through performance
benchmarking. In this system, utilities are &amp;#34;forced to compete with a
shadow-firm whose performance is determined by average or best practice
in the industry&amp;#34; (Braadbaart 2007: 680).&lt;/p&gt;
&lt;p&gt;
Research in the Netherlands shows that this type of benchmarking
enhances economic performance. There is a clear case for yardstick
competition (Estache et al. 2005; Tupper and Resende 2004). Yardstick
competition is, however, not a sine qua non for performance enhancement.
Also, collaborative rather than competitive, benchmarking has a positive
effect on utility performance (Braadbaart 2007). Regulation is
appropriate if firms have incentives to reduce costs and minimise the
level of service provision. The incentive to reduce cost is considered a
potential negative consequence of privatisation (Fumagalli et al. 2007).
Partly privatised utilities subject to service quality regulation
maintain incentives towards high levels of quality (Fumagalli et al.
2007).&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Status of Water privatisation in the World
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Most water and sanitation service are currently provided by publicly
owned organisations (Deichmann and Lall 2007; Estache et al. 2005).
However, in several countries around the world different modes and
levels of privatisation of water and sanitation services have been
implemented. The privatisation of state-owned utility service providers
has been most prominent in developing countries because the opportunity
cost of maintaining government-owned enterprises over private ownership
is higher than in developed countries (Deichmann and Lall 2007).&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/PrivateParticipation.jpg&#34; alt=&#34;Presence of the private sector in water and sanitation&#34; title=&#34;Presence of the private sector in water and sanitation&#34;/&gt;
&lt;figcaption&gt;
Presence of the private sector in water and sanitation (Estache et al. 2005).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The privatisation of state-owned utility providers is partially driven
by the World Bank. The privatisation conditions of reforms funded by the
World Bank is the privatisation of formerly state-owned enterprises
(Tsamenyi et al. 2008). Water privatisation is, however, a broad
sweeping term that can encompass a range of different models in
different parts of the supply chain, which is discussed in more detail
below. Broadly speaking, privatisation is part of the supply chain of
water and sanitation supply in around 35% of the countries of the
developed world and 80% of the countries in the developing world.&lt;/p&gt;
&lt;p&gt;
Estimates show that nearly half of the urban population in African
nations rely on private providers for water service (Auriol and Picard
2008). Research on the efficiency of private operators in this continent
shows that they are more cost-efficient and that corruption reduces
efficiency and matters more than ownership. However, no significant
difference between public and private operators is found once
environmental factors have been accounted for (Estache et al. 2005).&lt;/p&gt;
&lt;p&gt;
In 1989, Argentina initiated a process of privatising infrastructure
services, including water and sanitation (Chisari et al. 1999). Services
were privatised because of a need to alleviate the financial burden
imposed by public utilities. Before services were privatised, the
existing organisations were vertically disintegrated. In the water
sector, competition has been introduced through a bidding process.
Between 1993 and 1994, privatisation of water distribution resulted in a
4.9% reduction in inputs purchased as a share of total sales. The size
of the population served per staff member decreased by 27.6%, i.e. the
total number of employees increased.&lt;/p&gt;
&lt;p&gt;
Water efficiency, measured as distribution losses, improved over this
period. Lastly, the cost of water to consumers grew by 5.5 %. Overall,
privatisation of utilities in Argentina has increased labour
productivity, but higher cost for customers, while lowering cost for the
utility providers (Chisari et al. 1999). In Brazil, it was found that
there is no significant difference between public and private operators
regarding their productivity (Estache et al. 2005).&lt;/p&gt;
&lt;p&gt;
In 1989, the government sold ten publicly owned water/sanitation
companies in England and Wales and established a new, independent sector
regulator (van den Berg 1997). The regulator controls both water and
sanitation utilities with the aim to protect customers&amp;#39; interests
(Seppälä et al. 2004).&lt;/p&gt;
&lt;p&gt;
Water and sanitation service provision in the Australian state of
Victoria is fully in public hands, with many activities outsourced to
private partners. All state-owned service providers are regulated by the
Essential Services Commission. The Victorian government is currently
investigating means to increase private participation in the provision
of water and sanitation services through so-called Third Party Access
(Essential Services Commission 2009).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
General Arguments for Water Privatisation
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The public ownership model has been criticised because of a perception
that services provided by these institutions are often inadequate and
few utilities are able to recover the full cost as pricing is often
politically motivated (Deichmann and Lall 2007). The general argument
against public ownership of utility service providers is that public
services lack Adam Smith&amp;#39;s &amp;#39;invisible hand&amp;#39; to guide resource allocation
based on consumer preferences (Andreassen 1994). The regulator for water
and sewerage services in Victoria, Australia has expressed the
anticipated advantages of privatisation succinctly (Essential Services
Commission 2009: 9, emphasis added):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;More efficient allocation of resources (allocative efficiency);&lt;/li&gt;
&lt;li&gt;Efficiency and productivity improvements, leading to lower costs of
providing products and/or services from existing input sources,
processes and technologies (productive efficiency);&lt;/li&gt;
&lt;li&gt;Longer term efficiency and productivity improvements, with lower costs
and improved service quality arising from new and improved input
sources, processes and technologies (dynamic efficiency) and;&lt;/li&gt;
&lt;li&gt;Greater customer choice, with innovative offerings of products and/or
services that better reflect customer needs and preferences.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;DiLorenzo (1996) argues that the often proclaimed natural monopolies in
utility services are an economic fiction and their development was an
ex-post rationale for government intervention. There is, according to
DiLorenzo (1996), no evidence that a natural monopoly, i.e. one firm
achieving lower long-run average total cost than other companies, in the
industry thereby establishing a permanent monopoly, ever existed. The
existence of economies of scale in water and other public utilities does
not necessitate a monopoly because competitive and market forces will
naturally regulate an industry (DiLorenzo 1996).&lt;/p&gt;
&lt;p&gt;
Hart et al. (1997) point out that private suppliers deliver public
services at a lower cost than public providers. Public ownership of
utilities is generally viewed as generating inefficiencies because of
soft budget constraints as governments will subsidise money-losing
ventures. Empirical data from the United States shows that publicly
owned water utilities had higher costs than their privately owned
counterparts (Estache and Rossi 2002). The transfer from public to
private ownership is thus often advocated as a solution for the poor
economic performance of utility companies (Auriol and Picard 2008). The
economic arguments over efficiency in relation to ownership are,
however, not conclusive as some research indicates that there are no
statistically significant differences in efficiency between water
corporations, regardless of their ownership structure (Bakker 2007;
Estache and Rossi 2002).&lt;/p&gt;
&lt;p&gt;
Economic theory suggests that a privately owned monopolist will
over-invest in cost reduction if the quality of their service is not
regulated (Hart et al. 1997). This decrease in investment can have
negative consequences on service quality as investment and service
quality are closely related to the provision of utilities. Although it
can be shown that both private and public monopolists are equally likely
to under-invest in quality enhancements, publicly owned utility
providers will deliver a higher quality because there is no managerial
incentive to reduce cost (Fumagalli et al. 2007; Hart et al. 1997).&lt;/p&gt;
&lt;p&gt;
The case for government-owned service provision is generally stronger
when cost reductions are likely to reduce service quality, when quality
innovations are unimportant, and when corruption in government
procurement is a severe problem (Hart et al. 1997). In contrast, the
case for water privatisation is stronger when quality reducing cost
reductions can be controlled through regulation or by competition (Hart
et al. 1997).&lt;/p&gt;
&lt;p&gt;
Initiatives to privatise state-owned enterprises are often based on the
assumption that in private industry, managers have greater freedom to
set a corporate strategy and raise capital as is the case in publicly
owned organisations (Andreassen 1994; Fumagalli et al. 2007). Water
corporations require incentives to act in the public interest and to
ensure that managerial behaviour is disciplined. These incentives can be
provided through the introduction of competition (Andreassen 1994;
Deichmann and Lall 2007; Fumagalli et al. 2007).&lt;/p&gt;
&lt;p&gt;
Services delivered by publicly owned institutions are often considered
inadequate, few utilities are able to recover full cost and pricing is
politically motivated (Deichmann and Lall 2007). One of the main issues
identified by proponents of increased private business involvement in
the provision of utilities is that publicly owned services are not
subject to market forces (Fumagalli et al. 2007). Porter (1990) claims
on a macroeconomic level that corporate strategy, industry structure and
rivalry and demanding customers will stimulate service providers to
focus on the market.&lt;/p&gt;
&lt;p&gt;
To offer a high level of utility, the public sector must be more
marketed oriented, i.e. supply more differentiated services (Andreassen
1994). Privatised energy companies are improving their market position
by being more customer oriented and focusing on
&lt;a href=&#34;https://lucidmanager.org/marketing/water-utility-branding/&#34;&gt;branding&lt;/a&gt; in response to increased competition (Hartmann and Ibáñez 2007). The
principal objective of a Marketing Orientation is to provide a long-term
profit focus through three behavioural components (Narver and Slater
1990):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Customer orientation: Understanding customer&amp;#39;s needs to be able to
create superior value;&lt;/li&gt;
&lt;li&gt;Competitor orientation: Understanding the short and long-term
strengths and weaknesses of competitors; and&lt;/li&gt;
&lt;li&gt;Interfunctional coordination: Leveraging collective resources to
create value.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There has been strong opposition to the introduction of market forces in
water supply. The main argument being that water should be considered a
human right and not as a tradeable commodity. Water is regarded as a
human right as it is not substitutable and intrinsically linked with
other human rights, such as the right to life (Bakker 2007). These
arguments do, however, not preclude commercialisation of water supply
services because many other human rights are underpinned also by private
business involvement, e.g. the right to life and the food industry.
Another line of thought used to argue against commercial influences in
the supply of water is environmentally grounded.&lt;/p&gt;
&lt;p&gt;
Private companies are answerable to shareholders that seek profit
maximisation and will thus not be able to provide long-term sustainable
water supply solutions (Bakker 2007). However, market forces in water
services use the scarcity of water as a starting point and enforce that
it must be priced at the full economic and environmental cost, rather
than political pricing adopted in many jurisdictions. Using market
pricing will ensure that water is allocated to its highest value use
(Bakker 2007).&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Types of Water Privatisation
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;There are many levels at which participation of privately owned industry
can be achieved. Bakker (2007) identified three categories of resource
management reform and seven possible means to achieve this. Property
rights can be privatised in the form of riparian rights or the sale of
water supply infrastructure to the private sector. Deregulation can
occur where, for example, the state ceases direct control over water
quality mechanisms (Bakker 2007). Organisational types of reform
opportunities exist in using private sector partnerships, where
governments purchase a service instead of an asset (Auriol and Picard
2008).&lt;/p&gt;
&lt;p&gt;
The corporatisation of organisational structures is the conversion of
the business model from a local government to a publicly owned
corporation. The governance of resources can be reformed by
marketisation through the introduction of a water market and
commercialisation through the introduction of commercial principles in
water management. Lastly, (Bakker 2007) proposes decentralisation and
the subsequent introduction of community managed utility services as a
reform option. All these types of water privatisation can occur at
multiple places in the supply chain of water and sanitation services.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
The Water and Sanitation Service Supply Value Chain
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The supply of water and sanitation services has a circular supply chain
that is deeply connected with the natural environment (Figure 3.1).
Water is mostly sourced from rivers, groundwater, or more increasingly,
seawater. The so-called &amp;#39;raw water&amp;#39; can be distributed directly to
customers or treated to a higher level of quality, depending on customer
preferences. The sanitation supply chain starts with the collection and
transportation of wastewater from customers.&lt;/p&gt;
&lt;p&gt;
The wastewater is treated to a suitable standard and either
reincorporated in the natural water cycle or sold to other customers
(Figure 3.1). All these activities typically occur within a single
organisation with the supply chain only being interrupted by the brief
time that the water is being used at the customer&amp;#39;s property. The water
and sanitation industry particularly, where government-owned, is an
example of complete vertical integration. In most cases, water is
harvested or created, stored, treated, transported and retailed without
the intervention or involvement of external parties.&lt;/p&gt;
&lt;p&gt;
The supply chain for water and sanitation has some characteristics in
common with that of agricultural commodities. Both water and
agricultural commodities are harvested at particular times throughout
the year that does not necessarily match up with the demands patterns of
customers. The weather also plays a critical role in determining the
total yield of the harvest. The product must be stored so that demand
and supply can be matched. In agriculture, the commodity is stored in
silos, and in the water industry, it is stored in tanks, dams, the
reticulation network and aquifers.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/water-utility-supply-chain.png&#34; alt=&#34;Water and sanitation supply chain&#34; title=&#34;Water and sanitation supply chain&#34;/&gt;
&lt;figcaption&gt;
Water and sanitation supply chain.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
There is a significant difference between agriculture and water supply
chains in the mechanism used to meet consumer demand from the point of
storage. Agricultural commodities are shifted in discrete units or
bundles via road, rail and marine transport. Water is most commonly
supplied continuously to the customer via pipework directly into the
customer&amp;#39;s house. The service is provided on demand, with no need for
order placing or direct intervention from the service provider. The
supply chain for water services is entirely dissimilar to other
networked utilities, such as electricity or telecommunications in which
supply must always equal demand due to: the inability to store
electricity in any economically efficient way; and telecommunications
being a service in which supply and consumption are concurrent. The
logistical problem of water and sanitation supply is to design a
distribution network that is able to manage the diurnal demands of
customers (Smith 1999).&lt;/p&gt;
&lt;p&gt;
The physical provision of water and removal of wastewater are the
tangible aspects of the service product concept. Supporting, or
auxiliary services, as defined by Grönroos (1990), are those which
supplement and add value to the core service in order to differentiate
one service provider from another. An example of a supporting service
that could be provided by a water and sanitation provider s advice on
the efficient use of water. Facilitation services are those that assist
with the delivery and consumption of the core service (Grönroos 1990).
Examples of these are information provision, order taking, billing and
payment. All these activities occur in the retail interface between the
distribution and consumption of the services (Figure 3).&lt;/p&gt;
&lt;p&gt;
Vertically integrated monopolistic organisations have little need for
supporting services because there is no possibility to differentiate,
facilitation services are, however, indispensable. Supporting services
can be eliminated and mainly serve a marketing purpose (Grönroos 1990).
Due to the natural monopoly nature of water and sanitation distribution
networks, service providers are not able to differentiate on quality as
the same water or sewage flows through the same pipes. In a privatised
and marketised retail situation, providers can only compete in
supporting and facilitation services.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Privatisation of the Water and Sanitation Supply Chain
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Not all aspects of the water and sanitation supply chain display natural
monopoly characteristics and certain parts are thus suitable for
introducing privately owned service providers. Natural monopolies can be
assumed to exist in water storage (large dams), bulk water delivery and
distribution and the transport of wastewater. This leaves water
sourcing, treatment and water retailing as potentially competitive
aspects of the water supply chain. In sanitation services, the
collection and treatment of wastewater can be considered suitable for a
competitive environment (Essential Services Commission 2009). The
privatisation of individual aspects of the supply chain and the
breakdown of vertical integration will increase the number of marketing
channels in the chain (Kotler et al. 2007). The water and sanitation
marketing channel can be separated into four channels, i.e. sourcing,
treatment, distribution and retailing (Essential Services Commission
2009).&lt;/p&gt;
&lt;p&gt;
As indicated by Estache et al. (2005), privatisation of aspects of the
supply chain has been implemented in a majority of the countries around
the world. This privatisation is, however, mostly limited to private
sector partnerships, whilst maintaining government control over the full
supply chain. Some aspects of the supply chain that are generally
undertaken by private partners of public organisations are the
construction of water and sewage reticulation, the operation and
maintenance of that infrastructure and in some cases ownership of water
and wastewater treatment facilities.&lt;/p&gt;
&lt;p&gt;
As most water and sanitation supply organisations are currently in
vertically integrated public institutions, the entire supply chain is
within the control of one group, simplifying the marketing channel for
all involved. Vertical integration provides an environment in which the
transmission of information, money and the water itself is less
complicated than in a non vertically integrated supply chain. However,
the simplicity of this supply chain becomes more complex as a
competitive model is employed. As each marketing channel consists of
dissimilar organisations that cooperate for their common benefit, the
behaviour of each of the channel participants is not always aligned with
the common goal, leading to channel conflict (Kotler et al. 2007).
Introduction of competition in the retail interface for water and
sanitation can lead to both horizontal conflicts between competitors and
vertical conflict between channel participants.&lt;/p&gt;
&lt;p&gt;
The consequences of not effectively managing the supply chain may be
significant for retailers. The Bullwhip Effect phenomenon demonstrates
that there can be significant and exaggerated fluctuations in supply in
response to demand and the information provided to suppliers (Lee et al.
1997). The consequences of these include supply gluts, insufficient
storage and, at times, insufficient supply to meet demand. Challenges in
matching supply and demand are often related to imperfections in
information transmitted from one organisation to another. By having the
retail and supply functions within the same organisation, the speed at
which this information may be transmitted, interpreted, discussed and
improved upon is faster and more effective providing an advantage to the
Government-owned retailer.&lt;/p&gt;
&lt;p&gt;
The impact of this is that the private sector is likely to claim that a
level playing field does not exist and the likely result of this is the
introduction of probity arrangements to ensure that the information
provided to all retailers is substantially similar. Thus, the
consequence of introducing partial privatisation of the water and
sanitation supply chain is an increased complexity that could lead to
negative impacts for customers, unless the supply channel is aligned
through information sharing (Lee et al. 1997).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-7&#34;&gt;
Service Quality under Privatisation of Retail Services in Water and Sanitation
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Research on the effect of privatisation of water and sanitation
utilities mostly focuses on econometric modelling of macroeconomic
benefits (Estache et al. 2005; Fumagalli et al. 2007; Picazo-Tadeo et
al. 2008) and much less attention has been given to the effects on the
levels of customers service (Tsamenyi et al. 2008). Although little
research has been undertaken on the relationship between ownership and
service quality in water and sanitation services, all networked utility
services, such as electricity, gas, telecommunication, water and
sanitation can be considered analogous. Firstly, networked utility
services are considered a natural monopoly (DiLorenzo 1996) and have
traditionally been undertaken by government-owned organisations
(Deichmann and Lall 2007). There are also similarities in customer
satisfaction determinants between these services, specifically in
relation to continuity and quality of supply (Fumagalli et al. 2007;
Hartmann and Ibáñez 2007; Seppälä et al. 2004).&lt;/p&gt;
&lt;p&gt;
Because of the similarities between networked utility services and the
paucity of research in the field of marketing water and sanitation
services, this review focuses on research undertaken in different areas
of utility provision, mainly electricity retailing. The model used in
this paper is static in that it does not address the transition from
public to private ownership, but compares the pre- and
post-privatisation situation.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-8&#34;&gt;
Customer Satisfaction
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The definition of customer satisfaction is a consumer&amp;#39;s post-purchase
evaluation of the overall service experience and is an affective
reaction. Customer satisfaction is pivotal to create a sustainable
competitive advantage, specifically in relation to customer loyalty
(Lovelock et al. 2007). Two approaches to measuring service quality most
commonly used are ex-post Customer Satisfaction Surveys or ex-ante
evaluations of customer preferences (Ferrari and Salini 2008).
Satisfaction with utility services is largely determined by actual
service levels but is also influenced by personal characteristics and by
the evaluation of services relative to that of the customer&amp;#39;s peers
(Deichmann and Lall 2007).&lt;/p&gt;
&lt;p&gt;
An often cited tool for assessing customer perceptions of service
quality is SERVQUAL (Parasuraman et al. 1988). This instrument provides
five crucial dimensions of service quality: Reliability, Assurance, Tangibles, Empathy and
Responsiveness. The main benefit of SERVQUAL is its ability to examine
different service industries such as healthcare, banking, financial
services, and education (Nyeck et al. 2007) The SERVQUAL model has also
been used in water and sanitation industry (Alegre et al. 2000; Seppälä
et al. 2004).&lt;/p&gt;
&lt;p&gt;
The provision of services is usually dominated by intangibles, i.e. the
service itself is not a physical object. The intangibility of services
makes them difficult to visualise and evaluate, which highlights the
importance of tangibles in the marketing of services (Lovelock et al.
2007). Tangible aspects of water and sanitation provisions are first and
foremost any colour or odour issues related to the provided water or the
effectiveness of the sanitation. Other tangible elements of water and
sanitation service provision are, for example, the image of employees,
publication materials, local offices and so on (Parasuraman et al.
1988).&lt;/p&gt;
&lt;p&gt;
The water and sanitation service provision is, however, dominated by intangible elements as the service is provided with very little interaction between the customer and the service provider. The provision of utility services, such as water and sanitation, can thus be classified as an intangible, &lt;a href=&#34;https://lucidmanager.org/marketing/tap-water-paradoxes/&#34;&gt;low-involvement service&lt;/a&gt; (Lovelock 1983). Customers will, therefore, place a lower value on the tangible aspects of the end product and more value in the process of service delivery. As long as the service delivery is consistent and reliable, customers may be willing to pay a higher price (Walsch et al. 2005).&lt;/p&gt;
&lt;p&gt;
Reliability is the ability of a service provider to perform the promised
service dependably and accurately (Parasuraman et al. 1988). The
importance of reliability is highlighted by the fact that any major
breakdown in utility provision usually becomes national news. Research
by Deichmann and Lall (2007) undertaken in Bangalore, India, shows that
household satisfaction with a utility&amp;#39;s performance is directly related
to the number of hours per day water is available.&lt;/p&gt;
&lt;p&gt;
The remaining three parameters in the SERVQUAL model are directly
related to the behaviour of staff. Responsiveness encompasses the
willingness of staff to help customers and provide prompt service.
Assurance is the ability of employees to inspire trust and confidence
and empathy relates to the caring and individualised attention a firm
provides to customers (Parasuraman et al. 1988).&lt;/p&gt;
&lt;p&gt;
The core water and sanitation services are delivered at arm&amp;#39;s length as
they are provided directly on the customer&amp;#39;s premises. Supporting and
facilitating services, however, rely mostly on direct interaction
between staff of the organisation and the customer.&lt;/p&gt;
&lt;p&gt;
In subsequent work, Zeithaml et al. (1993), developed a model (Figure
4.1) to assess the nature and determinants of customer expectations of
service. The conceptual model specifies three different types of service
expectations: desired service, adequate service and predicted service.
Based on this model, five potential gaps in service provision have been
identified, of which three are discussed below.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/servqual-gap-model.png&#34; alt=&#34;ServQual Gap Model&#34; title=&#34;ServQual Gap Model&#34;/&gt;
&lt;figcaption&gt;
ServQual Gap Model.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
&lt;strong&gt;Gap 1&lt;/strong&gt; - Customer expectations and management&amp;#39;s perception of these.&lt;/p&gt;
&lt;p&gt;
The difference between the customer&amp;#39;s expectation of service and
management&amp;#39;s perception of these expectations is the first gap defined
by Zeithaml et al. (1993). In a publicly owned corporation, management&amp;#39;s
perception of customer expectations are mostly not market driven, but
politically motivated, as will be discussed below.&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Gap 2&lt;/strong&gt; - Establish the right service quality standards.&lt;/p&gt;
&lt;p&gt;
The actual service quality standards are the second possible source of
service gaps. Public utilities are homogeneous and do not reflect
different the demand characteristics of customers (Andreassen 1994;
Seppälä et al. 2004). Andreassen (1994) discussed factors that affect
business customer satisfaction in privatised state-owned enterprises and
found that heterogeneity among the users of public services is reflected
in different demand characteristics and that consequently, various
segments of users have significantly varying levels of satisfaction. The
defining distinction between publicly and privately owned water and
sanitation service providers is that the latter is driven by market
forces and will thus be more sensitive to segmentation of their customer
service offering.&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Gap 3&lt;/strong&gt; - Meeting service provision standards.&lt;/p&gt;
&lt;p&gt;
As far as meeting the actual service standards, research generally
indicates that there is no distinguishing difference between privately
and publicly owned service providers (Fumagalli et al. 2007; Estache et
al. 2005). The extant research on this topic is, however, focused on
meeting the primary service standards, such as continuity and quality of
supply, ignoring the supplementary services (Picazo-Tadeo et al. 2008;
Tsamenyi et al. 2008).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-9&#34;&gt;
Customer Behaviour
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;An interesting aspect of utility services provision is that consumer
behaviour can affect the quality of service delivery (Fumagalli et al.
2007). In water and sanitation, this is illustrated by the imposition of
usage limitations in the form of water restrictions in
many Australian states. Loyalty is a critical aspect of customer
behaviour and a key parameter in creating a financially profitable
relationship over time (Lovelock et al. 2007) and is generally
considered a more effective business strategy than attempting to acquire
new customers as the latter is much more expensive (Hartmann and Ibáñez
2007).&lt;/p&gt;
&lt;p&gt;
Due to the ubiquity of government-owned monopolies in the provision of
water and sanitation services, customer loyalty has not played a role of
importance in managerial considerations. The natural monopolistic nature
of utility services provides a large barrier to access for a competitive
market to emerge and changing providers is thus not a viable option for
the customer (Deichmann and Lall 2007). However, experience in areas
where service provision is open to competition shows that after
privatisation and the introduction of a competitive market, most
consumers will not be very willing to change (Hartmann and Ibáñez 2007).
In Germany, electricity consumers have been reluctant to exercise choice
and few private electricity customers have switched energy suppliers
(Walsch et al. 2005).&lt;/p&gt;
&lt;p&gt;
According to Hart et al. (1997), a market open to consumer choice in
which the customer can assess the service quality, a privatised provider
is rewarded for quality-enhancing efforts through repeat purchase by
customers. The relationship is, however, more complicated. Several
approaches to customer loyalty have been proposed in the literature. Gee
et al. (2008) introduce the concept of polygamous customers that are
loyal to several brands. In the provision of most utility services,
polygamous purchasing behaviour cannot occur because of infrastructure
constraints and the natural monopoly, i.e. each house can only have one
water and sanitation connection. Brand switching can, however, arise in
a situation where the retail function has been privatised, as is
commonly the case in telecommunications and the energy market.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/satisfaction-loyalty.jpg&#34; alt=&#34;Effect of competition on the Satisfaction-Loyalty relationship&#34; title=&#34;Effect of competition on the Satisfaction-Loyalty relationship&#34;/&gt;
&lt;figcaption&gt;
Effect of competition on the Satisfaction-Loyalty relationship (Jones and Sasser 1995: 91).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Jones and Sasser (1995) provide a model to predict the switching
behaviour of customers in a privatised water and sanitation retail
market. Common sense would dictate that the relationship between
satisfaction and loyalty is linear; the more satisfied a customer is,
the more likely they will remain loyal. The relationship is, however,
dependent upon the level of competition in the market. For water and
sanitation services in a situation of natural monopoly, either
privatised or in public hands, the relationship between customer loyalty
and satisfaction (Figure 4, top curve) is not relevant as the only
choice customers have is either to purchase or not purchase the service.
The more competitive a market becomes, the more sensitive customers will
be to switching and managing customer satisfaction will not be
sufficient to ensure customer loyalty.&lt;/p&gt;
&lt;p&gt;
Walsch et al. (2005) confirmed the findings of Jones and Sasser (1995)
and found that customer satisfaction by itself did not have a
significant effect on switching intentions of customers from German
energy suppliers. The intangibility and heterogeneity of utility
services make the interpretation of brands as promised to the customer
of particular importance (Hartmann and Ibáñez 2007). The loyalty of
residential customers in the energy market depends as much on brand
image as on switching cost and satisfaction (Andreassen 1994; Hartmann
and Ibáñez 2007). The research by Walsch et al. (2005) indicated that
monetary and non-monetary switching cost, risk aversion and lack of
transparency in the market are major determinants of the high levels of
customer loyalty they found. The market for services can be segmented
into &amp;#39;loyals&amp;#39;, &amp;#39;habituals&amp;#39;, &amp;#39;switchers&amp;#39; and &amp;#39;multi branders&amp;#39;, expressed
in the Diamond of Loyalty (Lovelock et al. 2007):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Loyals&lt;/em&gt; have the highest profit potential and have an active
preference for the brand with a strong emotional connection. They also
see a high perceived risk in switching brands.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Habituals&lt;/em&gt; are passive loyals through inertia. They are
behaviourally, but not attitudinal loyal and are passive brand
advocates. They are susceptible to switching when there is a service
failure or through competitor&amp;#39;s promotional deals. Their retention is
mostly based on convenience and switching costs.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Multi branders&lt;/em&gt; have a small repertoire of service brands and
actively search based on quality and price. They have little
involvement in the brand and often seek variety for its sake.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Switchers&lt;/em&gt; are characterised by a broad portfolio of brands and are
sensitive to price promotions and have a low perceived risk of
switching.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In summary, service marketing theory (Jones and Sasser 1995; Lovelock et
al. 2007) and research in the retail of utilities (Hartmann and Ibáñez
2007; Walker and Johnson 2005) show that a correlation exists between
customer satisfaction and customer loyalty. There is, however, no direct
causality between satisfaction and loyalty as other confounding
variables, such as customer psychology and brand image, are at play.&lt;/p&gt;
&lt;p&gt;
Given the experience in some privatised utility markets (Hartmann and
Ibáñez 2007; Walker and Johnson 2005), most customers could possibly be
classified as either Loyals or Habituals. The implications for managers
is that managing customer satisfaction will not be sufficient to
stimulate loyalty, as shown by Jones and Sasser (1995). The central
question to be asked is whether the existence of loyalty segmentation as
confirmed by Walsch et al. (2005) for electricity retail in Germany, as
exists in water and sanitation retailing.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-10&#34;&gt;
Managerial behaviour
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;One aspect of the relationship between ownership structure and service
quality in utility provision that has not been given much attention in
the literature is the impact of managerial behaviour on customer service
levels (Fumagalli et al. 2007). Managerial behaviour impacts on service
quality through job design, staff empowerment and development (Lovelock
et al. 2007).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Although voter satisfaction is related to customer satisfaction, it is a poor proxy.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
A significant difference between a privately or publicly owned service
provider is the intention of the owners. In publicly owned
organisations, managers are separated from the owners, while in
privately owned organisations, the owners play a direct role in the
management of the firm through directors. The core purpose of a
privately owned corporation is to maximise the return for its
stakeholders while for publicly owned organisations the objectives are
often political (Du Plessis et al. 2005). Seppälä et al. (2004),
however, states that regardless of their ownership structure, all water
and sanitation service providers share a common purpose and management
objectives (Seppälä et al. 2004), which was defined by Alegre et al.
(2000) as:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;#34;The achievement of the highest level of consumer satisfaction and service quality in line with the prevailing regulatory framework, whilst making best use of available resources&amp;#34;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Although it can be considered a truism that customer satisfaction is the
primary aim of both public and private organisations, the managerial
behaviour will be very different. A profit-maximising privately owned
firm will improve quality to the point where the marginal benefit to the
consumers of additional quality equals the marginal cost to the business
of increasing quality. For a politically oriented publicly owned firm,
quality improvements are often more related to the political will of the
responsible governments than to customer perception (Fumagalli et al.
2007). Although voter satisfaction is related to customer satisfaction,
it is a poor proxy.&lt;/p&gt;
&lt;p&gt;
Managers of a publicly owned utility service provider are separated from
the owners and have &amp;#39;private costs&amp;#39; of decisions that negatively impact
on service quality, while in privately owned corporations, managers
negate private benefits, usually in the form of reduced income
(Fumagalli et al. 2007).&lt;br&gt;
In private industry, managers have greater freedom to set a corporate
strategy and raise capital as is the case in publicly owned
organisations (Andreassen 1994; Fumagalli et al. 2007). Managers in
privately owned corporations are disciplined, i.e. act in the best
interest of the company, through the existence of competitors
(Andreassen 1994; Deichmann and Lall 2007; Fumagalli et al. 2007). This
principle assumes that effective corporate governance is in place to
negate the Agency Problem, i.e. the problem of managers adopting
discretionary behaviours other than investments (Du Plessis et al. 2005;
Fumagalli et al. 2007).&lt;/p&gt;
&lt;p&gt;
Fumagalli et al. (2007) analysed the relationship between privatisation
and service quality in the electricity industry and explored the
autonomous role of managerial behaviour. They found that a reduction in
management dominance through the larger presence of external directors
resulted in better supply quality.&lt;/p&gt;
&lt;p&gt;
Improvements in performance due to privatisation or regulation can be
explained by the introduction of new management styles and techniques,
leading to increased organisational efficiency and design. Top
management signals are one of the most influential forces driving a
market organisation (Andreassen 1994).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-11&#34;&gt;
Synthesis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The past decades, water and sanitation service providers have been
privatised in several jurisdictions around the world. The motivation for
this wave of reform is predominantly based on econometric
considerations. Evidence on the effectiveness of privatisation is mixed
but point towards there being no significant economic difference. The
research on this topic has been widely myopic of the marketing
implications of privatisation. Also, the environmental complexity and
the myriad of confounding variables, in particular, differences in
legislation around the globe, frustrate the possibility of drawing firm
conclusions.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/water-marketing/concepts.jpg&#34; alt=&#34;Relational model between ownership structure, customer satisfaction and behaviour&#34; title=&#34;Relational model between ownership structure, customer satisfaction and behaviour&#34;/&gt;
&lt;figcaption&gt;
Relational model between ownership structure, customer satisfaction and behaviour.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
A review of the extant literature on the privatisation of utility
services and services marketing theory shows managerial behaviour as a
possible independent variable influencing customer satisfaction as
described in the relational model in figure 5.1.&lt;/p&gt;
&lt;p&gt;
The transition from publicly- to a privately-owned provision of water
and sanitation services has been driven by a quest for improved
efficiency, demonstrated by the recent wave of water privatisation of
most networked utility services. In many countries around the world,
there is already significant private investment in the provision of
water and sanitation services, but the impact of privatisation on the
level of customer service has been widely ignored.&lt;/p&gt;
&lt;p&gt;
It is argued that a change of ownership structure in the provision of
retailing services significantly improves the behaviour of managers that
are responsible for the interfunctional coordination of the service
organisation. As described in the conceptual model, this has a direct
impact on all at least three dimensions of the SERVQUAL service
provision model: Responsiveness, Assurance and Empathy. The consequent
change in service quality acts to influence customer satisfaction and in
turn altering customers&amp;#39; loyalty behaviours.&lt;/p&gt;
&lt;p&gt;
The proposed model, though based on germane secondary research, has been
developed under the assumption that networked services such as
telecommunications, transport and energy are analogous to water and
sanitation services. It is proposed that future research is undertaken
to focus on testing this model, specifically within water and sanitation
service provision. Given the upcoming changes to the contestable
provision of services in the Victorian water and sanitation sector
recommended by the Essential Services Commission, the ideal industry
environment exists to test the model. In doing so, this model may
provide insights into how the industry may transition to a free-market
model in which each of the parties involved in the transaction described
by Milton Friedman in the epigraph will receive maximum benefit.&lt;/p&gt;
&lt;p&gt;

  &lt;div class=&#34;box&#34;&gt;
    &lt;div class=&#34;media&#34;&gt;
      &lt;figure class=&#34;media-left&#34;&gt;
        &lt;p class=&#34;image is-128x128&#34;&gt;
          &lt;img src=&#34;https://lucidmanager.org/images/books/2017b_wum.jpg&#34; alt = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34; title = &#34;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&#34;&gt;
        &lt;/p&gt;
      &lt;/figure&gt;
      &lt;div class=&#34;media-content&#34;&gt;
        &lt;div class=&#34;content&#34;&gt;
          &lt;p class=&#34;is-size-5 has-text-weight-bold&#34;&gt;Customer Experience Management for Water Utilities: Marketing Urban Water Supply&lt;/p&gt;
          &lt;p class=&#34;mb-2&#34;&gt;Practical framework for water utilities to become more focused on their customers following Service-Dominant Logic.&lt;/p&gt;
          &lt;div class=&#34;buttons&#34;&gt;
            &lt;a class=&#34;button is-info&#34; href=&#34;https://iwaponline.com/ebooks/book/327/Customer-Experience-Management-for-Water&#34; target=&#34;_blank&#34;&gt;
              &lt;span class=&#34;icon&#34;&gt;
                &lt;i class=&#34;fas fa-shopping-cart&#34;&gt;&lt;/i&gt;
              &lt;/span&gt;
              &lt;span&gt;IWA Publishing&lt;/span&gt;
            &lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-12&#34;&gt;
Bibliography
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-2&#34;&gt;
&lt;ul&gt;
&lt;li&gt;Alegre, H., Baptista, J.M., Jr, E. Cabrera, Cubillo, F., Duarte, P., Hirner, W., Merkel, W. and Parena, R. (2000) &lt;em&gt;Performance Indicators for Water Supply Services.&lt;/em&gt; 2nd ed. International Water Association.&lt;/li&gt;
&lt;li&gt;Andreassen, Tor Wallin (1994) Satisfaction, loyalty and reputation as indicators of Customer Orientation in the Public Sector. &lt;em&gt;International Journal of Public Sector Management&lt;/em&gt; 7(2): 16–34.&lt;/li&gt;
&lt;li&gt;Auriol, Emmanuelle and Picard, Pierre M. (2008) Infrastructure and Public Utilities Privatization in Developing Countries. &lt;em&gt;The World Bank conomic Review&lt;/em&gt; 23(1): 77–100.&lt;/li&gt;
&lt;li&gt;Bakker, Karen (2007) The Commons Versus the Commodity: After globalization, Anti-privatization and the Human Right to Water in the Global South. &lt;em&gt;Antipode&lt;/em&gt; 3(3): 430–455. &lt;/li&gt;
&lt;li&gt;Braadbaart, Okke (2007) Collaborative benchmarking, transparency and performance: Evidence from The Netherlands water supply industry. &lt;em&gt;Benchmarking: An International Journal&lt;/em&gt; 14(6): 677–692.&lt;/li&gt;
&lt;li&gt;Cadbury, Deborah (2003) &lt;em&gt;Seven wonders of the industrial world&lt;/em&gt;. London: Harper Perennial.&lt;/li&gt;
&lt;li&gt;Chisari, Omar, Estache, Antonio and Romero, Carlos (1999) Winners and losers from the privatization and regulation of utilities: Lessons from a general equilibrium model of Argentina. &lt;em&gt;The World Bank Economic Review&lt;/em&gt; 13(2): 357–378.&lt;/li&gt;
&lt;li&gt;Deichmann, U and Lall, S. (2007) Citizen Feedback and Delivery of Urban Services. &lt;em&gt;World Development&lt;/em&gt; 35(4): 649–662.&lt;/li&gt;
&lt;li&gt;DiLorenzo, Thomas J. (1996) The myth of natural monopoly. &lt;em&gt;The Review of Austrian Economics&lt;/em&gt; 9(2): 43-58.&lt;/li&gt;
&lt;li&gt;Du Plessis, J, McConvill, J and Bagaric, M (2005) &lt;em&gt;Principles of Contemporary Corporate Governance.&lt;/em&gt; Melbourne: Cambridge University Press.&lt;/li&gt;
&lt;li&gt;Essential Services Commission (2009) Inquiry into an Access Regime for Water and Sewerage Infrastructure Services - Issues Paper. Available at: &lt;a href=&#34;https://www.esc.vic.gov.au/&#34;&gt;www.esc.vic.gov.au&lt;/a&gt;. Accessed 3 November 2009.&lt;/li&gt;
&lt;li&gt;Estache, Antonio, Perelman, Sergio and Trujillo, Lourdes (2005) Infrastructure performance and reform in developing and transition economies: Evidence from a survey of productivity measures. &lt;em&gt;World Bank Policy Research Paper&lt;/em&gt; 3514.&lt;/li&gt;
&lt;li&gt;Estache, Antonio and Rossi, Martin A (2002) How different is the efficiency of public and private water companies in Asia? &lt;em&gt;The World Bank Economic Review&lt;/em&gt; 16(1): 139–148.&lt;/li&gt;
&lt;li&gt;Ferrari, P. A. and Salini, S. (2008) Measuring Service Quality: the opinion of Europeans about Utilities. FEEM &lt;em&gt;Working Paper No. 36.2008&lt;/em&gt;. Available at SSRN: &lt;a href=&#34;https://papers.ssrn.com/sol3/papers.cfm?abstract_id=1123414&#34;&gt;ssrn.com/abstract=1123414&lt;/a&gt;. Accessed 14 October 2009.&lt;/li&gt;
&lt;li&gt;Fumagalli, E, Garrone, P and Grilli, L (2007) Service quality in the electricity industry: The role of privatization and managerial behavior. &lt;em&gt;Energy Policy&lt;/em&gt; 35(12): 6212.&lt;/li&gt;
&lt;li&gt;Gee, Robert, Coates, Graham and Nicholson, Mike (2008) Understanding and profitably managing customer loyalty. &lt;em&gt;Marketing Intelligence &amp;amp; Planning&lt;/em&gt; 26(4): 359.&lt;/li&gt;
&lt;li&gt;Grönroos, Christiaan (1990) &lt;em&gt;Service Management and Marketing&lt;/em&gt;. Lexington: Lexington Books.&lt;/li&gt;
&lt;li&gt;Hart, Oliver, Shleifer, Andrei and Vishny, Robert W. (1997) The Proper Scope of Government: Theory and an Application to Prisons. &lt;em&gt;The Quarterly Journal of Economics&lt;/em&gt; 112(4): 1127–1161.&lt;/li&gt;
&lt;li&gt;Hartmann, Patrick and Ibáñez, Vanessa Apaolaza (2007) Managing customer loyalty in liberalized residential energy markets: The impact of energy branding. &lt;em&gt;Energy Policy&lt;/em&gt; 35(4): 2661.&lt;/li&gt;
&lt;li&gt;Jones, Thomas O. and Sasser, W. Earl (1995) Why satisfied customers defect. &lt;em&gt;Harvard Business Review&lt;/em&gt; 73(6): 88–99.&lt;/li&gt;
&lt;li&gt;Kotler, P., Brown, L., Adam, S., Burton, S. and Armstrong, G. (2007) &lt;em&gt;Marketing&lt;/em&gt;. 7th ed. Pearson Education Australia.&lt;/li&gt;
&lt;li&gt;Lee, Hau L., Padmanabhan, V. and Whang, Seungjin (1997) The Bullwhip Effect in Supply Chains. &lt;em&gt;Sloan Management Review&lt;/em&gt; 38(3): 93–102.&lt;/li&gt;
&lt;li&gt;Levy, David (1982) Diamonds, water, and Z goods: an account of the paradox of value. &lt;em&gt;History of Political Economy&lt;/em&gt; 4(3): 312–322.&lt;/li&gt;
&lt;li&gt;Lovelock, Christopher H. (1983) Classifying services to gain strategic marketing insights. &lt;em&gt;Journal of Marketing&lt;/em&gt; 47(3): 9–20.&lt;/li&gt;
&lt;li&gt;Lovelock, Christopher H., Patterson, Paul G. and Walker, Rhett H. (2007) &lt;em&gt;Services marketing. An Asian-Pacific and Australian perspective.&lt;/em&gt; 4th ed. Pearson Education Australia.&lt;/li&gt;
&lt;li&gt;Narver, J. and Slater, S. F. (1990) The Effect of a Market Orientation on business profitability. &lt;em&gt;Journal of Marketing&lt;/em&gt; 54(4): 20–35.&lt;/li&gt;
&lt;li&gt;Nyeck, S., Morales, M., Ladhari, R. and Pons, F. (2007) 10 years of service quality measurement: reviewing the use of the SERVQUAL instrument. &lt;em&gt;Cuadernos de Diffusion&lt;/em&gt; 7(13): 101–107.&lt;/li&gt;
&lt;li&gt;Parasuraman, A., Zeithaml, Valarie A. and Berry, Leonard L. (1988) SERVQUAL: A Multiple-Item Scale For Measuring Consumer Perceptions in service quality. &lt;em&gt;Journal of Retailing&lt;/em&gt; 64(1): 12–40.&lt;/li&gt;
&lt;li&gt;Picazo-Tadeo, A.J., Sáez-Fernández, F.J. and González-Gómez, Francisco (2008) Does service quality matter in measuring the performance of water utilities? &lt;em&gt;Utilities Policy&lt;/em&gt; 16(1): 30-38.&lt;/li&gt;
&lt;li&gt;Porter, Michael E. (1990) Competitive advantage of nations. &lt;em&gt;Harvard Business Review&lt;/em&gt; (2).&lt;/li&gt;
&lt;li&gt;Robertson, H.M. and Taylor, W.L. (1957) Adam Smith&amp;#39;s approach to the theory of value. &lt;em&gt;The Economic Journal&lt;/em&gt;: 181-198.&lt;/li&gt;
&lt;li&gt;Seppälä, Osmo T, Rajala, Riikka P and Katko, Tapio S (2004) Customer-Responsive water and sanitation services. &lt;em&gt;American Water Works Association Journal&lt;/em&gt; 96(6): 83.&lt;/li&gt;
&lt;li&gt;Smith, Denis, ed. (1999) &lt;em&gt;Water-supply &amp;amp; public health engineering&lt;/em&gt;. Aldershot Valorium.&lt;/li&gt;
&lt;li&gt;Tsamenyi, M, Onumah, J and Tettehkumah, E (2008) Post-privatization performance and organizational changes: Case studies from Ghana. &lt;em&gt;Critical Perspectives on Accounting.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Tupper, Henrique Cesar and Resende, Marcelo (2004) Efficiency and regulatory issues in the Brazilian water and sewage sector: an empirical study. &lt;em&gt;Utilities Policy&lt;/em&gt; 12(1): 29-40.&lt;/li&gt;
&lt;li&gt;Van den Berg, Caroline (1997) Water Privatization and Regulation in England and Wales. Public Policy for the Private Sector (115).&lt;/li&gt;
&lt;li&gt;Walker, Rhett H. and Johnson, Lester W. (2005) Managing the customer-service provider relationship with technology-enabled services. &lt;em&gt;Mt Eliza Business Review&lt;/em&gt; 7(2): 57-65.&lt;/li&gt;
&lt;li&gt;Walsch, Gianfranco, Groth, Markus and Wiedman, Klaus-Peter (2005) An examination of customers&amp;#39; motives to switch energy suppliers. &lt;em&gt;Journal of Marketing Management&lt;/em&gt; 21(3): 421-440.&lt;/li&gt;
&lt;li&gt;Zeithaml, Valarie A., Berry, Leonard L. and Parasuraman, A. (1993) The nature and determinants of customer expectations of service. &lt;em&gt;Journal of the Acadamy of Marketing Science&lt;/em&gt; 21(1): 1-12. &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Strategic Management and Serendipity — Luck in Business</title>
      <link>https://lucidmanager.org/management/strategic-management-and-serendipity/</link>
      <pubDate>Sun, 30 Aug 2009 20:17:41 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/strategic-management-and-serendipity/</guid>
      <description>
	
&lt;p&gt;
Strategic management is one of the most discussed issues in business studies. But what is strategy and does it improve business performance? This essay examines the relationship between strategic management and serendipity in light of strategic management studies.&lt;/p&gt;
&lt;p&gt;
Life is characterised by serendipity, and much of human culture is, in essence, a means to deal with the unpredictable. We can not know whether the next harvest will fail, whether we still have a job next year or whether we will die. Ancient systems, such as astrology and other forms of divination were developed to reduce uncertainty in people&amp;#39;s lives.&lt;/p&gt;
&lt;p&gt;
After the era of enlightenment, divination was replaced by science, and we now rely on weather forecasters, medical professionals, engineers and other professionals to provide information to help us plan our lives.&lt;/p&gt;
&lt;p&gt;
What is valid for life, in general, is also adequate for managing an organisation. An organisation is a group of people that are bound together through a common goal. To increase the likelihood that organisations achieve objectives, they require management, i.e. actions of members of the organisation aimed at reducing uncertainty. One of the most significant uncertainties in business is the existence of competitors and their intrinsic unpredictable actions. Strategic management is a specific kind of management that seeks to reduce this uncertainty.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Strategic Management Schools of Thought
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The distinction between prescriptive theories, such as those propounded
by Igor Ansoff and Michael Porter, and descriptive schools of strategic
thinking are discussed. It is argued that an organisation can not rely
solely on formal, prescriptive systems to develop and implement strategy
and that an integrated approach is required to act strategically and
increase the chances of success.&lt;/p&gt;
&lt;p&gt;
Socially constructed phenomena, such as religion, culture and management
are notoriously hard to define. This fact is undoubtedly the case for
business strategy, and although many scholars have applied their
intellect to this problem, no consensus has thus far emerged (Forster
and Browne 1996; Mintzberg 1987). The most productive approach has been
to move away from essentialist “strategy is …” type definitions that
attempt to capture strategy in one quintessential sentence. Mintzberg
(1987) criticises the reductionist approach to strategy definition by
comparing it with a group of blind scientists describing an elephant by
touch alone. One says it is a trunk, the other might focus on the legs,
but nobody is able is to describe the elephant as a whole. To circumvent
perceived issues with essentialist definitions, a phenomenological view,
characterising different perspectives of strategic thinking in a model
or taxonomy is preferred.&lt;/p&gt;
&lt;p&gt;
Several authors have proposed systems to classify strategic approaches
for business. For example, Igor Ansoff (1987) defined a matrix of four
generic strategies and Michael Porter (1980) described three generic
strategies to achieve competitive advantage.&lt;/p&gt;
&lt;p&gt;
Igor Ansoff, often credited as the Father of Strategic Management,
started his career as a mathematician and later moved into the field of
management (Hussey 1999). Mintzberg credits Ansoff as being instrumental
in the development of the Planning School (Mintzberg and Lampel 1999).
Being trained as a mathematician, it is not surprising that Ansoff&amp;#39;s
strategic thinking revolved around structure and order. The subtitle of
the first edition of Corporate Strategy was “An analytic approach to
business policy for growth and expansion” (Ansoff 1987). The process of
strategy formulation is, according to Ansoff, not a creative activity
but a formal one, consisting of distinct steps supported by checklists
and other control techniques (Mintzberg and Lampel 1999). Ansoff
published a great deal on turbulent and discontinuous change (Hussey 1999). 
But Ansoff, thinking like a mathematician, sought to control the
unpredictability of the external environment with checklists, budgets
and operating plans. The reality he thus tried to control is, however,
not physical and predictable, but social and therefore less likely to be
controllable through analytic means.&lt;/p&gt;
&lt;p&gt;
Almost two decades after Ansoff published his first ideas on strategic
management, Michael Porter came on the scene and quickly attained the
status of management guru. In his book Competitive Strategies, Porter
(1980) argues that only three strategies exist which provide
opportunities for success. The differences between these strategies are
in the strategic advantage sought from either cost or differentiation
and the target aimed at (Speed 1989). Mintzberg and Lampel (1999) place
the work of Porter in the Positioning School, a prescriptive view on
strategy popular in the 1980s. In Porter&amp;#39;s view, a strategy can be
reduced to a generic position taking based on a formal analysis of the
external environment. Because of the intuitive appeal of Porter&amp;#39;s work,
it quickly picked up by management consultants, who proclaimed it to be
a scientific truth (Mintzberg and Lampel 1999). One often heard
criticism of Porter&amp;#39;s work is, however, that it lacks empirical support,
using selective case studies to make his point (Speed 1989).&lt;/p&gt;
&lt;p&gt;
Henry Mintzberg employs a more philosophical approach when he classifies
strategic business thinking in ten Schools of Thought, which
he describes in their historical and ideological context. Early
theorists, such as Igor Ansoff, focused on the analytical aspects of
strategy formation. The first three schools in Mintzberg&amp;#39;s taxonomy are
therefore prescriptive and focus on how strategy ought to be formulated.
One of the major premises of the prescriptive schools is the Performance
Claim, which states that the more an organisation engages in systematic
strategic planning, the more likely it will result in above average
returns. The prescriptive schools have been influential in the discourse
of strategy formulation, but have failed to explain the process of
strategy execution (Mintzberg 1990).&lt;/p&gt;
&lt;p&gt;
Later developments in strategic management literature moved away from
the prescriptive approaches modelled on the quantitative sciences and
their inherent presumption of a controllable world. The descriptive
schools of thought are inspired by the qualitative social and cultural
sciences and study what businesses did to be successful for other
organisations to learn from their approaches. The descriptive schools
move from a focus on apriori strategic planning to a-posteriori dynamic
strategy formulation and execution.&lt;/p&gt;
&lt;p&gt;
For practitioners, the prescriptive schools of thought are desirable,
illustrated by the ubiquity of tools such as SWOT analysis and generic
strategies, such as those developed by Ansoff (1987) and Porter (1980).
The descriptive schools are somewhat problematic for practitioners of
strategic management because they do not provide straightforward recipes
for success. Analogous to the Naturalistic Fallacy in moral philosophy,
where an ought cannot be derived from an is, the descriptive schools
(strategy as an is) are not very suitable for managers to determine what
strategic decision ought to be made. The question raised by Mintzberg&amp;#39;s
taxonomy of strategic thought and other similar taxonomies is how
average practitioners can decide which strategy they should employ.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Strategic Management and Serendipity
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;One of the major premises of the prescriptive schools of strategic
management thought is the Performance Claim, which can be formally
expressed as (Hill et al. 2004: 23):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Strategic planning, on average, has a positive impact on company performance.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Miller and Cardinal (1994) investigated how firm size, capital intensity
and environmental turbulence influences performance in firms with
different degrees of formal strategic planning. They found that
correlations between planning and business results show a relatively
large fluctuation (-0.30 &amp;lt; r&lt;sup&gt;2&lt;/sup&gt; &amp;lt; 0.71), but are skewed towards
positive performance. They also concluded that stronger
planning-profitability correlations emerge when firms face turbulent
environments (Miller and Cardinal 1994). Rogers et al. (1999)
investigated whether the relationship between strategic planning
processes and organisational performance depends on the content of the
strategy pursued and not just the extent of planning. They concluded
that formal strategic planning positively influences company
performance, as expressed in the Performance Claim. Miller and Cardinal
(1994) also support the Performance Claim but argue that companies
typically only realise 63% of the potential value of their strategy
because of defects in planning and execution. They provide a list of
possible causes of performance loss but do not seem to recognise that
unpredictable events can negatively influence performance and imply that
any strategy can be realised, as long as planned and executed
appropriately.&lt;/p&gt;
&lt;p&gt;
However, some academics question the idea that formal strategic planning
systems are a sufficient condition to improve company performance and
argue that luck and serendipity play a critical role in determining
competitive advantage (Mintzberg 1979; Hart 1992; Hamel 1996). This
criticism is supported by the fact that that the prescriptive view of
strategy formation contains a logical inconsistency. In prescriptive
schools, a strategy is often defined as the actions a company takes to
attain superior performance (Hill et al. 2004). However, when a strategy
is thus defined, the Performance Claim becomes a tautology:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Actions taken to attain superior performance, on average, have a positive impact on company performance.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Another issue with prescriptive schools of thought is the presumed
causality from plan to action to succeed. The definition of strategy
discussed above expresses an intent (“Actions taken to attain …”).
This intent does, however, not imply a causal link between planning
action and success. Hamel (1996) argues that strategic planning, as
practised in business management, is not strategic at all. He claims
that strategy development tends to be a reductionist process, based on
simple rules and heuristics, working from the present to the future,
rather than the other way around. The strategic planning process is
largely extrapolative, and it is assumed that the future will resemble
the past, an assumption that David Hume has shown to be irrational. 
Hamel, therefore, emphasises the creative
aspects of strategic management and points out that it is not a rote
process that can be instrumentalised in neat systems, such as SWOT
diagrams and generic strategies. A strategy is in the view of Hamel
(1996: 71) a “quest that must be a subversive revolution to improve
company performance”.&lt;/p&gt;
&lt;p&gt;
Logical analysis of the principles of the prescriptive schools of
strategic thought shows them to be invalid because the Performance Claim
is tautological. However, the empirical fact of the Performance Claim
holds at least some truth remains. This seeming contradiction emerges
because the relationship between planning and organisational success is
more complicated than was assumed in the research. Firstly, the analysis
only used companies still in existence, leaving out those that did
employ strategic planning but failed. Secondly, without conducting fully
controlled studies, it is near impossible to prove causality between
planning and success. A positive correlation does not imply that
planning is the cause of a good business result.&lt;/p&gt;
&lt;p&gt;
Hart (1992) summarises the discourse between proponents of strict formal
planning and those that stress the limits of this approach. He refers to
formal planning as the rational model for strategy formulation. The
rational model advocates to consider all available alternatives,
identify and evaluate all of the consequences of each alternative and
then select the preferred choice. Researchers challenging this approach
argue that organisations can achieve only limited rationality because of
individual cognitive limits, heuristics and biases in human judgement
(Forster and Browne 1996).&lt;/p&gt;
&lt;p&gt;
The process of strategy formation is, according to Mintzberg (1979), the
interplay between the formal intended strategies and informal emergent
strategies, mediated by leadership. What he emphasises is that strategy
is not a fixed plan, nor does it change systematically at prearranged
times at the will of management. Mintzberg also emphasises the
unpredictability of the external environment. An organisation can find
itself in a stable environment for long periods of time, without the
need to change its strategy. Sometimes the environment can, however,
become so turbulent that even the best planning techniques are useless
because of the high level of unpredictability (Mintzberg 1979). This
seems to contradict the finding of Miller and Cardinal (1994) that
stronger planning-profitability correlations emerge when firms face
turbulent environments. This is not unexpected as those companies that
succumbed to the turbulent environment were not included in the
research. This leaves the question of whether to follow prescriptive or
descriptive schools of thought open. The most productive answer is that
strategic management is a complex synergy of apriori intended and
a-posteriori emergent strategy and positive company performance are
brought about by a combination of both. Thus, although formal planning
is not a sufficient condition to obtain superior company performance, it
is most certainly a necessary condition.&lt;/p&gt;
&lt;p&gt;
Research into strategy formulation has resulted in a plethora of
strategic management theories. The fundamental differences between
individual theories and the fact that they come and go in quick
succession support the claim that there is no firm scientific basis for
theories of management (Miller and Cardinal 1994). Strategic management
theory is an eclectic field with contributions from military history,
engineering, industrial economics, organisational sociology,
behavioural, cognitive and social psychology, anthropology and political
science (Forster and Browne 1996). Strategic management is thus more
aligned with social sciences than the exact sciences and as such needs a
methodology that suits the unpredictability of human behaviour, rather
than a rational model, feigning predictability.&lt;/p&gt;
&lt;p&gt;
Management deals with human beings and their social interaction and both
the external and internal environment are in a constant state of flux. A
strategy will only improve performance if its formulation takes the
fundamental unpredictability of the world into account. A strategy
cannot be formulated through rational systems that model the real world.
Formulating strategy is a continuously developing narrative between the
organisation and the external environment.&lt;/p&gt;
&lt;p&gt;
Strategic planning as a means to reduce uncertainty in organisations is
a young science in which many different perspectives have been explored.
Following a taxonomy based on descriptive and prescriptive strategic
management, it has been shown that a formal planning approach by itself
can not cause a company to achieve above-average returns.&lt;/p&gt;
&lt;p&gt;
Although empirical research points towards a positive correlation
between strategic planning and company performance, these studies suffer
from methodological problems. This problem does, however, not imply that
strategic planning as a formal exercise is futile. Formal strategic
planning is vital for prudent management. Not as a means to define the
course for years ahead, but as a way to be able to anticipate the
unpredictability of external influences.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
References
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;ul&gt;
&lt;li&gt;Ansoff, Igor (1987) &lt;em&gt;Corporate strategy.&lt;/em&gt; London: Penguin Business.&lt;/li&gt;
&lt;li&gt;Forster, J. and Browne, M. (1996) &lt;em&gt;Principles of Strategic Management&lt;/em&gt;, chap. The evolution of strategic management thought. Macmillan, 21–50.&lt;/li&gt;
&lt;li&gt;Hamel, Gary (1996) &amp;#39;Strategy as revolution&amp;#39;. &lt;em&gt;Harvard Business Review&lt;/em&gt; (July–August): 69–82.&lt;/li&gt;
&lt;li&gt;Hart, Stuart L. (1992) &amp;#39;An integrative framework for strategy-making processes&amp;#39;. &lt;em&gt;Academy of Management Review&lt;/em&gt; 17(2): 237–351.&lt;/li&gt;
&lt;li&gt;Hill, W.L., Jones, Gareth R. and Galvin, Peter (2004) &lt;em&gt;Strategic management: An integrated approach.&lt;/em&gt; Milton: Wiley.&lt;/li&gt;
&lt;li&gt;Hussey, David (1999) &amp;#39;Igor Ansoff&amp;#39;s continuing contribution to strategic management&amp;#39;. &lt;em&gt;Strategic Change&lt;/em&gt; 8(7): 375–392.&lt;/li&gt;
&lt;li&gt;Miller, C. Chet and Cardinal, Laura B. (1994) &amp;#39;Strategic planning and firm performance: a synthesis of more than two decades of research&amp;#39;. &lt;em&gt;Acadamy of Management Journal&lt;/em&gt; 37(6): 1649–1665.&lt;/li&gt;
&lt;li&gt;Mintzberg, H. (1987) &amp;#39;The strategy concept I: Five Ps for strategy&amp;#39;. &lt;em&gt;California Management Review&lt;/em&gt; 30(1): 11–24.&lt;/li&gt;
&lt;li&gt;Mintzberg, Henry (1979) &amp;#39;Patterns is strategy formation&amp;#39;. &lt;em&gt;International Studies of Management and Organisation&lt;/em&gt; IX(3): 67–86.&lt;/li&gt;
&lt;li&gt;Mintzberg, Henry (1990) &amp;#39;Strategy formation: Schools of thought&amp;#39;. In James W. Frederickson, ed., &lt;em&gt;Perspectives on strategic management.&lt;/em&gt; Harper Business, 105–235.&lt;/li&gt;
&lt;li&gt;Mintzberg, Henry and Lampel, Joseph (1999) &amp;#39;Reflecting on the strategy process&amp;#39;. &lt;em&gt;Sloan Management Review&lt;/em&gt; 40(3): 21–30.&lt;/li&gt;
&lt;li&gt;Porter, Michael E. (1980) &lt;em&gt;Competitive strategy. Techniques for analyzing industries competitors&lt;/em&gt;. New York: The Free Press.&lt;/li&gt;
&lt;li&gt;Rogers, Patrick R., Miller, Alex and Judge, William Q. (1999) &amp;#39;Using information processing theory to understand planning/performance relationships in thecontext of strategy&amp;#39;. &lt;em&gt;Strategic Management Journal&lt;/em&gt; 20(6): 567–577.&lt;/li&gt;
&lt;li&gt;Speed, Richard J. (1989) &amp;#39;Oh Mr Porter! A Re-Appraisal of Competitive Strategy&amp;#39;. &lt;em&gt;Marketing Intelligence and Planning&lt;/em&gt; 7(5): 8–11.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Strategic Management and Business Performance</title>
      <link>https://lucidmanager.org/management/strategic-management-and-business-performance/</link>
      <pubDate>Fri, 28 Aug 2009 23:16:36 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/strategic-management-and-business-performance/</guid>
      <description>
	
&lt;p&gt;
A considerable amount of research has been devoted to establishing a relationship between strategic management and business performance. The spectrum of conclusions ranges from strong positive correlations to claims that the role of formal planning systems in business management is only informational (Rogers, Miller &amp;amp; Judge 1999, 567–568). Hill, Jones &amp;amp; Galvin (2004, 23) take a position in this debate by claiming that &amp;#34;strategic planning, on average, has a positive impact on company performance&amp;#34;.&lt;/p&gt;
&lt;p&gt;
This claim further referred to as the &amp;#39;Performance Claim&amp;#39;, is based on research conducted by Miller &amp;amp; Cardinal (1994) and Rogers et al. (1999). Many academics question the usefulness of formal strategic planning systems as a means to improve company performance and argue that &lt;a href=&#34;https://lucidmanager.org/management/strategic-management-and-serendipity/&#34;&gt;serendipity&lt;/a&gt; plays a critical role in determining competitive advantage (Mintzberg 1979, Hart 1992, Hamel 1996).&lt;/p&gt;
&lt;p&gt;
This essay evaluates the claim that strategic planning has a positive influence on company performance. This paper argues that an organisation can not rely solely on formal systems to develop a corporate strategy. Although empirical research points towards a positive correlation between strategic planning and company performance, these studies suffer from some methodological problems.&lt;/p&gt;
&lt;p&gt;
It will further be argued that because strategic management is not an exact science, strategy formulation requires a great deal of intuition and company performance relies to some extent on serendipity. This finding does, however, not imply that strategic planning as a formal exercise is futile. Strategic planning is vital for excellent management of an organisation. Not as a means to plot the course for years ahead, but as a way to be able to anticipate the unpredictability of external influences.&lt;/p&gt;
&lt;p&gt;
In the next section of this essay, the terms of the performance claim will be clarified. Following a discussion of research supporting and rejecting the Performance Claim, the different viewpoints are analysed and, an integrated approach to strategic planning will be proposed.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Strategic Management and Business Performance
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Performance Claim (Strategic planning, on average, has a positive impact on company performance) has two terms that need clarification before it can be assessed: strategic planning and company performance.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
What is strategic planning?
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Hill et al. (2004, 5) define strategy regarding its function as: &amp;#34;an
action a company takes to attain superior performance&amp;#34;. Functional
definitions are, however, not suitable to assess the Performance Claim.
When a strategy is defined as the action(s) taken to improve
performance, the claim that strategy enhances performance becomes a
tautology (Actions taken to attain superior performance, on average,
have a positive impact on company performance). A different kind of
definition is required to assess the Performance Claim.&lt;/p&gt;
&lt;p&gt;
Mintzberg (1979, 11) argued that strategic planning is a multifaceted
phenomenon which is impossible to define in a short essential
definition. He rejects any interpretation of strategy that restricts it
to explicit, a priori guidelines and expands restrictive definitions by
including evolved, a posteriori, consistencies in decisional behaviour
as a strategy. Mintzberg advocates a phenomenological approach and
defines strategy as a &amp;#34;plan, ploy, pattern, position and perspective&amp;#34;
(Mintzberg 1987).&lt;/p&gt;
&lt;p&gt;
The multifaceted approach of Mintzberg is more suitable to assess the
Performance Claim because it explains what strategic management is or
can be, not what it is intended to do. Strategic planning is the formal
process, or set of processes used to determine the strategies (actions)
of the organisation (Hill et al. 2004, 5). Not all strategy is, however,
derived from a formalised process. Hill et al. (2004, 23) distinguish,
following Mintzberg, between intended strategy and emergent strategy. In
intended strategy—the formal strategic planning process—strategic
choices are based on rigorous analysis of external and internal factors.&lt;/p&gt;
&lt;p&gt;
Emergent strategies, on the other hand, originate from organisational
grassroots. Emergent strategies are not developed but evolve in an
organisation through actions that the organisation takes in reaction to
internal and external circumstances (Hill et al. 2004, 20). The
discourse around the Performance Claim focuses on the impact on the
performance of strategic planning as a formalised process. In this
essay, the Performance Claim will be evaluated from both perspectives.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Company performance
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Company performance is traditionally related to increasing shareholder
value. Performance can, however, also be measured regarding reduction of
environmental footprint, improved occupational health and safety
performance, increased customer satisfaction and so on. All research
referred to in this essay uses the restricted interpretation of company
performance, e.g. financial performance.&lt;/p&gt;
&lt;p&gt;
A key term in the Performance Claim is that company performance is on
average positively affected by formal strategic planning. The research
referred to in this essay (Miller &amp;amp; Cardinal 1994, Rogers et al. 1999)
investigated whether a positive correlation between the amount of
strategic planning and company performance exists; the more formal
strategic planning, the better a company will perform.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
The Performance Claim
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The Performance Claim states that there exists a positive correlation
between the extent of formal strategic planning and financial company
performance.&lt;/p&gt;
&lt;p&gt;
Miller &amp;amp; Cardinal (1994) argue that strategic planning positively
influences financial performance of an organisation. They investigated
how firm size, capital intensity and environmental turbulence influence
performance in firms with different degrees of formal strategic
planning. The authors concluded that the mean correlations support the
thesis that planning positively affects growth and profitability. The
correlations show a fairly large fluctuation (\(0.30 &amp;lt; r^{2} &amp;lt; 0.71\)), but
are skewed towards positive performance. They also concluded that
stronger planning-profitability correlations emerge when firms face
turbulent environments (Miller &amp;amp; Vaughan 2001, 1658).&lt;/p&gt;
&lt;p&gt;
Rogers et al. (1999) argued that a direct link between strategic
planning and performance could not be made without considering the
moderating effect of the actual content of the strategy. They
investigated whether the relationship between strategic planning
processes and organisational performance depends on the content of the
strategy pursued and not just the extent of planning. Strategic planning
was measured by using a questionnaire completed by representatives of
several banks, which resulted in a set of planning dimensions:
accounting control, integration &amp;amp; coordination, flexibility, goals &amp;amp;
plans, scanning and broad analysis. When the data was controlled to
include strategy content, it was found that strategy content moderates
the relationship between planning and performance. The overall
conclusion of their research was that formal strategic planning
positively influences company performance, as expressed in the
Performance Claim.&lt;/p&gt;
&lt;p&gt;
Mankins &amp;amp; Steele (2005) support the Performance Claim but argue that
companies typically only realise 63% of the potential value of their
strategy because of defects in planning and execution. Mankins and
Steele provide a list of causes of performance loss but do not recognise
that contingencies can negatively influence company performance. They
thus imply that any strategy can be realised, as long as planned and
executed appropriately.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Emergent Strategy and company performance
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Several researchers emphasise the importance of emergent strategy
formulation and downplay the role of formal strategic planning. They
argue that luck plays a critical role in whether an organisation is
successful or not (Mintzberg 1979, Hart 1992, Hamel 1996).&lt;/p&gt;
&lt;p&gt;
Strategy formation is, according to Mintzberg, the interplay between the
formal, intended strategies and informal, emergent strategies, mediated
by leadership (Mintzberg 1979, 72). He emphasises that strategy is not a
fixed plan, nor does it change systematically at prearranged times at
the will of management (Mintzberg 1979, 84). Mintzberg emphasises the
unpredictability of the external environment. An organisation can find
itself in a stable environment for long periods of time, without the
need to change its strategy. Sometimes the environment can, however,
become so turbulent that even the best planning techniques are useless
because of the high level of unpredictability (Mintzberg 1979, 75). This
seems to contradict the finding of Rogers et al. (1999) that stronger
planning-profitability correlations emerge when firms face turbulent
environments. Companies that perform well in a chaotic environment
acknowledge that circumstances are in eternal flux. Both Rogers and
Mintzberg are correct, the world is unpredictable, but proper strategic
planning includes provisions for this uncertainty, such as scenario
planning (Hill et al. 2004, 23).&lt;/p&gt;
&lt;p&gt;
Hamel (1996) argues that strategic planning as it is practised in
business management is not strategic at all. He claims that strategy
development tends to be a reductionist process, based on simple rules
and heuristics, working from the present to the future, rather than the
other way around. The strategic planning process is mostly
extrapolative, and it is assumed that the future will resemble the past,
an assumption that David Hume has shown to be irrational more than 250
years ago (Prevos 2005). Hamel emphasises the creative aspect of
strategic management and points out that it is not a rote process that
can be instrumentalised in neat systems, but a quest that must be a
subversive revolution to improve company performance (Hamel 1996, 71).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
An integrated approach
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Hill et al. (2004, 130) argue that, although luck may be a reason for an
organisation&amp;#39;s success in particular cases, it is an unconvincing
explanation for the persistent success of a company. They find it
&amp;#34;difficult to imagine how sustained excellence &lt;em&gt;…&lt;/em&gt; could result from
anything other than a conscious effort&amp;#34; (Hill et al. 2004, 130). There
are, however, many examples of how luck has positively influenced the
future of organisations dramatically, and vice versa how unpredictable
external circumstances have negatively influenced an organisation&amp;#39;s
fortune.&lt;/p&gt;
&lt;p&gt;
Empirical research shows a positive correlation between the extent of
formal strategic planning and company performance (Miller &amp;amp; Cardinal
1994, Rogers et al. 1999). This research does, however, not prove a
causal link between strategic planning and company performance. From an
evolutionary perspective, only those companies that maintain a positive
performance will survive. The research did not include an analysis of
failed companies and their strategic planning. Furthermore, the research
focusses on realised strategies. Mintzberg argues in this context that
achieved strategy is always a combination of intended and emergent
strategies (Mintzberg 1979, Mintzberg 1987). Following Mintzberg&amp;#39;s
typology of strategy formulation, the positive correlation between
strategic planning and performance is not only based on formal,
intended, strategy. Emergent strategy, and thus serendipity, luck and
informal strategy formulation, play an essential role in achieving
positive performance. This concept also explains the seeming
contradiction between Rogers and Mintzberg regarding the influence of
turbulence. Hill et al. (2004, 21) recognise the mutual importance of
intended and emergent strategy and stress that management needs to
understand the process of emergence and intervene when appropriate. Even
though these strategies evolve without going through the formal process,
management needs to evaluate these and select those that align with the
vision set for the organisation.&lt;/p&gt;
&lt;p&gt;
Hart (1992) summarises the discourse between proponents of strict formal
planning and those that stress the limits of this approach. He refers to
formal planning as the rational model for strategy formulation. The
rational model advocates to consider all available alternatives,
identify and evaluate all of the consequences of each option and then
select the preferred alternative. Researchers challenging this approach
argue that organisations can achieve only limited rationality because of
individual cognitive limits, heuristics and biases in human judgement.&lt;/p&gt;
&lt;p&gt;
Hart proposes an integrated approach to strategy formulation. Hart
argues that prior literature on the subject has focused on a particular
theme and has failed to capture the full range of the phenomenon of
strategic planning.&lt;/p&gt;
&lt;p&gt;
An integrated approach to strategic management is required to get the
full benefits. Strategic planning will not automatically positively
influence performance once put into place; it requires constant
&amp;#34;tinkering and kludging&amp;#34; to deal with continually changing
circumstances.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Strategic management as a science
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Research into strategy formulation has resulted in a plethora of
strategic management theories. The fundamental differences between
individual approaches and the fact that they come and go in quick
succession support the claim that there is no firm scientific basis for
theories of management (Miller &amp;amp; Vaughan 2001, 5).&lt;/p&gt;
&lt;p&gt;
Strategic management theory is an eclectic field with contributions from
military history, engineering, industrial economics, organisational
sociology, behavioural, cognitive and social psychology, anthropology
and political science (Foster &amp;amp; Browne 1996, 21). Strategic management
is thus more aligned with social sciences than the exact sciences and as
such needs a methodology to suit the unpredictability of human
behaviour, rather than a rational model, feigning predictability.&lt;/p&gt;
&lt;p&gt;
Management deals with human beings and their social interaction and both
the external and internal environment are in a constant state of flux. A
strategy will only improve performance if its formulation takes the
fundamental unpredictability of the world into account. Strategy cannot
be formulated through rational systems that model the real world.
Formulating strategy is a continuously developing narrative between the
organisation and the external environment.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Conclusion
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;In this essay, the question of whether strategic planning has, on
average, a positive impact on company performance has been investigated.
It has been argued that this is indeed the case, but a business can not
rely on formal strategy planning alone to affect performance positively.&lt;/p&gt;
&lt;p&gt;
Although research (Miller &amp;amp; Cardinal 1994, Rogers et al. 1999) has
established a positive correlation between strategic planning and
company performance, it has not found a causal relationship between
formal strategic planning and improved company performance. Strategy
formulation is a complex synergy of intended and emergent strategy, and
positive company performance is brought about by a combination of both.&lt;/p&gt;
&lt;p&gt;
It has also been argued that strategic management as science is closely
related to social sciences and that the methodology of strategy
formulation needs to fit the nature of the discipline. This idea does
not mean that strategic planning is a futile exercise. Even in uncharted
waters, a course needs to be chosen, even if there are no reference
points for orientation. Strategic planning is vital for ensuring
continued good company performance. Only those organisations that
practice some form of strategic planning will survive. Not strategy as a
rational model to plot the course for years ahead, but as a narrative
between the organisation and the external environment, anticipating the
unpredictability of external influences.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
References
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-2&#34;&gt;
&lt;ul&gt;
&lt;li&gt;Foster, J. &amp;amp; Browne, M. (1996), &lt;em&gt;Principles of Strategic Management&lt;/em&gt;, Macmillan, chapter The evolution of strategic management thought, pp. 1–50.&lt;/li&gt;
&lt;li&gt;Hamel, G. (1996), Strategy as revolution, &lt;em&gt;Harvard Business Review&lt;/em&gt; (July–August), 69–82.&lt;/li&gt;
&lt;li&gt;Hart, S. L. (1992), An integrative framework for strategy-making processes, &lt;em&gt;Academy of Management Review&lt;/em&gt; 17(2), 237–351.&lt;/li&gt;
&lt;li&gt;Hill, W., Jones, G. R. &amp;amp; Galvin, P. (2004), &lt;em&gt;Strategic management: An integrated approach&lt;/em&gt;, Wiley, Milton.&lt;/li&gt;
&lt;li&gt;Mankins, M. C. &amp;amp; Steele, R. (2005), Turning great strategy into great performance, &lt;em&gt;Harvard Business Review&lt;/em&gt; (July–August), 64–72.&lt;/li&gt;
&lt;li&gt;Miller, C. C. &amp;amp; Cardinal, L. B. (1994), Strategic planning and firm performance: a synthesis of more than two decades of research, &lt;em&gt;Academy of Management Journal&lt;/em&gt; 37(6), 1649–1665.&lt;/li&gt;
&lt;li&gt;Miller, T. R. &amp;amp; Vaughan, B. J. (2001), Messages from the management past: Classic writers and contemporary problems, &lt;em&gt;SAM Advanced Management Journal&lt;/em&gt; pp. 4–11.&lt;/li&gt;
&lt;li&gt;Mintzberg, H. (1979), Patterns is strategy formation, &lt;em&gt;International Studies of Management and Organisation&lt;/em&gt; IX(3), 67–86.&lt;/li&gt;
&lt;li&gt;Mintzberg, H. (1987), The strategy concept I: Five Ps for strategy, &lt;em&gt;California Management Review&lt;/em&gt; 30(1), 11–24.&lt;/li&gt;
&lt;li&gt;Rogers, P. R., Miller, A. &amp;amp; Judge, W. Q. (1999), Using information processing theory to understand planning/performance relationships in the context of strategy, &lt;em&gt;Strategic Management Journal&lt;/em&gt; 20(6), 567–577.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Environmental Ethics for Managers: Using Deontic Constraints</title>
      <link>https://lucidmanager.org/management/environmental-ethics-for-managers-deontic-constraints/</link>
      <pubDate>Wed, 22 Jul 2009 21:39:42 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/environmental-ethics-for-managers-deontic-constraints/</guid>
      <description>
	
&lt;p&gt;
What responsibility does a manager have concerning environmental ethics? Mr Freeman was a model citizen with a long career in public service. In 2003 he held the position of Director of Infrastructure at the Port Macquarie-Hasting Council and was responsible for the implementation of infrastructure works. However, this year Mr Freeman paid a hefty personal price after an error of judgement destroyed the habitat of two threatened animal species during road construction project (Land &amp;amp; Environment Court of New South Wales 2009). This case is of importance because Justice Lloyd pierced the corporate veil for environmental offences by holding Mr Freeman partially personally accountable for the damage caused by the construction works (Blake Dawson 2009; Thomas 2009).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Justice Lloyd pierced the corporate veil for environmental offences.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
This essay discusses the Corporate Governance aspects of this case from the stakeholder perspective and an ethical perspective. A combination of utilitarian and Kantian environmental ethics is used to argue that the Council failed to recognise the environment as a stakeholder and as such gave preference to potential financial gain over the environmental damage. Furthermore, it is recommended that governance systems based on ISO 14001 could have prevented the destruction of habitat.&lt;/p&gt;
&lt;p&gt;
In 2003, Port Macquarie-Hasting Council (the Council) engaged in the construction of roadworks on land owned by the Council in an area known as Partridge Creek. Mr Freeman was responsible for overseeing these works. As part of the preparation for this project, several environmental assessments were undertaken, and the Council was aware that this land is a habitat of the Grass Owl and the Eastern Chestnut Mouse, both listed as threatened species. Construction works commenced, ignoring this information and destroyed habitat for these species (Land &amp;amp; Environment Court of New South Wales 2007, 2009).&lt;/p&gt;
&lt;p&gt;
Council and Mr Freeman were prosecuted by Mr Garrett, representing the Department of Environment and Conservation. Justice Lloyd found that Council&amp;#39;s system of works to mitigate environmental risk had failed in that Mr Freeman “completed a tick-a-box checklist which did not even mention the threatened species” (Land &amp;amp; Environment Court of New South Wales 2009: 28). One of Mr Freedman&amp;#39;s defences was that he had no training in environmental assessments and that no manuals were available and he thus could not be held liable for the quality of the evaluations.&lt;/p&gt;
&lt;p&gt;
Justice Lloyd found this not to be a sufficient defence (Land &amp;amp; Environment Court of New South Wales 2009: 81). Justice Lloyd further observed that: “… as a director and sometimes acting General Manager of the council Mr Freeman ought to have made proper efforts to find out what was required for a proper assessment after having become aware that such an assessment was required” (Land &amp;amp; Environment Court of New South Wales 2009: 162).&lt;/p&gt;
&lt;p&gt;
Both the Council and Mr Freedman were found guilty. Mr Freeman was convicted of paying $57,000 in fines and $167,500 prosecutor&amp;#39;s costs. Council was convicted of paying similar amounts (Land &amp;amp; Environment Court of New South Wales 2009). The proceedings against the Council and Mr Freeman have prompted improvements to the way projects are managed, including a project management facilitation process aimed at ensuring there is a documented and accountable process for projects planning and obtaining approvals. Environmental checklists have been rewritten, and measures to ensure that staff are properly trained to have been implemented (Land &amp;amp; Environment Court of New South Wales 2009; Port Macquarie-Hastings Council 2007: 163).&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Stakeholder Perspective
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Given that Port Macquarie-Hastings Council is not a corporation in the traditional sense of the word, i.e. it is not owned by shareholders, the standard owner-centric model for corporations cannot be applied to this case. The Council is therefore viewed from the stakeholder perspective. A stakeholder is any person or organisation that has an interest in the dealings of the Council (Du Plessis et al. 2005). In this model, directors and managers have a &lt;a href=&#34;https://lucidmanager.org/management/milton-friedman-corporate-social-responsibility/&#34;&gt;responsibility to all stakeholders&lt;/a&gt;, including the owners.&lt;/p&gt;
&lt;p&gt;
Management must look after the health of the organisation, balancing the competing claims of the different stakeholders (Beauchamp and Bowie 1997). Two of the stakeholders that have an interest in the Council, i.e. the community and the environment, are discussed below.&lt;/p&gt;
&lt;p&gt;
The community in which the Council operates is its most important stakeholder. As the Council is a public organisation, no specific owners can be identified. The community is effectively acting in this role, and the owners of the Council are thus the people of Port Macquarie and Hastings. Complicating factor in the case of public organisations, such as Councils and utilities, is that most owners are also customers of that same organisation. The community is thus a stakeholder that
embodies both the owners and the customers of the Council.&lt;/p&gt;
&lt;p&gt;
Corporations are characterised by a separation of ownership and control of operations. This characterisation is the genesis of the Agency Problem, which deals with the difficulty of effective corporate control to ensure that managers act in the best interest of the owners. Managers, who serve as agents for the owners, may not always work in the best interest of owners when control is separate from ownership (Bonazzi 2007).&lt;/p&gt;
&lt;p&gt;
Stakeholder theory effectively expands the realm of interest of the organisation to all stakeholders. The &lt;em&gt;Agency Problem&lt;/em&gt; is thus also expanded as none of the stakeholders, including the community, have no direct control over decisions made by the Council. The case under consideration is an illustration of the Agency Problem. Mr Freeman has taken environment risk to obtain financial benefits to the detriment of the environmental, resulting in significant monetary damages. Mr Freedman thereby damaged the interests of the community, as the additional financial burden will negatively impact on the level of service the Council can provide.&lt;/p&gt;
&lt;p&gt;
Managers will optimise decisions only if appropriate incentives are given, clear limits of responsibility are defined, and activities are monitored (Bonazzi 2007). From the court proceedings, there is, however, no evidence that a comprehensive process for managing environmental risk was in place and the internal audit program did not include environmental risk (Land &amp;amp; Environment Court of New South Wales 2009).&lt;/p&gt;
&lt;p&gt;
After the initial court proceedings, the Council developed a comprehensive Project Management Framework and compliance with these requirements was added to the internal audit plan (Port Macquarie-Hastings Council 2007), thereby protecting the interests of the community. The Natural Environment is the second importantstakeholder in this case.&lt;/p&gt;
&lt;p&gt;
Although the natural environment is voiceless and can thus not express its preferences, it is embodied by lobby groups and environmental regulators. The environment is generally included as a stakeholder because of the recognition that it is an essential aspect of the long-term sustainability of corporations and society in general (Du Plessis et al. 2005). As discussed below, the standard ethical theory is anthropocentric and is as such, not able to account for the environment. This has created a situation where the environment is seen as a means to achieve financial objectives, resulting in its short-term exploitation.&lt;/p&gt;
&lt;p&gt;
Mr Freeman made an error in judgement in that he prioritised the short-term financial interests of the Council over the long-term interests of the environment. This is in line with the classical view of the firm in which all benefits are internalised, and the costs of actions are externalised (Beauchamp and Bowie 1997). In effect, the environment, embodied by the two threatened species, has paid the price for the financial gain anticipated by the Council. Governments have put environmental legislation in place to regulate the behaviour of managers, to counter the natural tendency of corporations to externalise the cost of their actions. It is clear from the court proceedings that Mr Freeman did not recognise the environment as a stakeholder with intrinsic value and it was only because of legislative pressures that the Council adopted a better way to mitigate environmental damage in future projects.&lt;/p&gt;
&lt;p&gt;
In summary, the stakeholder view of an organisation ensures that the no harm principle applies to all stakeholders, rather than only the owners. For activities with potential harm to the natural environment, it is essential to consider it as a stakeholder, represented by relevant legislation and interest groups.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Environmental Ethics for Managers and Deontic Constraints
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;From an ethical point of view, the Council has given priority to maximising the financial return of the land over its environmental value (Land &amp;amp; Environment Court of New South Wales 2009: 74). To assess the moral implications of the Council&amp;#39;s actions, two ethical models (Brennan and Lo 2008) are applied to this case.&lt;/p&gt;
&lt;p&gt;
Consequential environmental ethics consider an action right or wrong by assessing the perceived consequences. In utilitarianism, the most widely used consequentialist theory, the outcome of an action is considered good if ‘utility&amp;#39;, i.e. pleasure or happiness, is maximised. For utilitarian environmental philosophers, such as Peter Singer (1979), this argument is extended to include animals. In other words, for an action to be ethical, the overall utility as a consequence of the action for all sentient beings needs to be maximised.&lt;/p&gt;
&lt;p&gt;
However, utilitarianism is problematic as an ethical theory for environmental concerns (Brennan and Lo 2008). The environment does not only consist of humans and animals, but also of non-sentient entities such as plants, rivers and landscapes. Following the utilitarian strand of thought, these are not objects of moral concern as they cannot experience pleasure or pain and are thus of instrumental value to the satisfaction of sentient beings (Brennan and Lo 2008).&lt;/p&gt;
&lt;p&gt;
To determine whether the actions of the Council were ethical from a utilitarian point of view would require an extensive cost-benefit analysis, the so called Hedonistic Calculus, which lies outside the scope of this essay. What can be asserted is that the Council&amp;#39;s actions reduced the utility of the threatened species by destroying their natural habitat. Whether this has preference over the anticipated financial return anticipated through the new infrastructure is not immediately apparent.&lt;/p&gt;
&lt;p&gt;
Deontological theories consider whether an action is right or wrong irrespective of the consequences. Following Emmanuel Kant&amp;#39;s second formulation of the Categorical Imperative, humanity can never be used as a means to an end: “Act in such a way that you treat humanity, whether in your person or the person of any other, always at the same time as an end and never merely as a means to an end.” (Kennett and Townsend 1998: 75). In deontological environmental ethics, the anthropocentrism of the Categorical Imperative is expanded to include the environment (Brennan and Lo 2008). From a stakeholder theory perspective, every stakeholder, including the environment, has intrinsic value and a right not to be treated as a means to an end. This view is expressed in concepts such as product liability, industrial relations and environmental regulation (Beauchamp and Bowie 1997). A deontological environmental thinker could thus argue that the Council violated the intrinsic value of the two threatened species because they were used as a means to an end; as a means to obtain financial gain.&lt;/p&gt;
&lt;p&gt;
In summary, assessing this case from an ethical perspective confirms the importance of including the environment as a stakeholder with intrinsic value. This case illustrates that without this concept the environment can be used as a means to an end, as a means to increase the utility of the other stakeholders.&lt;/p&gt;
&lt;p&gt;
This case shows that using a stakeholder view of an organisation, as opposed to the classical view which gives preference to the owners, provides a better model to ensure all legal and moral obligations can be fulfilled. Furthermore, it is essential to recognise the natural environment as a stakeholder with equal intrinsic value equal to all other stakeholders. Assessing this case from an ethical perspective shows that the utilitarian point of view can lead to infinitely complex discussions about the utility of the consequences of each action the Council can undertake. How can the Council decide which values have precedence in this case? From a legal point of view, there is no issue as legislative powers have agreed to provide the threatened species with intrinsic preferential values over the anticipated financial gain. The principle nevertheless remains. Some organisations aim to alleviate this issue by using a Triple Bottom Line approach, in which financial, social and environmental values are compared.&lt;/p&gt;
&lt;p&gt;
This inherently utilitarian point of view has, however, never been implemented to its fullest extent because there is no agreement between the relative value of environmental versus social and financial values (Norman and MacDonald 2004). In practical terms, what is the value of the survival chances of the Grass Owl and the Eastern Chestnut Mouse compared to the social and financial benefits of the road construction undertaken by Council? Regardless of the inherent issues with consequentialism, it is an intuitively appealing model that is widely used in decision-making processes.&lt;/p&gt;
&lt;p&gt;
The non-consequentialist deontological view offers a way to mitigate the issues inherent with utilitarianism. Although in practice a Triple Bottom Line analysis is required to come to decisions, the law acts as a deontic constraint to ensure that voiceless stakeholders, such as the environment, are provided with intrinsic value. This forces organisations to act dutifully to the environment and other stakeholders.&lt;/p&gt;
&lt;p&gt;
From a practical point of view, the managerial impact of this case is that senior managers can be held personally accountable and that they need to consider the environment as a stakeholder with intrinsic value.&lt;/p&gt;
&lt;p&gt;
Not being an expert in the issue at hand is not accepted as a reasonable defence (Thomas 2009). Being aware of environmental issues is not sufficient and taking active steps to implement a robust Environmental Management System is the best risk management approach (Blake Dawson 2009; Thomas 2009). Most Australian states and territories maintain environmental laws which effectively deem certain corporate officers to be guilty of offences which their corporate officers commit (Thomas 2009). These laws are necessary to ensure that corporations and public organisations appropriately assign value to the environment over anticipated financial gains and other perceived internalised benefits.&lt;/p&gt;
&lt;p&gt;
One mechanism to control environmental risk, used by many organisations around the world, is ISO 14001:2007 Environmental Management Systems. This international benchmark defines standards for management commitment to ensure that directors and senior managers are aware of and actively involved in mitigating environmental risk (Maharaj and Ramnath 2005). The risk of habitat destruction would have been recognised and mitigated had the Council implemented such a system before undertaking the road construction works.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
References
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;ul&gt;
&lt;li&gt;Beauchamp, Tom L. and Bowie, Norman E., eds. (1997) &lt;em&gt;Ethical theory and business.&lt;/em&gt; 5th ed. Prentice Hall.&lt;/li&gt;
&lt;li&gt;Blake Dawson (2009) Prosecution of employees for breaches of environmental legislation.&lt;/li&gt;
&lt;li&gt;Bonazzi, Livia (2007) &amp;#39;Agency theory and corporate governance: A study of the effectiveness of board in their monitoring of the CEO&amp;#39;. &lt;em&gt;Journal of Modelling in Management&lt;/em&gt; 2(1): 7–23.&lt;/li&gt;
&lt;li&gt;Brennan, Andrew and Lo, Yeuk-Sze (2008) &lt;a href=&#34;http://plato.stanford.edu/archives/fall2008/entries/ethics-environmental/&#34;&gt;Environmental Ethics&lt;/a&gt;. In Edward N. Zalta, ed., The Stanford Encyclopedia of Philosophy, fall 2008.&lt;/li&gt;
&lt;li&gt;Du Plessis, J, McConvill, J and Bagaric, M (2005) &lt;em&gt;Principles of Contemporary Corporate Governance.&lt;/em&gt; Melbourne: Cambridge University Press.&lt;/li&gt;
&lt;li&gt;Kennett, Jeanette and Townsend, Aubrey, eds. (1998) &lt;em&gt;Ethics. Unit Study Guide&lt;/em&gt;. Monash University.&lt;/li&gt;
&lt;li&gt;Land &amp;amp; Environment Court of New South Wales (2007) Garrett v Freeman (No. 4).&lt;/li&gt;
&lt;li&gt;Land &amp;amp; Environment Court of New South Wales (2009) Garrett v Freeman (No. 5); Garrett v Port Macquarie Hastings Council.&lt;/li&gt;
&lt;li&gt;Maharaj, Priya S and Ramnath, Kelvin (2005) &amp;#39;Benefits in an Environmental Management System&amp;#39;. &lt;em&gt;ASQ World Conference on Quality and Improvement Proceedings&lt;/em&gt; : 347–352.&lt;/li&gt;
&lt;li&gt;Norman, Wayne and MacDonald, Chris (2004) &amp;#39;Getting to the Bottom of Triple Bottom Line&amp;#39;. &lt;em&gt;Business Ethics Quarterly&lt;/em&gt; 14(2): 243–262.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://www.pmhc.nsw.gov.au/&#34;&gt;Port Macquarie-Hastings Council&lt;/a&gt; (2007) &amp;#39;Council meeting 06 August 2007&amp;#39;. &lt;/li&gt;
&lt;li&gt;Singer, Peter (1979) &lt;em&gt;Practical Ethics&lt;/em&gt;. Cambridge University Press.&lt;/li&gt;
&lt;li&gt;Thomas, Nick (2009) &amp;#39;Environmental compliance for directors and managers—a timely reminder&amp;#39;. &lt;em&gt;Keeping good companies&lt;/em&gt; 61(4): 231–233.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Milton Friedman on Corporate Social Responsibility</title>
      <link>https://lucidmanager.org/management/milton-friedman-corporate-social-responsibility/</link>
      <pubDate>Tue, 14 Jul 2009 00:00:00 +0000</pubDate>
      <author>Peter Prevos &amp; Ian Watson</author>
      <guid>https://lucidmanager.org/management/milton-friedman-corporate-social-responsibility/</guid>
      <description>
	
&lt;p&gt;
The question of how ethics and morality can be applied to human experience is a vexed one. Though philosophers have discussed abstract ethical dilemmas for most of recorded history, there appears to &lt;a href=&#34;https://horizonofreason.com/culture/ethical-relativism-example/&#34;&gt;be no universal answer to resolve ethical problems&lt;/a&gt;. The varied works of philosophers have led to the development of ethical frameworks that may be applied to any particular situation. This essay discusses the views of  Milton Friedman on corporate social responsibility.&lt;/p&gt;
&lt;p&gt;
The answer to an ethical question may differ depending on which moral framework is used. For this reason, taking complex and abstract ethical theories and applying them to the decision-making processes of company directors can lead to unresolvable arguments in boardrooms, restaurants, shareholders meetings, scholarly journals and, of course, the media. Milton Friedman proposed a guiding principle for business ethics in a New York Times article, provocatively titled: “The social responsibility of business is to increase its profits”:&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;… there is one and only one social responsibility of business to use its resources and engage in activities designed to increase its profits so long as it stays in the rules of the game, which is to say, engages in open and free competition, without deception or fraud.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
This statement raises the question of whether directors can act in any way to increase profits. Although Friedman is clear that directors as agents of the business have to play within the rules of the game, this still leaves room for unethical behaviour. Does this mean that directors can act in any way to increase profits?&lt;/p&gt;
&lt;p&gt;
A further question raised by his article is whether corporations should engage in socially responsible activities. In this essay, Milton Friedman&amp;#39;s view is discussed and contrasted with the socio-economic view of Corporate Social Responsibility. It will be argued that directors cannot act in any way to increase profits and that corporations should engage in socially responsible activities as it can be shown that they at least have an indirect positive effect on organisational performance.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Milton Friedman and Corporate Social Responsibility
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Friedman argued for a direct form of capitalism and against any activity that distorts economic freedom.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-2&#34; href=&#34;#footnote-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; Socially responsible activities conducted by a corporation are, according to Friedman, distorting economic freedom because shareholders are not able to decide how their money will be spent. Friedman thus argues that corporations should focus on those activities that are causally related to company profit, effectively excluding charitable activities that do not directly generate revenue:&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-3&#34; href=&#34;#footnote-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;…[there] has been the claim that business should contribute to support charitable activities and especially to universities. Such giving by corporations is an inappropriate use of corporate funds in a free-enterprise society.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Another principle expressed by Milton Friedman is the need to stay within the rules of the game, explicitly avoiding deception and fraud. This principle is further clarified when he writes:&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-4&#34; href=&#34;#footnote-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A corporate executive … has direct responsibility to conduct business in accordance with[shareholder] desires …[i.e.] to make as much money as possible while conforming to their basic rules of the society, both those embodied in law and those embodied in ethical custom.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
This quotation implies that Friedman does not proclaim that directors can act in any way to maximise profit as they have to abide by the law and follow ethical custom. He, however, excludes explicitly charitable activities as they do not directly contribute to profit. A good corporation in Milton Friedman&amp;#39;s view is not one that undertakes activities only because they are ethically sound, but because they are economically viable. One of Friedman&amp;#39;s main arguments for excluding Corporate Social Responsibility from business stems from his views on the ethical spending:&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-5&#34; href=&#34;#footnote-5&#34;&gt;5&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Your money on yourself—spent wisely;&lt;/li&gt;
&lt;li&gt;Your money on others—spend wisely but challenging;&lt;/li&gt;
&lt;li&gt;People&amp;#39;s money on yourself—little incentive to economise;&lt;/li&gt;
&lt;li&gt;People&amp;#39;s money on other people— the role of government and &lt;a href=&#34;https://nancy-drew2326.medium.com/types-of-corporate-social-responsibility-programs-2a46d6b3edd2&#34;&gt;Corporate Social Responsibility programs&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Friedman argues that it is not appropriate for a corporate executive or director to embark on socially responsible programmes because there is little incentive for prudent expenditure, mainly when one is spending money owed to the shareholders through dividends.&lt;/p&gt;
&lt;p&gt;
Friedman proclaimed that a corporation is a morally neutral legal construct with maximising returns for shareholders as its single purpose. Directors and executives of a corporation are employed to achieve this sole objective. The only moral responsibility of directors and executives is to meet shareholder expectations, which is to maximise their return on investment.&lt;/p&gt;
&lt;p&gt;
Friedman&amp;#39;s view is akin to social Darwinism, applying the survival of the fittest principle to the market to ensure the best of all possible outcomes. Friedman interprets this principle as the corporation with the highest return to shareholders. When the issue of an electric company that cut supply to a customer for non-payment upon which the customer died as a consequence was presented to Friedman, he applied the Kantian view to justify their actions. He argued that a utility company that does not cut off electricity to non-paying customers would perish as there is no reason for customers to pay their bills. In Friedman&amp;#39;s view, disconnecting non-paying customers has to be regarded as a universal maxim, regardless of the specific outcomes. He considers this as ethical because the directors have a moral duty to ensure the survival of the corporation.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/ev_Uph_TLLo?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Milton Friedman (1978) &lt;em&gt;Milton Friedman Speaks&lt;/em&gt; (Video). &lt;em&gt;The Idea Channel&lt;/em&gt;.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Socio-economic School
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The counterpoint to Friedman&amp;#39;s view is developed in the socio-economic school of Corporate Social Responsibility. One of the leading proponents of this view proposed the Iron Law of Responsibility, which holds that the “social responsibilities of businessmen need to be commensurate with their social power”, which was further built upon by Frederick:&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-6&#34; href=&#34;#footnote-6&#34;&gt;6&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;… businessmen should oversee the operation of an economic system that fulfils the expectations of the public. And this means in turn that the economy&amp;#39;s means of production should be employed in such a way that production and distribution should enhance total socio-economic welfare.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The socio-economic view is a utilitarian argument as emphasises that the total socio-economic welfare of society should be enhanced, rather than focusing on the well-being of shareholders, as Friedman proclaimed. Companies that operate exclusively for the sake of maximising shareholder return and thus do not engage in socially responsible activities are considered unethical in the utilitarian point of view. Following the utilitarian adage of providing the greatest good for the greatest number of people, companies are ethically obliged to participate in socially responsible activities that maximise the total welfare of all stakeholders. There is, however, a problem with applying standard consequentialist theories where we are required to maximise agent-neutral value.&lt;/p&gt;
&lt;p&gt;
Utilitarianism does not distinguish between people whose utility should be maximised and thus requires a &lt;a href=&#34;https://lucidmanager.org/management/environmental-ethics-for-managers-deontic-constraints/&#34;&gt;deontic constraint&lt;/a&gt; to ensure that maximisation of the welfare of all stakeholders does not jeopardise the long-term prospects of the business. A deontic constraint is a principle that assigns a value to individual agents over others, and in the case of corporate social responsibility, it could be argued that the rights of the shareholders should be protected in preference of the rights of the whole of society.&lt;/p&gt;
&lt;figure&gt;
&lt;p alt=&#34;What would Milton Friedman say about Fair Trade? - Ethical marketing in Schiphol airport, Amsterdam.&#34; title=&#34;Ethical marketing in Schiphol airport.&#34;&gt;
&lt;img src=&#34;https://lucidmanager.org/images/mba/ethical-trade.jpg&#34; alt=&#34;/images/mba/ethical-trade.jpg&#34; title=&#34;/images/mba/ethical-trade.jpg&#34;/&gt;&lt;/p&gt;
&lt;figcaption&gt;
What would Milton Friedman say about Fair Trade? - Ethical marketing in Schiphol airport, Amsterdam.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;If corporate social responsibility is detrimental to business, as suggested by Friedman, then shareholders will tend to avoid investing in companies that act socially responsible. There is, however, empirical evidence that this is not the case. Firstly, Friedman fails to acknowledge that acting ethically can be a valuable marketing proposition. By understanding the desires of consumers, a corporation can offer products and services that match their ethical thresholds, thereby adding value to both shareholders and consumers, thus avoiding &lt;a href=&#34;https://lucidmanager.org/marketing/marketing-myopia/&#34;&gt;marketing myopia&lt;/a&gt; as described by Theodore Levitt.&lt;/p&gt;
&lt;p&gt;
Consumers prefer products and services that make claims of social responsibility on product labels.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-7&#34; href=&#34;#footnote-7&#34;&gt;7&lt;/a&gt;&lt;/sup&gt; Herzberg&amp;#39;s Motivator-Hygiene Theory theoretically supports this research. Hygiene Factors are minimum conditions that must be met in the workplace to prevent work dissatisfaction. Meijer and Schuyt examined the role of Corporate Social Responsibility in purchasing behaviour and found that for Dutch consumers, corporate social performance serves more as a Hygiene Factor than as a Motivator. Interestingly, this behaviour was not related to household income. &lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-8&#34; href=&#34;#footnote-8&#34;&gt;8&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Secondly, the growth of ethical investments demonstrates that some investors prefer organisations that do not seek profit maximisation by imposing ethical constraints on their operations.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-9&#34; href=&#34;#footnote-9&#34;&gt;9&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
There is also a clear case to be made that Motivator-Hygiene Theory can be applied to shareholders. Executives and directors that behave unethically create significant shareholder dissatisfaction, as demonstrated by the many recent examples or corporate misbehaviour.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-10&#34; href=&#34;#footnote-10&#34;&gt;10&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Lastly, a meta-study undertaken by Griffin and Mahon showed that there is no consensus on a causal relationship between the level of socially responsible spending and business performance or shareholder satisfaction.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-11&#34; href=&#34;#footnote-11&#34;&gt;11&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Milton Friedman on Corporate Social Responsibility
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Milton Friedman argued vehemently against spending shareholder&amp;#39;s money for anything that does not directly contribute to increasing shareholder wealth. He took the Kantian view that directors must look after the interests of shareholders, which seek wealth maximisation. As socially responsible activities, in the opinion of Friedman, reduce wealth, companies should not engage in any charitable activities.&lt;/p&gt;
&lt;p&gt;
The socio-economic view claims that companies should maximise the good for the greatest number of people. Following a utilitarian strand of thought, this view holds that companies should engage in socially responsible actions because it maximises the wealth of all stakeholders. However, to ensure that financial sustainability of the corporation is not eroded, deontic constraints that recognise the right of shareholders to a reasonable return, need to be put in place.&lt;/p&gt;
&lt;p&gt;
In conclusion, directors do not have total freedom to maximise profit as they have to act within both the legal and ethical rules of the game. Furthermore, for companies to be genuinely ethical, they should engage in a reasonable level of socially responsible activities as this maximises the wealth of all stakeholders.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Footnotes
&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Milton Friedman. (1970) The social responsibility of business is to enhance its profits. New York Times 32(13): 122–126. Previously published in Milton Friedman (1962) &lt;em&gt;Capitalism and freedom&lt;/em&gt;. University of Chicago Press.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-2&#34;&gt;&lt;a href=&#34;#footnote-reference-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Hammond, J.D. (2003) Remembering Economics. &lt;em&gt;Journal of the History of Economic Thought&lt;/em&gt; 25(2): 133–143.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-3&#34;&gt;&lt;a href=&#34;#footnote-reference-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Friedman 1962: 135.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-4&#34;&gt;&lt;a href=&#34;#footnote-reference-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Friedman 1970.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-5&#34;&gt;&lt;a href=&#34;#footnote-reference-5&#34;&gt;5&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Waldman, D.A. and Siegel, D. (2008) Defining the socially responsible leader. &lt;em&gt;The Leadership Quarterly&lt;/em&gt; 19(1): 117–131.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-6&#34;&gt;&lt;a href=&#34;#footnote-reference-6&#34;&gt;6&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Davis, K. (1960) Can business afford to ignore social responsibilities. &lt;em&gt;California Management Review&lt;/em&gt; 2(3): 70–76, p.71. Frederick, W.C. (1960) The growing concern over business responsibility. &lt;em&gt;California Management Review&lt;/em&gt; 2(4): 54–61.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-7&#34;&gt;&lt;a href=&#34;#footnote-reference-7&#34;&gt;7&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Hiscox, M.J. and Smyth, N.F.B. (2006) &lt;em&gt;Is There Consumer Demand for Improved Labor Standards? Evidence from Field Experiments in Social Labelling&lt;/em&gt;. Department of Government, Harvard University.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-8&#34;&gt;&lt;a href=&#34;#footnote-reference-8&#34;&gt;8&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Meijer, M.M. and Schuyt, T. (2005) Corporate social performance as a bottom line for consumers. &lt;em&gt;Business &amp;amp; Society&lt;/em&gt; 44(4): 442–461.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-9&#34;&gt;&lt;a href=&#34;#footnote-reference-9&#34;&gt;9&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Guay, T., Doh, J.P. and Sinclair, G. (2004) Non-governmental organisations, shareholder activism, and socially responsible investments: ethical, strategic, and governance implications. &lt;em&gt;Journal of Business Ethics&lt;/em&gt; 52(1): 125–139.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-10&#34;&gt;&lt;a href=&#34;#footnote-reference-10&#34;&gt;10&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Carson, T.L. (2003) Self-interest and business ethics: Some lessons of the recent corporate scandals. &lt;em&gt;Journal of Business Ethics&lt;/em&gt; 43(4): 389–394.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-11&#34;&gt;&lt;a href=&#34;#footnote-reference-11&#34;&gt;11&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Griffin, J.J. and Mahon, J.F. (1997) The corporate social performance and corporate financial performance debate: Twenty-five years of incomparable research. &lt;em&gt;Business &amp;amp; Society&lt;/em&gt; 36(1): 5–31.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>An Introduction to Human Resource Management in Hanoi</title>
      <link>https://lucidmanager.org/management/human-resource-management-in-hanoi/</link>
      <pubDate>Fri, 26 Jun 2009 00:00:00 +0000</pubDate>
      <author>Peter Prevos &amp; Ian Watson</author>
      <guid>https://lucidmanager.org/management/human-resource-management-in-hanoi/</guid>
      <description>
	
&lt;p&gt;
A major attraction of travelling to other countries is that people are different to what we are used to at home. A few hours in an aeroplane carries us to places where an incomprehensible language is spoken, exotic food is eaten and almost everything else is different from what we are accustomed to. This is most certainly true for people travelling from Australia to Vietnam. The organised chaos of Hanoian traffic, the colourful markets and the narrow streets in the Old Quarter—everything is different. If everything is different, then it can be assumed that people also manage organisations in a different way and as such also manage people differently.&lt;/p&gt;
&lt;figure&gt;
&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
			&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/0iIEo6cqYpQ?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;figcaption&gt;
Hanoi Street Traffic
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The economy of Vietnam is transitioning from a centrally planned to a free market system and has moved from a situation of crisis after the war against the Americans to a vibrant, fast-growing nation. The main
question for this research is to provide a description of contemporary Human Resource Management in Hanoi, within the context of their transitioning economy.&lt;/p&gt;
&lt;p&gt;
This project is part of a research expedition to Hanoi, undertaken by the &lt;a href=&#34;https://lucidmanager.org/tags/mba/&#34;&gt;Graduate School of Management&lt;/a&gt; of La Trobe University, with assistance from Hanoi University. Data was gathered through site visits to seven local businesses and government organisations and through five confidential interviews with managers of local businesses.&lt;/p&gt;
&lt;p&gt;
Vietnam has gone through enormous changes since the introduction of Doi Moi, Vietnam&amp;#39;s economic restoration policy that commenced in 1986, the government policy that seeks to transition the Vietnamese economy from a centrally-planned to a market-driven economy (Williams 1992). The process of transition in developing economies has a major impact on the way business is adopted (Warner et al. 2005) and the way Human Resource Management practices are conducted.&lt;/p&gt;
&lt;p&gt;
Several researchers have investigated management styles in Vietnamese organisations and found significant differences between Vietnamese and Western styles of management (Nguyen 2000; Quang and Vuong 2002; Rowley and Abdul-Rahman 2008). Country culture is, however, not a homogeneous phenomenon and significant differences between the work values of North and South Vietnamese management exist (Ralston et al. 1999). This report is thus focused on Human Resource Management in North Vietnam and specifically the capital Hanoi.&lt;/p&gt;
&lt;p&gt;
A literature review of Human Resource management in Vietnam shows that Vietnamese management styles in the state sector can be “bureaucratic, familial, conservative and authoritarian”, emphasising clear reporting relationships, formal communication and strict control (Quang and Vuong 2002: 52). The &lt;em&gt;familial&lt;/em&gt; style was also widely accepted in Vietnamese enterprises; developed from &lt;a href=&#34;https://lucidmanager.org/management/nepotism-in-the-workplace/&#34;&gt;family workshops&lt;/a&gt;. In contrast, Quang and Vuong (2002) further found that a participative management style was often practised in the joint venture sector, where expatriate managers brought in Western and Japanese principles of management. Rowley and Abdul-Rahman (2008) researched the existence of convergence towards a Western style of management in Vietnamese Human Resource Management practices. They found evidence of this occurring, but argued against the use of a universal Western-inspired model of Human Resource Management and described an alternative model based on Asian values.&lt;/p&gt;
&lt;p&gt;
Following the initial review of the literature, two research questions were formulated, both very open, to allow for flexibility during the research:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;What is the role of Human Resource Management in transitioning economies?&lt;/li&gt;
&lt;li&gt;What are Human Resource Management practices in contemporary Vietnam?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The purpose of the research was not to determine how Human Resource Management in Vietnam relate to business performance, but to examine what Human Resource Management practices are actually used. The qualitative research data is analysed in detail, combined with further literature review. From the analysis, three major topics emerge.&lt;/p&gt;
&lt;p&gt;
Firstly, Vietnamese managers have a salience for management theories origination outside of Vietnam, particularly Japan and the United States.&lt;/p&gt;
&lt;p&gt;
Secondly, companies seem to rely on social networks for recruitment. This is in contrast to most Australian organisations, where public advertisements are the dominant vehicle for &lt;a href=&#34;https://lucidmanager.org/management/recruitment/&#34;&gt;recruitment&lt;/a&gt;. Research by Breaugh (1981: 145) showed that the source of recruitment is “strongly related to subsequent job performance, absenteeism and work attitudes” and that people recruited through newspaper advertisement missed almost twice as many days as those recruited through other sources, such as employee referrals.&lt;/p&gt;
&lt;p&gt;
The third finding is an indication that performance management in collective cultures, such as Vietnam, is more effective when aimed at improving the collective rather than focusing solely on the individual. Further detailed research is required to validate this hypothesis. &lt;/p&gt;
&lt;p&gt;
The managerial relevance of this research is to provide insight into Vietnamese Human Resource Management practices for those considering to invest or work in this country. The findings in this paper can also have implications for the way in which recruitment practices are conducted in Australia, specifically the use of social networks to find suitable candidates. The relevance of this report extends also into the academic realm as the secondary purpose of this project is to assess the usability of Grounded Theory in Human Resource Management research.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Literature Review
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-2&#34;&gt;
Human Resource Management in transitioning economies
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;With the introduction of Doi Moi in 1986, Vietnam has become a country with an outwardly paradoxical system, simultaneously maintaining a socialist system and a capitalist free market economy (Rowley and Abdul-Rahman 2008). This combination of socialism and capitalism seems paradoxical, but the duality of systems fits well within the Daoist inspired perspective of Vietnamese culture (Templet 1998).&lt;/p&gt;
&lt;p&gt;
A transitioning economy, such as is the case in Vietnam, is defined as one that changes from “plan to market” (Warner, Edwards, Polonsky and Pucko 2005: 3). With the collapse of the Iron Curtain in 1989, many European countries commenced the journey towards a free market economy. Before the dramatic events in Europe, countries in Asia independently started their transition.&lt;/p&gt;
&lt;p&gt;
China introduced reform after the death of Mao Zedong in 1976 and Vietnam introduced their economic restoration policy in 1986 (Warner et al. 2005). The term &amp;#39;transition&amp;#39; is somewhat problematic as the end situation is not clearly defined. Given the unpredictability of complex processes such as macroeconomic change, the endpoint of transition cannot be known a priori (Warner et al. 2005). After the collapse of communism in Europe, Fukuyama (1992) euphorically proclaimed that this signified the final victory of the free market economy and that all countries would converge towards a unified economic system. Recent history has, however, falsified Fukuyama&amp;#39;s predictions. The rise of Islamic banking as a viable and competitive alternative to conventional systems is a case in point (Khan and Bhatti 2008). The discussion about the nature of macroeconomic systems is complex and outside the scope of this report. Of particular interest to the Human Resource perspective is not so much the end goal, but the process of transition.&lt;/p&gt;
&lt;p&gt;
Warner et al. (2005) describe the process of transition from a centrally-planned to a free-market-economy in four dimensions (Figure 1). They describe a process that commences with changes in the External Economic Environment, usually the opening of foreign trade into the transitioning country. As the barriers to imports fall and more foreign products enter the market, competition in the internal market increases, which creates a link between the external and internal economic environment. In Vietnam, the start of the restoration process included a liberalisation of the import of consumer goods (Irvin 1995).&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/mba/diamond.png&#34; alt=&#34;Relationship between external and internal economic environments, organisational strategy, structure and managerial culture&#34; title=&#34;Relationship between external and internal economic environments, organisational strategy, structure and managerial culture&#34;/&gt;
&lt;figcaption&gt;
Figure 1: Relationship between external and internal economic environments, organisational strategy, structure and managerial culture (Warner et al. 2005: 17).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
The second wave of reform is related to the Internal Economic
Environment. Increased competition caused by foreign competitors
entering the market leads to changes in prices as the balance of supply
and demand alters. This process also involves a reform of the financial
system of the transitioning country, which is an ongoing process in
Vietnam (Dinh 1997; Ninh 2003; Thanh and Quang 2008). Changes in the
economic system make capital more readily available and facilitate
entrepreneurial activities. One major consequence of the liberalisation
of the Vietnamese economy is that the number of State Owned Enterprises
(SEO) has been reduced from 12,000 to 6,000 (Warner et al. 2005).&lt;/p&gt;
&lt;p&gt;
The process of divestment and privatisation of State Owned Enterprises
is still underway and is managed by the State Capital Investment
Corporation, who seek to divest a further 200 SEOs over the next two
years (SCIC 2009). Changes in the external and internal economic
environment initiate the third wave of reform, which is related to how
organisations achieve their goals. Economic forces and changes in the
competitive landscape cause organisations in transitioning economies to
reassess their Organisational Strategy and Structure. This is the moment
where businesses move from a reactive to a proactive approach in their
response to the reforms. Changes in Organisational Strategy and
Structure can, however, not be successful unless the Managerial Culture
of an organisation evolves into a performance-based system (Warner et
al. 2005).&lt;/p&gt;
&lt;p&gt;
The fourth aspect of the transitional model, Managerial Culture,
involves changes in the way individual managers approach their work. The
changing roles of managers in transitional economies can be linked to
the often cited division of labour for managers described by Mintzberg
(1971). In a planned economy, the role of managers is not as significant
as in a free market model. For example, in a free market model managers
are prime resource allocators, whereas in a planned economy resource
allocation is controlled by politicians. This implies that the demands
on managers in planned economies are lower than in a market economy.
More importantly, the demands on managers in a transitioning economy,
including their Human Resource Management skills, are even higher than
in an established market economy (Warner et al. 2005).&lt;/p&gt;
&lt;p&gt;
The model described by Warner et al. (2005) provides a framework to
analyse the processes of economic transition in countries where
macroeconomic change is taking place. The framework seems to suggest a
causality between the four aspects of transition in linear succession.
However, each of the four aspects influences each other in a network of
interdependence and reiteration of the cycle.&lt;/p&gt;
&lt;p&gt;
Changes in managerial culture improve the conditions for foreign
companies to enter a country as local companies have obtained improved
managerial competencies. Changes in organisational strategy and
structure lead to changes in the internal economic environment because
the institutions that govern the economic environment are also
influenced by transitional processes. It could be argued that the
process of transition is never ending, blurring the lines between a
developed and developing economy in some instances. Human Resource
Management plays an active role in the transitioning process as it can
play a strategic role by enabling organisations to achieve their
objectives (de Cieri et al. 2008; Hanson et al. 2008). In the background
of the transition framework, Tradition, Society, Economy and Politics
are local influences on this process of change (Warner et al. 2005).&lt;/p&gt;
&lt;p&gt;
Tradition and society are components of national culture and every
management approach is deeply affected by local culture and values
because management is, by its very nature, influenced by attitudes on
how people are viewed in a culture (Hofstede 1996). In the next chapter,
the nature of People Management (Human Resource Management) practices in
Vietnam is discussed.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Human Resource Management in Hanoi
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Human Resource Management is a wide and varied aspect of business
management that can broadly be defined as “the policies, practices and
systems that influence employee behaviour and performance” (de Cieri et
al. 2008: 4). Human Resource Management practices are, in effect, a
combination of applied psychology and sociology and, as such, a
reflection of an organisation&amp;#39;s view of humanity. They are a reflection
of how people view themselves and the society in which they interact. As
organisations are embedded in the society in which they operate, they
will, therefore, reflect the culture of that country and the
effectiveness of Human Resource Management practices will differ
depending on the cultural landscape in which they are implemented.&lt;/p&gt;
&lt;p&gt;
Organisations in developed countries deploy a suite of practices, but it
depends on the organisation&amp;#39;s structure, goals, customer profile and
societal context as to which practices are used. Given the plethora of
approaches available to managers, the Western model of Human Resource
Management can be considered inherently incoherent, which prompts one to
question the notion of &amp;#39;best practice&amp;#39; (Rowley and Abdul-Rahman 2008;
Thang et al. 2007).&lt;/p&gt;
&lt;p&gt;
It would seem that there is a significant benefit to the HR function of
a Vietnamese company becoming familiar with HR management methodologies
used in developed nations. This would allow a Vietnamese company to
quickly use and apply methodologies that have a good fit with the
organisation&amp;#39;s goals. However, there is the risk that a certain Human
Resource Management practice currently used in Vietnamese companies,
whatever those practices may be, has the potential to provide greater
benefit to the company than the methodologies used in developed nations.
Managers must be aware of sociocultural factors, particularly since the
rational systems that originate from the developed economies tend to
homogenise cultural distinctions (Hansen and Brooks 1994). The
reinterpretation of HR management methodologies by Vietnamese companies
may provide unexpected benefit beyond Vietnam. The introduction of total
quality management into Japanese firms by W. Edwards Deming and its
subsequent reinterpretation within the Japanese context has been not
only a boon to Japanese firms, contributing significantly to their rapid
development, but has also proven extremely beneficial and applicable to
many Western firms (Gill and Wong 1998; Wren 2005). The benefits of
documenting and understanding Vietnamese beneficial practices and also
understanding modified practices is vital to the improving management,
and in the case of this study, Human Resource Management in Vietnam,
Asia, developing and developed nations alike.&lt;/p&gt;
&lt;p&gt;
When examining the Vietnamese context, it is difficult to determine
whether there are intrinsically Vietnamese people-management practices
without conducting in-depth comparative research. However, as suggested
by Meyer (2006), there is a hazard of confirmation bias in the conduct
of research when he suggested that: “Scholars working within existing
theoretical frameworks may, in fact, limit their cognitive horizons …
Empirical tests of hypotheses derived from mainstream theories may
confirm the theory, even if the overall explanatory power is weak. On
the surface, firm behaviour may be sufficiently similar to allow Western
theories to be tested and confirmed, yet this does not imply that the
same variables are actually important in the local context.”&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
The Flow of Human Resource Management Practices
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Examining HR management practices in the Vietnamese context has been
conducted in the past and has provided some useful information about the
attitudes toward HR management in Vietnam. Management styles in the
State-Controlled sector have been found to be “bureaucratic, familial,
conservative and authoritarian”, emphasising clear reporting
relationships, formal communication and strict control (Quang and Vuong
2002: 52). The heritage of family workshops is widely accepted to have
given rise to the “familial” style of management that is commonplace in
Vietnam.&lt;/p&gt;
&lt;p&gt;
A participative work style is predominantly found in joint venture
organisations (Quang and Vuong 2002) in which the Western style of
management has been effectively imported to Vietnam via expatriate
managers from Western Countries and Japan (Rowley and Abdul-Rahman
2008). While the work of Quang, Vuong, Rowley and Abdul-Rahman explain
some aspects of Human Resource Management in Vietnam, there is a
significant gap in scholarly research into Vietnamese Human Resource
Management practice. In a broader sense, a model developed by Zhu (2008)
seeks to explain how management practices flow between the United
States, Europe and Asia (Figure 2). The development of Human Resource
Management methodologies in East Asia is predominantly influenced by
companies operating in those countries. As economies develop to a point
at which Foreign Direct Investment (FDI) is liberalised and subsequently
increases, as shown in the model by Warner et al. (2005) (Figure 1), 
companies import their native Human Resource Management
practices when moving to another country. In this respect, Human
Resource Management practices are co-imported with foreign capital.&lt;/p&gt;
&lt;p&gt;
As foreign investment increases, there is also an increase in demand for
skilled local labour. This skilled labour needs to be developed within a
foreign or local education system. This is equally true for general
organisational administration training, such as accounting and finance.
Management training provided in Hanoi and in Western Universities
appears to be mainly based upon Western management practices. As shown
in the model below (Figure 2), the greatest flow of capital, human
resources management practice and training is from the United States,
where individual values and rewards are promoted (Zhu 2008).&lt;/p&gt;
&lt;p&gt;
With the strong inflow of foreign Human Resource Management practices as
an economy develops, there is the risk that pre-existing practices may
be lost. Through a more thorough exploration of existing Human Resource
Management practices, two different but linked opportunities may be
leveraged. The first opportunity is to promote and emphasise
Vietnamese Human Resource Management to improve the success of companies
operating in Vietnam. The second opportunity is the flow of
beneficial Human Resource Management models from Vietnam to the rest of
Asia and Western countries.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/mba/relationships.jpg&#34; alt=&#34;Relationship and influences of HR practices between Western and East Asian countries&#34; title=&#34;Relationship and influences of HR practices between Western and East Asian countries&#34;/&gt;
&lt;figcaption&gt;
Figure 2: Relationship and influences of HR practices between Western and East Asian countries (Zhu 2008).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Vietnamese Human Resource Management Practices—Making the most of an opportunity
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;If there are pre-existing Human Resource Management practices that work
particularly well within the Vietnamese context, there is an opportunity
to thoroughly examine these practices and determine what works well
within that context. With the opening of the Vietnamese economy to
foreign investment there may be a limited window of opportunity to study
and explore Vietnamese Human Resource Management, to define the
endogenous practices and to document the success of these practices
before they are, in effect, inundated by the Human Resource Management
practices of the West and other more developed Asian nations such as
Singapore and Japan.&lt;/p&gt;
&lt;p&gt;
There is a genuine and documented risk that education practices are in
place that encourages, possibly inadvertently, the wholesale adoption of
western Human Resource Management practices in emerging economies of
Asia. Asian management scholars, notably from China, receive training in
western Human Resource Management practices and are strongly encouraged
to adopt these within their organisations. There is also encouragement
for these scholars to publish in the top Western Human Resource
Management journals (Tsui 2004).&lt;/p&gt;
&lt;p&gt;
The establishment of research and educational capacity in
Vietnamese Human Resource Management training organisations, such as
universities, would advance Asian management research. This would allow
“scholars to shift their emphasis from theory application to developing
new theories, and from benchmarking against Anglo-American models to
comparative research within the region” (Meyer 2006: 120).&lt;/p&gt;
&lt;p&gt;
It is important to ensure that these Vietnamese practices are examined,
defined, and incorporated into management training curricula. If there
is a wider benefit of these management practices, then incorporation
into Western models of Human Resource Management should be encouraged.
As training in management theory, particularly with the rise and rise of
foreign MBAs bring a greater emphasis on Western management theory,
there is the risk that beneficial application of indigenous Human
Resource Management may be lost to Vietnam and the rest of the world.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Wider benefit of Vietnamese Human Resource Management
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The benefit of Vietnamese Human Resource Management practices being
defined and applied in Vietnam is almost self-evident. It is more likely
that the application of Vietnamese Human Resource Management practices
will be successful and more beneficial because they have been developed
within a single societal framework. However, there may be more benefit
to understanding Vietnamese Human Resource Management practices. As can
be seen in Figure 3, while the predominant flow of Human Resource
Management practices is from the United States into Asia and Europe,
there are also flows from Asia to Europe and the United States.
Understanding Vietnamese Human Resource Management practices are likely
to have the benefit of assisting Western countries to better manage
their FDI efforts in Vietnam and there may be the additional benefit in
promoting Vietnamese Human Resource Management practices in their
associated organisations in the West.&lt;/p&gt;
&lt;p&gt;
The adoption of Western Human Resource Management practices in Vietnam
may also have additional benefits outside of Vietnam. It is likely that
scholars will apply their Western Human Resource Management training in
their Vietnamese companies and will find that some practices will work
and others will require modification to be successful. It is the
modification of Western Human Resource Management practices in the
Vietnamese context that may lead to improved management techniques that
are applicable not only to Vietnam but also to Western Human Resource
Management much as Deming&amp;#39;s introduction of Western Management practices
in Japan had significant benefit to the rest of the world.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
The way forward
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;As described above, although some studies have been conducted (Budhwar
2009; Kamoche 2001; Nguyen 2002; Nguyen and Bryant 2004), there is a
significant gap in the understanding of Human Resource Management
practices that are currently being used in Vietnam. The transmission
of Human Resource Management practices from the West does have benefit
to Vietnamese organisations but also creates a risk that pre-existing
Vietnamese Human Resource Management practices may be lost. It is
through research that these practices may be defined, documented, and
incorporated into HR training curricula in both Vietnam and the West.
This will have a clear benefit for Vietnamese managers and, potentially,
HR practitioners throughout the world.&lt;/p&gt;
&lt;p&gt;
This research project seeks to draw out Vietnamese management practices,
to contribute to filling this gap in knowledge and help managers employ
tools to assist with maximising the performance and well being of
workers throughout Vietnam, Asia and the Western world.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
Research Method
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Formal interviews have been conducted in five privately-owned
organisations, selected by Hanoi University, a research partner of the
Graduate School of Management. Two of the interviewees were European
managers working for Vietnamese companies. All respondents were
university educated males between the age of 30 and 50. Only three
interviews were dedicated to Human Resource Management as respondents
were shared with other research groups in the Hanoi expedition.&lt;/p&gt;
&lt;p&gt;
The research was undertaken following the Straussian school of Grounded
Theory (Jones and Noble 2007). All interviews were conducted very openly
and covering a wide range of topics across the field of Human Resource
Management and no hypothesis was defined prior
to the data collection process. The questionnaire was loosely followed
to allow for an open dialogue between the interviewers and the
respondents. Depending on the reaction of the respondent, certain topics
were discussed in more detail than was the case with other interviews.
This method of interviewing allowed for greater flexibility and for
gathering contextually rich information. It also provided an atmosphere
in which participants were more open to providing data than in a closed
interview.&lt;/p&gt;
&lt;p&gt;
All participants were fully informed about the purpose of the interview
by means of a Participant Consent Form. This contained, besides the
consent form, also a form to withdraw consent and an outline of the
general purpose of the expedition. This form did, however, not contain a
return address to submit the request and as such, no withdrawals have
been received. One participant was willing to be interviewed but refused
to sign the consent form. The interview continued, but the data has not
been used in the report. All data obtained from the interviews remain
confidential. Participating organisations and managers have been
deidentified in this report. The raw research data is kept by the
authors and will be destroyed after the results of the subject have been
published by the University.&lt;/p&gt;
&lt;p&gt;
A collective application for all research groups in the Hanoi expedition
was submitted to the University Human Ethics Committee (UHEC). The
application excludes recording of the interview. No verbatim transcripts
have thus been prepared and analysis relied solely on notes taken during
the interview. Although some proponents of grounded theory argue against
taping and transcribing of interviews (Charmaz 2006), it was found to be
a restrictive requirement for this research. In one interview, the
respondent was a German expatriate who only spoke Vietnamese and German.
Since no Vietnamese translator was present, one of the researchers
conducted the interview in German, simultaneously translating to the
other researchers and taking notes. The directive not to record
interviews restricted the research and constrained the quality of the
data as the dynamics of the interview not always allowed accurate
note-taking.&lt;/p&gt;
&lt;p&gt;
After each interview, the raw notes were transcribed by both researchers
and in those cases where both were present, notes were compared to
ensure consistency. The raw data were collated into a single document
and coded in accordance with the standard procedures in Grounded Theory,
as described in the previous chapter. After Coding, seven categories
emerged from the data, some of which with their own subcategories.
Sorting of all data revealed that some categories are linked to each
other (such as Motivation and Reward).&lt;/p&gt;
&lt;p&gt;
A semantic diagram was used to prepare a memo for each category.
Extensive memoing has been undertaken during the expedition itself and
the analysis was substantially complete upon returning to Australia.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/mba/semantic-diagram.png&#34; alt=&#34;Semanic diagram&#34; title=&#34;Semanic diagram&#34;/&gt;
&lt;figcaption&gt;
Figure 3: Semanic diagram.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Based on this information, three categories were selected for further
analysis, i.e. Vietnamese Style Human Resource Management, Recruitment
and Motivation. Further literature review on the selected categories has
been undertaken, enabling the formulation of three hypotheses. The
limited amount of data did not allow drawing any firm conclusions about
these phenomena. The last step in the research was the identification of
a Core Category. It was found that the Core Category, binding all
observed phenomena, is Collectivism. In order to stay as close as
possible to the original words of the respondents, the raw data has been
transcribed into four vignettes, which are provided in the next chapter,
after which a detailed analysis of the data is provided.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
Results
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-2&#34;&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-10&#34;&gt;
Company A
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Mr A is the manager of a business department in a large distribution
company based in Hanoi. The core competency of this organisation is the
export and import of rice. In excellent English, Mr A explained that the
business has recently horizontally expanded into the retail industry and
currently operates some convenience stores and a supermarket in the
city. They are committed to expanding their presence in retail but are
on a steep learning curve.&lt;/p&gt;
&lt;p&gt;
They struggle with overseas competition because foreign companies have
easier access to capital, better knowledge of the retail industry and
better Human Resource Management systems. The main issue is that
overseas companies have good training models and a “HR structure”.
Company A is developing and implementing a suitable HRM approach with
the assistance of consultants. They use Japanese and Western models as a
reference, but select only those aspects they find suitable. Mr A
smilingly said: “Western or Japanese model is not suitable”, but he did
not provide details on how he determines which methods are more likely
to be suitable.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-11&#34;&gt;
Company B
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Mr B is the manager of a large department store that focuses on home
improvement, furniture and related products. He was expatriated from
Germany a few months prior to the interview, which was conducted in
German. He experiences difficulties in transforming the business because
Vietnamese managers shy away from internal conflict and are always
looking for harmony. Mr B is of the opinion that some internal conflict
is required to make the business more successful. When asked his view on
what it takes to be successful an European manager in Vietnam he
resolutely answered: “adapt or die”.&lt;/p&gt;
&lt;p&gt;
He believes that the rate of social change in Vietnam is very fast and
he anticipates social unrest because of this. Not in the form of riots
or demonstrations, but through “passivität”, best translated as passive
resistance against capitalist values.&lt;/p&gt;
&lt;p&gt;
He experiences trouble motivating local staff and showed statistics that
the labour cost to turnover ratio in Vietnam is more than four times
higher than in Germany. One of the reasons for this is that almost half
of the store&amp;#39;s employees are security staff. Shoplifting is a big
problem and to deter people from stealing, photos of shoplifters that
were caught are displayed at the store entrance. Mr B believes this
works as a deterrent because it is a way to ensure that shoplifters
literally lose face.&lt;/p&gt;
&lt;p&gt;
Individual productivity is, as shown by the above figures, very low in
his business. Mr B believes this is a leftover of the transition from a
Planned Economy, with high job security and no drivers to increase
productivity. Being from former East Germany, he has seen a similar
transition. However, he is of the opinion that the uptake of capitalist
values by his staff is going slowly compared to his own experience. He
said that the Vietnamese have an expectation of a job for life, without
the requirement to be productive.&lt;/p&gt;
&lt;p&gt;
The business is introducing Key Performance Indicator (KPI) based
salaries. He believes, however, that it is more important to reward
subjective measures first because these are most lacking, i.e. keeping
the store clean, correct merchandising and so on, rather than focusing
on sales volumes. This relates back to the problems with staff
motivation mentioned earlier.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/mba/wordle.png&#34; alt=&#34;Word frequency distribution in the interviews&#34; title=&#34;Word frequency distribution in the interviews&#34;/&gt;
&lt;figcaption&gt;
Figure 4: Word frequency distribution in the interviews.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-12&#34;&gt;
Company C
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-12&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Mr C is the Finance Manager of a privately owned distribution and
logistics company that maintains trucks and warehouses, employing about
2,000 people.&lt;/p&gt;
&lt;p&gt;
When Company C recruits staff, they follow a three-step process. First,
they review existing staff, then they use informal networks to find
suitable people. Last option is to use a Headhunter, i.e. external
recruitment agencies. The selection process depends on the vacancy they
seek to fill. For middle and lower staff, the process involves
psychological testing (IQ) and practical tests to ascertain whether they
are suitable. For high-level positions, no testing is undertaken and
Company C relies on references. Interviews with applicants are
undertaken after the testing or obtaining references.&lt;/p&gt;
&lt;p&gt;
An important selection criterion for Company C is the applicant&amp;#39;s
perceived adaptability to their business culture. They target Vietnamese
people that work at multinational corporations (MNC) because of their
experience with working in an occidental management environment.
However, these people find it hard to fit back into a Vietnamese
business after working for an MNC.&lt;/p&gt;
&lt;p&gt;
The main difference between Company C and an internationally owned
company is that in the latter, everything is very procedurised by using
“SOP or something like that”, they follow “steps A, B and C”. In Company
C there are no strict procedures to be followed and some people,
particularly those that have worked for an MNC for a while, “get
confused about what to do next”. They need staff who are able to work in
this environment.&lt;/p&gt;
&lt;p&gt;
Company C wants to upgrade their HR systems to match that of MNCs that
operate in Vietnam. They believe the best way to achieve this is to use
a western HRM model, adapted to Vietnamese culture. Mr C reads Western
management textbooks but chooses selectively on what to apply. They try
to duplicate the systems used by MNC in Vietnam.&lt;/p&gt;
&lt;p&gt;
In Company C, lower and middle staff follow training on the job. They
are developing the “soft skills” of middle management. There are no
cultural issues with implementing western HRM models in the lower
echelons because “lower people follow orders”. Vietnamese people are not
fond of personal development beyond a certain point. There is currently
no culture of “learning forever”. This is the old attitude and Mr C
believes that a future recession will change that mindset.&lt;/p&gt;
&lt;p&gt;
Salaries are based on Key Performance Indicators, but they are different
for each department. In sales, 20–30% of salary is dependent upon
achievement sales volumes. Most staff members have individual KPIs.
Secondary conditions such as annual leave, healthcare and share options
exist for higher level positions. Tertiary conditions focus around staff
outings, which is a Vietnamese tradition.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-13&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-13&#34;&gt;
Company D
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-13&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Company D is active in the hospitality industry and operates several
pubs and restaurants in Hanoi and Ho Chi Minh City, targeting Western
expatriates and travellers. Mr D is the part owner and manager of the
business. He is originally from the United Kingdom and moved to Hanoi
several years ago. He speaks Vietnamese and is able to communicate with
staff in their own language. Mr D has no formal management education and
has a background in retail and pubs in England. This is where he has
obtained a keen insight in the marketing of services.&lt;/p&gt;
&lt;p&gt;
One of the other owners of Company D also owns a charity in which street
children are provided with an opportunity to be trained in hospitality.
Through this connection, Company D is operated with a strong sense of
&lt;a href=&#34;https://lucidmanager.org/management/milton-friedman-corporate-social-responsibility/&#34;&gt;social corporate responsibility&lt;/a&gt;. There is a strict separation between the
charity and the business and they thus do not hire graduates from the
charity. Company D recruits most of its staff from the groups of people
that were not able to obtain a place in the charity training program but
are considered suitable. The selection is followed by a conversation
with Mr D, another manager and a Vietnamese staff member. The candidate
has already been selected, so this is only an introduction to the
business. Company D occasionally uses social networks to find new staff
and expert jobs, such as accountants, are advertised. The success of
their approach is illustrated by one girl who used to sell eggs in the
street, became a cashier and is now studying to be an accountant.&lt;/p&gt;
&lt;p&gt;
The company focuses strongly on training and Mr D proudly mentioned that
a former waitress, who is now the training manager of Company D, will
soon move to Melbourne to undertake hospitality training at TAFE. Most
new recruits are about 20 years old and have a basic knowledge of
English because they used to shine shoes or sell lighters and so on.
Because most new recruits are former street children, training of new
staff members with the basics, including personal hygiene. All training
is undertaken in-house through a mentoring system and for large groups
by the training manager.&lt;/p&gt;
&lt;p&gt;
They just opened a new restaurant, which took six months to train all
staff. New recruits have three months to learn the trade and start
“busting tables and cleaning ashtrays”. Mr D is developing a staff
handbook in Vietnamese and English. The handbook focuses on their rights
and provides an overview of organisational values.&lt;/p&gt;
&lt;p&gt;
Company D provides a wide range of benefits, including help with
accommodation, interest-free loans, vaccinations, English classes, a
medical program (they even paid for heart surgery for one staff member)
and a medical checks. They also provide a uniform and some new clothes
for new staff, because they have no wardrobe of their own.&lt;/p&gt;
&lt;p&gt;
Some successful staff have been given a share in the company as a bonus.
These are full shares which make them eligible to become a company
director. They also provide free meals to staff when they are at work.
Salary is performance-based, which is measured subjectively through
conversation with their mentor. Some staff have doubled their salary in
three months. Every two years they take their staff on an all expenses
paid trip. They also provide transport to weddings and funerals.&lt;/p&gt;
&lt;p&gt;
It is a company rule that staff are not supposed to stand still and
always look for an opportunity to provide customer service. Mr D said
that Vietnamese jobs are usually quiet inactive and it takes some effort
to ingrain this behaviour. Mr D also recounted an episode where he
publicly escorted a staff member out of the premises because he was
caught stealing. This caused problems for him because both the staff
member and he lost face.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-14&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-14&#34;&gt;
Analysis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-14&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;From the data, seven categories emerged, some with their own subcategories:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Vietnamese Style Human Resource Management&lt;/li&gt;
&lt;li&gt;Reward (Primary, Secondary and Tertiary)&lt;/li&gt;
&lt;li&gt;Recruitment (Social Networks and Formal)&lt;/li&gt;
&lt;li&gt;Legal&lt;/li&gt;
&lt;li&gt;Training &amp;amp; Development (Western Education and In-house provision)&lt;/li&gt;
&lt;li&gt;Motivation&lt;/li&gt;
&lt;li&gt;Culture (Face and Collectivism)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Analyses of the data showed that Reward and Motivation are closely
related and that three categories, Vietnamese Style Human Resource
Management, Recruitment and Rewards &amp;amp; Motivation, provided the best
opportunities for theory building.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-15&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-15&#34;&gt;
Vietnamese Human Resource Management
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-15&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;A recurring topic in all interviews was the existence and nature of a
Vietnamese style of Human Resource Management. Most companies were in
the process of researching Western and Japanese Human Resource
Management methodologies and implementing these in their own
organisations. There was a strong perception among the interviewed
Vietnamese managers that the Western model of Human Resource Management
is something to strive for. Although, methods were used selectively to
ensure organisational and cultural fit.&lt;/p&gt;
&lt;p&gt;
Interviewees were not able to pinpoint the type of methodologies they
believed to be suitable in a Vietnamese context and which were not.
Vietnamese managers are embedded in their own culture and are not
necessarily acutely self-aware of the differences between occidental and
oriental culture. The fact that they have a personal preference for a
certain management approach is an illustration of the culture in which
they are embedded.&lt;/p&gt;
&lt;p&gt;
The need to research the suitability of existing management
methodologies in emerging countries has been identified by several
scholars (Budhwar 2009; Meyer 2006; Rowley and Abdul-Rahman 2008).
Recent research by Thang et al. (2007) has shown that foreign practices
which tend to be in harmony with the norms, beliefs and assumptions of
Vietnamese culture have the best chance to improve business performance.
Practices that are based on confrontation or impose ethnocentric methods
are likely to fail. This was illustrated by Mr B, who lamented that
Vietnamese managers in his organisation shy away from confrontation,
something which he saw as necessary to create a healthy dialogue. This
is consistent with the pluralistic approach preferred in Europe, as
shown in Figure 5&lt;/p&gt;
&lt;p&gt;
Another aspect that was mentioned in several interviews and site visits
was management training. Most managers expressed a preference for a
Western-style management education. Larger companies send their people
overseas to further their education. This aligns with the common
Vietnamese tendency to prefer foreign products over locally made things.
This attitude can be traced back to the time before Doi Moi, typified by
a lack of quantity and quality of consumer goods (Thang et al. 2007:
125). The popularity of Western management education in Vietnam can also
be seen as a result of the many development projects over the past
decades, providing management education (Napier 2008).&lt;/p&gt;
&lt;p&gt;
From the observed salience for foreign Human Resource Management approaches a first hypothesis can be formulated.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;H1 : Vietnamese managers have a preference for adopting Human Resource Management practices with a foreign origin.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
This hypothesis may actually be proven incorrect in that the
co-importation of capital and Human Resource Management practices
outlined in Chapter 3 has led to Western Human Resource Management
training being more widely available rather than being preferred. No
firm conclusion can be drawn from the obtained data.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-16&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-16&#34;&gt;
Reward &amp;amp; Motivation
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-16&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Reward mechanisms can be categorised into three distinct types. Primary
reward is the monetary remuneration an employee receives. Secondary
reward refers to all non-financial entitlements, such as annual leave,
lunch breaks and so on. Tertiary reward refers to the social benefits of
being part of an organisation, but which are not part of the formal
employment relationship. Primary reward mechanisms outlined in the site
visits and interviews all follow methodologies very familiar to those
used in Australian organisations, i.e. a focus on individual reward. All
companies use a salary scale to value different jobs and maintain a
bonus system to reward the performance of staff. A secondary reward was
provided in all organisations in accordance with the Labour Laws of
Vietnam (Chee and Dung 2008).&lt;/p&gt;
&lt;p&gt;
Most interesting was the emphasis of many organisations on tertiary
rewards, such as staff outings, interest-free loans, transport to
weddings and funerals, buying the occasional unexpected gift and also
providing a “pleasant workspace” was mentioned. One company that
excelled in this area was Company D. The businesses they manage are well
known among travellers and expatriates in Hanoi and Ho Chi Min City
because of the excellent service provided by staff. Staff seem to be
much more motivated to provide great service than in other Vietnamese
businesses. For example, in Company B, the manager expressed that staff
were not self-motivated to provide service, which he attributed to
Vietnamese culture. While Company D focuses on tertiary rewards and is
achieving great results, Company B focuses on individual rewards and
faces motivation problems. From these observations a second hypothesis
can be formulated:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;H2 : In collectivist cultures, tertiary rewards are more likely to motivate staff than primary and secondary rewards.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The hypothesis is theoretically supported through Vroom&amp;#39;s Expectancy
Theory (Robbins and Judge 2007) and empirical research that indicates
that Vietnam and most other South-East Asian countries are collectivist
in nature (Hofstede 1993).&lt;/p&gt;
&lt;p&gt;
According to Vroom, who follows a behaviourist model of psychology, the
“strength of a tendency to act in a certain way depends on the strength
of an expectation that the act will be followed by an outcome and on the
attractiveness of that outcome” (Robbins and Judge 2007: 208). Vroom&amp;#39;s
model uses three concepts to explain motivation.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/mba/expectancy-theory.png&#34; alt=&#34;Expectancy Theory&#34; title=&#34;Expectancy Theory&#34;/&gt;
&lt;figcaption&gt;
Figure 5: Expectancy Theory (Robbins and Judge 2007: 208).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;ol&gt;
&lt;li&gt;Expectancy: the likelihood, as perceived by the individual, that exerting a given amount of effort will lead to performance.&lt;/li&gt;
&lt;li&gt;Instrumentality: the degree to which the individual is convinced that performing at a certain level will lead to desired rewards.&lt;/li&gt;
&lt;li&gt;Valance: the degree to which organisational rewards match an individual&amp;#39;s personal goals.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The basic utility of Expectancy Theory is that, in order to enhance the
performance of individuals, rewards need to be linked to the required
behaviour and that these rewards are anticipated and wanted by
employees. An employment relationship is underpinned by principles of
mutuality and reciprocity (Heap 2008) in that employees expect a return
for their efforts, as outlined in Expectancy Theory.&lt;/p&gt;
&lt;p&gt;
A return can be provided to employees on three levels, as outlined
above. Following the principle of Valance in Vroom&amp;#39;s theory, rewards in
a society with a predominantly collective nature should reflect this. In
other words, a focus on tertiary rewards and social benefits will
theoretically lead to a better performance outcome.&lt;/p&gt;
&lt;p&gt;
The data obtained in this research does, however, not provide sufficient
evidence to confirm or falsify this hypothesis and further researched is
required to test its validity.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-17&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-17&#34;&gt;
Recruitment &amp;amp; Selection
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-17&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;The third result emerging from the data is the preference for social
networks in the recruitment of new staff, this contrasts with Australian
firms where newspaper advertisements are the prevalent way to attract
applicants to new positions (Wooden and Harding 1998). The third
hypothesis is thus:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;H3 : Recruitment in countries with a collective nature, such as Vietnam, is primarily conducted through social networks.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The purpose of recruitment is to communicate the existence of a vacancy
to those segments of the job market that an organisation seeks to
recruit from (de Cieriet al. 2008). The recruitment process is
influenced by several factors, as illustrated in Figure 6.&lt;/p&gt;
&lt;p&gt;
It is the recruiter&amp;#39;s task to increase the likelihood of a match between
the applicant and vacancy characteristics, in other words, to achieve
job fit&amp;#39;. Job fit is bidirectional as vacancy characteristics need to
match applicant characteristics and vice versa. Only a bidirectional job
fit ensures that the incumbent will be in the best possible position to
contribute positively to the organisation. This is achieved by
controlling the three influencing factors. Human resource policies
affect the characteristics of the vacancy (job design). Recruitment
sources determine which segment of the job market is targeted and thus
influence applicant characteristics. The recruiters themselves also
influence the job choice through their impact on both job design and
applicant characteristics. Using social networks as a source of
recruitment influences applicant characteristics because the criteria
upon which the social network is defined determine who will be
considered for the position.&lt;/p&gt;
&lt;p&gt;
Breaugh (1981: 145) showed that the source of recruitment is “strongly
related to subsequent job performance, absenteeism and work attitudes”.
People placed through universities and to a lesser extent those sourced
through newspapers were “inferior in performance” to applicants who were
sourced through advertisements in professional publications (Breaugh
1981: 145), which is a form of social network. People recruited through
newspaper advertisement missed almost twice as many days as those
recruited through other sources, such as employee referrals (Breaugh
1981). The field study was conducted in one particular research
organisation in the USA.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/mba/recruitment-factors.png&#34; alt=&#34;Factors influencing the recruitment process&#34; title=&#34;Factors influencing the recruitment process&#34;/&gt;
&lt;figcaption&gt;
Figure 6: Factors influencing the recruitment process (de Cieri et al. 2008: 260).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
A possible explanation of this phenomenon is the Individual Difference
Hypothesis in which it is stated that recruitment sources differ in the
types of the applicants they reach (education, class, self-image and so
on), which results in different performance outcomes. Following this
theory, people recruited through employee referrals may be more capable
or have a better cultural fit than individuals recruited from public
sources because current employees and other members of the social
network screen potential applicants before they consider them for a
position in the organisation as their own reputation is at stake
(Breaugh and Starke 2000).&lt;/p&gt;
&lt;p&gt;
It should be noted that recruitment and selection are two distinctly
different aspects of Human Resource Management. Although people are
recruited because they are a member of a social network, this does not
imply that they are necessarily selected because of this. All
respondents acknowledged that an interview formed part of the selection
process and in some instances, psychological and technical aptitude
tests were used to determine the most suitable candidate.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-18&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-18&#34;&gt;
Core Category
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-18&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Following the analysis of the identified categories, a core category
emerged. The core category, i.e. the concept that ties the findings
together, is the collective nature of Vietnamese society. This concept
has been widely discussed in management literature, spearheaded by the
research undertaken by Dutch sociologist Geert Hofstede (1983).&lt;/p&gt;
&lt;p&gt;
Collectivism emphasises human interdependence and the importance of a
group. On the other end of the spectrum, individualism is the degree to
which people give primacy to the individual over the group to which they
belong. Countries with a high level of individualism (IDV, see Figure
7), such as Australia, prioritise individual rights over the rights of
the collective. In countries with low scores in IDV, the collectivist
societies, such as Vietnam, the rights of the individual are often
subordinated to the collective (Hofstede 1983, 1993). The preference for
using social networks as a means of recruiting staff is an expression of
the collective nature of Vietnamese culture. Although this research was
conducted with limited data, the preference for social network
recruiting was also confirmed in many informal conversations with
Vietnamese managers not partaking in the interviews.&lt;/p&gt;
&lt;p&gt;
The use of social networks is contrasted with the preference of
newspaper advertisements in Australian firms, as identified by Wooden
and Harding (1998). This is in line with the core category as Australia
is considered an individualistic country (Figure 7.3) and newspaper
advertisements focus on random individuals. Collectivism was apparent in
how businesses manage staff performance. There seems to be a focus on
tertiary rewards, which are also an expression of the collectivist
nature of Vietnam. With regards to Primary and Secondary rewards, Thang
et al. (2007) investigated the transferability of occidental management
practices into Vietnam and found that individualism is one of the
underlying assumptions for a pay-for-performance system. The long-held
Confucian collectivist values in Vietnamese society will, however, make
it difficult for these methods to be successful. A pay for performance
system is more likely to be applicable to the younger generations. As
the per capita, Gross Domestic Product of Vietnam rises, the level of
individualism is also expected to rise, as shown by Hofstede (1993).&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/mba/australia-vietnam.png&#34; alt=&#34;Cultural dimensions for Australia and Vietnam&#34; title=&#34;Cultural dimensions for Australia and Vietnam&#34;/&gt;
&lt;figcaption&gt;
Figure 7: Cultural dimensions for Australia and Vietnam (Hofstede 2009).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-19&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-19&#34;&gt;
Conclusions
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-19&#34; class=&#34;outline-text-2&#34;&gt;
&lt;blockquote&gt;
&lt;p&gt;They say you come to Vietnam and you understand a lot in a few minutes.
But the rest has got to be lived.&lt;/p&gt;
&lt;p&gt;
Graham Greene (1977), &lt;em&gt;The Quiet American&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The research in Vietnam and associated literature review has unearthed
some interesting prospects for further research into Human Resource
Management in this country.&lt;/p&gt;
&lt;p&gt;
Firstly, even only a very limited amount of interviews were conducted,
the contextually rich nature of the data and using the Grounded Theory
approach allowed for the formulation of some promising hypotheses. It
is, however, because of the limited number of observations that were
able to be made that the results can only be considered hypotheses at
this time. Grounded Theory is thus a potentially successful method for
researching Human Resource Management practices in Vietnam. Given that
many scholars recommend in-depth research in this region an opportunity
is created to enhance the findings of this report through follow-up
studies.&lt;/p&gt;
&lt;p&gt;
The first hypothesis states that Vietnamese managers have a preference
for adopting Human Resource Management practices with a foreign origin.
This preference may be because of a perceived superiority of foreign
models or simply because Vietnamese practices are not very well
documented. This illustrates the importance of foundational research
into the actual methods used in Vietnamese organisations in order to be
able to enhance the global body of knowledge in this area.&lt;/p&gt;
&lt;p&gt;
The second hypotheses, which states that in collectivist cultures,
tertiary rewards are more likely to motivate staff than primary and
secondary rewards, is based on only two observations but is supported by
Vroom&amp;#39;s expectancy theory and Hofstede&amp;#39;s work on national cultures.
Should this assertion be proven to be correct after subsequent research,
it may have a significant impact on how both Vietnamese and foreign
companies structure their reward portfolio.&lt;/p&gt;
&lt;p&gt;
Lastly, the finding that recruitment in the researched organisations is
primarily conducted through social networks, combined with earlier
research on correlations between recruitment source and staff
performance, warrants further research. Australian organisations cast
wide nets in their search for new staff members by advertising in
newspapers distributed to anyone with an interest in local matters. If
this hypothesis is confirmed, a model can be developed to manage social
network recruiting, which could possibly lead to lower recruitment cost.
This would be a recognition of Vietnamese Human Resource Management and
alleviate the need to introduce models from the USA, which have shown to
be not always successful.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-20&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-20&#34;&gt;
References
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-20&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Breaugh, James A. (1981) Relationship between recruiting sources and
employee performance, absenteeism, and work attitudes. &lt;em&gt;Academy of
Management Journal&lt;/em&gt; 24(1): 142–147.&lt;/p&gt;
&lt;p&gt;
Breaugh, James A. and Starke, Mary (2000) Research on employee
recruitment: So many studies, so many remaining questions. &lt;em&gt;Journal of
Management&lt;/em&gt; 26: 405–434.&lt;/p&gt;
&lt;p&gt;
Budhwar, Pawan (2009) Future research on human resource management
systems in Asia. &lt;em&gt;Asia Pacific Journal of Management&lt;/em&gt; 26(2): 197–218.&lt;/p&gt;
&lt;p&gt;
Charmaz, Kathy (2006) &lt;em&gt;Constructing Grounded Theory.&lt;/em&gt; Sage Publications.&lt;/p&gt;
&lt;p&gt;
Chee, Patrick and Dung, Le Thi Tuyet (2008) Overview of the Labour Law
in Vietnam. &lt;em&gt;Asialaw&lt;/em&gt; June/July.&lt;/p&gt;
&lt;p&gt;
de Cieri, Helen, Kramar, Robon, Noe, Raymond A., Hollenbeck, John R.,
Gerhart, Barry and Wright, Patrick M. (2008) &lt;em&gt;Human Resource Management
in Australia&lt;/em&gt;. 3rd ed. McGraw-Hill Irwin.&lt;/p&gt;
&lt;p&gt;
Dinh, Viet D. (1997) Financial reform and economic development in
Vietnam. &lt;em&gt;Law and Policy in International Business&lt;/em&gt; 28(3): 857–892.&lt;/p&gt;
&lt;p&gt;
Egan, T. M. (2002) Grounded Theory Research and Theory Building.
&lt;em&gt;Advances in Developing Human Resources&lt;/em&gt; 4(3): 277–295.&lt;/p&gt;
&lt;p&gt;
Essential Services Commission (2009) Inquiry into an access regime for
water and sewerage infrastructure services—Issues Paper. Available at:
&lt;a href=&#34;http://www.esc.vic.gov.au&#34;&gt;www.esc.vic.gov.au&lt;/a&gt;. Accessed 22 February 2009.&lt;/p&gt;
&lt;p&gt;
Fukuyama, Francis (1992) &lt;em&gt;The end of history and the last man.&lt;/em&gt; Free Press.&lt;/p&gt;
&lt;p&gt;
Gill, R. and Wong, A. (1998) The cross-cultural transfer of management
practices: The case of Japanese human resource management practices in
Singapore. &lt;em&gt;The International Journal of Human Resource Management&lt;/em&gt;
9(1): 116–135.&lt;/p&gt;
&lt;p&gt;
Hansen, Carol D. and Brooks, Ann K. (1994) A review of cross-cultural
research on human resource development. &lt;em&gt;Human Resource Development
Quarterly&lt;/em&gt; 5(1): 55–74.&lt;/p&gt;
&lt;p&gt;
Hanson, Dalles, Dowling, Peter J., Hitt, Michael A., Ireland, R. Duane
and Hoskisson, Robert E. (2008) &lt;em&gt;Strategic management. Competitiveness &amp;amp;
globalisation.&lt;/em&gt; Cengage Learning.&lt;/p&gt;
&lt;p&gt;
Heap, Lisa (2008) The Australian Charter of Employment Rights: Setting
the standard for new legislation and good practice. &lt;em&gt;Journal of
Industrial Relations&lt;/em&gt; 40(2): 349–353.&lt;/p&gt;
&lt;p&gt;
Hofstede, Geert (1983) National Cultures in Four Dimensions: A
research-based Theory of Cultural Differences among Nations.
&lt;em&gt;International Studies of Management and Organizations&lt;/em&gt; XIII(1): 46–74.&lt;/p&gt;
&lt;p&gt;
Hofstede, Geert (1993) &lt;em&gt;Allemaal Andersdenkenden (Cultures and
Organisations: Software of the Mind).&lt;/em&gt; Amsterdam: Contact.&lt;/p&gt;
&lt;p&gt;
Hofstede, Geert (1996) An American in Paris: The Influence of
Nationality on Organization Theories. &lt;em&gt;Organization Studies&lt;/em&gt; 17(3):
525–537.&lt;/p&gt;
&lt;p&gt;
Irvin, George (1995) Vietnam: Assessing the achievements of Doi Moi.
&lt;em&gt;The Journal of Development Studies&lt;/em&gt; 31(5): 725.&lt;/p&gt;
&lt;p&gt;
Jones, Robert and Noble, Gary (2007) Grounded theory and management
research: a lack of integrity? &lt;em&gt;Qualitative Research in Organizations
and Management&lt;/em&gt; 2(2): 84–103.&lt;/p&gt;
&lt;p&gt;
Kamoche, Ken (2001) Human Resources in Vietnam: The Global Challenge.
&lt;em&gt;Thunderbird International Business Review&lt;/em&gt; 43(5): 625–650.&lt;/p&gt;
&lt;p&gt;
Khan, M. Mansoor and Bhatti, M. Ishaq (2008) Islamic banking and
finance: on its way to globalization. Managerial Finance 34(10):
708–725.&lt;/p&gt;
&lt;p&gt;
Kim, Joo Yup and Nam, Sang Hoon (1998) The concept and dynamics of face:
Implications for organizational behavior in Asia. &lt;em&gt;Organization Science&lt;/em&gt;
9(4): 522–534.&lt;/p&gt;
&lt;p&gt;
Learmonth, Mark (2006) Doing critical management research interviews
after reading Derrida. &lt;em&gt;Qualitative Research in Organizations and
Management&lt;/em&gt; 1(2): 83–97.&lt;/p&gt;
&lt;p&gt;
Liamputtong, Pranee and Ezzy, Douglas (2005) &lt;em&gt;Qualitative research
methods.&lt;/em&gt; 2nd ed. Oxford University Press.&lt;/p&gt;
&lt;p&gt;
Meyer, Klaus E. (2006) Asian management research needs more
self-confidence. &lt;em&gt;Asia Pacific Journal of Management&lt;/em&gt; 23(2): 119–137.&lt;/p&gt;
&lt;p&gt;
Mintzberg, Henry (1971) Managerial Work: Analysis from Observation.
&lt;em&gt;Management Science&lt;/em&gt; 18(2): B97–B110.&lt;/p&gt;
&lt;p&gt;
Napier, N.K. (2008) Management Education in Emerging Economies: The
Impossible Dream? &lt;em&gt;Journal of Management Education&lt;/em&gt; 32(6): 792–819.&lt;/p&gt;
&lt;p&gt;
Nguyen, Nguyen, Foulks, Edward F. and Carlin, Kathleen (1991) Proverbs
as psychological interpretations among Vietnamese. &lt;em&gt;Asian Folklore
Studies&lt;/em&gt; 50: 311–318.&lt;/p&gt;
&lt;p&gt;
Nguyen, Laam Huu (2002) &lt;em&gt;Role and copetence profiles Human Resource
Development practitioners in Vietnam&lt;/em&gt;. Ph.D. thesis, Texas A&amp;amp;M
University.&lt;/p&gt;
&lt;p&gt;
Nguyen, Thang V. and Bryant, Scott E. (2004) A Study of the Formality of
Human Resource Management Practices in Small and Medium-Size Enterprises
in Vietnam. International Small Business Journal 22(6): 595–618.&lt;/p&gt;
&lt;p&gt;
Nguyen, Thang Van (2000) Work attitudes in Vietnam. &lt;em&gt;Acadamy of
Management Review&lt;/em&gt; 14(4): 142–146.&lt;/p&gt;
&lt;p&gt;
Ninh, Le Khuong (2003) &lt;em&gt;Investment of rice mills in Vietnam: The role
for financial market imperfections and uncertainty.&lt;/em&gt; University of
Groningen. Available at: &lt;a href=&#34;http://irs.ub.rug.nl/ppn/25039801X&#34;&gt;irs.ub.rug.nl/pnn/25039801X&lt;/a&gt;. Accessed 6 March 2009.&lt;/p&gt;
&lt;p&gt;
Quang, T. and Vuong, N. T. (2002) Management Styles and Organisational
Effectiveness in Vietnam. &lt;em&gt;Research and Practice in Human Resource
Management&lt;/em&gt; 10(2): 36–55. Available at:
rphrm.curtin.edu.au/2002/issue2/vietnam.html, downloaded 27 December 2008.&lt;/p&gt;
&lt;p&gt;
Ralston, David A., Thang, Nguyen Van and Napier, Nancy K. (1999) A
comparative study of work values of North and South Vietnamese managers.
&lt;em&gt;Journal of International Business Studies&lt;/em&gt; 30(4): 655-672.&lt;/p&gt;
&lt;p&gt;
Robbins, Stephen P. and Judge, Timothy A. (2007) &lt;em&gt;Organizational
Behavior.&lt;/em&gt; 12th ed. New Jersey: Pearson Prentice Hall.&lt;/p&gt;
&lt;p&gt;
Rowley, Chris and Abdul-Rahman, Saaidah, eds. (2008) &lt;em&gt;The changing face
of management in South East Asia.&lt;/em&gt; London &amp;amp; New York: Routledge.&lt;/p&gt;
&lt;p&gt;
SCIC (2009) State Capital Investment Corporation. Information brochure.&lt;/p&gt;
&lt;p&gt;
Storberg-Walker, Julia (2007) Understanding the conceptual development
phase of applied theory-building research: A grounded approach. &lt;em&gt;Human
Resource Development Quarterly&lt;/em&gt; 18(1): 63–90.&lt;/p&gt;
&lt;p&gt;
Strauss, Anselm and Corbin, Juliet (1990) &lt;em&gt;Basics of qualitative
research. Grounded theory procedures and techniques.&lt;/em&gt; Newbury Park:
Sage.&lt;/p&gt;
&lt;p&gt;
Templet, Robert (1998) &lt;em&gt;Shadows in the wind.&lt;/em&gt; Abacus.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Recruitment Woes—Management Gets the Employees it Deserves</title>
      <link>https://lucidmanager.org/management/recruitment/</link>
      <pubDate>Thu, 30 Apr 2009 06:19:02 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/recruitment/</guid>
      <description>
	
&lt;blockquote&gt;
&lt;p&gt;“Management gets the employees it deserves”, Carl snarlingly uttered as he returned to his desk. Natasha, with whom he had shared a cubicle for longer than they cared to remember, turned around. “What makes you say that” What happened? Carl was obviously still upset as he threw his hands in the air. “This new guy is useless, why do they hire people like that” …&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
This situation is a type of conversation that can be heard in &lt;a href=&#34;https://lucidmanager.org/management/human-resource-management-in-hanoi/&#34;&gt;offices around the world&lt;/a&gt;. On what grounds do organisations hire people and when they are hired, how do they ensure that they contribute to organisational goals? That an organisation gets the employees it deserves implies a causal relationship between the actions of managers as representatives of their organisation and the performance of employees.&lt;/p&gt;
&lt;p&gt;
One of the first to research these questions in a systematic way was &lt;a href=&#34;https://lucidmanager.org/management/frederick-taylor-management-fundamentalism/&#34;&gt;Frederick Taylor&lt;/a&gt; (1911). Taylor himself certainly got the employees he deserved. His Spartan approach, combined with a negative view of labourers, spawned a lot of unrest and workers literally threw spanners in the works. Taylor&amp;#39;s controversial practices even became subject to a congressional investigation. Contemporary human resource management has a more balanced view on recruitment and how people can be managed to increase the likelihood that organisational objectives are achieved. Human resource management well practised can potentially give a significant advantage over competitors (de Cieri et al. 2008: 48).&lt;/p&gt;
&lt;p&gt;
The importance of selecting and retaining suitable people is even more important in an economic recession. Brown (2008: 17) wrote in this context that:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;it is hard to recruit and retain good staff. If [during the recession] you let them go, it could make or break a company&amp;#39;s reputation.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
This essay discusses the ways in which an organisation conducts recruitment, selects, motivates and retains the staff it needs, rather than the staff it deserves. The first section discusses the importance of recruitment and selection. The second section provides a cursory overview of performance management. It will be argued that organisations indeed get the employees they deserve because the extent to which employees contribute to organisational objectives is directly related to the quality of the effort invested by an organisation to recruit, select and motivate staff.&lt;/p&gt;
&lt;p&gt;
Recruitment and selection are the practices of an organisation by which it identifies and attracts people considered to be able to contribute to the achievement of the organisation&amp;#39;s objectives. The recruitment process is aimed at communicating the existence of a vacancy to those segments of the job market that an organisation seeks to recruit from. &lt;/p&gt;
&lt;p&gt;
In the selection process, appropriate mechanisms are used to choose the candidate that is most likely to contribute to the organisation&amp;#39;s objectives (de Cieri et al. 2008).&lt;/p&gt;
&lt;p&gt;
The recruitment process is influenced by several factors. The main objective of Recruitment and Selection is to increase the likelihood of a match between applicant and vacancy characteristics, or job fit. Job fit is bidirectional as the vacancy characteristics need to fit the applicant characteristics and vice versa. Only if the fit is bidirectional will the incumbent be in the best possible position to contribute positively to the organisation. This is achieved by controlling the three influencing factors. Human resource policies affect the characteristics of the vacancy (job design). Recruitment sources determine which segment of the job market is targeted and thus influence applicant characteristics. The recruiters themselves also influence the job choice through their impact on both job design and applicant characteristics.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/mba/recruitment-factors.png&#34; alt=&#34;Factors influencing the recruitment process&#34; title=&#34;/images/mba/recruitment-factors.png&#34; tile=&#34;Factors influencing the recruitment process&#34;/&gt;
&lt;figcaption&gt;
Factors influencing the recruitment process (de Cieri et al. 2008: 260).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Human resource policies are the guiding principles that shape how an organisation wishes to undertake its human resource practices. They are the starting point of all systems, including workforce planning practices (State Services Authority 2007). The characteristics of the vacancy, such as position objectives, responsibility level and remuneration are determined in the workforce planning process.&lt;/p&gt;
&lt;p&gt;
Traditionally, recruitment and selection is aimed at finding an applicant that matches the job requirements. Some organisations use a juxtaposed approach by designing a job to suit a candidate (Fox 2000). Lee (1994) and Mackinlay (1993) advocate a mutual adaptability between the organisation and the candidate to ensure the best possible job fit. From this it can be concluded that Human Resource policies need to be flexible to allow the recruiters to achieve the best outcome.&lt;/p&gt;
&lt;p&gt;
The source of recruitment influences applicant characteristics because each source istargeted towards a certain segment of the job market. Research by Breaugh (1981: 145) showed that the source of recruitment is strongly related to subsequent job performance, absenteeism and work attitudes. Breaugh (1981: 145) showed that people placed through universities and to a lesser extent those sourced through newspapers, were inferior in performance to applicants who were sourced through advertisements in professional publications. People recruited through newspaper advertisement missed almost twice as many days as those recruited through other sources, such as employee referrals (Breaugh 1981).&lt;/p&gt;
&lt;p&gt;
However, Wooden and Harding (1998) reported that the most popular and most successful recruitment source in Australian private industry, as measured by the number of filled vacancies, are newspaper advertisements. One possible explanation of this phenomenon is the Individual Difference Hypothesis in which it is stated that recruitment sources differ in the types (education, class, self-image and so on) of applicants they reach, which will result in different outcomes. &lt;/p&gt;
&lt;p&gt;
Following this hypothesis, people recruited through employee referrals may be more capable than individuals recruited from public sources because current employees will screen potential applicants before they consider them for a position in the organisation as their own reputation is at stake (Breaugh and Starke 2000).&lt;/p&gt;
&lt;p&gt;
Recent research has shown that managers in Hanoi prefer informal networks, such as family members of existing staff, as a source of recruitment (Watson and Prevos 2009). Vietnamese managers perceive hiring from the extended network of staff to achieve better organisational commitment. The effectiveness of informal networks as a prime recruitment source is evidenced by the original research by Breaugh (1981) and would seem to support the Individual Difference Hypothesis. &lt;/p&gt;
&lt;p&gt;
Recruiters influence vacancy characteristics because they are often involved in the design of the jobs to be recruited. The psychological traits of a recruiter also influence applicant characteristics. De Cieri et al (2008) identify warmth and informativeness as important aspects. In general, applicants respond more positively to recruiters with these traits. It is a recruiter&amp;#39;s task to provide an atmosphere in which applicants are able to fully explore their suitability. Many people are nervous in an interview situation and the recruiter sometimes needs to help the applicant by ensuring the requirements of the position are clearly communicated.&lt;/p&gt;
&lt;p&gt;
The recruiter also passively influences applicant characteristics because they interpret information provided by the applicant and determine to what extent they match the vacancy requirements. From a philosophical perspective, the  recruitment process involves a hermeneutic in which the applicant and the recruiter need to interpret each other&amp;#39;s expectations by processing the information provided. &lt;/p&gt;
&lt;p&gt;
The fact that the recruitment process is undertaken in a power imbalance (Heap 2008) adds an additional layer of complexity because both parties are rarely prepared to be fully open to each other, which requires special communication and interpretation skills of the recruiter.&lt;/p&gt;
&lt;p&gt;
Many selection methods such as interviews, psychometric testing, physical ability tests and situational exercises, are at the disposal of recruiters. There are five main issues to be considered regarding these methods (de Cieri et al. 2008). The measures used to determine the best candidate need to be consistent and reliable and as much as possible free from random error. &lt;/p&gt;
&lt;p&gt;
Secondly, the outcomes need to be generalisable and free from contextual influences. The usefulness or utility of the selection process is the third important point. Penultimately, any method used during selection needs to be tested for legality, specially regarding possible discrimination of applicants. Last aspect is the validity of the selection method, which is the extent to which a measure used in selection assesses all relevant aspects of future job performance.&lt;/p&gt;
&lt;p&gt;
The validity of a selection method is determined by measuring the correlation between an applicant&amp;#39;s test scores and their future performance on the job (de Cieri et al. 2008). Validity can, however, only be determined for quantitative methods, such as psychometric testing and physical testing. &lt;a href=&#34;https://lucidmanager.org/management/free-personality-test/&#34;&gt;Personality inventory&lt;/a&gt; tests are a popular quantitative method for personnel selection. An applicant&amp;#39;s personality inventory is considered to influence performance as research shows that successful managers share a large number of personality traits. However, the validity of personality testing has not been generally supported in research. Besides issues with validity, there are  also legal impediments as a personality test can be perceived as an invasion of privacy (Scroggins et al. 2009).&lt;/p&gt;
&lt;p&gt;
In qualitative methods, the predictive validity is much harder to measure and is influenced by the characteristics of the recruiter and their ability to communicate job expectations and interpret information provided by the candidate, as discussed above.&lt;/p&gt;
&lt;p&gt;
Given the issues sketched above, no recruitment and selection process is consistently able to deliver a perfect fit between vacancy characteristics and applicant characteristics. Also, the dynamic nature of business requires people to adapt to new situations not foreseen during the recruitment and selection process. Thus, in the quest of having the best possible employees, recruitment and selection are only the first step. After new staff have been hired, ongoing performance management, which can be defined as the “process through which managers ensure that the activities and outputs of employees are congruent with the objectives of the organisation” (de Cieri et al. 2008: 43), is required. The objective of performance management is to motivate staff o consistently undertake their daily tasks with intensity, persistence and effort (Robbins and Judge 2007).&lt;/p&gt;
&lt;p&gt;
A plethora of motivation theories has been proposed over the past decades. One of the most widely accepted models is Victor Vroom&amp;#39;s Expectancy Theory. According to Vroom, the “strength of a tendency to act in a certain way depends on the strength of an expectation that he act will be followed by an outcome and on the attractiveness of that outcome” (Robbins and Judge 2007: 208). Vroom&amp;#39;s model uses three concepts to explain motivation.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://lucidmanager.org/images/mba/expectancy-theory.png&#34; alt=&#34;/images/mba/expectancy-theory.png&#34; title=&#34;/images/mba/expectancy-theory.png&#34; /&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Expectancy: the likelihood, as perceived by the individual, that exerting a given amount of effort will lead to performance.&lt;/li&gt;
&lt;li&gt;Instrumentality: the degree to which the individual is convinced that performing at a certain level will lead to a desired outcome.&lt;/li&gt;
&lt;li&gt;Valance: the degree to which organisational rewards match an individual&amp;#39;s personal goals.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The basic utility of Expectancy Theory is that in order to enhance performance of individuals, managers should link rewards to performance and that these rewards are deserved and wanted by employees. An employment relationship is underpinned by principles of mutuality and reciprocity (Heap 2008) in that employees expect a return for their efforts, as outlined in Expectancy Theory. A return can be provided to employees on three levels. A primary employment condition is the remuneration employees receive in return for their labour. Many systems have been developed to shape remuneration in order to motivate employees to behave in a certain manner.&lt;/p&gt;
&lt;p&gt;
However, research undertaken by Hertzberg has led him to conclude that money is a limited means of motivating staff. He classified salary as a Hygiene Factor, rather than a Motivator, which means that remuneration keeps people from being dissatisfied, but only has limited utility in motivating staff to improve performance (Robbins and Judge 2007).&lt;/p&gt;
&lt;p&gt;
Secondary employment conditions, such as annual leave are also considered Hygiene Factors, specially in countries where these are considered basic entitlements. The tertiary level of employee rewards relates to those aspects of the employment relationship that are usually not controlled through a formal agreement. They can be social benefits, work conditions or more ephemeral aspects of a working relationship such as a sense of achievement or recognition. An example of a company that uses tertiary benefits to motivate and retain staff is Google. Their offices are known for their informal atmosphere, including many opportunities to relax and play games (de Cieri et al. 2008).&lt;/p&gt;
&lt;p&gt;
Providing better tools of the trade can also be a means to motivate staff and improve performance. One example is knowledge management which, besides having the ability to create a competitive advantage through the creation of intellectual property, also assist individuals to perform better because effective knowledge management systems may relieve individuals of the burden of reinventing the wheel, freeing them to engage in more creative tasks (Child and Shumate 2007: 30). Research by Child and Shumate (2007) lead them to conclude that knowledge management that is based on tacit knowledge held by individuals, rather than moving that knowledge to repositories, has a positive effect on team performance. &lt;/p&gt;
&lt;p&gt;
Managers should focus on communication training, relationship building and other social knowledge management techniques. This research illustrates that opportunities to motivate staff and improve organisational performance go beyond traditional primary and secondary reward systems. Besides recruiting, selecting and managing the performance of staff, it is also imperative for organisations to minimise staff turnover. An employee leaving an organisation can cost about two times their annual salary to replace (Eaton 2003). Many professional firms record staff turnover among young professionals of around 25%. The most often cited cause for this is that the younger generations have high expectations of their career and actively seek out opportunities to improve their situation. The younger generation have a whole-of-life orientation, rather than a focus on work-life balance and for them work is just another aspect of their lives that has to match the rest of their existence (Heathcote 2004).&lt;/p&gt;
&lt;p&gt;
Many solutions have been proposed to maximise staff retention. For example, organisations offering family-friendly policies are successful at retaining employees, even if individuals did not use the policies themselves (Eaton 2003). However, “few scholars have demonstrated the mechanisms through which such policies function (or do not) to enhance firm performance” (Eaton 2003: 163). Eaton (2003) also found that control over work time, flexibility and pace of work are important determinants in creating positive levels of commitment and productivity. Other possible solutions to retain staff are talent management, including career customisation, work solutions such as changing the design of an organisation or moving into virtual workplaces; and having clear and powerful employee value propositions (Brown 2008).&lt;/p&gt;
&lt;p&gt;
In conclusion, the statement “management gets the employees it deserves” is correct as &amp;#39;deserving&amp;#39; implies that the quality of staff is related to the quality of the effort an organisation invests in Human Rescource Management. The methods and strategies discussed in this essay show that an organisation can have active control over the employees it gets. More specifically, an organisation needs to be actively involved in developing Human Resource policies to ensure jobs are designed to maximise the likelihood of a good job fit.&lt;/p&gt;
&lt;p&gt;
Recruiting also needs to be undertaken through appropriate sources to ensure that the right segment of the job market is targeted and recruiters need to be selected and trained to ensure the best outcome in the recruitment process.&lt;/p&gt;
&lt;p&gt;
Selection methods also have an impact on the ability of an organisation to the find employees it wants. Finding the right method is problematic in light of issues with reliability and validity. Quantitative methods, such as
personality testing, can give a false sense of validity and qualitative methods suffer from hermeneutic problems. To mitigate these issues, recruiter training and experience are the most effective means to enhance the selection process. &lt;/p&gt;
&lt;p&gt;
Lastly, motivational theories show that employee reward, specially beyond remuneration can have a positive effect on staff motivation and performance. Organisations need to actively seek out what type of reward works best with their staff and ensure that the benefits for high performing staff are communicated.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
References
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;ul&gt;
&lt;li&gt;Breaugh, James A. (1981) &amp;#39;Relationship between recruiting sources and employee performance, absenteeism, and work attitudes&amp;#39;. &lt;em&gt;Academy of Management Journal&lt;/em&gt; 24(1): 142–147.&lt;/li&gt;
&lt;li&gt;Breaugh, James A. and Starke, Mary (2000) &amp;#39;Research on employee recruitment: So many studies, so many remaining questions&amp;#39;. &lt;em&gt;Journal of Management&lt;/em&gt; 26: 405–434.&lt;/li&gt;
&lt;li&gt;Brown, B. (2008) &amp;#39;&lt;a href=&#34;https://www.aim.com.au/blog/reality-bites&#34;&gt;Reality bites&lt;/a&gt;&amp;#39;. Management Today.&lt;/li&gt;
&lt;li&gt;Child, Jeffrey and Shumate, Michelle (2007) &amp;#39;The impact of communal knowledge repositories and people-based knowledge management on perceptions of team effectiveness&amp;#39;. &lt;em&gt;Management Communication Quarterly&lt;/em&gt; 21(1): 29–54.&lt;/li&gt;
&lt;li&gt;de Cieri, Helen, Kramar, Robin, Noe, Raymond A., Hollenbeck, John R., Gerhart, Barry and Wright, Patrick M. (2008) &lt;em&gt;Human Resource Management in Australia&lt;/em&gt;. 3rd ed. McGraw-Hill Irwin.&lt;/li&gt;
&lt;li&gt;Eaton, Susan (2003) &amp;#39;If you can use them: Flexibility policies, organisational commitment and perceived performance&amp;#39;. &lt;em&gt;Industrial Relations&lt;/em&gt; 42(2): 145–167.&lt;/li&gt;
&lt;li&gt;Fox, C. (2000) &amp;#39;Tech talent: The rank truth&amp;#39;. &lt;em&gt;Australian Financial Review&lt;/em&gt;: 74.&lt;/li&gt;
&lt;li&gt;Heap, Lisa (2008) &amp;#39;The Australian Charter of Employment Rights: Setting the standard for new legislation and good practice&amp;#39;. &lt;em&gt;Journal of Industrial Relations&lt;/em&gt; 40(2): 349–353.&lt;/li&gt;
&lt;li&gt;Heathcote, Andrew (2004) &amp;#39;Young and restless&amp;#39;. &lt;em&gt;Business Review Weekly: BRW&lt;/em&gt;: 26 February.&lt;/li&gt;
&lt;li&gt;Lee, Richard (1994) &amp;#39;Recruitment in context&amp;#39;. &lt;em&gt;Librarian Career Development&lt;/em&gt; 2(2): 3–7.&lt;/li&gt;
&lt;li&gt;Mackinlay, Marcelo (1993) &amp;#39;New strategies for a tough job market&amp;#39;. &lt;em&gt;The Canadian Manager&lt;/em&gt; 18(2): 16–17.&lt;/li&gt;
&lt;li&gt;Robbins, Stephen P. and Judge, Timothy A. (2007) &lt;em&gt;Organizational Behavior&lt;/em&gt;. 12th ed. New Jersey: Pearson Prentice Hall.&lt;/li&gt;
&lt;li&gt;Scroggins, Wesley A., Thomas, Steven L. and Morris, Jerry A. (2009) &amp;#39;Psychological testing in personnel selection, Part III: The resurgence of personality testing&amp;#39;. &lt;em&gt;Public Personnel Management&lt;/em&gt; 38(1): 67–77.&lt;/li&gt;
&lt;li&gt;State Services Authority (2007) &lt;em&gt;Workforce Planning Process Model.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Taylor, Frederick Winslow (1911) &lt;em&gt;The Principles of Scientific Management&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Wooden, Mark and Harding, Don (1998) Recruitment practices in the private sector: Results from a national survey of employers. Asia Pacific Journal of Human Resources 36(73): 73–87.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Searching for the Essence of Entrepreneurship — A Misguided Quest</title>
      <link>https://lucidmanager.org/management/essence-of-entrepreneurship/</link>
      <pubDate>Fri, 20 Feb 2009 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/essence-of-entrepreneurship/</guid>
      <description>
	
&lt;p&gt;
Public figures such as Henry Ford, Richard Branson, Dick Smith and &lt;a href=&#34;https://lucidmanager.org/data-science/trumpworld-analysis/&#34;&gt;Donald Trump&lt;/a&gt; influence the conventional notion of the entrepreneur as a unique individual. Entrepreneurs have achieved celebrity status and have given rise to many myths about entrepreneurship. One of these myths is the idea that the essence of entrepreneurship is an innate ability that can not be acquired and that business instinct is more important than business skill.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Because of their prominent status in society, entrepreneurs have become the heroes of contemporary society, admired as heroes for their ability to accumulate wealth and create economic prosperity.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-2&#34; href=&#34;#footnote-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Entrepreneurs are the heroes of society
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Academic discourse about &lt;a href=&#34;https://lucidmanager.org/management/becoming-an-entrepreneur/&#34;&gt;entrepreneurship&lt;/a&gt; is divided and sometimes even confusing.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-3&#34; href=&#34;#footnote-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;  Are entrepreneurs guided by a Protestant ethic, as proclaimed by Max Weber or are they, following Schumpeter, unique individuals exercising mental freedom? Do entrepreneurs have a high need to achieve (&lt;em&gt;n-Ach&lt;/em&gt;), following McClelland&amp;#39;s theory of motivation, or are they, as argued by de Vries, victims of a traumatic childhood? Who are these heroes of contemporary capitalism? &lt;/p&gt;
&lt;p&gt;
In this essay, entrepreneurs from four continents are discussed and contrasted, guided by the literature on entrepreneurship. Entrepreneurs from different continents are chosen to provide a cross-cultural perspective on the phenomenon. Freddy Heineken is included because of his controversial place in Dutch society. Michael Dell is often touted as the quintessential entrepreneur. Australian Peter Terret provides a contrast to Heineken and Dell because of the modest size of his venture. Lastly, Vietnamese entrepreneur Le Khac Hiep represents a non-Western perspective.&lt;/p&gt;
&lt;p&gt;
The available information about these people is used to deconstruct the mythology of the entrepreneur, in search of the essence of entrepreneurship. The essay finds that the essentialist approach to entrepreneurial studies can only  provide limited insight and that narrative analysis of entrepreneurial biographies should be the preferred method to study this phenomenon. The managerial impact of this conclusion is that the most effective way to become more entrepreneurial is to explore the biographies of successful entrepreneurs.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Biographies of Entrepreneurs
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-3&#34;&gt;
Freddy Heineken
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Freddy (Alfred) Heineken (1923–2002) is one of the most well known Dutch entrepreneurs of the twentieth century. He joined the &lt;a href=&#34;http://www.heineken.nl/&#34;&gt;Heineken&lt;/a&gt; brewery in Amsterdam during the Second World War, which was founded in 1863 by his grandfather. After the war, Freddy worked several years in the sales department of Heineken&amp;#39;s American importer, where he developed his marketing skills. Some years later, Freddy decided to buy the majority of shares, creating the starting point of more than four decades of successful entrepreneurship. Under his leadership, which ended in 1989, Heineken grew to become one of the major breweries in the world and one of the most recognisable beer brands. In the Netherlands, Freddy Heineken was a celebrity entrepreneur, especially after his kidnapping and subsequent release in 1983.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-4&#34; href=&#34;#footnote-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Shortly after his death, several facts about Heineken&amp;#39;s activities outside his business have been revealed. Providing an insight into his personality and motivational drives. These revelations show him to be an influential power broker in Dutch politics, using his marketing skills to assist political friends in the liberal party (VVD). These aspects of his biography reveal him to be a strong Machiavellian type, which was most likely a personality trait that assisted him in growing the business. The Machiavellian personality type is generally considered to be pragmatic, emotionally distanced and prioritising the goals over the
means.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-5&#34; href=&#34;#footnote-5&#34;&gt;5&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I don&amp;#39;t sell beer, I sell good times.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
Above all, the entrepreneurial essence of Freddy Heineken is that he was a gifted marketer. He is reputed to have said: “I don&amp;#39;t sell beer, I sell good times”, illustrating that Heineken did not suffer from Marketing Myopia, as defined by Levitt.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-6&#34; href=&#34;#footnote-6&#34;&gt;6&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
He understood the need to focus on the perceived benefits of his product, rather than marketing the product itself. This vision enabled him to position Heineken beer and differentiate it from other brands. Heineken used his marketing skills as a vehicle for his high need for achievement and drive to accumulate power. It is the combination of his strong personality and his marketing skills that made him the successful entrepreneur he became to be.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-4&#34;&gt;
Michael Dell
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Michael Dell was interested in technology from a young age and started to sell computers while still attending university. Selling computers was not something new in 1984, but Dell sold computers directly to consumers, bypassing traditional distribution channels.&lt;/p&gt;
&lt;p&gt;
This strategy allowed him to minimise distribution costs and thus generate above-average profits. He decided to quit university and corporatise his business, which has since then grown into one of the largest computer manufacturers in the world. His dissatisfaction with existing computer suppliers enabled him to recognise an opportunity in this market.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-7&#34; href=&#34;#footnote-7&#34;&gt;7&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
The success of his business is also founded on an understanding of consumer needs. Dell regularly reads Usenet forums, chat rooms and Web sites to find out what customers think about his products: “I learn about things we are doing well. I learn when we screw up”.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-8&#34; href=&#34;#footnote-8&#34;&gt;8&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Michael is reluctant to provide information about his private life, making it difficult to tap into the psychology of this entrepreneur. Dell, who used to compete in triathlons, is described by Ralph Szygenda, CIO of General Motors, as a “violent competitor who doesn&amp;#39;t like to lose”, illustrating Dell&amp;#39;s competitive drive. According to a long time friend, Michael Dell is very determined and has “never deviated from his early business vision and almost enjoyed being doubted by others”, Illustrating his high need for achievement.&lt;/p&gt;
&lt;p&gt;
Michael Dell&amp;#39;s entrepreneurial essence could be his insight in supply chain management and customer focus, revolutionising marketing logistics, not only in the computer industry but across industries, Dell has continued to innovate their supply chain, being one of the first businesses (in 1996) to utilise the Internet to market computers directly to consumers.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-5&#34;&gt;
Peter Terret
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-5&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Australian entrepreneur Peter Terret has a background in geodetic and topographic survey and developed an interest in Global Positioning Systems (GPS) in 1986. He is the Managing Director of &lt;a href=&#34;http://www.rapidmap.com.au/&#34;&gt;RapidMap&lt;/a&gt;, a medium-sized company established in 1994, that specialises in geospatial equipment and services. RapidMap has since grown into an international provider delivering geospatial products and services.&lt;/p&gt;
&lt;p&gt;
Compared to the previously discussed entrepreneurial heavyweights Heineken and Dell, RapidMap is a modest business. Although RapidMap is a global player in the geospatial services market, compared to Heineken and Dell, it is a small business. The entrepreneurial principles that determine the destiny of all businesses are, however, independent of size.&lt;/p&gt;
&lt;p&gt;
Just like Dell, Terret has been able to recognise an imperfection in the market. While Dell developed a marketing strategy, based on his dissatisfaction with the computer market, Terret&amp;#39;s insight was that he tapped into the need for some organisations, such as water corporations, to manage various physical assets over a large geographical area. Their ability to recognise opportunity is based on knowledge of the markets in which they operate and being able to think from the consumer&amp;#39;s perspective. Parallel with Heineken, Terret based the success of his venture also on his marketing skills. By augmenting his product with the field-kit, RapidMap was able to differentiate itself from the competition, enabling Terret to capture the emerging market for mobile GPS solutions.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-6&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-6&#34;&gt;
Le Khac Hiep
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-6&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Le Khac Hiep is one of the many entrepreneurs that benefit from &lt;a href=&#34;https://lucidmanager.org/management/human-resource-management-in-hanoi/&#34;&gt;Vietnam&amp;#39;s Doi Moi&lt;/a&gt; (restoration) policy and transition from a centrally controlled economy to a market economy. He is the chairman of &lt;a href=&#34;https://www.vingroup.net/&#34;&gt;VinCom Joint Stock Company&lt;/a&gt;, specialising in property development. VinCom has two major holdings: VinCom City Towers in Hanoi and the Sofitel VinPearl Resort and Spa in Hha Trang province.&lt;/p&gt;
&lt;p&gt;
Compared to Michael Dell and Terret, Hiep was not the &lt;em&gt;primum movens&lt;/em&gt; of  VinCom, but just like Heineken, hired by the company. This contrary to the common notion of the entrepreneur as the person starting a venture, which shows that the fortunes of an organisation can be turned by hiring people with an entrepreneurial mindset.&lt;/p&gt;
&lt;p&gt;
Le Khac Hiep states that one of the most important aspects of his achievement is a “hunger for success and aggressiveness and … the desire to do something meaningful for family friends and people”. Suzanne Young, who interviewed Hiep, portrays him as a person with “graciousness and modesty with a respectful disposition and hunger for achievement”. He shares a high desire for achievement with Heineken and Dell, but Hiep&amp;#39;s definition of success is grounded in family, friends and people in general. In a Western cultural context, achievement is usually directed at personal success.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-7&#34; class=&#34;outline-3&#34;&gt;
&lt;h3 id=&#34;headline-7&#34;&gt;
Discussion
&lt;/h3&gt;
&lt;div id=&#34;outline-text-headline-7&#34; class=&#34;outline-text-3&#34;&gt;
&lt;p&gt;Two common themes can be extracted from the case studies. All four described entrepreneurs show a high need for achievement (&lt;em&gt;n-Ach&lt;/em&gt;) as defined by McClelland. The direction of the need to achieve is determined by culture, biography and personality.&lt;/p&gt;
&lt;p&gt;
Le Khac Hiep illustrates this link with culture. His need to achieve is more focused at the collective, rather than his personal achievement, illustrating the individualism-collectivism spectrum identified by Hofstede.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-9&#34; href=&#34;#footnote-9&#34;&gt;9&lt;/a&gt;&lt;/sup&gt; South-East Asian cultures, such as Vietnam, are classified as collectivist cultures, while the Netherlands, Australia and the USA are classified as individualistic. &lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-8&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-8&#34;&gt;
The Philosopher&amp;#39;s Stone of entrepreneurialism
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-8&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Characteristic of entrepreneurs described in business literature is that their need for achievement is expressed through commercial activities. A need for achievement can, however, also be internally directed, such as is the case with most artists, or the need to achieve can be aimed at changing the behaviour of others, such as is the case with, for example, political activists.&lt;/p&gt;
&lt;p&gt;
Although artists, activists and other people also exhibit entrepreneurial behaviour, the extant literature on entrepreneurs focuses on business ventures, with the aim the extract the Philosopher&amp;#39;s Stone of entrepreneurialism so that others can duplicate their achievements. A high need to achieve is a &lt;em&gt;sine qua non&lt;/em&gt; for any entrepreneur. It is a necessary condition that to be entrepreneurial one needs a high drive to succeed. &lt;/p&gt;
&lt;p&gt;
Findings from McClelland, who demonstrated a link between the need to achieve and economic growth, support this idea. It is, however, not a sufficient condition to become more entrepreneurial. Other personal attributes, i.e. abilities, attitudes, skills and knowledge are also important determinants of an entrepreneurial mindset.&lt;/p&gt;
&lt;p&gt;
The second aspect is the relationship between learnt skills and innate abilities of the entrepreneur. Michael Dell seems to have a natural ability to recognise opportunity and has developed his marketing skills in the process. Freddy Heineken also obtained his marketing skills on the job, while expatriated to the United States. The available data does not indicate whether Peter Terret and Le Khac Hiep have formal qualifications in management.&lt;/p&gt;
&lt;p&gt;
However, from this, it can not be concluded that entrepreneurs by definition have an innate ability to recognise marketing opportunities rather than being skilled in marketing techniques. First of all, the selected sample is too small to draw a general conclusion. Secondly, the available biographies are incomplete and could hide any formal education undertaken by these entrepreneurs.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-9&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-9&#34;&gt;
Synthesis
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-9&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The four entrepreneurs discussed in this overview illustrate that entrepreneurship is not an isolated Western cultural phenomenon. All four entrepreneurs show a high need for achievement and an (innate) ability to spot opportunities in the market. The culture-independent nature of entrepreneurial behaviour is confirmed by numerous ethnographic studies of, for example, the Ibos in Nigeria or the in Columbia. But, does the fact that entrepreneurship is a culture-independent phenomenon support the conclusion that there is an essence of entrepreneurship?&lt;/p&gt;
&lt;p&gt;
Entrepreneurial narratives offer a wide range of characteristics that entrepreneurs are considered to be imbued with. Cunningham and Lischeron identified several schools of thought in entrepreneurship studies.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-10&#34; href=&#34;#footnote-10&#34;&gt;10&lt;/a&gt;&lt;/sup&gt; The Great Person school assumes that entrepreneurs have an innate intuition and ability to be entrepreneurs. The Psychological Characteristics school focuses on personality traits as enablers of entrepreneurial success. &lt;/p&gt;
&lt;p&gt;
The Classical School follows the Schumpeterian idea of the entrepreneur as an innovator. The more pragmatic Management School sees entrepreneurs as organisers of economic ventures, trained in the necessary technical skills.&lt;/p&gt;
&lt;p&gt;
Lastly, the Leadership school focuses on the ability of entrepreneurs to motivate people. All schools of thought have in common that they are essentialist, endeavouring to define those aspects of entrepreneurial behaviour that are characteristic to all entrepreneurs.&lt;/p&gt;
&lt;p&gt;
Cunningham and Lischeron argue that the current variety of schools of thought is because the academic study of entrepreneurs is a young field of endeavour and propose a pragmatic approach that uses insights from all schools of thought, depending on the stage of development the business is in. This call for paradigmatic pluralism reflects the complex nature of entrepreneurialism, but it also shows a deeper problem in entrepreneurial studies.&lt;/p&gt;
&lt;p&gt;
Defining dynamic phenomena such as entrepreneurship from an essentialist perspective is an impossible task because the complexity of social reality continuously presents new aspects that do not fit into a previously considered complete definition. No list of characteristics associated with entrepreneurship can ever be considered a sufficient condition for a particular person to become an entrepreneur. &lt;/p&gt;
&lt;p&gt;
Some characteristics, such as /n-/Achievement, can be considered a necessary condition for entrepreneurship to arise. Environmental obstacles and opportunity factors, such as community acceptance social shifts and resource availability, interact with personal attributes and it is the convergence of the two that enable successful business ventures. Given the unpredictable nature of environmental obstacles and opportunity factors, prospects of establishing a causal model of successful entrepreneurship are minimal.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-10&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-10&#34;&gt;
The myth of the entrepreneur
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-10&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Entrepreneurial narratives portray the entrepreneur as the hero of contemporary capitalism. This view, influenced by the early work of Schumpeter which emphasises the achievements of the individual, shows many parallels with the role of the hero in mythology. In mythology, a hero is a person from a humble background who needs to leave the group in search of adventure. The hero overcomes adversity and temporary failures but eventually succeeds in achieving his or her goals. Whelan and O&amp;#39;Gorman demonstrated that the typical entrepreneurial biography has many parallels with traditional hero mythology. The entrepreneur is mythological, not in the sense of myth as a fake story, but as an archetypal person in contemporary society.&lt;/p&gt;
&lt;p&gt;
Following the hero theme, the label &amp;#39;entrepreneurial&amp;#39; is mostly associated with people who are successful, Excluding those that did not succeed.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-11&#34; href=&#34;#footnote-11&#34;&gt;11&lt;/a&gt;&lt;/sup&gt; This value-laden use of the category entrepreneurial directs all research effort into those that were successful.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-12&#34; href=&#34;#footnote-12&#34;&gt;12&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
This approach is analogous with a palaeontologist who only studies species that have survived evolutionary pressures, ignoring those that are extinct. Using this method creates a sanitised and incomplete picture of the entrepreneurial phenomena.&lt;/p&gt;
&lt;p&gt;
French anthropologist Bruno Latour investigated the process of science creation and found that the results of scientific work are an idealised version of the actual process. This process is also active in entrepreneurial studies.&lt;/p&gt;
&lt;p&gt;
Entrepreneurial biographies are always incomplete and sanitised versions of reality. Entrepreneurs that are researched project their self-image on the information they provide about themselves which can lead to subconscious repression of the role of serendipity or even actively censoring of biographies. Researchers are forced to condense the ambiguity of entrepreneurial reality into the concepts described in research. One such condensed aspect of entrepreneurialism is the focus on individual achievements, mainly ignoring the influence that spouses, colleagues, suppliers and others have on the entrepreneur. This focus on the individual matches the mythological hero aspects of entrepreneurialism and is contrary to the emphasis on teamwork in contemporary business discourse.&lt;/p&gt;
&lt;p&gt;
In light of the paradigmatic confusion and problematic aspects of essentialism, some researchers have called for and experimented with alternative methods to research entrepreneurs.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-13&#34; href=&#34;#footnote-13&#34;&gt;13&lt;/a&gt;&lt;/sup&gt; They propose to use interpretive methods to study entrepreneurs. The scholar of entrepreneurship should engage the available information and uncover gender, class and other aspects, looking from a prosopographical perspective that includes the network of people around the entrepreneur. This aspect will lead to a deep &lt;em&gt;Verstehen&lt;/em&gt; of entrepreneurial behaviour instead of a catalogue of characteristics and models.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-11&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-11&#34;&gt;
There is no essence of entrepreneurship
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-11&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The search for the essence of entrepreneurial thinking and behaviour is guided by the desire to be able to duplicate the successes of the studied subjects. It is thought that assuming the essence of entrepreneurship can be found; this knowledge can help others to achieve the same.&lt;/p&gt;
&lt;p&gt;
The paradigmatic confusion in entrepreneurial studies illustrates, however, that there is no essence of entrepreneurship. The absence of essence is supported by current thinking in the philosophy of science. This idea does not imply that entrepreneurship cannot be successfully studied to assist others in becoming more entrepreneurial.&lt;/p&gt;
&lt;p&gt;
The most meaningful way to learn how to become more entrepreneurial is to examine the behaviour of entrepreneurs and read their biographies and interpretations of their behaviour. Universities should equip students of entrepreneurialism with skills to analyse and deconstruct narrative to gain a deep understanding of the entrepreneurs that came before them.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-12&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-12&#34;&gt;
Notes
&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Wellington, D.C. and Zandvakili, S. (2006) &amp;#39;The entrepreneurial myth, globalisation and American economic dominance&amp;#39;. &lt;em&gt;International Journal of Social Economics&lt;/em&gt; 33(9): 615.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-2&#34;&gt;&lt;a href=&#34;#footnote-reference-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Whelan, G. and O&amp;#39;Gorman, C. (2007) &amp;#39;The Schumpeterian and universal hero myth in stories of Irish entrepreneurs&amp;#39;. &lt;em&gt;Irish Journal of Management&lt;/em&gt; 28(2): 79–107.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-3&#34;&gt;&lt;a href=&#34;#footnote-reference-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;de Goey, F. (1996) Ondernemersgeschiedenis in Amerika, Nederland en België&amp;#39;. Entrepreneural history in the Netherlands, America and Belgium]. In &lt;em&gt;Jaarboek voor economische, bedrijfs- en techniekgeschiedenis&lt;/em&gt;. NEHA; Pech, R., ed. (2009) &lt;em&gt;Entrepreneurial courage, audacity, genius&lt;/em&gt;. Sydney: Pearson Education; Steyaert, C. (1998) &amp;#39;A qualitative methodology for process studies of entrepreneurship&amp;#39;. &lt;em&gt;International Studies of Management &amp;amp; Organisation&lt;/em&gt; 27(3): 13–33; Wellington and Zandvakili, 2006.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-4&#34;&gt;&lt;a href=&#34;#footnote-reference-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Heineken (2005) &lt;a href=&#34;https://en.wikipedia.org/wiki/Heineken_International#History&#34;&gt;The history of Heineken&lt;/a&gt;; Smit, B. (1996) Heineken. &lt;em&gt;Een Leven in de Brouwerij [A life in the brewery]&lt;/em&gt;. Nijmegen: SUN.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-5&#34;&gt;&lt;a href=&#34;#footnote-reference-5&#34;&gt;5&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Robbins, S.P. and Judge, T.A. (2007) &lt;em&gt;Organizational Behavior&lt;/em&gt;. 12th ed. New Jersey: Pearson Prentice Hall.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-6&#34;&gt;&lt;a href=&#34;#footnote-reference-6&#34;&gt;6&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Levitt, T. (1960) &amp;#39;Marketing Myopia&amp;#39;. &lt;em&gt;Harvard Business Review&lt;/em&gt; 38(4): 45–56.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-7&#34;&gt;&lt;a href=&#34;#footnote-reference-7&#34;&gt;7&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Burke, S. (2003) &amp;#39;Michael Dell&amp;#39;. &lt;em&gt;CRN&lt;/em&gt; 1075: 30;35.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-8&#34;&gt;&lt;a href=&#34;#footnote-reference-8&#34;&gt;8&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Fishman, C. (2001) &lt;a href=&#34;https://web.archive.org/web/20090306210559/http://www.fastcompany.com/magazine/44/dell.html&#34;&gt;Facetime with Michael Dell&lt;/a&gt;. &lt;em&gt;Fast Company&lt;/em&gt; (44).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-9&#34;&gt;&lt;a href=&#34;#footnote-reference-9&#34;&gt;9&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Hofstede, G. (1993) &lt;em&gt;Allemaal Andersdenkenden (Cultures and Organisations: Software of the Mind)&lt;/em&gt;. Amsterdam: Contact.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-10&#34;&gt;&lt;a href=&#34;#footnote-reference-10&#34;&gt;10&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Cunningham, J. B. and Lischeron, J. (1991) &amp;#39;Defining entrepreneurship&amp;#39;. &lt;em&gt;Journal of Small Business Management&lt;/em&gt; 29(1): 45–61.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-11&#34;&gt;&lt;a href=&#34;#footnote-reference-11&#34;&gt;11&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Legge, J. and Hindle, K. (1997) &lt;em&gt;Entrepreneurship: How Innovators Create the Future.&lt;/em&gt; South Melbourne: MacMillan.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-12&#34;&gt;&lt;a href=&#34;#footnote-reference-12&#34;&gt;12&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Seymour, R.G. (2006) &amp;#39;Hermeneutic phenomenology and international entrepreneurship research&amp;#39;. &lt;em&gt;Journal of International Entrepreneurship&lt;/em&gt; 4: 137–155.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-13&#34;&gt;&lt;a href=&#34;#footnote-reference-13&#34;&gt;13&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Jennings, P.L., Perren, L. and Carter, S. (2005) &amp;#39;Alternative perspectives on entrepreneurship research&amp;#39;. &lt;em&gt;Entrepreneurship theory and practice&lt;/em&gt; 29(2): 145–152.; Seymour, 2006; Steyaert, 1998.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>Self-Knowledge for Managers through Personality Testing</title>
      <link>https://lucidmanager.org/management/self-knowledge-for-managers/</link>
      <pubDate>Fri, 30 May 2008 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/self-knowledge-for-managers/</guid>
      <description>
	
&lt;blockquote&gt;
&lt;p&gt;One&amp;#39;s own is well hidden for one&amp;#39;s own; and of all treasure troves, one&amp;#39;s own is the last to be excavated ….&lt;/p&gt;
&lt;p&gt;
Friedrich Nietzsche, &lt;em&gt;Alzo sprach Zarathustra&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The importance of self-knowledge for managers and everybody else has been acknowledged through the ages and across cultures. A visitor to the temple of Apollo at Delphi in ancient Greece was commanded to “Know Thyself”, and Chinese philosopher Lao wrote that “self-knowledge is enlightenment”.&lt;/p&gt;
&lt;p&gt;
Thousands of years later, the search for the real self is still central to the human experience. Contemporary management thinkers also recognise the importance of self-knowledge and have linked it to improved management performance and subsequently the success of the organisation.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; Self-knowledge is different from knowledge of the objective world.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-2&#34; href=&#34;#footnote-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
It is, by definition, subjective and is thus not easily obtained, as illustrated by the epigraph. Sigmund Freud and Carl Rogers, two of the most influential psychotherapists of the last century, theorised that people have a &lt;a href=&#34;https://horizonofreason.com/science/hidden-personality/&#34;&gt;hidden personality&lt;/a&gt; of which they are not aware. It is this unknown, subconscious, nature of personality that creates epistemological hurdles and makes self-knowledge a hidden treasure.&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Psychometric Testing
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The holy grail of human resource management is to find the perfect staff member. Countless books are devoted to the recruitment process and predicting performance based on interviews, résumés, reference checks and psychometric testing. At Lucid Manager we have written several articles about the machinations of recruitment.&lt;/p&gt;
&lt;p&gt;
The main problem with this approach is that the balance of power is presumed to be on the recruiter&amp;#39;s side. This unbalanced relationship forces the applicant to be like a dancing monkey, performing the tricks that he or she believes will please the recruiters. The applicant is often left to second-guessing the &amp;#39;right&amp;#39; answer to the questions. And although we are often told that there are no right or wrong answers, this is of course not correct. Some answers get you the job and the ones that don&amp;#39;t. The recruitment process is a case of double deception, both the recruiter and the applicant are not willing to have a genuine conversation because they are limited by the script of the traditional
job interview.&lt;/p&gt;
&lt;p&gt;
Many different types of psychometric tests have been developed to determine a subject&amp;#39;s personality or other aspects of the self. It seems that self-knowledge for managers is only a few tickboxes away. These tests are used in clinical settings and research but are also widely used for &lt;a href=&#34;https://lucidmanager.org/management/deception-in-recruitment/&#34;&gt;recruitment&lt;/a&gt; and leadership development.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-3&#34; href=&#34;#footnote-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
For my &lt;a href=&#34;https://lucidmanager.org/tags/mba/&#34;&gt;MBA studies&lt;/a&gt;, I was asked to undertake a battery of personality and motivation tests in an attempt to improve my self-knowledge. The central question to be answered is whether this myriad of numbers and classifications describe me as a person and whether they can provide deeper self-knowledge to enable me to be a better manager.&lt;/p&gt;
&lt;p&gt;
Numerous studies have shown that psychometric tests can be used to make predictions about the behaviour of individuals and job performance. There are, however, many situational variables, such as organisational culture, which influence behaviour. Research indicates that personality plays the most significant role in situations where there are no social clues on how to behave.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-4&#34; href=&#34;#footnote-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Some of the often used methodologies are scientifically problematic. There is little empirical evidence to confirm the validity of the &lt;a href=&#34;http://en.wikipedia.org/wiki/Mbti&#34;&gt;Myers-Briggs Type Indicator&lt;/a&gt;. Also for &lt;a href=&#34;http://en.wikipedia.org/wiki/Theory_X&#34;&gt;Theory X/Y&lt;/a&gt; and &lt;a href=&#34;http://en.wikipedia.org/wiki/Clayton_Alderfer&#34;&gt;ERG Theory&lt;/a&gt;, there is little or no evidence to verify the validity of their assumptions.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-5&#34; href=&#34;#footnote-5&#34;&gt;5&lt;/a&gt;&lt;/sup&gt; A problematic aspect of self-administered psychometric testing is a high level of inherent confirmation bias, also known as the `&lt;a href=&#34;http://en.wikipedia.org/wiki/Forer_effect&#34;&gt;Forer Effect&lt;/a&gt;&amp;#39;.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-6&#34; href=&#34;#footnote-6&#34;&gt;6&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Am I very conscientious, or do I perceive myself to be conscientious? Am I an extroverted person, or is it my high level of energy which subjugates any innate introverted personality? Do the results of these tests provide a picture of my inner self, or are they a reflection of my perceived self?&lt;/p&gt;
&lt;p&gt;
The test results do not reveal any information beyond what has been entered by me, because the results are only a linguistic rearrangement of the answers. This idea is confirmed by recent research that showed that most people could guess the outcome of personality tests without actually undertaking them.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-7&#34; href=&#34;#footnote-7&#34;&gt;7&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Self-Knowledge for Managers
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Comprehensive self-knowledge can thus not be obtained by completing surveys because they can only reveal the perceived self and are not capable of unearthing the inner (subconscious) self. Psychometric tests are suitable only as a vehicle for introspection, providing an entry point for reflecting on one&amp;#39;s self. This introspection can, however, not occur without life experience to reflect on.&lt;/p&gt;
&lt;p&gt;
Obtaining self-knowledge, considered essential for leadership development, requires something more profound and more substantial, as alluded to by Nietzsche in the epigraph to this blog entry. As situational variables predominately control our behaviour, the only way to obtain self-knowledge is life-experience.&lt;/p&gt;
&lt;p&gt;
Only by being exposed to a multitude of situations and challenges can we know what our personality is. As we gain life experience, our inner and perceived selves slowly converge. Maturity is the situation where the inner self and the perceived self are almost identical, and self-knowledge becomes apparent. Even the most carefully designed personality test can not leapfrog the knowledge obtained through life experience. Carl Gustav Jung, who inspired the development of the MBTI recognised this when he wrote:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Anyone who wants to know the human psyche … would be better advised to abandon exact science … and wander with human heart through the world.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
This foray into psychometric testing leaves me to conclude that no psychometric test can ever replace the fullness of life experience to obtain true self-knowledge. Experiences such as exposing oneself to challenging situations, occasionally exploring the boundaries of morality, experiencing different cultures or going through emotional turmoil are the only meaningful ways to gain self-knowledge.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
Free Personality Test
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Are you still interested in taking a personality test after reading this essay?&lt;/p&gt;
&lt;p&gt;
Please take place on our virtual divan and answer the twenty-two questions below to find out what your Forer Workstyle Inventory is. Remember, there are no wrong answers, we don&amp;#39;t collect your personal information, so what are you waiting for?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;center&gt;
    &lt;span class=&#34;icon is-large&#34;&gt;
      &lt;a href=&#34;https://prevos.shinyapps.io/Personality_Test/&#34; target=&#34;_blank&#34;&gt;&lt;i class=&#34;fa-3x fa fa-clipboard&#34;&gt;&lt;/i&gt;&lt;/a&gt;
    &lt;/span&gt;
      &lt;div class=&#34;content&#34;&gt;Click on the icon to go to the test.&lt;/div&gt;
&lt;/center&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Notes
&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Bourner, T. (1996). Personal development to improve management. &lt;em&gt;Management Development Review&lt;/em&gt;, 9(6), 4; McMahon, T. J. (1992). Teaching management to MBA students: The issue of pedagogy. &lt;em&gt;Journal of Managerial Psychology&lt;/em&gt;, 7/(1), 21–25; Smith, B. (1993). `Building Managers from the Inside Out&amp;#39; - Developing managers through competency-based action learning. &lt;em&gt;Journal of Management Development&lt;/em&gt;, 12(1), 43–48.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-2&#34;&gt;&lt;a href=&#34;#footnote-reference-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Gertler, B. (2003) Self-knowledge. In E. N. Zalta (Ed.), &lt;a href=&#34;https://plato.stanford.edu/entries/self-knowledge/&#34;&gt;The Stanford Encyclopedia of Philosophy&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-3&#34;&gt;&lt;a href=&#34;#footnote-reference-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Michael, J. (2003). Using the Myers-Briggs type indicator as a tool for leadership development? Apply with caution. &lt;em&gt;Journal of Leadership and Organizational Studies&lt;/em&gt; 10(1), 68–81.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-4&#34;&gt;&lt;a href=&#34;#footnote-reference-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Gray, P. (2002). &lt;em&gt;Psychology&lt;/em&gt; (4th ed.). New York: Worth Publishers; Robbins, S. P., &amp;amp; Judge, T. A. (2007). &lt;em&gt;Organizational behaviour&lt;/em&gt; (12th ed.). New Jersey: Pearson Prentice Hall.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-5&#34;&gt;&lt;a href=&#34;#footnote-reference-5&#34;&gt;5&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Lorr M. (1991) An empirical evaluation of the MBTI typology. &lt;em&gt;Personality and Individual Differences&lt;/em&gt;, 11(12), 1141–1145.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-6&#34;&gt;&lt;a href=&#34;#footnote-reference-6&#34;&gt;6&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Forer, B. R. (1949). The fallacy of personal validation: A classroom demonstration of gullibility. &lt;em&gt;Journal of Abnormal Psychology&lt;/em&gt;, 44 (1), 118–123.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-7&#34;&gt;&lt;a href=&#34;#footnote-reference-7&#34;&gt;7&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Furnham, A., &amp;amp; Dissou, G. (2007). The relationship between self-estimated and test-derived scores of personality and intelligence. &lt;em&gt;Journal of Individual Differences&lt;/em&gt; 28 (1), 37–44.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>The Capitalist Philosophers: Frederick Taylor, Mayo and Deming</title>
      <link>https://lucidmanager.org/management/frederick-taylor-management-fundamentalism/</link>
      <pubDate>Fri, 02 May 2008 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/management/frederick-taylor-management-fundamentalism/</guid>
      <description>
	
&lt;p&gt;
Management thinkers played an influential role in shaping the twentieth century, but they remained in the shadow of those who Time Magazine considers the most prominent. The influence of visionaries such as Frederick Taylor, Elton Mayo and W. Edwards Deming is, however, immense as their ideas were &lt;a href=&#34;https://horizonofreason.com/culture/management-philosophy/&#34;&gt;instrumental&lt;/a&gt; in creating the prosperity of the late twentieth century. Have these management thinkers found the &lt;a href=&#34;https://lucidmanager.org/management/management-alchemy/&#34;&gt;philosopher&amp;#39;s stone of management&lt;/a&gt; or did they spawn management fundamentalism?&lt;/p&gt;
&lt;div id=&#34;outline-container-headline-1&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-1&#34;&gt;
Frederick Taylor
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-1&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Frederick Taylor (1856–1915) was born to a wealthy Quaker family in Philadelphia and was raised with traditional Protestant values, which espouse hard work and discipline. Childhood friends recall him analysing everything, even a game of croquet or rounders. His passion for perfection and sport was rewarded when in 1881 Taylor and his brother in law became the first men&amp;#39;s double US tennis champions. Although passing the entry exam for Harvard University, Taylor did not attend the &lt;em&gt;alma mater&lt;/em&gt; of his family. Instead, he became an apprentice pattern maker and machinist in 1873. Five years later, he was employed at the Midvale Steel Company as a labourer and worked his way up to chief engineer in six years. While working at Midvale, Taylor obtained a degree in Mechanical Engineering through part-time study at the Stevens Institute of Technology.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-1&#34; href=&#34;#footnote-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/mba/frederick-taylor.jpg&#34; alt=&#34;Frederick Taylor (1856-1915)&#34; title=&#34;Frederick Taylor (1856-1915)&#34;/&gt;
&lt;figcaption&gt;
Frederick Taylor (1856–1915).
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
Taylor&amp;#39;s thinking was emblematic of the rationalist and pragmatic spirit of the late nineteenth century. It was a time when the successes of the exact sciences led to the belief that this type of thinking also applies to the social sciences. The Hobbesian view of society as a machine and the fact that psychology was only an embryonic science, profoundly influenced Taylor&amp;#39;s thinking. Society was thrown into disarray because of the rapid transition from small-scale traditional social systems to the sprawling cities of the industrial age. This development was combined with an increase in individualism, following the call of enlightenment philosophers such as Immanuel Kant for people to think for themselves.&lt;/p&gt;
&lt;p&gt;
It was also a time of rapid vertical economic growth for the United States, spearheaded by the construction of an extensive railway network, which enabled manufacturers to develop high-density distribution networks. Economic activity focused on increasing production because of the intense hunger for goods, which required the improvement of manufacturing techniques to keep up with demand. President Roosevelt remarked in this context that: &amp;#34;The conservation of our national resources is only preliminary to the larger question of national efficiency.&amp;#34;&lt;/p&gt;
&lt;p&gt;
It was these words that Taylor used to open his most influential 1911 monograph, &lt;em&gt;The Principles of Scientific Management&lt;/em&gt;. Taylor developed his management theory when encountering the practice of “systematic soldiering”, which is the intentional limitation of productivity by labourers, at the Midvale Steel Works. Taylor&amp;#39;s protestant ethic emphasising diligent labour as a means to personal salvation and upper-class upbringing prevented him from accepting this ingrained practice.&lt;/p&gt;
&lt;p&gt;
Taylor&amp;#39;s motives were outwardly humanistic as he aimed to &amp;#34;secure the maximum prosperity for the employer, coupled with the maximum prosperity for each employee. Taylor&amp;#39;s focus on increasing productivity was based on the idea that “maximum prosperity can exist only as the result of maximum productivity”.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-2&#34; href=&#34;#footnote-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Contemporary marketing literature suggests a variety of means to increase prosperity, such as communications and pricing strategies. These sophisticated marketing strategies were, however, not generally practised during Taylor&amp;#39;s time and so his only means to improve prosperity was to increase efficiency.&lt;/p&gt;
&lt;p&gt;
Taylor observed that factory workers had their trade handed down through word of mouth and he lamented that this “rule of thumb” knowledge, was “not in possession of the management”. Taylor&amp;#39;s strategy was therefore principally aimed at transferring power from the worker to management and develop a science to replace traditional knowledge. Although Taylor mentions “an almost equal division of the responsibility between management and the workmen
[sic]”, his idea of shared responsibility was to move all initiative and control over work methods from labourers to management. His attitude towards labourers is reminiscent of Kant&amp;#39;s Vormünder (guardians), as he does not want them to think for themselves. Taylor&amp;#39;s ideal factory is like a termite colony; using rigid work patterns which convert employees into mindless workers.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-3&#34; href=&#34;#footnote-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
Taylor and his colleagues ran a series of experiments with hauling pig iron. His description of this activity shows disdain, rooted in his sense of class distinctions, for the average worker: “… it would be possible to train an intelligent gorilla to become a more efficient pig-iron handler than any man can be”, thereby justifying his strict division of labour. Using an early application of ergonomics, Taylor determined that pig iron hauliers should be able to move 48 metric tonnes per day (1,144 pigs of iron), instead of the usual 13 tonnes (304 pigs). The workers were offered a salary increase from $1.15 per day to $1.85. To the labourers, a sixty percent wage increase would have sounded fantastic, but they had to increase productivity by 376%! Taylor justified this by arguing that customers should enjoy part of the productivity gains, but he also thought that labourers would not be able to handle earning too much money and that they would become “extravagant and dissipated”.&lt;/p&gt;
&lt;p&gt;
Taylor had, however, great difficulty implementing his theories and ccasionally resorted to lowering wages to &amp;#34;motivate&amp;#34; workers and using a form of Social Darwinism to weed out all those who were not able to achieve the high production standards. Taylor&amp;#39;s experiments were not received favourably; workers threw spanners in the works and Taylorism was also subject to a congressional investigation. In spite of this resistance, Taylorism remained popular for several decades.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-2&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-2&#34;&gt;
Elton Mayo
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-2&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;Australian born psychologist &lt;a href=&#34;https://en.wikipedia.org/wiki/Elton_Mayo&#34;&gt;Elton Mayo&lt;/a&gt; (1880–1949) was asked in 1928 to help interpret the data obtained from the Hawthorne experiments. Mayo was a proponent of the psychology of Sigmund Freud and challenged the idea of people as purely rational beings. This in contrast with Taylor, who relied upon mathematical reasoning to improve management practices and analysed people as if they were machines.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-4&#34; href=&#34;#footnote-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
The experiments conducted at the Hawthorne plant of Western Electric were initially performed to investigate the relationships between workplace conditions and productivity. One hypothesis productivity maximises at a particular light intensity had to be rejected, as productivity increased regardless of light intensity. The researchers concluded that uncontrolled variables had influenced productivity and eventually concluded that the psychology of the total situation was an important factor.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&#34;https://lucidmanager.org/images/mba/elton-mayo.jpg&#34; alt=&#34;Elton Mayo&#34; title=&#34;Elton Mayo&#34;/&gt;
&lt;figcaption&gt;
Elton Mayo.
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;
It could be argued that Taylor foretold the outcomes of Hawthorne. When working at the Simmonds Rolling Machine Company, he noted that productivity increased when: “each [ball bearing checking] girl was made to feel that she was the object of special care and interest”. However, Taylor has never conducted any detailed studies to investigate this phenomenon.&lt;/p&gt;
&lt;p&gt;
One of the variables Mayo and his colleagues studied at Hawthorne was the influence of rest periods on productivity. This was, however, not a new idea as Taylor had introduced regular rest periods for the ball bearing checking girls and noted that productivity increased. Taylor&amp;#39;s perspective was, however, not psychological but ergonomic. He was interested in improving the efficiency of the human machine, without regarding the mind.&lt;/p&gt;
&lt;p&gt;
Mayo also encountered the practice of soldiering at Hawthorne. Researchers found that a group of workers paid on a piece-rate arrangement had established their output norm, based on what they thought would be fair. In contrast with Taylor, Mayo did not seek to eradicate the informal organisation. Instead, he tried to find ways to create an equilibrium between the official and informal organisation.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-3&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-3&#34;&gt;
W. Edwards Deming
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-3&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The founder of Total Quality Management, W. Edwards Deming (1900–1993) was imbued with Taylor&amp;#39;s systematic approach, but with a more enlightened understanding of human psychology. To improve the pig-iron loading, Deming would have advised Taylor to motivate workers to provide suggestions to increase efficiency, rather than relying on stopwatch and slide-rule yielding engineers. Taylor&amp;#39;s hierarchical view of the world and his belief in a strict division of responsibility impeded him from recognising workers as part of the solution. Taylor&amp;#39;s writings are, however, contradictory, because he does seem to believe that “every encouragement … should be given [to the worker] to suggest improvements”, contradicting with his ideas about the division of labour cited above.&lt;/p&gt;
&lt;p&gt;
There are many points of difference and similarities between Deming and Taylor. They both used a method based on science and placed high value on facts. They also both saw that management and employees have similar interests and both acknowledged the importance of customers. Their points of difference are due to their place on the timeline of management thought. Deming had the advantage of the psychological insights of management researchers such as Mayo, while Taylor was limited by his belief in the exact sciences and the limited availability of psychological knowledge.&lt;sup class=&#34;footnote-reference&#34;&gt;&lt;a id=&#34;footnote-reference-5&#34; href=&#34;#footnote-5&#34;&gt;5&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
The currently widely implemented Six Sigma business improvement methodology echoes the philosophy of Scientific Management. The Six Sigma method is often summarised with DMAIC: Design, Measure, Analyse, Improve and Control. These steps are closely aligned to Taylor&amp;#39;s principles of scientific management, and Six Sigma is a form of Taylorism, enhanced with customer focus advocated by Deming and an understanding of psychology. Remnants of Taylorism can also be found in call centres. Operators are closely monitored, and their work is modelled using mathematical formulae, such as the Erlang-C equation. There is also a strict division of labour as in most call centres; operators are provided with detailed scripts, eliminating human spontaneity which is considered prone to error, from the interaction between customers and operators. The result of this is that call centres suffer from enormous rates of staff dissatisfaction and turnover and that some are calling for a more psychological approach.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-4&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-4&#34;&gt;
Conclusion
&lt;/h2&gt;
&lt;div id=&#34;outline-text-headline-4&#34; class=&#34;outline-text-2&#34;&gt;
&lt;p&gt;The end of the nineteenth century was a pivotal period in the history of Western culture. Fast developments since the industrial revolution had caused social turmoil, but also increased a sense of individualism, flowing on from the ideals of the enlightenment, proclaimed by Kant and others. Taylor, however, clung to the old values of the &lt;em&gt;Ancien Régime&lt;/em&gt; and implemented a strict division of labour. &lt;/p&gt;
&lt;p&gt;
Taylor can be called a fundamentalist as he had an unshakable belief that his method was the only right way. Historical forces were, however, much stronger than Taylor. Subsequent management theories proclaimed a more subtle psychological approach to motivate staff, acknowledging the employees are free-thinking individuals. Although Taylor recognised that “some special incentive” was required to motivate labourers, he failed to seek ways to internally motivate them because he limited himself to the methods of the exact sciences. It is for these reasons that Taylor&amp;#39;s work has only very limited applicability in a contemporary management setting.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;outline-container-headline-5&#34; class=&#34;outline-2&#34;&gt;
&lt;h2 id=&#34;headline-5&#34;&gt;
Notes
&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&#34;footnotes&#34;&gt;
&lt;hr class=&#34;footnotes-separatator&#34;/&gt;
&lt;div class=&#34;footnote-definitions&#34;&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-1&#34;&gt;&lt;a href=&#34;#footnote-reference-1&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Gabor, Andrea (2000) &lt;em&gt;The capitalist philosophers.&lt;/em&gt; New York: Three Rovers Press.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-2&#34;&gt;&lt;a href=&#34;#footnote-reference-2&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Taylor, Frederick W. (19110) &lt;em&gt;The principles of scientific management&lt;/em&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-3&#34;&gt;&lt;a href=&#34;#footnote-reference-3&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Pech, Richard J. (2001) &amp;#39;Termites, group behaviour, and the loss of innovation: conformity rules!&amp;#39; &lt;em&gt;Journal of Managerial Psychology&lt;/em&gt; 16(7): 559–574.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-4&#34;&gt;&lt;a href=&#34;#footnote-reference-4&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Wren, David A. (2005) &lt;em&gt;The history of management thought&lt;/em&gt;. 5th ed. Wiley.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;footnote-definition&#34;&gt;
&lt;sup id=&#34;footnote-5&#34;&gt;&lt;a href=&#34;#footnote-reference-5&#34;&gt;5&lt;/a&gt;&lt;/sup&gt;
&lt;div class=&#34;footnote-body&#34;&gt;
&lt;p&gt;Knouse, Stephen B., Carson, Paula Phillips and Carson, Kerry D. (1993) &amp;#39;W. Edward Deming and Frederick Winslow Taylor: A Comparison of two leaders who shaped the world&amp;#39;s view of management&amp;#39;. &lt;em&gt;International Journal of Public Administration&lt;/em&gt; 16(10): 1621–1658.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

      </description>
    </item>
    
    
    
    <item>
      <title>A Brief Guide to Providing Insights as a Service</title>
      <link>https://lucidmanager.org/data-science/testing/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <author>Peter Prevos</author>
      <guid>https://lucidmanager.org/data-science/testing/</guid>
      <description>
	
      </description>
    </item>
    
    
  </channel>
</rss>
