<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>DaveParr.Info</title>
    <subtitle>Blog and personal website of Dave Parr, Data Scientist and Software Engineer</subtitle>
    <link href="https://www.daveparr.info/atom.xml" rel="self" type="application/atom+xml"/>
    <link href="https://www.daveparr.info/"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2024-01-16T00:00:00+00:00</updated>
    <id>https://www.daveparr.info/atom.xml</id>
    <entry xml:lang="en">
        <title>Moving Starpilot to GraphQL</title>
        <published>2024-01-16T00:00:00+00:00</published>
        <updated>2024-01-16T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/moving-starpilot-to-graphql/" type="text/html"/>
        <id>https://www.daveparr.info/blog/moving-starpilot-to-graphql/</id>
        
        <content type="html">&lt;p&gt;After building &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;starpilot&quot;&gt;Starpilot&lt;&#x2F;a&gt; at the end of last year and using it for a little. I became pretty frustrated with the time it took to create the vectorstore. Specifically, the time it took to read the relevant repo data from GitHub’s REST api via &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;PyGithub&#x2F;PyGithub&quot;&gt;PyGithub&lt;&#x2F;a&gt;. I &lt;a href=&quot;https:&#x2F;&#x2F;www.daveparr.info&#x2F;blog&#x2F;copilot-for-your-github-stars-1cep&#x2F;&quot;&gt;outlined the choices I made&lt;&#x2F;a&gt; in the original blog post, but to summarise: &lt;code&gt;PyGithub&lt;&#x2F;code&gt; wraps the GitHub REST api and is used to read the repos that are starred by a user on GitHub, and then pass this to a function that iterates over &lt;em&gt;each&lt;&#x2F;em&gt; repo for &lt;em&gt;each&lt;&#x2F;em&gt; piece of data I want to extract. I’m sure that for many (most) use cases this isn’t an issue, but for getting 9 pieces of data for lists of sometimes hundreds or even thousands of repos, it’s the wrong tool for the job. There is overhead to set up the connection, then execute the call, and wait for the response to come back. The total number of calls is roughly:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;txt&quot; class=&quot;language-txt z-code&quot;&gt;&lt;code class=&quot;language-txt&quot; data-lang=&quot;txt&quot;&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;9[pieces of information] * 1000[number of repos] + 1[list of user starred repos]
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This is slow. To be fair I wasn’t surprised by this. I actually expected it and just accepted it so I could get onto making the tool somewhat useful. Now I know it is useful though, it’s time to optimise. For my list of 800 starred repos it takes about 20 minutes on my desktop. Luckily, I’ve found a way to 10x the speed of this process down to 2 minutes for the same list on the same machine using GraphQL.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;how-i-did-it&quot;&gt;How I did it&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;graphql&quot;&gt;GraphQL&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;graphql.org&#x2F;&quot;&gt;GraphQL&lt;&#x2F;a&gt; is a query language for APIs and a runtime for fulfilling those queries with your existing data. It provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools. GraphQL is perfect for the needs of this project as:&lt;&#x2F;p&gt;
&lt;h3 id=&quot;github-graphql-explorer&quot;&gt;GitHub GraphQL Explorer&lt;&#x2F;h3&gt;
&lt;p&gt;GitHub provides a &lt;a href=&quot;https:&#x2F;&#x2F;docs.github.com&#x2F;en&#x2F;graphql&quot;&gt;GraphQL api&lt;&#x2F;a&gt;. The Github GraphQL api allows you to structure a query for a specific set of information for a repo, then use that structure to return the same set of of structured information for each repo that a specific user has starred, all in one call. GitHub also provides a &lt;a href=&quot;https:&#x2F;&#x2F;docs.github.com&#x2F;en&#x2F;graphql&#x2F;overview&#x2F;explorer&quot;&gt;GraphQL explorer&lt;&#x2F;a&gt; to help you build your queries. However after a while I found this limiting, mostly because the page renders so that only around a 3rd of the screen is the playground with a mad amount of space for the header, footer and sidebar. Therefore I installed:&lt;&#x2F;p&gt;
&lt;h3 id=&quot;insomnia&quot;&gt;Insomnia&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;insomnia.rest&#x2F;&quot;&gt;Insomnia&lt;&#x2F;a&gt; is a desktop editor for developing APIs. I liked it because the workspace is more fully featured, allowing you to save queries and sync them to your cloud account for storage, and handles authentication and suppliying variables. Because part of the GraphQL specification is that each API can be &lt;a href=&quot;https:&#x2F;&#x2F;graphql.org&#x2F;learn&#x2F;introspection&#x2F;&quot;&gt;&lt;em&gt;introspected&lt;&#x2F;em&gt;&lt;&#x2F;a&gt; it also behaved exactly like the GitHub Explorer and provided autocomplete, documentation and error linting for the queries I was writing. This was a huge help in getting the queries right. GitHub’s GraphQL interface is HUUUUGE. With Insomnia I was able to build up the query I needed in stages, testing each part as I went (Insomnia the app, not the sleep problem). However, I still needed to integrate this into my code. Most tutorials seem to suggest that the thing to do is just take the query, wrap it in &lt;code&gt;&amp;quot;&amp;quot;&amp;quot; myQuery here&amp;quot;&amp;quot;&amp;quot;&lt;&#x2F;code&gt; and pass it to requests, but that seemed like a perfect way to accidentally break 90 lines of code with an unlintable typo. I wanted to use a python library that would allow me to build the query in a more structured way that is harder to break by accident, and also allow me to pass variables to the query. I found:&lt;&#x2F;p&gt;
&lt;h3 id=&quot;graphql-query&quot;&gt;&lt;code&gt;graphql-query&lt;&#x2F;code&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;denisart&#x2F;graphql-query&quot;&gt;denisart&#x2F;graphql-query&lt;&#x2F;a&gt; is a Python package to build GraphQL queries from the core abstract pieces of the GraphQL language. I found this really useful as I learnt more about GraphQL and how it’s mental model is formed of fields with potentially optional arguments, nodes, edges and fragments. It also helped to make editing in VS Code directly a lot easier as it supports type hinting, so you can’t put an &lt;code&gt;Argument&lt;&#x2F;code&gt; or &lt;code&gt;Field&lt;&#x2F;code&gt; in the wrong place. As I iterated over the last tweaks to the query I found I actually didn’t need to go back to Insomnia as much. However, &lt;code&gt;graphql-query&lt;&#x2F;code&gt; doesn’t actually act as a client to the GraphQL api, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;starpilot&#x2F;blob&#x2F;5c688eb70727d860ca9a0659f20fda988b5b686a&#x2F;starpilot&#x2F;utils&#x2F;utils.py#L61-L138&quot;&gt;it just builds the query&lt;&#x2F;a&gt;. For that I needed:&lt;&#x2F;p&gt;
&lt;h3 id=&quot;gql&quot;&gt;&lt;code&gt;gql&lt;&#x2F;code&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;graphql-python&#x2F;gql&quot;&gt;gql&lt;&#x2F;a&gt; is a Python library for handling GraphQL queries in Python through a client. This became particularly useful as a (reasonable) limitation of GitHub’s GraphQL API is that when returning back a &lt;code&gt;repo&lt;&#x2F;code&gt; type node, you can only return up to 100 per call. Therefore I needed to paginate through the results. I would have liked it if &lt;code&gt;gql&lt;&#x2F;code&gt; had a way to handle this for me, but I couldn’t find it if it does, so I wrote a small bit of simple logic to handle that. The slightly tricky thing about pagination on this node is that you need to handle it with a GraphQL &lt;code&gt;cursor&lt;&#x2F;code&gt;. This is a string that is returned with each node that you can use to tell the API where to start the next page of results from. I found that the easiest way to handle this was &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;starpilot&#x2F;blob&#x2F;5c688eb70727d860ca9a0659f20fda988b5b686a&#x2F;starpilot&#x2F;utils&#x2F;utils.py#L172-L184&quot;&gt;to use a &lt;code&gt;while&lt;&#x2F;code&gt; loop&lt;&#x2F;a&gt; and pass the cursor back to the query as a variable. When the query return is empty for a last cursor, the loop breaks, and the results are returned. I did debate a more complex approach that involved counting the number of expected repos first, modulo 100, and then using that to determine the number of pages to request, but I decided that was overkill for my use case.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;other-tweaks&quot;&gt;Other tweaks&lt;&#x2F;h2&gt;
&lt;p&gt;Because the data that is returned from the API comes as a dict for each repo, I modified the old function that iterated over each repo to get all the data for a specific repo. This function also contained the logic to write the data to disk for iteration over by &lt;code&gt;langchain&lt;&#x2F;code&gt;, so it seemed a suitable change. As I’d also learnt some more about &lt;code&gt;jq&lt;&#x2F;code&gt; and how it is used in &lt;code&gt;langchain&lt;&#x2F;code&gt; I realised that instead of creating a &lt;code&gt;json&lt;&#x2F;code&gt; file with 2 dicts, one for &lt;code&gt;metadata {...}&lt;&#x2F;code&gt; and one for &lt;code&gt;content {...}&lt;&#x2F;code&gt; I realised I could just &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;starpilot&#x2F;blob&#x2F;5c688eb70727d860ca9a0659f20fda988b5b686a&#x2F;starpilot&#x2F;utils&#x2F;utils.py#L193-L221&quot;&gt;write the data structure as a single dict&lt;&#x2F;a&gt;, and then use &lt;code&gt;jq&lt;&#x2F;code&gt; to &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;starpilot&#x2F;blob&#x2F;5c688eb70727d860ca9a0659f20fda988b5b686a&#x2F;starpilot&#x2F;utils&#x2F;utils.py#L256-L277&quot;&gt;extract the data I needed&lt;&#x2F;a&gt; via tha optional &lt;code&gt;metadata_func&lt;&#x2F;code&gt; argument in &lt;code&gt;langchain.document_loaders.JSONLoader&lt;&#x2F;code&gt;. I got tripped up for a while as I had mistakenly written a behaviour into &lt;code&gt;metadata_func&lt;&#x2F;code&gt; that effectively &lt;em&gt;re-imputed&lt;&#x2F;em&gt; a &lt;code&gt;None&lt;&#x2F;code&gt; value into the &lt;code&gt;description&lt;&#x2F;code&gt; value &lt;em&gt;after&lt;&#x2F;em&gt; the &lt;code&gt;format_repo()&lt;&#x2F;code&gt; function had taken the value &lt;em&gt;and&lt;&#x2F;em&gt; key out of the file saved to disk, which was then passed to &lt;code&gt;Chroma&lt;&#x2F;code&gt; via the &lt;code&gt;JSONLoader&lt;&#x2F;code&gt;. I managed to debug that however, and then I implemented the suggestion from the helpful error message to use &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;starpilot&#x2F;blob&#x2F;5c688eb70727d860ca9a0659f20fda988b5b686a&#x2F;starpilot&#x2F;utils&#x2F;utils.py#L295&quot;&gt;&lt;code&gt;langchain.vectorstores.utils.filter_complex_metadata()&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;  as a (slightly redundant) safeguard. I’d already got it wrong once so…&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-tweaks-that-didn-t-make-it&quot;&gt;The tweaks that didn’t make it&lt;&#x2F;h2&gt;
&lt;p&gt;A version of the GraphQL query that I used originally went the whole hog and also returned the &lt;code&gt;README.md&#x2F;README.rst&lt;&#x2F;code&gt; from the repo. I’m certain that many of the readmes have great context that will enhance the embedding in the vectorstore, however I found that returning all that data significantly eroded the performance gains. To the extent that though I had 10x speeded up the process of reading the data from GitHub, I was now spending 10x longer generating the embedding via &lt;code&gt;langchain.embeddings.GPT4ALLEmbeddings&lt;&#x2F;code&gt;. I know that the OpenAI embedding model seems to be much faster from some trials I’ve done, but I’m not (yet) happy to migrate over as it increases the cost of running &lt;code&gt;starpilot&lt;&#x2F;code&gt;. However, not to the extent that it’s unviable (probably still less than a cup of coffee), but I’m not sure I’m ready to commit to that yet. Maybe as I work towards building an agent architecture for &lt;code&gt;starpilot&lt;&#x2F;code&gt; I’ll revisit this. When I do, I’ll probably implement a way to summarise the use case from the readmes and strip out the things like installation instructions. That summary would then be the part used in the embedding.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;&#x2F;h2&gt;
&lt;p&gt;Using Github’s GraphQL API has allowed me to &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;starpilot&#x2F;commit&#x2F;5c688eb70727d860ca9a0659f20fda988b5b686a&quot;&gt;10x the speed of reading the data from GitHub&lt;&#x2F;a&gt;. Developing for GraphQL is maybe even &lt;em&gt;less&lt;&#x2F;em&gt; of a hassle than for REST APIs, as the introspection allows you to build complex queries in a more structured way with a better linting and autocomplete driven experience up front. I’m not sure that means &lt;em&gt;all&lt;&#x2F;em&gt; API’s should be GraphQL. It’s pretty clear the benefits come when the data that is being returned (or operations being performed) are being done on data objects with a huge amount of structure. The other benefit is being able to batch up calls on that structure. The introspection aspects of it also help with learning, developer experience and good documentation, however arguably a chunk of this idea is already available on REST APIs via OpenAPI&#x2F;Swagger, so it’s not a unique selling point.&lt;&#x2F;p&gt;
&lt;p&gt;Developing GraphQL in Python also seems pretty robust, with a number of other options I didn’t include for GraphQL clients in the language ecosystem, as well as other tools that I didn’t need for starpilot like GraphQL servers. I had worried it would be pretty under tooled, and that GraphQL client side was a very “JavaScript” thing to do. Luckily that wasn’t the case.&lt;&#x2F;p&gt;
&lt;p&gt;In the future either on this project or another I’d like to explore &lt;code&gt;graphql-query&lt;&#x2F;code&gt; ’s support for fragments to dynamically extend the query render at call time (e.g. to include the readme data in the query based on a boolean flag in the function signature). I’d also maybe look at &lt;a href=&quot;https:&#x2F;&#x2F;gql.readthedocs.io&#x2F;en&#x2F;latest&#x2F;advanced&#x2F;dsl_module.html&quot;&gt;&lt;code&gt;gql&lt;&#x2F;code&gt;’s support for creating a Domain Specific Language (DSL) for a given GraphQL schema&lt;&#x2F;a&gt;. I only spotted that after I had finished my work with &lt;code&gt;graphql-query&lt;&#x2F;code&gt; so I didn’t spend time resolving the same problem, but if I need to write more GraphQL in Python I’ll definitely look at that.&lt;&#x2F;p&gt;
&lt;p&gt;Hopefully this speed up will make &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;starpilot&quot;&gt;&lt;code&gt;starpilot&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; more approachable for a lot of people. I know I’ve been irritated in my own development cycle iterating over &lt;code&gt;star pilot read&lt;&#x2F;code&gt; and waiting for the data to come back, so at the very least I’ve saved myself some time and learnt a bunch in the process.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Copilot for your GitHub stars</title>
        <published>2023-11-19T00:00:00+00:00</published>
        <updated>2023-11-19T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/copilot-for-your-github-stars-1cep/" type="text/html"/>
        <id>https://www.daveparr.info/blog/copilot-for-your-github-stars-1cep/</id>
        
        <content type="html">&lt;p&gt;How do you use your GitHub stars? &lt;&#x2F;p&gt;
&lt;p&gt;I’d guess if you’ve been programming for a few years you’ve probably hit the star button at the top of a few of your favourite repos. I know some people I follow have done it &lt;em&gt;thousands&lt;&#x2F;em&gt; of times. Do you go back to them though? Do you review them for inspiration for your next project or go to them when you’re stuck on a partictular problem?&lt;&#x2F;p&gt;
&lt;h2 id=&quot;inspiration&quot;&gt;Inspiration&lt;&#x2F;h2&gt;
&lt;p&gt;I’ve always assumed I would use them but I never have. I found myself doing some research recently into how to build software that uses LLMs, with the deliberate goal of building an as yet undefined side-project. I wanted to build something I hadn’t built before, something that was hopefully a little original, and maybe even &lt;strong&gt;useful&lt;&#x2F;strong&gt;! So yet again I was starring repos like LangChain and Chroma, swearing this time would be different. &lt;&#x2F;p&gt;
&lt;p&gt;As I was running through blog posts and diligently smashing the star buttons I realised that I had just hit on exactly what I wanted to try. I wanted to bring my GitHub stars right into my editor. I wanted to be able to have them next to me as I was working and get a sensible set of suggestions on what might be useful for my needs at that moment, and I had just been starring the exact repos that could make this happen!&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-original-idea&quot;&gt;The original idea&lt;&#x2F;h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Use a dataset of your personal stars to inform retrival augmented generation for a question and answer large language model deployed in a command line interface&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;I thought this would be useful for a few reasons:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;By having it in the CLI its available right in my editor, and to every project.&lt;&#x2F;li&gt;
&lt;li&gt;By having a set of your personal stars the suggestions are already curated by your interests and preferences. Mine are all Python and R librarys, wierd data bases and charting libraries. Yours might mostly be Ruby gems, or web frameworks, or tools for embedded systems.&lt;&#x2F;li&gt;
&lt;li&gt;By using a large language model the tool &lt;em&gt;might&lt;&#x2F;em&gt; be more capable of understanding the intentention of your goals, for instance the query “Suggest how to build a web app” might be able to infer that you’d likely want a front end component, a backend component and a data storage component, and might even deal with servers and deployment.&lt;&#x2F;li&gt;
&lt;li&gt;By using large language models the tool &lt;em&gt;might&lt;&#x2F;em&gt; be more capable of semantic search rather than keyword matching which suits this problem as there is no strong standard on how a library describes it self through it’s topics, description and documentation.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;semantic-vs-keyword&quot;&gt;Semantic vs keyword&lt;&#x2F;h3&gt;
&lt;h4 id=&quot;keyword&quot;&gt;Keyword&lt;&#x2F;h4&gt;
&lt;p&gt;A keyword search looks for the exact letters in a string, or potentially a partial match. As an example the query &lt;code&gt;&amp;quot;Data Science&amp;quot;&lt;&#x2F;code&gt; would find things that exactly matched the charcters in the string &lt;code&gt;&amp;quot;Data Science&amp;quot;&lt;&#x2F;code&gt; and maybe also &lt;code&gt;[&amp;quot;Data&amp;quot;, &amp;quot;Science&amp;quot;, &amp;quot;DS&amp;quot;]&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;semantic&quot;&gt;Semantic&lt;&#x2F;h4&gt;
&lt;p&gt;A semantic search looks for the &lt;em&gt;conceptual&lt;&#x2F;em&gt; similarity between things, so in this context &lt;code&gt;&amp;quot;Data Science&amp;quot;&lt;&#x2F;code&gt; would find things that matched the vector embedding of &lt;code&gt;&amp;quot;Data Science&amp;quot;&lt;&#x2F;code&gt; as well as maybe also the vector embeddings that are associated with &lt;code&gt;[&amp;quot;Machine Learning&amp;quot;, &amp;quot;Artificial Intelligence&amp;quot;]&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;And so I ran &lt;code&gt;poetry new starpilot&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;starpilot&quot;&gt;starpilot&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;why-retrival-augmented-generation-matters&quot;&gt;Why retrival augmented generation matters&lt;&#x2F;h2&gt;
&lt;p&gt;Retrieval Augmented Generation (RAG) is a technique used by large language models to cope with some of the limitations inherent in what are also sometimes referred to as ‘Foundational’ models. &lt;&#x2F;p&gt;
&lt;p&gt;When a model like GPT3 is trained, it is fed large amounts of textual data written by humans. These get translated into ‘weights’ in a nueral net. To overly simplify, these weights tell the model what the next most likely text is that follows the text it has already been shown. &lt;&#x2F;p&gt;
&lt;p&gt;However, these models don’t know much about what has happened recently, what other programming resources really exist rather than what just sounds like it should exist, or where to exactly get a specific repo or webpage.&lt;&#x2F;p&gt;
&lt;p&gt;Retrieval augmented generation solves this by allowing you to feed the large language model with known real, up to date and relevant information. &lt;&#x2F;p&gt;
&lt;h2 id=&quot;vectorstores&quot;&gt;Vectorstores&lt;&#x2F;h2&gt;
&lt;p&gt;A type of data base called a vectorstore is commonly used for this because they are deliberately optimised towards a similarity search use case. They achieve this in a few ways:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Vectorstores store what you pass them as a ‘vector embedding’. A vector embedding takes data (like text or images) and converts them to a list like representation of numbers.&lt;&#x2F;li&gt;
&lt;li&gt;Vectorstores keep similar vector embeddings close together in memory. This means that they are as fast as possible at returning lots of documents that have similar semantic meaning, because they are all clustered together.&lt;&#x2F;li&gt;
&lt;li&gt;Vectorstores have APIs that are specifically designed for these use cases, with querying methods that lean towards semantic searches more than sql queries, and loading techniques that integrate tightly into other systems that generate these vector embeddings from large language models.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;designing-a-system&quot;&gt;Designing a system&lt;&#x2F;h2&gt;
&lt;p&gt;With this set of goals and new knowledge I got to work working out which puzzle pieces I needed and how to fit them together. This time I did go through my stars (and a few other things), though maybe this is for the last time!&lt;&#x2F;p&gt;
&lt;p&gt;I figured I could get started using 4 main open source repos. &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;starpilot&#x2F;commit&#x2F;4846bcd43b598d0c5d6fb408fbe2d622076b999f#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711&quot;&gt;My first commit to my pyproject.toml&lt;&#x2F;a&gt; used these projects:&lt;&#x2F;p&gt;
&lt;h3 id=&quot;typer&quot;&gt;Typer&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;tiangolo&#x2F;typer&quot;&gt;tiangolo&#x2F;typer&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;typer&lt;&#x2F;code&gt; is a pretty trendy framework for building CLI tools in python right now. It embraces typing, uses function decorators to magically turn your functions into CLI commands, and has relatively clear documention.&lt;&#x2F;p&gt;
&lt;p&gt;I chose &lt;code&gt;typer&lt;&#x2F;code&gt; specifically because:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;I wanted to see what the hype was about&lt;&#x2F;li&gt;
&lt;li&gt;I think typing helps write better code&lt;&#x2F;li&gt;
&lt;li&gt;I found the documentation really helpful to get started easily&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;langchain-ai&#x2F;langchain&quot;&gt;langchain-ai&#x2F;langchain&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;langchain&lt;&#x2F;code&gt; is the most mature and well embraced large language model orchestration framework. Langchain itself doesn’t supply you with any specific llm or vector store or embedding approach. Instead it is deliberately ‘vendor agnostic’. It provides a common set of APIs and abstractions across a staggering number of vector data bases, large language models and embedding engines. &lt;&#x2F;p&gt;
&lt;p&gt;I chose &lt;code&gt;langchain&lt;&#x2F;code&gt; because:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;It is the most established tool in a brand new space&lt;&#x2F;li&gt;
&lt;li&gt;I wasn’t really sure which suppliers of vectorstores and large languge models made the most sense for my use case&lt;&#x2F;li&gt;
&lt;li&gt;I found the documentation really helpful to get started&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;chroma&quot;&gt;Chroma&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;chroma-core&#x2F;chroma&quot;&gt;chroma-core&#x2F;chroma&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;chroma&lt;&#x2F;code&gt; is a vectorstore that has great support from Langchain. There are many others as well but Chroma won out at this stage because:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;I can run &lt;code&gt;chroma&lt;&#x2F;code&gt; as an ‘embedded’ data store, e.g. it runs locally on the users machine&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;chroma&lt;&#x2F;code&gt; was the most often used vectorstore in the Langchain docs for RAG tasks&lt;&#x2F;li&gt;
&lt;li&gt;It was trivially easy to set up to the point at which I was convinced reading the tutorials that they had to have made a mistake&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;gpt4all&quot;&gt;GPT4All&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;nomic-ai&#x2F;gpt4all&quot;&gt;nomic-ai&#x2F;gpt4all&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;gpt4all&lt;&#x2F;code&gt; provides a set of LLM models and embedding engines that are also well supported by Langchain. &lt;code&gt;gpt4all&lt;&#x2F;code&gt; was appealing because:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;It runs locally on ‘normal’ machines&lt;&#x2F;li&gt;
&lt;li&gt;It seems well supported and maintained&lt;&#x2F;li&gt;
&lt;li&gt;It is open about what data it was trained on and what data it will use to train on&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;pygithub&quot;&gt;PyGithub&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;PyGithub&#x2F;PyGithub&quot;&gt;Pygithub&#x2F;PyGithub&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Soon after this I realised that &lt;code&gt;pygithub&lt;&#x2F;code&gt; would be an easy way to go to GitHub to get the information I needed and bring it back into &lt;code&gt;starpilot&lt;&#x2F;code&gt; to load into the vectorstore. I had initially thought I might be able to use the &lt;a href=&quot;https:&#x2F;&#x2F;python.langchain.com&#x2F;docs&#x2F;integrations&#x2F;document_loaders&#x2F;github&quot;&gt;GitHub Document Loader&lt;&#x2F;a&gt; built into &lt;code&gt;langchain&lt;&#x2F;code&gt;, though once I sat down to really work it out I realised that this doesn’t give access to a users stars, so I needed an alternative.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-other-way-to-build&quot;&gt;The other way to build&lt;&#x2F;h2&gt;
&lt;p&gt;There were alternatives in all these choices. I think these are all totally viable parts to build effectively the same system:&lt;&#x2F;p&gt;
&lt;h3 id=&quot;click&quot;&gt;Click&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;pallets&#x2F;click&quot;&gt;pallets&#x2F;click&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I actually am using &lt;code&gt;click&lt;&#x2F;code&gt;, sort of. &lt;code&gt;typer&lt;&#x2F;code&gt; is built ontop of &lt;code&gt;click&lt;&#x2F;code&gt;, but to be honest I didn’t really know that before I’d mostly decided. &lt;code&gt;click&lt;&#x2F;code&gt; looks like a really great project, but it wasn’t &lt;em&gt;as&lt;&#x2F;em&gt; clear how to get started.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;llama-index&quot;&gt;Llama Index&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;run-llama&#x2F;llama_index&quot;&gt;run-llama&#x2F;llama_index&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;llama_index&lt;&#x2F;code&gt; is probably a great project, but I only found it late in my thinking on this project. If I start a different project it’s suitable for any time soon I’m definately going to try it out as a comparison.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;faiss&quot;&gt;Faiss&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;facebookresearch&#x2F;faiss&quot;&gt;facebookresearch&#x2F;faiss&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I’d used &lt;code&gt;faiss&lt;&#x2F;code&gt; in a tutorial on vectorstores before. It didn’t strike me as hugely intuitive to use or as simple to set up (it’s recommended installation path is via conda). I also don’t particularly like Facebook so I’m happy to use an alternative. &lt;&#x2F;p&gt;
&lt;h3 id=&quot;openai&quot;&gt;OpenAI&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;openai&#x2F;openai-python&quot;&gt;openai&#x2F;openai-python&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I’d used &lt;code&gt;openai&lt;&#x2F;code&gt; for a handful of tutorials and notebook experiments already and been very happy with it. However for a project like this I wasn’t really sure what the operational costs would be, and if they would be worth it for the benefit the tool provides. That combined with the requirement to have network connectivity while using the tool pushed me towards experimenting with alternatives. Luckily with &lt;code&gt;langchain&lt;&#x2F;code&gt; I should be able to provide it as an optional backend in the future?&lt;&#x2F;p&gt;
&lt;h2 id=&quot;what-state-is-starpilot-now&quot;&gt;What state is &lt;code&gt;starpilot&lt;&#x2F;code&gt; now?&lt;&#x2F;h2&gt;
&lt;p&gt;“actively developed”, “v0.1.0”, “untested” and “it runs on my machine” are good descriptions of the project right now.&lt;&#x2F;p&gt;
&lt;p&gt;I’ve spent a few evenings this month on it, and see myself at least spending a few more on it next month. The API is getting breaking changes almost everytime I open the project. It’s got 0 real tests. It should get some soon though. It requires a few manual installation steps that are documented in &lt;code&gt;README.md&lt;&#x2F;code&gt; but haven’t yet even been attempted on another machine other than the one I’m on right now.&lt;&#x2F;p&gt;
&lt;p&gt;It also doesn’t yet achieve exactly what I want it to, but I see no reason yet that it can’t with some more development time.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;current-features&quot;&gt;Current features&lt;&#x2F;h3&gt;
&lt;h4 id=&quot;starpilot-read-mycoolusername&quot;&gt;&lt;code&gt;starpilot read MyCoolUserName&lt;&#x2F;code&gt;&lt;&#x2F;h4&gt;
&lt;p&gt;This will connect to Github and read the starred repos of the user &lt;code&gt;MyCoolUserName&lt;&#x2F;code&gt;. Then it will go to each of those repos and get the topics and descriptions (and optionally the readmes) and load these into &lt;code&gt;chroma&lt;&#x2F;code&gt; which is persisted on the local hard drive.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;starpilot-shoot-insert-topic-here&quot;&gt;&lt;code&gt;starpilot shoot &amp;quot;insert topic here&amp;quot;&lt;&#x2F;code&gt;&lt;&#x2F;h4&gt;
&lt;p&gt;This will spin up the &lt;code&gt;chroma&lt;&#x2F;code&gt; database and perform a semantic similarity search on the string given in the command, then return the documents that seem to be the most relevant.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;starpilot-fortuneteller-insert-a-question-here&quot;&gt;&lt;code&gt;starpilot fortuneteller &amp;quot;Insert a question here&amp;quot;&lt;&#x2F;code&gt;&lt;&#x2F;h4&gt;
&lt;p&gt;This will perform the exact same search as the &lt;code&gt;shoot&lt;&#x2F;code&gt; command, but then spin up a large language model and pass the results into the large language model for processing. It then returns the documents it found as well as the response from the LLM&lt;&#x2F;p&gt;
&lt;h2 id=&quot;so&quot;&gt;So….&lt;&#x2F;h2&gt;
&lt;p&gt;That’s where this project is at. I’ve learnt a tonne about the available tools and relevant techniques in this space already, which was really the main goal of starting to begin with!&lt;&#x2F;p&gt;
&lt;p&gt;That said the progress I’ve made so far only makes me more curious about what else can be done with this and what else can be solved towards the vision of “Making your GitHub stars more valuable in your daily coding”. Here’s some ideas that I’ve found exciting while getting my hands dirty that might show up in the future. These are along with the obvious things like any testing at all, a simpler way to set up the project on your machine, better error handling, a more sensible way to update the vectorstore than drop everything and rebuild each time, etc. &lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Inspecting the current projects description (both it’s loose goals as well as more specific things like what packages it already uses) so that things that are already used aren’t suggested and are instead used to inform the response.&lt;&#x2F;li&gt;
&lt;li&gt;Dynamically creating a GitHub list of similar starred repos for your user (though that would probably rely on &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;orgs&#x2F;community&#x2F;discussions&#x2F;8293?sort=new&quot;&gt;this suggestion to extend the GitHub API&lt;&#x2F;a&gt;) so that you naturally have some ways of saving and sharing your starred repos that solve a specific problem between sessions in your terminal&lt;&#x2F;li&gt;
&lt;li&gt;Building starpilot into a research agent that can perform actions such as installing the selected suggestion into the current project or be sent to GitHub to find new projects that solve the current goals that you haven’t starred yet&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;what-do-you-think&quot;&gt;What do you think?&lt;&#x2F;h2&gt;
&lt;p&gt;Does this sound like something intersting to you, maybe even something useful? Did this just spark inspiration in you for a new project? Does this actually already exist somewhere and I’m just being an idiot? Let me know :)&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>My GitHub profile shows my popular DEV.to posts and GitHub repos automatically</title>
        <published>2020-08-05T00:00:00+00:00</published>
        <updated>2020-08-05T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/my-github-profile-shows-my-popular-dev-to-posts-and-github-repos-automatically-2n05/" type="text/html"/>
        <id>https://www.daveparr.info/blog/my-github-profile-shows-my-popular-dev-to-posts-and-github-repos-automatically-2n05/</id>
        
        <content type="html">&lt;p&gt;This is my github profile:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;DaveParr&quot;&gt;DaveParr&#x2F;DaveParr&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;background&quot;&gt;Background&lt;&#x2F;h2&gt;
&lt;p&gt;I made it because I saw this repo by zhiiyang&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;zhiiiyang&#x2F;zhiiiyang&quot;&gt;zhiiiyang&#x2F;zhiiiyang&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Thanks to @mokkapps for this article which uses the twitter updating
action for discovering it.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;mokkapps&#x2F;how-i-built-a-self-updating-readme-on-my-github-profile-418d&quot;&gt;How I built a self updating readme&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;motivation&quot;&gt;Motivation&lt;&#x2F;h2&gt;
&lt;p&gt;It took my a little while to decide what to do with my profile. I wanted
something data driven, and I wanted something to show-off my programming
successes. So I decided to show my most popular repos, and also to show
my most popular dev.to posts! I noticed that zhiiiyang made extensive
use of &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;r-lib&#x2F;actions&quot;&gt;&lt;code&gt;r-lib&#x2F;actions&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;, and I’ve
found that it was really valuable for my project too!&lt;&#x2F;p&gt;
&lt;h2 id=&quot;method&quot;&gt;Method&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;repos&quot;&gt;Repos&lt;&#x2F;h3&gt;
&lt;p&gt;The repos script was where I started. Building from zhiiiyang’s work, I
built a &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;DaveParr&#x2F;blob&#x2F;5c66bd4a2bd970ec7ad85e6de56fedcc75fbf74f&#x2F;.github&#x2F;workflows&#x2F;main.yml&quot;&gt;GitHub
workflow&lt;&#x2F;a&gt;
to call a script I had written.&lt;&#x2F;p&gt;
&lt;p&gt;The &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;DaveParr&#x2F;blob&#x2F;5c66bd4a2bd970ec7ad85e6de56fedcc75fbf74f&#x2F;repos.R&quot;&gt;script was quite
simple&lt;&#x2F;a&gt;.
It gets my repos from the GitHub API through the
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;r-lib&#x2F;gh&quot;&gt;&lt;code&gt;gh&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; package, and tidies the return using
&lt;code&gt;hoist&lt;&#x2F;code&gt; to grab the important bits. It then filters and pivots the data
into a simple plot.&lt;&#x2F;p&gt;
&lt;p&gt;The most interesting part was where zhiiiyang added the output as a
commit by the action itself. The authentication for the action is
actually allowed by this section:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;yaml&quot; class=&quot;language-yaml z-code&quot;&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;z-source z-yaml&quot;&gt;&lt;span class=&quot;z-string z-unquoted z-plain z-out z-yaml&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-yaml&quot;&gt;env&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-mapping z-yaml&quot;&gt;:&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-string z-unquoted z-plain z-out z-yaml&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-yaml&quot;&gt;GITHUB_PAT&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-mapping z-yaml&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-unquoted z-plain z-out z-yaml&quot;&gt;${{ secrets.GITHUB_TOKEN }}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I did stumble a little over the correct path to the plot image. It turns
out that you can use the relative location (&lt;code&gt;.&#x2F;graph.png&lt;&#x2F;code&gt;) which will
work if you are viewing the README from &lt;em&gt;within&lt;&#x2F;em&gt; the repo, but to make
it work when the README is displayed from my &lt;em&gt;user&lt;&#x2F;em&gt; page you have to use
the absolute path
(&lt;code&gt;https:&#x2F;&#x2F;github.com&#x2F;daveparr&#x2F;daveparr&#x2F;blob&#x2F;main&#x2F;graph.png&lt;&#x2F;code&gt;).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;posts&quot;&gt;Posts&lt;&#x2F;h3&gt;
&lt;p&gt;The posts was actually pretty easy once I’d got used to how GitHub
Action operate, and also how the GitHub &lt;code&gt;README&lt;&#x2F;code&gt; profiles worked.&lt;&#x2F;p&gt;
&lt;p&gt;The key part was actually a feature I recently developed for my own
package.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;dev.to.ol&quot;&gt;DaveParr&#x2F;dev.to.ol&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;dev.to.ol&lt;&#x2F;code&gt; is a package to help R users manage their dev.to content. In
particular I had recently finished the functions that return data from
the API about your published articles. The key to this is to have the
DEV.TO api key that you want to use set as an encrypted secret in the
repo. once that is set, my package can read it if it’s set as an
environmental variable along with the &lt;code&gt;GITHUB_PAT&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;yaml&quot; class=&quot;language-yaml z-code&quot;&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;z-source z-yaml&quot;&gt;&lt;span class=&quot;z-string z-unquoted z-plain z-out z-yaml&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-yaml&quot;&gt;env&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-mapping z-yaml&quot;&gt;:&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-string z-unquoted z-plain z-out z-yaml&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-yaml&quot;&gt;DEVTO&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-mapping z-yaml&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-unquoted z-plain z-out z-yaml&quot;&gt;${{ secrets.DEVTO }}&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-string z-unquoted z-plain z-out z-yaml&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-yaml&quot;&gt;GITHUB_PAT&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value z-mapping z-yaml&quot;&gt;:&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-unquoted z-plain z-out z-yaml&quot;&gt;${{ secrets.GITHUB_TOKEN }}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Because my package returns a tidy data.frame like object, it was trivial
to munge it down to just what I wanted to show, and then format it
neatly with &lt;code&gt;knitr&lt;&#x2F;code&gt;. I also went all in on the &lt;code&gt;r-lib&#x2F;actions&lt;&#x2F;code&gt; examples,
and now not only generate the new data for both the chart and blogs
during the GitHub action, but also do the full compile from &lt;code&gt;.Rmd&lt;&#x2F;code&gt; to
&lt;code&gt;.md&lt;&#x2F;code&gt; using the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;DaveParr&#x2F;blob&#x2F;1f0d043ead21077879e4ba8bb282d66f9a6e1cb3&#x2F;.github&#x2F;workflows&#x2F;main.yml#L18&quot;&gt;&lt;code&gt;setup-pandoc&lt;&#x2F;code&gt;
action&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;lessons-in-automation&quot;&gt;Lessons in automation&lt;&#x2F;h2&gt;
&lt;p&gt;I’d been meaning to explore GitHub Actions for a little while, and I
found a few things out that I’m going to be considering in the future as
I develop this an other projects.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;pricing-vs-performance-on-macos-and-linux&quot;&gt;Pricing vs performance on macOS and Linux&lt;&#x2F;h3&gt;
&lt;p&gt;It’s free to a point, and then you need to pay. I had a look at the
&lt;a href=&quot;https:&#x2F;&#x2F;docs.github.com&#x2F;en&#x2F;github&#x2F;setting-up-and-managing-billing-and-payments-on-github&#x2F;about-billing-for-github-actions&quot;&gt;pricing
plan&lt;&#x2F;a&gt;
and noticed that your runtime impacts your pricing. Most of the examples
from &lt;code&gt;r-lib&#x2F;actions&lt;&#x2F;code&gt; run from macos-latest, as does zhiiiyang’s project.
In GitHub Actions pricing a minute of macOS runtime is worth &lt;em&gt;10
minutes&lt;&#x2F;em&gt; of linux runtime. I ran on macOS for a while too, but
eventually thought that it might be a smart idea for a long running
personal project to convert to a linux run time, though now I’ve done it
I’m debating going back to mac.&lt;&#x2F;p&gt;
&lt;p&gt;The ‘problem’ is that I did not write this process to be fast, or light.
It’s a silly hobby project to over-automate because I can. Therefore, on
Linux I am now actually &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;DaveParr&#x2F;blob&#x2F;1f0d043ead21077879e4ba8bb282d66f9a6e1cb3&#x2F;.github&#x2F;workflows&#x2F;main.yml#L21-L29&quot;&gt;compiling the packages on each installation
&lt;em&gt;AND&lt;&#x2F;em&gt; installing libcurl for the api
calls&lt;&#x2F;a&gt;.
The cost savings I make from not picking the faster run time in this
case are approximately negated by the increase in actual run time. By
eye, that part of the job runs at about 10 minutes now, where as on mac
it was about 10 times faster as the pre-compiled binaries could just be
downloaded and would run ‘out of the box’. I’ll probably change it back
in a little while after I’ve checked how variable it can be.&lt;&#x2F;p&gt;
&lt;p&gt;Potential solutions could include some form of caching (which I’ve heard
is maybe supported?) or running the action in my own docker image with
the pre-compiled, though TBH that sounds like work, and this is supposed
to be fun :P&lt;&#x2F;p&gt;
&lt;h3 id=&quot;r-lib-actions-for-the-rmd&quot;&gt;r-lib actions for the Rmd&lt;&#x2F;h3&gt;
&lt;p&gt;I really like the idea of compiling the &lt;code&gt;README.md&lt;&#x2F;code&gt; for a package from
the &lt;code&gt;README.Rmd&lt;&#x2F;code&gt; we often use in R. I’ve often forgotten in my own work
to do that key step before a push, and having a relatively simple
automation backed into where my repos live will likely be something I
use in the future. The best part of this trick is that &lt;code&gt;r-libs&#x2F;actions&lt;&#x2F;code&gt;
does the most irritating part of ‘making Pandoc work’ for me. So I can
just profit!&lt;&#x2F;p&gt;
&lt;h2 id=&quot;successs&quot;&gt;Successs!&lt;&#x2F;h2&gt;
&lt;p&gt;I really liked hacking this out. I got to put my &lt;code&gt;dev.to.ol&lt;&#x2F;code&gt; package to
another practical lesson and learn about GitHub Actions. Feel free to
re-create this on your profiles, either by grabbing bits or by just
lifting the whole thing. One of the reasons I built it the way I did is
so it could be relatively portable between users, and maybe solve a
problem for more than just me. So if you get this deployed on your
profile, or get stuck, I’d love to hear from you!&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>How to calculate a Pokemons &#x27;power level&#x27; using kmeans</title>
        <published>2020-07-17T00:00:00+00:00</published>
        <updated>2020-07-17T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/how-to-calculate-a-pokemons-power-level-using-kmeans-4m8g/" type="text/html"/>
        <id>https://www.daveparr.info/blog/how-to-calculate-a-pokemons-power-level-using-kmeans-4m8g/</id>
        
        <content type="html">&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;pokedex&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;tidyverse&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;tidymodels&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;showtext&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;font_add_google&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Press Start 2P&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;showtext_auto&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;theme_set&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;theme_pokedex&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

knitr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;opts_chunk&lt;span class=&quot;z-keyword z-accessor z-dollar z-r&quot;&gt;$&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;set&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;fig.showtext&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-language z-r&quot;&gt;TRUE&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;the-heros-journey&quot;&gt;The Heros Journey&lt;&#x2F;h2&gt;
&lt;p&gt;Pokemon games have a very familiar cycle. You start with one of 3
Pokemon. You adventure out with your new buddy, facing tougher and
tougher Pokemon, in greater variety. Many of your Pokemon evolve over
time, and eventually you find the end-game legendaries in a climactic
battle of titans!&lt;&#x2F;p&gt;
&lt;p&gt;You can even see this story in the data. Here is the &lt;code&gt;base_experience&lt;&#x2F;code&gt;
of all the Pokemon, identified by game generation. The &lt;code&gt;base_experience&lt;&#x2F;code&gt;
is the basic amount of experience that is gained by the winner of a
battle from a specific species. e.g. If you &lt;em&gt;beat&lt;&#x2F;em&gt; a Bulbasaur, your
Pokemon &lt;em&gt;gains&lt;&#x2F;em&gt; experience based on a formula which uses Bulbasaurs
&lt;code&gt;base_experience&lt;&#x2F;code&gt;. Because of that we can see it as a proxy value for
how &lt;em&gt;powerful&lt;&#x2F;em&gt; a Pokemon is. If it’s more powerful, it will be harder to
beat, and so reward you with more experience when you win.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; base_experience&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;colour&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; generation_id&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_point&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Base Experience for each Pokemon&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;DaveParr&#x2F;dev.to-posts&#x2F;master&#x2F;pokemon-power-levels_files&#x2F;figure-gfm&#x2F;plot%20base%20experience-1.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;In each generation you can see a few attributes:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;power level - 3(ish) tiers, grouped in different vertical lanes&lt;&#x2F;li&gt;
&lt;li&gt;progression - a (generally) increasing trend in the base power value&lt;&#x2F;li&gt;
&lt;li&gt;the up-ticks at the start and the end of each gen are the starters
top-tier evolution (Woo Blastoise!) and the Legendaries at the
end-game&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Lets see if we can group each Pokemon into a &lt;code&gt;power_level&lt;&#x2F;code&gt;. A
categorical grouping which relates it to other Pokemon with similar
&lt;code&gt;base_experience&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;grouping-and-counting&quot;&gt;Grouping and counting&lt;&#x2F;h2&gt;
&lt;p&gt;Maybe we can explicitly describe the power levels of each tier of
Pokemon with a simple process? Can we group each Pokemon by evolutionary
chain, and then count each Pokemons order within the group?&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;group_by&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;evolution_chain_id&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;power_level&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;row_number&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; pokemon_group_count

&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;pokemon_group_count&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; base_experience&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;colour&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;as_factor&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;power_level&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_point&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Power level by group count&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;colour&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;power_level&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;DaveParr&#x2F;dev.to-posts&#x2F;master&#x2F;pokemon-power-levels_files&#x2F;figure-gfm&#x2F;plot%20by%20group%20count-1.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Sort of? Generally we capture the pattern, but we don’t actually get it
very right. First off, there are more than 3 evolutionary tiers in our
engineered feature. We can also see there are some Pokemon are
classified as a &lt;code&gt;power_level&lt;&#x2F;code&gt; higher than 1, but still in the lowest
group on this list. Why might have caused this?&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon_group_count &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;power_level &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;3&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;pull&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;evolution_chain_id&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; pokemon_group_count_mistakes

pokemon_group_count &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;evolution_chain_id &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%in%&lt;&#x2F;span&gt; pokemon_group_count_mistakes&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
         name&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
         base_experience&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
         generation_id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
         evolution_chain_id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
         power_level&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;  &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;arrange&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;evolution_chain_id&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; name&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; base_experience&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; evolution_chain_id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; power_level&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  knitr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: right&quot;&gt;id&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;name&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;base_experience&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;evolution_chain_id&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;power_level&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;43&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Oddish&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;64&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;18&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;44&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Gloom&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;138&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;18&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;45&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Vileplume&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;221&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;18&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;182&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Bellossom&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;221&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;18&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;60&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Poliwag&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;60&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;26&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;61&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Poliwhirl&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;135&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;26&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;62&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Poliwrath&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;230&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;26&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;186&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Politoed&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;225&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;26&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;106&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Hitmonlee&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;159&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;47&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;107&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Hitmonchan&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;159&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;47&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;236&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Tyrogue&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;42&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;47&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;237&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Hitmontop&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;159&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;47&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;133&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Eevee&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;65&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;67&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;134&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Vaporeon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;184&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;67&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;135&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Jolteon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;184&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;67&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;136&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Flareon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;184&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;67&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;196&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Espeon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;184&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;67&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;197&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Umbreon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;184&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;67&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;6&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;470&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Leafeon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;184&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;67&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;7&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;471&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Glaceon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;184&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;67&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;8&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;700&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Sylveon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;184&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;67&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;9&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;265&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Wurmple&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;56&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;135&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;266&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Silcoon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;72&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;135&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;267&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Beautifly&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;178&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;135&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;268&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Cascoon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;72&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;135&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;269&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dustox&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;173&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;135&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;280&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Ralts&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;40&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;140&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;281&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Kirlia&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;97&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;140&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;282&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Gardevoir&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;233&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;140&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;475&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Gallade&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;233&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;140&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;789&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Cosmog&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;40&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;413&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;790&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Cosmoem&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;140&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;413&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;791&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Solgaleo&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;306&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;413&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;792&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Lunala&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;306&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;413&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;So there are some clear problems with this approach. In Gen 1 we had
some branching evolution with the Eevee family. Not only was this family
expanded in multiple generations to eventually 8 variations, but we also
saw more branching evolution trees as well. We also got ‘baby’ Pokemon.
Pokemon that are actually pre-cursors to other Pokemon, but are listed
later in the Pokedex.&lt;&#x2F;p&gt;
&lt;p&gt;Luckily there is another variable we can use, that should be a whole lot
better.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;evolves-from-species&quot;&gt;&lt;code&gt;evolves_from_species&lt;&#x2F;code&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Each Pokemon that evolves from another Pokemon has the Pokemon they
evolve froms &lt;code&gt;id&lt;&#x2F;code&gt; as the value in the &lt;code&gt;evolves_from_species_id&lt;&#x2F;code&gt;
variable. Maybe we can use that to break up the Pokemon into their
‘power levels’.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;The following code is not my best work, however I spent some time on a more recursive strategy, but it was honestly miles more confusing. For the purposes of a silly example for a blog, I think this is prefferable.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;power_level&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;case_when&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;is.na&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;evolves_from_species_id&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;power_level &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; pokemon_1

pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;power_level&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;case_when&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;evolves_from_species_id &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%in%&lt;&#x2F;span&gt; pokemon_1&lt;span class=&quot;z-keyword z-accessor z-dollar z-r&quot;&gt;$&lt;&#x2F;span&gt;id &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;power_level &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; pokemon_2

pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;power_level&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;case_when&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;evolves_from_species_id &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%in%&lt;&#x2F;span&gt; pokemon_2&lt;span class=&quot;z-keyword z-accessor z-dollar z-r&quot;&gt;$&lt;&#x2F;span&gt;id &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;3&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;power_level &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;3&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; pokemon_3

&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;bind_rows&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;pokemon_1&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; pokemon_2&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; pokemon_3&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;arrange&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;id&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;power_level&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;as_factor&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;power_level&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; pokemon_evolves_from

pokemon_evolves_from &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; base_experience&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;colour&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; power_level&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_point&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Power level by evolves_from&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;DaveParr&#x2F;dev.to-posts&#x2F;master&#x2F;pokemon-power-levels_files&#x2F;figure-gfm&#x2F;plot%20by%20evolves_from-1.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Hmm, that’s actually worse? Lets focus on the Pokemon labelled
&lt;code&gt;power_level&lt;&#x2F;code&gt; 1, but are up where we would expect level 3 Pokemon to be.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon_evolves_from &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;base_experience &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;200&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;amp;&lt;&#x2F;span&gt; power_level &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; name&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; base_experience&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  knitr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: right&quot;&gt;id&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;name&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;base_experience&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;144&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Articuno&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;145&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Zapdos&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;146&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Moltres&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;150&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Mewtwo&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;306&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;151&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Mew&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;243&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Raikou&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;244&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Entei&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;245&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Suicune&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;249&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Lugia&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;306&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;250&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Ho-Oh&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;306&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;251&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Celebi&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;377&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Regirock&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;378&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Regice&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;379&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Registeel&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;380&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Latias&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;381&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Latios&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;382&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Kyogre&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;302&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;383&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Groudon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;302&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;384&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Rayquaza&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;306&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;385&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Jirachi&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;386&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Deoxys&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;480&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Uxie&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;481&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Mesprit&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;482&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Azelf&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;483&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dialga&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;306&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;484&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Palkia&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;306&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;485&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Heatran&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;486&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Regigigas&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;302&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;487&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Giratina&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;306&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;488&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Cresselia&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;489&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Phione&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;216&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;490&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Manaphy&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;491&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Darkrai&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;492&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Shaymin&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;493&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Arceus&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;324&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;494&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Victini&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;531&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Audino&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;390&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;638&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Cobalion&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;639&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Terrakion&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;640&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Virizion&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;641&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Tornadus&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;642&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Thundurus&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;643&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Reshiram&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;306&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;644&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Zekrom&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;306&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;645&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Landorus&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;646&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Kyurem&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;297&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;647&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Keldeo&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;261&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;648&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Meloetta&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;649&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Genesect&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;716&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Xerneas&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;306&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;717&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Yveltal&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;306&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;718&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Zygarde&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;719&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Diancie&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;720&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Hoopa&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;721&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Volcanion&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;785&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Tapu Koko&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;257&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;786&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Tapu Lele&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;257&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;787&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Tapu Bulu&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;257&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;788&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Tapu Fini&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;257&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;793&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Nihilego&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;257&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;794&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Buzzwole&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;257&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;795&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Pheromosa&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;257&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;796&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Xurkitree&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;257&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;797&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Celesteela&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;257&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;798&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Kartana&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;257&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;799&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Guzzlord&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;257&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;800&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Necrozma&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;801&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Magearna&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;802&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Marshadow&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;805&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Stakataka&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;257&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;806&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Blacephalon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;257&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;807&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Zeraora&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;270&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;So these Pokemon are nearly all ‘Legendary’. They are big end-game
Pokemon, with real rarity in game. They also don’t evolve from, or to,
anything, so our rule doesn’t classify them effectively.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon_evolves_from &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;base_experience &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;lt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;200&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;amp;&lt;&#x2F;span&gt; base_experience &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;100&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;amp;&lt;&#x2F;span&gt; power_level &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; name&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; base_experience&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  knitr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: right&quot;&gt;id&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;name&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;base_experience&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;83&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Farfetch’d&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;132&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;115&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Kangaskhan&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;172&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;127&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Pinsir&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;175&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;128&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Tauros&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;172&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;131&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Lapras&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;187&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;132&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Ditto&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;101&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;142&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Aerodactyl&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;180&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;201&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Unown&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;118&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;203&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Girafarig&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;159&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;206&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dunsparce&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;145&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;213&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Shuckle&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;177&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;214&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Heracross&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;175&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;222&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Corsola&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;144&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;225&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Delibird&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;116&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;227&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Skarmory&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;163&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;234&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Stantler&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;163&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;241&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Miltank&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;172&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;302&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Sableye&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;133&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;303&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Mawile&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;133&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;311&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Plusle&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;142&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;312&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Minun&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;142&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;313&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Volbeat&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;151&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;314&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Illumise&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;151&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;324&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Torkoal&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;165&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;327&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Spinda&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;126&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;335&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Zangoose&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;160&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;336&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Seviper&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;160&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;337&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Lunatone&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;161&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;338&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Solrock&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;161&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;351&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Castform&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;147&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;352&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Kecleon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;154&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;357&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Tropius&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;161&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;359&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Absol&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;163&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;369&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Relicanth&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;170&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;370&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Luvdisc&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;116&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;417&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Pachirisu&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;142&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;440&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Happiny&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;110&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;441&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Chatot&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;144&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;442&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Spiritomb&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;170&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;455&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Carnivine&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;159&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;479&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Rotom&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;154&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;538&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Throh&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;163&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;539&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Sawk&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;163&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;550&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basculin&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;161&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;556&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Maractus&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;161&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;561&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Sigilyph&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;172&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;587&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Emolga&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;150&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;594&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Alomomola&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;165&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;615&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Cryogonal&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;180&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;618&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Stunfisk&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;165&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;621&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Druddigon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;170&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;626&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Bouffalant&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;172&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;631&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Heatmor&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;169&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;632&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Durant&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;169&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;676&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Furfrou&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;165&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;701&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Hawlucha&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;175&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;702&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dedenne&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;151&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;707&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Klefki&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;165&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;741&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Oricorio&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;167&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;764&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Comfey&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;170&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;765&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Oranguru&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;172&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;766&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Passimian&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;172&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;771&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Pyukumuku&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;144&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;772&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Type: Null&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;107&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;774&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Minior&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;154&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;775&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Komala&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;168&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;776&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Turtonator&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;170&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;777&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Togedemaru&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;152&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;778&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Mimikyu&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;167&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;779&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Bruxish&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;166&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;780&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Drampa&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;170&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;781&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dhelmise&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;181&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;803&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Poipole&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;189&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;These Pokemon are not end game, but they either have very short
evolution trees (2 Pokemon long), or no evolution tree at all.&lt;&#x2F;p&gt;
&lt;p&gt;So our ‘group count’ process doesn’t work well, and neither does our
‘&lt;code&gt;evolves_from_species&lt;&#x2F;code&gt;’ process. We’re going to have to to learn some
new moves.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;tm01-e-g-tidy-models-01&quot;&gt;TM01 (e.g. Tidy Models 01)&lt;&#x2F;h2&gt;
&lt;p&gt;Clustering is the process of using machine learning to derive a
categorical variable from data. The simplest form of clustering that
seems relevant to our problem is k-means. Seeing as we have a pretty
good intuition that 3 groups &lt;em&gt;implicitly&lt;&#x2F;em&gt; exist in this data, and a
clear &lt;em&gt;visualisation&lt;&#x2F;em&gt; supporting us, lets cut straight to asking R for 3
groups. k-means clustering aims to divide the data into a &lt;em&gt;known&lt;&#x2F;em&gt; number
of groups which is set in the &lt;code&gt;centers&lt;&#x2F;code&gt; argument, and doesn’t require
any data to be fed to it as examples of what makes up a ‘group’. That
sentence might be a little confusing, as we do obviously give it some
data. What we &lt;em&gt;don’t&lt;&#x2F;em&gt; give it is a training data set which has examples
of what Pokemon are supposed to be in a given group, labelled with the
group they are supposed to be in, e.g. Squirtle is in group 1, Wartortle
is in group 2, Blastoise is in group 3, and then give it unlabelled data
to classify, e.g. “What group is Charmeleon in?”. k-means will &lt;em&gt;figure
out&lt;&#x2F;em&gt; how to split the continuous variable &lt;code&gt;base_experience&lt;&#x2F;code&gt; into 3
groups.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;set.seed&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;68&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;base_experience&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;  &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;kmeans&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;centers&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;3&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;augment&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;pokemon&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; pokemon_cluster
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;how-kmeans-works&quot;&gt;How kmeans works&lt;&#x2F;h3&gt;
&lt;p&gt;First, we set centroids to be at random positions in the data. To make
sure this doesn’t effect consistency in my article I’ve used &lt;code&gt;set.seed&lt;&#x2F;code&gt;
so k-means starts looking for the centres of our clusters from the same
position each time. A ‘centroid’ can be seen as a ‘centre point’ for
each cluster. We have the same number of centroids set as the value set
in the &lt;code&gt;centers&lt;&#x2F;code&gt; argument. Each data point is then assigned to it’s
closest centroid.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;The Sum of Squared Errors (SSE) from the centroids is then used as an
&lt;em&gt;objective function&lt;&#x2F;em&gt; towards a &lt;em&gt;local minimum&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;This is the core concept of how k-means calculates a solution. The Sum
of Squared Errors are calculated like this:&lt;&#x2F;p&gt;
&lt;p&gt;{% katex %}
\sum^n_{i-1}(x_i-\bar{x})^2
{% endkatex %}&lt;&#x2F;p&gt;
&lt;p&gt;What this means is for each group, the distance from the centroid to
each observation is measured, and then squared. Then each of those
squared distances, one per observation in the group, is totalled.&lt;&#x2F;p&gt;
&lt;p&gt;The centroid is then moved to the &lt;em&gt;average&lt;&#x2F;em&gt; value of it’s group. Because
the centroids are now no longer in the same position as when the SSE was
calculated, the SSE is now recalculated for all observations, to each of
the &lt;em&gt;new&lt;&#x2F;em&gt; centroid positions. This means that some observations are now
closer to a &lt;em&gt;different&lt;&#x2F;em&gt; centroid, and so get assigned to a &lt;em&gt;different&lt;&#x2F;em&gt;
cluster.&lt;&#x2F;p&gt;
&lt;p&gt;Then the centroids are moved &lt;em&gt;again&lt;&#x2F;em&gt; to the &lt;em&gt;new&lt;&#x2F;em&gt; average of the &lt;em&gt;new&lt;&#x2F;em&gt;
cluster. Each cluster then gets &lt;em&gt;new distances&lt;&#x2F;em&gt; calculated. This will go
on until termination when, each centroid is in the average position of
the cluster, and each observation in the cluster is closest to the
&lt;em&gt;centroid&lt;&#x2F;em&gt; it is currently assigned to.&lt;&#x2F;p&gt;
&lt;p&gt;That’s a slightly wordy description of a complicated process. I
recommend that you have a look at the &lt;a href=&quot;https:&#x2F;&#x2F;www.tidymodels.org&#x2F;learn&#x2F;statistics&#x2F;k-means&#x2F;&quot;&gt;k-means explanation in tidy
models&lt;&#x2F;a&gt; to really
cement the concept. It also contains &lt;em&gt;the most adorable animation of a
statistical concept in existance&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;how-to-use-it&quot;&gt;How to use it&lt;&#x2F;h3&gt;
&lt;p&gt;Here, I’ve simply selected the one column of data, &lt;code&gt;base_experience&lt;&#x2F;code&gt;,
and piped it into &lt;code&gt;kmeans&lt;&#x2F;code&gt;, which is part of base R. This returns a
super un-tidy list like object of class &lt;code&gt;&amp;quot;kmeans&amp;quot;&lt;&#x2F;code&gt;, however, with
&lt;code&gt;tidymodels&lt;&#x2F;code&gt; we can easily make it usable.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;augment&lt;&#x2F;code&gt; helps us to match the output of the &lt;code&gt;kmeans&lt;&#x2F;code&gt; function back to
our data for easier processing. The output of &lt;code&gt;kmeans&lt;&#x2F;code&gt; doesn’t actually
contain any of the other information about our data, it only got given
one column remember? &lt;code&gt;augment&lt;&#x2F;code&gt; goes through the return of &lt;code&gt;kmeans&lt;&#x2F;code&gt;,
finds the relevant bit, and matches it neatly back to our original data
ready for plotting in one step!&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon_cluster &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; base_experience&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;colour&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; .cluster&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_point&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Power level by kmeans clustering&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;DaveParr&#x2F;dev.to-posts&#x2F;master&#x2F;pokemon-power-levels_files&#x2F;figure-gfm&#x2F;plot%20cluster-1.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;This is a &lt;em&gt;lot&lt;&#x2F;em&gt; better. It gives us really clear groups, in exactly
where we expected them. It’s also tonnes simpler code!&lt;&#x2F;p&gt;
&lt;p&gt;Lets check some of our boundary positions, just to make sure it makes
sense.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon_cluster &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;.cluster &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;1&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;amp;&lt;&#x2F;span&gt; base_experience &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;100&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; name&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; base_experience&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  knitr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: right&quot;&gt;id&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;name&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;base_experience&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;132&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Ditto&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;101&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;440&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Happiny&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;110&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;699&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Aurorus&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;104&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;762&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Steenee&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;102&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;772&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Type: Null&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;107&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon_cluster &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;.cluster &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;2&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;amp;&lt;&#x2F;span&gt; base_experience &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;200&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; name&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; base_experience&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  knitr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: right&quot;&gt;id&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;name&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;base_experience&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;189&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Jumpluff&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;207&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;Ditto and Type: Null are just a plain weird Pokemon due to their
abilities messing with their type. Happiny is a baby type, but from a
family with an &lt;em&gt;insane&lt;&#x2F;em&gt; base_experience. Jumpluff is an awkward edge
case. Technically the 3rd evolution, it’s still got an &lt;em&gt;extremely&lt;&#x2F;em&gt; low
base_experience. Potentially this is for game balancing as they are
relatively regularly encountered? Aurorus and Steenee I do not have a
good hypothesis for.&lt;&#x2F;p&gt;
&lt;p&gt;Generally I think that this is a pretty good solution. There are maybe a
few edge cases that are open to interpretation, but that’s just what we
get sometimes with machine learning. Lacking a labelled training data
set, we can’t compute a confusion matrix or ROC-curve.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;&#x2F;h2&gt;
&lt;p&gt;We’ve found a situation in the ‘real’ world where we know from context
there is a categorical relationship, but from the data available it’s
not possible to classify that precisely. However we can create this
categorisation using machine learning! Even better, we can use the
&lt;code&gt;tidymodels&lt;&#x2F;code&gt; package to help us do it quickly and cleanly.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>The Missingno Experiment and Multiple Form Pokemon</title>
        <published>2020-07-01T00:00:00+00:00</published>
        <updated>2020-07-01T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/the-missingno-experiment-and-multiple-form-pokemon-26ga/" type="text/html"/>
        <id>https://www.daveparr.info/blog/the-missingno-experiment-and-multiple-form-pokemon-26ga/</id>
        
        <content type="html">&lt;h2 id=&quot;wild-missingno-appeared&quot;&gt;Wild missingno appeared!&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;media2.giphy.com&#x2F;media&#x2F;G7rSYPWEeTjY4&#x2F;giphy.gif?cid=ecf05e47f8faf1991ba53b479305d68e25326d15db3d6769%5Cu0026rid=giphy.gif&quot; alt=&quot;Battle entry animation of a ‘wild missingno appeared’ from pokemon red&#x2F;blue&quot; &#x2F;&gt;
Missingno is the patron Pokemon of data science. You’re just casually
surfing up and down your data, doing some sweet coding, when suddenly a
bunch of missing and corrupted data gets in you way, and you suddenly
have a bunch of random items in your bag for no reason. OK, well maybe I
just have a messy bag.&lt;&#x2F;p&gt;
&lt;p&gt;The valuable part of this metaphor is the part where you battle
Missingno, and win. I’ve been doing this with my Pokedex project
recently, to try and iron out what data I can rely on from my data
source, and what’s a bit patchy.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;pokedex&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;tidyverse&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;naniar&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;skimr&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;go-skimr&quot;&gt;Go, Skimr!&lt;&#x2F;h2&gt;
&lt;p&gt;Skimr gives us a text based summary view. As well as the basics on data
set size, it also shows us some statistical values, but most valuably it
describes how many values are missing, and in what columns.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  skimr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;skim&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: left&quot;&gt;&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Name&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Piped data&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Number of rows&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;807&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Number of columns&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;24&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;_______________________&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Column type frequency:&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;character&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;8&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;list&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;1&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;numeric&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;15&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;________________________&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Group variables&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;None&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;Data summary&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Variable type: character&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: left&quot;&gt;skim_variable&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;n_missing&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;complete_rate&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;min&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;max&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;empty&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;n_unique&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;whitespace&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;identifier&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;20&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;807&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;type_1&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;8&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;18&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;type_2&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;402&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.50&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;8&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;18&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;name&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;12&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;807&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;genus&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;11&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;21&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;589&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;color&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;20&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.98&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;6&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;10&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;shape&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;20&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.98&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;9&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;14&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;habitat&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;422&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.48&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;13&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;9&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;&lt;strong&gt;Variable type: list&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: left&quot;&gt;skim_variable&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;n_missing&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;complete_rate&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;n_unique&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;min_length&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;max_length&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;flavour_text&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;807&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;&lt;strong&gt;Variable type: numeric&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: left&quot;&gt;skim_variable&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;n_missing&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;complete_rate&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;mean&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;sd&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;p0&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;p25&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;p50&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;p75&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;p100&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;hist&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;id&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;404.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;233.11&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;202.5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;404&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;605.5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;807.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▇▇▇▇▇&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;species_id&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;404.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;233.11&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;202.5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;404&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;605.5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;807.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▇▇▇▇▇&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;height&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.16&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.08&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.1&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.6&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;14.5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▇▁▁▁▁&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;weight&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;61.77&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;111.52&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.1&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;9.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;27&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;63.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;999.9&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▇▁▁▁▁&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;base_experience&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;144.85&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;74.95&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;36.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;66.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;151&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;179.5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;608.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▇▇▁▁▁&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;is_default&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▁▁▇▁▁&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;hp&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;68.75&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;26.03&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;50.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;65&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;80.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;255.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▃▇▁▁▁&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;attack&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;76.09&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;29.54&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;55.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;75&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;95.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;181.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▂▇▆▂▁&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;defense&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;71.73&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;29.73&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;50.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;67&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;89.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;230.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▅▇▂▁▁&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;special_attack&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;69.49&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;29.44&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;10.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;45.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;65&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;90.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;173.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▃▇▅▂▁&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;special_defense&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;70.01&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;27.29&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;20.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;50.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;65&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;85.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;230.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▇▇▂▁▁&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;speed&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.00&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;65.83&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;27.74&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;45.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;65&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;85.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;160.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▃▇▆▂▁&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;generation_id&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;20&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.98&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3.67&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.94&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;2.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;7.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▇▅▃▅▅&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;evolves_from_species_id&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;426&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.47&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;364.35&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;232.43&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;156.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;345&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;570.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;803.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▇▆▅▆▅&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;evolution_chain_id&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;20&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.98&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;195.96&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;124.57&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;84.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;187&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;303.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;427.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;▇▆▅▆▅&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;I was expecting some missing data in &lt;code&gt;type_2&lt;&#x2F;code&gt;, and
&lt;code&gt;evolves_from_species_id&lt;&#x2F;code&gt;, but I wasn’t expecting only half of &lt;code&gt;habitat&lt;&#x2F;code&gt;
to be there. Either I broke something in my data pipeline, or the data
wasn’t there to begin with. &lt;code&gt;colour&lt;&#x2F;code&gt;, &lt;code&gt;shape&lt;&#x2F;code&gt;, &lt;code&gt;generation_id&lt;&#x2F;code&gt; and
&lt;code&gt;evolution_chain_id&lt;&#x2F;code&gt; are all missing 20 entries each, which is a bit or
a coincidence. I wonder if they are all missing from the same Pokemon?&lt;&#x2F;p&gt;
&lt;h2 id=&quot;visdat-i-choose-you&quot;&gt;Visdat I choose you!&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;code&gt;visdat&lt;&#x2F;code&gt; is a package that helps you visualise missing data and data
types.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;visdat&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;vis_dat&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;pokemon&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;DaveParr&#x2F;dev.to-posts&#x2F;master&#x2F;missingno-experiment_files&#x2F;figure-gfm&#x2F;visdat-1.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;This clearly shows us the data types in each column, and where values
are missing in context. It looks like habitat might just not be
available after a certain time. It also looks like &lt;code&gt;colour&lt;&#x2F;code&gt;, &lt;code&gt;shape&lt;&#x2F;code&gt;,
&lt;code&gt;generation_id&lt;&#x2F;code&gt; and &lt;code&gt;evolution_chain_id&lt;&#x2F;code&gt; looks like they are maybe all
missing from the same individual Pokemon?&lt;&#x2F;p&gt;
&lt;h2 id=&quot;go-naniar&quot;&gt;Go, Naniar!&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;code&gt;Naniar&lt;&#x2F;code&gt; helps us check through plots where relationships between
missing values and other variables might occur. Lets check first if
there is a relationship between &lt;code&gt;generation_id&lt;&#x2F;code&gt; and &lt;code&gt;evolution_chain_id&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;generation_id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; evolution_chain_id&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_miss_point&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;DaveParr&#x2F;dev.to-posts&#x2F;master&#x2F;missingno-experiment_files&#x2F;figure-gfm&#x2F;naniar_missing_all-1.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;This plot might need a little explanation. For the &lt;code&gt;Not Missing&lt;&#x2F;code&gt; blue
values, this is a normal &lt;code&gt;geom_point()&lt;&#x2F;code&gt;. However, where the values are
marked as &lt;code&gt;Missing&lt;&#x2F;code&gt; pink they are deliberately moved below the &lt;code&gt;(0,0)&lt;&#x2F;code&gt;
mark for the &lt;em&gt;axis they are missing values for&lt;&#x2F;em&gt;, then they ‘jitter’, to
avoid over-plotting. The little cluster at the far bottom left in a line
marks that for &lt;em&gt;all&lt;&#x2F;em&gt; values where &lt;code&gt;evolution_chain_id&lt;&#x2F;code&gt; being missing,
&lt;code&gt;generation_id&lt;&#x2F;code&gt; is also missing. Let’s have a look at the
&lt;code&gt;evolves_from_species_id&lt;&#x2F;code&gt; variable just to help us understand.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;evolves_from_species_id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; generation_id&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_miss_point&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;DaveParr&#x2F;dev.to-posts&#x2F;master&#x2F;missingno-experiment_files&#x2F;figure-gfm&#x2F;naniar_missing_half-1.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;This is showing that in every game generation (Red&#x2F;Blue, X&#x2F;Y, etc.) that
there are Pokemon that have an &lt;code&gt;evolves_from_species_id&lt;&#x2F;code&gt;, i.e. they have
a precursor Pokemon, and that there are also Pokemon that &lt;em&gt;don’t&lt;&#x2F;em&gt; have a
precursor. Just what we see in the games. It’s also showing that have
neither &lt;code&gt;generation_id&lt;&#x2F;code&gt; or &lt;code&gt;evolves_from_species_id&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;who-is-that-pokemon&quot;&gt;Who is that Pokemon?&lt;&#x2F;h2&gt;
&lt;p&gt;Now we know the characteristics of the missing data we are interested
in, we can pull them out easily. Especially with the newly released
&lt;a href=&quot;https:&#x2F;&#x2F;dplyr.tidyverse.org&#x2F;articles&#x2F;colwise.html&quot;&gt;&lt;code&gt;across()&lt;&#x2F;code&gt; function&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;missing_cols \u003c&lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;-&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;c&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;color&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;shape&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;generation_id&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;evolves_from_species_id&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;across&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;missing_cols&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;is.na&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;.x&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;name&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; identifier&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; missing_cols&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; missing_pokes

missing_pokes &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; knitr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: left&quot;&gt;name&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;identifier&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;color&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;shape&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;generation_id&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;evolves_from_species_id&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Deoxys&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;deoxys-normal&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Wormadam&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;wormadam-plant&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Giratina&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;giratina-altered&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Shaymin&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;shaymin-land&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basculin&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;basculin-red-striped&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Darmanitan&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;darmanitan-standard&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Tornadus&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;tornadus-incarnate&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Thundurus&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;thundurus-incarnate&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Landorus&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;landorus-incarnate&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Keldeo&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;keldeo-ordinary&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Meloetta&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;meloetta-aria&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Meowstic&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;meowstic-male&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Aegislash&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;aegislash-shield&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Pumpkaboo&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;pumpkaboo-average&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Gourgeist&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;gourgeist-average&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Oricorio&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;oricorio-baile&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Lycanroc&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;lycanroc-midday&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Wishiwashi&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;wishiwashi-solo&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Minior&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;minior-red-meteor&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Mimikyu&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;mimikyu-disguised&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;So it looks like in the current version of the package, these Pokemon
all have ‘complex’ identifiers. This is because these Pokemon all have
different forms. Some vary by colour like
&lt;a href=&quot;https:&#x2F;&#x2F;bulbapedia.bulbagarden.net&#x2F;wiki&#x2F;List_of_Pok%C3%A9mon_with_form_differences#Basculin&quot;&gt;Basculin&lt;&#x2F;a&gt;
which can be Red or Blue striped, others have ability transformations,
like
&lt;a href=&quot;https:&#x2F;&#x2F;bulbapedia.bulbagarden.net&#x2F;wiki&#x2F;List_of_Pok%C3%A9mon_with_form_differences#Aegislash&quot;&gt;Aegislash&lt;&#x2F;a&gt;
or which game it was caught in like
&lt;a href=&quot;https:&#x2F;&#x2F;bulbapedia.bulbagarden.net&#x2F;wiki&#x2F;List_of_Pok%C3%A9mon_with_form_differences#Deoxys&quot;&gt;Deoxys&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;missing_pokes &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;pull&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;name&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  stringr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;str_to_lower&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;.&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; missing_pokes_name_list

pokedex&lt;span class=&quot;z-keyword z-accessor z-dollar z-r&quot;&gt;$&lt;&#x2F;span&gt;pokemon_species &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
    stringr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;str_to_lower&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;identifier&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%in%&lt;&#x2F;span&gt; missing_pokes_name_list
    &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;identifier&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; generation_id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; evolves_from_species_id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; shape_id&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; color_id&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  knitr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: left&quot;&gt;identifier&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;generation_id&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;evolves_from_species_id&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;shape_id&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;color_id&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;deoxys&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;12&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;8&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;wormadam&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;412&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;giratina&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;10&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;shaymin&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;8&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;basculin&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;darmanitan&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;554&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;8&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;8&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;tornadus&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;thundurus&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;landorus&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;4&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;keldeo&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;8&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;10&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;meloetta&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;12&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;9&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;meowstic&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;6&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;677&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;6&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;aegislash&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;6&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;680&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;pumpkaboo&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;6&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;gourgeist&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;6&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;710&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;oricorio&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;7&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;9&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;8&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;lycanroc&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;7&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;744&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;8&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;wishiwashi&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;7&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;2&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;minior&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;7&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;1&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;3&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;mimikyu&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;7&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;2&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;10&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;If we go back to the raw source data, we can see that the data is
actually there for most cases, it just didn’t join properly because in
the source data, they are identified by the simple name, in lower case,
and in &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;pokedex&#x2F;blob&#x2F;ebe078c291ffa4eb757d09e0641553de63c5a530&#x2F;data-raw&#x2F;pokemon.R#L59-L61&quot;&gt;this version of the
package&lt;&#x2F;a&gt;
this data is joined on &lt;code&gt;id&lt;&#x2F;code&gt; AND the column that actually has the complex
name. Also, because shape and color link &lt;em&gt;through&lt;&#x2F;em&gt; this data, they are
missed as well!&lt;&#x2F;p&gt;
&lt;h2 id=&quot;you-defeated-wild-missingno&quot;&gt;You defeated wild missingno!&lt;&#x2F;h2&gt;
&lt;p&gt;This is all based on my Pokedex R data package, which I’m just about to
fix :)&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;pokedex&quot;&gt;daveparr&#x2F;pokedex&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Why did I make this dev.to API wrapper?</title>
        <published>2020-06-30T00:00:00+00:00</published>
        <updated>2020-06-30T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/why-did-i-even-bother-making-this-dev-to-api-wrapper-2nk2/" type="text/html"/>
        <id>https://www.daveparr.info/blog/why-did-i-even-bother-making-this-dev-to-api-wrapper-2nk2/</id>
        
        <content type="html">&lt;p&gt;&lt;code&gt;dev.to.ol&lt;&#x2F;code&gt; is 0.0.1!&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;daveparr&#x2F;dev.to.ol&quot;&gt;daveparr&#x2F;dev.to.ol&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;what-s-in-the-box&quot;&gt;What’s in the box?&lt;&#x2F;h2&gt;
&lt;p&gt;dev.to.ol has the minimum set of viable functions I think it needs to
operate, and (just) enough testing to keep it stable. The api is
starting to come together and there seems to be at least 1 other person
who cares enough about this project to talk about it to someone else, so
I thought it might be handy to get a little more together about things.
I also wanted to make up a celebration to share a little about why I
made it and what dev.to means to me.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;are-there-other-similar-boxes&quot;&gt;Are there other similar boxes?&lt;&#x2F;h2&gt;
&lt;p&gt;R is in many ways a literate programming language. Markdown is pretty
baked into most of our ecosystem through &lt;a href=&quot;https:&#x2F;&#x2F;rmarkdown.rstudio.com&#x2F;&quot;&gt;R
Markdown&lt;&#x2F;a&gt;, as is
&lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;LaTeX_&quot;&gt;LaTeX&lt;&#x2F;a&gt;. I think because of this,
and the frequent usage in academic publishing, R users have developed
tooling for blogging pretty heavily. We have
&lt;a href=&quot;https:&#x2F;&#x2F;bookdown.org&#x2F;yihui&#x2F;blogdown&#x2F;&quot;&gt;blogdown&lt;&#x2F;a&gt; and
&lt;a href=&quot;https:&#x2F;&#x2F;rstudio.github.io&#x2F;distill&#x2F;&quot;&gt;distill&lt;&#x2F;a&gt; which are becoming very
widely used and feature rich, and @maelle has written a pretty
comprehensive guide to all the different approaches in the &lt;a href=&quot;https:&#x2F;&#x2F;scientific-rmd-blogging.netlify.app&#x2F;&quot;&gt;Scientific
Blogging with R Markdown
course&lt;&#x2F;a&gt; including her own
solution for Wordpress,
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;maelle&#x2F;goodpress&quot;&gt;goodpress&lt;&#x2F;a&gt;. As Data Scientists
(emphasis on the &lt;em&gt;science&lt;&#x2F;em&gt;), we need to share our work reproducibly, and
in a way that encourages understanding and review.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;so-why-have-another-box&quot;&gt;So why have another box?&lt;&#x2F;h2&gt;
&lt;p&gt;I was looking for something to keep me sane while I was furloughed.&lt;&#x2F;p&gt;
&lt;p&gt;Also, I had poked around dev.to about a year before, and was impressed
by what I took to be it’s un-official mission statement of “We aren’t
Medium, we’re what Medium should have been”.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;devteam&#x2F;medium-was-never-meant-to-be-a-part-of-the-developer-ecosystem-25a0&quot;&gt;Medium was never meant to be a part of the developer ecosystem&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I’m sure there is a lot more to it than that, especially with the recent
&lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;devteam&#x2F;for-empowering-community-2k6h&quot;&gt;Forem&lt;&#x2F;a&gt;
announcement, but personally, that was a hook I perceived which really
stuck me.&lt;&#x2F;p&gt;
&lt;p&gt;However, at the time the in built editor was “fine”. Fine enough, but
not great. I’m also used to R Notebooks, where I write my code next to
my prose, and compile the whole thing in one. It seemed valuable to
bring that ability to my dev.to posts. I also was aware of all the
alternatives above, but dev.to offered 2 things that were different to
the above options:&lt;&#x2F;p&gt;
&lt;h3 id=&quot;hosted-and-managed-service&quot;&gt;Hosted and managed service&lt;&#x2F;h3&gt;
&lt;p&gt;Don’t get me wrong, I have nothing but love for JAMstack and static
sites in general. I &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;satRdays&#x2F;satRday_site_template&quot;&gt;maintain a template for making them for SatRdays
conferences&lt;&#x2F;a&gt;.
However, I don’t love the process of doing it. In this case I absolutely
believe in the cause, which is why I continue to volunteer on the
project. However, the process of interacting with static sites doesn’t
actually make me &lt;em&gt;happy&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;I was looking for the simplest way I could casually blog, which ideally
required no extra work beyond writing articles (to start with).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;community&quot;&gt;Community&lt;&#x2F;h3&gt;
&lt;p&gt;I wanted at least a few people to read my articles, and I wanted to read
theirs. I’m sure I could have accomplished this with more work in SEO,
cultivating a social media network and all that jazz, but again: I just
wanted to write some stuff that some people might read, and read their
stuff. dev.to had a discovery feed, it had active users, it had
community. This was just what I was looking for. I also kind of hate
twitter (yes, I still use it when I ‘have’ to).&lt;&#x2F;p&gt;
&lt;h2 id=&quot;motivation&quot;&gt;Motivation&lt;&#x2F;h2&gt;
&lt;p&gt;Initially my work flow sucked. I wrote an &lt;code&gt;.Rmd&lt;&#x2F;code&gt; in RStudio. Compiled it
to a GitHub flavoured &lt;code&gt;.md&lt;&#x2F;code&gt;. Copy and pasted the output into the editor,
added the meta data, then uploaded all the images. If I found I’d made a
mistake, I’d either do the right thing, which was edit the &lt;code&gt;.Rmd&lt;&#x2F;code&gt;,
recompile, re-copy-pasta, or I’d more often do the quick thing which is
enter the browser editor and fix the typo.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;inception&quot;&gt;Inception&lt;&#x2F;h2&gt;
&lt;p&gt;As I was chewing over the best way to make this work gooder (I am a
programmer after all), a few things happened simultaneously.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;most-of-the-r-users-on-the-site-syndicate&quot;&gt;Most of the R users on the site syndicate&lt;&#x2F;h3&gt;
&lt;p&gt;There are some really great R users on here already:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;juliasilge&quot;&gt;juliasilge&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;sckott&quot;&gt;sckott&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;maelle&quot;&gt;maelle&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;colinfay&quot;&gt;colinfay&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I found out that most of the R users here I follow are actually
&lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;juliasilge&#x2F;status&#x2F;1260580363971317765&quot;&gt;re-syndicating through rss&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;That’s great for them, but I was actually trying to avoid my own site!&lt;&#x2F;p&gt;
&lt;h3 id=&quot;dev-to-has-an-api&quot;&gt;Dev.to has an API&lt;&#x2F;h3&gt;
&lt;p&gt;I was poking around older posts and found out that dev.to has an
&lt;a href=&quot;https:&#x2F;&#x2F;docs.dev.to&#x2F;api&quot;&gt;API&lt;&#x2F;a&gt;. At the time I thought I might play with
webhooks to boot ‘saved’ articles into pocket to work on my e-reader (at
some point I still might). However, in this case it was kind of perfect.
An API driven work flow between .Rmd in RStudio and the hosted dev.to
community. I could see it in my head, and it’s not like I was busy in
May…&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.daveparr.info&#x2F;blog&#x2F;posting-from-rmd-to-dev-to-5gld&#x2F;&quot;&gt;posting from .Rmd to dev.to&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;evolution&quot;&gt;Evolution&lt;&#x2F;h2&gt;
&lt;p&gt;After proving it ‘might’ be doable, I did some work fleshing out the
‘best’ way to do it.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.daveparr.info&#x2F;blog&#x2F;posting-straight-from-rmd-to-dev-to-1j4p&#x2F;&quot;&gt;posting straight from .Rmd to dev.to (for real this time)&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;So I started some super-basic minimum viable functions. How do I get the
post to turn up on dev.to? How do I make the meta-data work with the
post? What happens if I’ve published and need to correct a typo? All
solvable, all import features, and all now implemented and tested. I got
to learn a lot about testing API wrappers with &lt;code&gt;vcr&lt;&#x2F;code&gt; thanks to @sckott.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.daveparr.info&#x2F;blog&#x2F;testing-my-dev-to-api-package-with-testthat-webmockr-and-vcr-2dgm&#x2F;&quot;&gt;Testing my dev.to.ol package&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;The functions in the package changed a bit as I went through user
testing by using it to write my posts on dev.to that you can see here. I
was also able to generate content pretty quick because I could write
about developing the functions that I was testing at the same time by
writing the articles. Virtuous cycles! (&#x2F; black holes)&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;media2.giphy.com&#x2F;media&#x2F;lKKXOCVviOAXS&#x2F;giphy.gif?cid=ecf05e471b5c83569df22ec5aad248c62cb864b40d6efed4%5Cu0026rid=giphy.gif&quot; alt=&quot;a robot in a patterned blue suit on a marble floor infinitely crawling away from a black hole eating everything&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;At this point I was also starting to look for new work, and was
wondering about if I had made the choice backwards. Maybe I did need my
own site after all. Somewhere to put my CV, and that looked a bit more
professional, and maybe didn’t have so much clutter of articles mixed
with my own questions and a bunch of content from other people. Then I
discovered the @stackbit integration!&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;devteam&#x2F;you-can-now-generate-self-hostable-static-blogs-right-from-your-dev-content-via-stackbit-7a5&quot;&gt;You can now generate self-hostable static blogs right from your DEV content via Stackbit&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;This meant that I could hand off all the hosting and styling and
management and deploys to them, but still get a hugo repo which I can
tailor how I want, such as removing the &lt;code&gt;#meta&lt;&#x2F;code&gt; and &lt;code&gt;#help&lt;&#x2F;code&gt; posts, which
wouldn’t be useful to a recruiter, but also automatically put my content
into a presentable site, with a few contextual links to thing like my
GitHub and LinkedIn under my personal &lt;a href=&quot;https:&#x2F;&#x2F;www.daveparr.info&#x2F;blog&#x2F;why-did-i-even-bother-making-this-dev-to-api-wrapper-2nk2&#x2F;daveparr.info&quot;&gt;daveparr.info&lt;&#x2F;a&gt;
domain.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.daveparr.info&#x2F;blog&#x2F;i-made-my-dev-to-content-into-a-website-to-find-a-new-job-2kn5&#x2F;&quot;&gt;I made my dev.to content into a blog to find a new job&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;future&quot;&gt;Future&lt;&#x2F;h2&gt;
&lt;p&gt;The primary future goal is finding a good way to reference images in the
article in a way that dev.to can use. It’s likely that this will end up
being github itself. Additionally better testing is probably on the
cards as I go. The functions and package API have stabilised enough now
that this can be comprehensive, and getting some CI&#x2F;CD would be nice
too. I’m also planning on working on smarter ways to run analytics on
the data you can get back from the API about your posts. Maybe even an
inbuilt shiny app?&lt;&#x2F;p&gt;
&lt;p&gt;I hope some others of you might find the package useful, and maybe this
might motivate you to share the work you might already be doing in R, or
even pick up R as a new language!&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;unsplash.com&#x2F;photos&#x2F;WPTHZkA-M4I&quot;&gt;Photo by Erwan Hesry&lt;&#x2F;a&gt; via
Unsplash&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Nativefier is bonkers</title>
        <published>2020-06-26T00:00:00+00:00</published>
        <updated>2020-06-26T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/nativefire-is-bonkers-4m43/" type="text/html"/>
        <id>https://www.daveparr.info/blog/nativefire-is-bonkers-4m43/</id>
        
        <content type="html">&lt;p&gt;I made an electron app in 4 lines…&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;sh&quot; class=&quot;language-sh z-code&quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;nativefier&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;http:&#x2F;&#x2F;musicforprogramming.net&#x2F;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-option z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-parameter z-shell&quot;&gt; -&lt;&#x2F;span&gt;n&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;musicforprogramming&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-cd z-shell&quot;&gt;cd&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; musicforprogramming-linux-x64&#x2F;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; chmod +x musicforprogramming&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;.&#x2F;musicforprogramming&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;motivation&quot;&gt;Motivation&lt;&#x2F;h1&gt;
&lt;p&gt;I like music, but don’t like music in browser tabs. Basically because i have it open all the time, I want to find and control it easily, and I don’t want it cluttering up an area that might be soley focused on work. &lt;&#x2F;p&gt;
&lt;p&gt;I discovered some neat apps for google play, and wanted to see if there was one for my other go to, &lt;a href=&quot;http:&#x2F;&#x2F;musicforprogramming.net&#x2F;&quot;&gt;musicforprogramming&lt;&#x2F;a&gt;. There wasn’t, so I just casually googled how to convert a page into an electron app and OMFG!&lt;&#x2F;p&gt;
&lt;h1 id=&quot;solution&quot;&gt;Solution&lt;&#x2F;h1&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;nativefier&#x2F;nativefier&quot;&gt;Nativefier&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.todesktop.com&#x2F;guides&#x2F;nativefier&quot;&gt;This post&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;www.addictivetips.com&#x2F;ubuntu-linux-tips&#x2F;nativefier-turn-websites-into-linux-apps&#x2F;&quot;&gt;this one&lt;&#x2F;a&gt; helped iron out some kinks and now I can launch programming music right from my VS code terminal!&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;dev-to-uploads.s3.amazonaws.com&#x2F;i&#x2F;7dh4uokd2pt0zxgeye0n.png&quot; alt=&quot;vs code and an electron app of musicforprogramming made with nativefier&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;extra-credit&quot;&gt;Extra credit&lt;&#x2F;h1&gt;
&lt;pre data-lang=&quot;sh&quot; class=&quot;language-sh z-code&quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-support z-function z-alias z-shell&quot;&gt;alias&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-name z-function z-alias z-shell&quot;&gt;musicforprogramming&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-assignment z-shell&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-unquoted z-shell&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;~&#x2F;Dev&#x2F;musicforprogramming-linux-x64&#x2F;musicforprogramming
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Building my first Django project with CSS and Static Files</title>
        <published>2020-06-25T00:00:00+00:00</published>
        <updated>2020-06-25T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/building-my-first-django-project-with-css-and-static-files-12g1/" type="text/html"/>
        <id>https://www.daveparr.info/blog/building-my-first-django-project-with-css-and-static-files-12g1/</id>
        
        <content type="html">&lt;p&gt;I’m working through &lt;a href=&quot;https:&#x2F;&#x2F;djangoforbeginners.com&#x2F;&quot;&gt;Django for Beginners by William S. Vincent&lt;&#x2F;a&gt;. Until now we’ve had some pretty barebones Times New Roman style UI, however that’s all about to change! I think.&lt;&#x2F;p&gt;
&lt;p&gt;I’m really appreciating this incremental iteration of concepts in each new Chapter. Each time I start a new app for the chapter it’s engraining the muscle memory and concept recall into me. I’m able to run through the first 5 lines of code at the CLI nearly from memory. It’s also a great mechanism to help you if you get stuck on a wierd error and don’t know what to do. You know the next chapter will have a clean slate. Great idea William.&lt;&#x2F;p&gt;
&lt;p&gt;The repetition isn’t just the set-up though.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;“Now we can add the functionality for individual blog pages. How do we do that? We need to create a new view, url, and template. I hope you’re noticing a pattern in development with Django now!”&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;I sure am. &lt;&#x2F;p&gt;
&lt;p&gt;I’m glad that the book also doesn’t go into non-django areas, but still points readers to places to look for more info. The last chapter pointed me towards some resources to understand more about databases, and this one does similar with CSS.&lt;&#x2F;p&gt;
&lt;p&gt;It was interesting to see that the approach used to identify a blog post for navigation in the URL patterns looked &lt;em&gt;kinda&lt;&#x2F;em&gt; regex-ish:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;py&quot; class=&quot;language-py z-code&quot;&gt;&lt;code class=&quot;language-py&quot; data-lang=&quot;py&quot;&gt;&lt;span class=&quot;z-source z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;urlpatterns&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-python&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-sequence z-list z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-sequence z-begin z-python&quot;&gt;[&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;path&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;post&#x2F;&amp;lt;int:pk&amp;gt;&#x2F;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-python&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;BlogDetailView&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;as_view&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-python&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-python&quot;&gt;name&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-assignment z-python&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;post_detail&lt;span class=&quot;z-punctuation z-definition z-string z-end z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-sequence z-python&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;path&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-python&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;BlogListView&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;as_view&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-python&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-python&quot;&gt;name&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-assignment z-python&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;home&lt;span class=&quot;z-punctuation z-definition z-string z-end z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-sequence z-python&quot;&gt;,&lt;&#x2F;span&gt;
&lt;span class=&quot;z-punctuation z-section z-sequence z-end z-python&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;int:pk&amp;gt;&lt;&#x2F;code&gt; is the part that identifies the blog post required for the url to link from the ListView to the DetailView. It was interesting to find out there was something like a unique identifier for each post baked into it in the background. I was wondering about how this primary key is treated in bigger projects. Is it common to keep this approach of integer ordered primary keys, or do they get replaced in larger, more complex projects with hashes or other unique ids?&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Why use AWS Lambda for Data Science?</title>
        <published>2020-06-23T00:00:00+00:00</published>
        <updated>2020-06-23T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/why-use-aws-lambda-for-data-science-421/" type="text/html"/>
        <id>https://www.daveparr.info/blog/why-use-aws-lambda-for-data-science-421/</id>
        
        <content type="html">&lt;h2 id=&quot;motivation&quot;&gt;Motivation&lt;&#x2F;h2&gt;
&lt;p&gt;Serverless is a way to deploy code, without having to manage the
infrastructure underneath it. In AWS terms this means there is an
compute instance that runs your code, except you don’t control it, and
that might be a good thing. It only exists when it’s asked for by
something else, and therefore you only pay for the work it does. If you
need to do work concurrently you get a new instance, which also goes
away as soon as you don’t need it, so it’s scaleable.&lt;&#x2F;p&gt;
&lt;p&gt;For a data scientist this is an interesting prospect for a number of
reasons. The first is keeping you hands clean. Not all people in this
role come from a ‘operations’ background. Many of us are analysts first,
and graduate into the role. However, that shouldn’t mean we don’t ‘own
our deployments’. However, it also means that we might not have the
background, time or inclination to really get into the nitty-gritty.
Managed infrastructure, that can scale seamlessly out of the box is a
nice middle ground. We can still manage our own deployments, but theres
less to worry about than owning your own EC2 instances, let alone a
fleet of them. The way that the instances themselves die off is also
valuable. We may be doing work that requires 24&#x2F;7 processing, but often,
we aren’t. Why pay for a box which might have 50% required utilisation
time, or even less?&lt;&#x2F;p&gt;
&lt;h3 id=&quot;limits&quot;&gt;Limits&lt;&#x2F;h3&gt;
&lt;p&gt;Just like in everything there is a balance. There are &lt;em&gt;physical&lt;&#x2F;em&gt; limits
to this process. I’ve had success deploying data science assets in this
architecture, but if you can’t fit your job in these limits, this
already isn’t for you. Sure, data science &lt;em&gt;can be&lt;&#x2F;em&gt; giant machine
learning models on huge hardware with massive data volumes, but we have
to be honest and acknowledge that it isn’t always. K.I.S.S. should apply
to everything.&lt;&#x2F;p&gt;
&lt;p&gt;If you can get good enough business results with a linear regression,
don’t put in 99% more effort to train the new neural network hotness to
get a 2% increase in performance. Simplicity in calculation, deployment,
and explainability &lt;em&gt;matter&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;“No ML is easier to manage than no ML” ©
&lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;julsimon&#x2F;status&#x2F;1124383078313537536&quot;&gt;@julsimon&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;getting-started&quot;&gt;Getting started&lt;&#x2F;h2&gt;
&lt;pre data-lang=&quot;python&quot; class=&quot;language-python z-code&quot;&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;z-source z-python&quot;&gt;&lt;span class=&quot;z-meta z-statement z-import z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-import z-from z-python&quot;&gt;from&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-statement z-import z-python&quot;&gt;&lt;span class=&quot;z-meta z-import-source z-python&quot;&gt; &lt;span class=&quot;z-meta z-import-path z-python&quot;&gt;&lt;span class=&quot;z-meta z-import-name z-python&quot;&gt;scipy&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-statement z-import z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-import z-python&quot;&gt;import&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-statement z-import z-python&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-statement z-import z-python&quot;&gt; &lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;stats&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-statement z-import z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-import z-python&quot;&gt;import&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;numpy&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-import z-as z-python&quot;&gt;as&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;np&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

&lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;np&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;random&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;seed&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-python&quot;&gt;12345678&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;x&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-python&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;np&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;random&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;random&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-python&quot;&gt;10&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;y&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-python&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-python&quot;&gt;1&lt;span class=&quot;z-punctuation z-separator z-decimal z-python&quot;&gt;.&lt;&#x2F;span&gt;6&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-python&quot;&gt;*&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;x&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-python&quot;&gt;+&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;np&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;random&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;random&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-integer z-decimal z-python&quot;&gt;10&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;slope&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;, &lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;intercept&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;, &lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;r_value&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;, &lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;p_value&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;, &lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;std_err&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-python&quot;&gt;=&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;stats&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;linregress&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;x&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-python&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;y&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This is a nonsense linear regression. IMHO it’s a data science ‘Hello
World’. Let’s make it an AWS Lambda serverless function.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;diff&quot; class=&quot;language-diff z-code&quot;&gt;&lt;code class=&quot;language-diff&quot; data-lang=&quot;diff&quot;&gt;&lt;span class=&quot;z-source z-diff&quot;&gt;&lt;span class=&quot;z-markup z-inserted z-diff&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-inserted z-diff&quot;&gt;+&lt;&#x2F;span&gt; import json
&lt;&#x2F;span&gt;from scipy import stats
import numpy as np
&lt;span class=&quot;z-markup z-inserted z-diff&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-inserted z-diff&quot;&gt;+&lt;&#x2F;span&gt; def lambda_handler(event, context):
&lt;&#x2F;span&gt;  np.random.seed(12345678)

x = np.random.random(10)
y = 1.6*x + np.random.random(10)

slope, intercept, r_value, p_value, std_err = stats.linregress(x, y) 
&lt;span class=&quot;z-markup z-inserted z-diff&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-inserted z-diff&quot;&gt;+&lt;&#x2F;span&gt;   return_body = {
&lt;&#x2F;span&gt;  +       &amp;quot;m&amp;quot;: slope, &amp;quot;c&amp;quot;: intercept,&amp;quot;r2&amp;quot;: r_value ** 2, 
  +       &amp;quot;p&amp;quot;: p_value, &amp;quot;se&amp;quot;: std_err
  +   }
&lt;span class=&quot;z-markup z-inserted z-diff&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-inserted z-diff&quot;&gt;+&lt;&#x2F;span&gt;   return {&amp;quot;body&amp;quot;: json.dumps(return_body)}
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;These changes achieve 3 things:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Turning a &lt;em&gt;script&lt;&#x2F;em&gt; into a &lt;em&gt;function&lt;&#x2F;em&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Supplying the function arguments &lt;code&gt;event&lt;&#x2F;code&gt; and &lt;code&gt;context&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Formatting the return as json&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;These are required as AWS Lambda needs a &lt;em&gt;function&lt;&#x2F;em&gt;. This is so that its
&lt;em&gt;event driven architecture&lt;&#x2F;em&gt; can feed in data through &lt;code&gt;event&lt;&#x2F;code&gt;, and so
that it’s &lt;code&gt;json&lt;&#x2F;code&gt; formatted data can both be received by your function,
and then also the response be returned by that function into the rest of
the system.&lt;&#x2F;p&gt;
&lt;p&gt;You can then open up the AWS console in a browser, navigate to the
Lambda service, and then copy and paste this into this screen:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;DaveParr&#x2F;dev.to-posts&#x2F;master&#x2F;snakes-lambdas_files&#x2F;basic.png&quot; alt=&quot;aws console lambda editor&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;You can then hit run and…&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;DaveParr&#x2F;dev.to-posts&#x2F;master&#x2F;snakes-lambdas_files&#x2F;basic-fail.png&quot; alt=&quot;aws console lambda editor with an error message&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;What happened? Well, because it’s a &lt;em&gt;managed&lt;&#x2F;em&gt; instance, the function
doesn’t know what &lt;code&gt;scipy&lt;&#x2F;code&gt; is. It’s not installed on the cloud, it was
installed on your machine…&lt;&#x2F;p&gt;
&lt;h2 id=&quot;layers&quot;&gt;Layers&lt;&#x2F;h2&gt;
&lt;p&gt;AWS lambda doesn’t &lt;code&gt;pip install ....&lt;&#x2F;code&gt;. Seeing as these run on compute
instances that turn up when needed, and are destroyed when not needed,
with no attached storage, you need to find a way to tell AWS what your
dependencies are, or you’ll just have to write super-pure base Python!
Well, that may not be &lt;em&gt;strictly&lt;&#x2F;em&gt; true. &lt;code&gt;json&lt;&#x2F;code&gt; is &lt;em&gt;built in by default to
every instance&lt;&#x2F;em&gt;, so is &lt;code&gt;boto3&lt;&#x2F;code&gt;, but what about our data science buddies?
&lt;code&gt;numpy&lt;&#x2F;code&gt;, &lt;code&gt;scipy&lt;&#x2F;code&gt; are &lt;em&gt;&lt;a href=&quot;https:&#x2F;&#x2F;aws.amazon.com&#x2F;blogs&#x2F;aws&#x2F;new-for-aws-lambda-use-any-programming-language-and-share-common-components&#x2F;&quot;&gt;published by
aws&lt;&#x2F;a&gt; as layers&lt;&#x2F;em&gt;. Layers are bundles of code, that contain the dependencies you need to run the functions you write.
So in this case we can open the ‘layers’ view in AWS and attach these to our function.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;DaveParr&#x2F;dev.to-posts&#x2F;master&#x2F;snakes-lambdas_files&#x2F;layers.png&quot; alt=&quot;layers&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Now that you’ve attached all your dependencies with layers, go ahead and
run your function again.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;DaveParr&#x2F;dev.to-posts&#x2F;master&#x2F;snakes-lambdas_files&#x2F;basic-success.png&quot; alt=&quot;editor&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Success! So now you know the basics of how to put some Python data
science into practice on AWS Lambda.&lt;&#x2F;p&gt;
&lt;p&gt;This is a companion post to my talk on using data science in AWS lambda.
If you’re keen to know more, and can’t wait for me to write it all up
here. You can get the gist of the whole talks from &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;snakes_and_lambdas&quot;&gt;this repo&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>3 minimal features for my dev.to api wrapper</title>
        <published>2020-06-17T00:00:00+00:00</published>
        <updated>2020-06-17T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/3-minimal-features-for-my-dev-to-api-wrapper-371l/" type="text/html"/>
        <id>https://www.daveparr.info/blog/3-minimal-features-for-my-dev-to-api-wrapper-371l/</id>
        
        <content type="html">&lt;p&gt;I’ve made 3 very small features for my &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;dev.to.ol&quot;&gt;open source R package wrapping
the dev.to API&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;create-new-article&quot;&gt;&lt;code&gt;create_new_article&lt;&#x2F;code&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Now that the main requirements for the file to post are stabilising,
I’ve written a quick and dirty function to make a boilerplate article:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;create_new_article &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function z-r&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-r&quot;&gt;function&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-parameters z-r&quot;&gt;,&lt;&#x2F;span&gt;
           &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;series&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-single z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;series&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-parameters z-r&quot;&gt;,&lt;&#x2F;span&gt;
           &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;tags&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-single z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;[&amp;quot;tag1&amp;quot;, &amp;quot;tag2&amp;quot;]&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-parameters z-r&quot;&gt;,&lt;&#x2F;span&gt;
           &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;file&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
    boilerplate_frontmatter &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt;
      glue&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;glue&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
        &lt;span class=&quot;z-string z-quoted z-single z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;---&lt;span class=&quot;z-constant z-character z-escape z-r&quot;&gt;\n&lt;&#x2F;span&gt;title: &amp;quot;{title}&amp;quot;&lt;span class=&quot;z-constant z-character z-escape z-r&quot;&gt;\n&lt;&#x2F;span&gt;output: github_document&lt;span class=&quot;z-constant z-character z-escape z-r&quot;&gt;\n&lt;&#x2F;span&gt;series: &amp;quot;{series}&amp;quot;&lt;span class=&quot;z-constant z-character z-escape z-r&quot;&gt;\n&lt;&#x2F;span&gt;tags: {tags}&lt;span class=&quot;z-constant z-character z-escape z-r&quot;&gt;\n&lt;&#x2F;span&gt;---&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
      &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

    &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;cat&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;boilerplate_frontmatter&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;file&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; file&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This will use the &lt;a href=&quot;https:&#x2F;&#x2F;glue.tidyverse.org&#x2F;&quot;&gt;&lt;code&gt;glue&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; package to put
the strings in the function argument into the right place in the
boilerplate YAML front matter. If then uses &lt;code&gt;cat&lt;&#x2F;code&gt; to either print that
to screen, or to create a new file with it, if a file path is supplied.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;main-image&quot;&gt;&lt;code&gt;main_image&lt;&#x2F;code&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;If there is a &lt;code&gt;main_image&lt;&#x2F;code&gt; parameter in the &lt;code&gt;YAML&lt;&#x2F;code&gt; front matter that is
a url of an image, that image will be set as the cover image of the
post. I got this one from a photo by &lt;a href=&quot;https:&#x2F;&#x2F;unsplash.com&#x2F;@juliandufort?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Julian
Dufort&lt;&#x2F;a&gt;
on
&lt;a href=&quot;https:&#x2F;&#x2F;unsplash.com&#x2F;s&#x2F;photos&#x2F;3?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText&quot;&gt;Unsplash&lt;&#x2F;a&gt;.
I &lt;em&gt;believe&lt;&#x2F;em&gt; that if you put an unsplash URL into this field that goes
&lt;strong&gt;directly to the image&lt;&#x2F;strong&gt; it is within their
&lt;a href=&quot;https:&#x2F;&#x2F;unsplash.com&#x2F;license&quot;&gt;license&lt;&#x2F;a&gt;, though if anyone knows
something to the contrary please let me know. It’s the first time I have
used this service, despite hearing about it for years.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;collapse-spaces-tags&quot;&gt;Collapse spaces tags&lt;&#x2F;h2&gt;
&lt;p&gt;I recently fooled myself for a good ten minutes into thinking that there
was a problem with my API code yesterday when I kept getting a 422
response to putting a new article up, when in fact it was that I had a
space character in one of my tags. Now the &lt;code&gt;post_new_article&lt;&#x2F;code&gt; function
collapses any spaces it encounters in tags. Achieving this was a breeze
with &lt;a href=&quot;https:&#x2F;&#x2F;purrr.tidyverse.org&#x2F;&quot;&gt;&lt;code&gt;purrr&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; and
&lt;a href=&quot;https:&#x2F;&#x2F;stringr.tidyverse.org&#x2F;&#x2F;&quot;&gt;&lt;code&gt;stringr&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;purrr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;map&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;file_frontmatter&lt;span class=&quot;z-keyword z-accessor z-dollar z-r&quot;&gt;$&lt;&#x2F;span&gt;tags&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; stringr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;str_remove_all&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This little nugget takes the list of tags, and then maps the function
&lt;code&gt;str_remove_all&lt;&#x2F;code&gt; across all the spaces. This isn’t at all exposed to the
user, as it’s non-negotiable from the API side anyway :)&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Webscraping with rvest and themeing ggplot</title>
        <published>2020-06-16T00:00:00+00:00</published>
        <updated>2020-06-16T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/webscraping-with-rvest-and-themeing-ggplot-4573/" type="text/html"/>
        <id>https://www.daveparr.info/blog/webscraping-with-rvest-and-themeing-ggplot-4573/</id>
        
        <content type="html">&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;tidyverse&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;pokedex&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;ggplot2.tidyverse.org&#x2F;&quot;&gt;&lt;code&gt;ggplot&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; is the ‘default’ plotting
library in R. It’s a very old package now, but has been kept up-to-date
and is one of the core ‘tidyverse’ packages.
&lt;a href=&quot;https:&#x2F;&#x2F;rvest.tidyverse.org&#x2F;&quot;&gt;&lt;code&gt;rvest&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; is also a tidyverse package that
deals with web scrapping, inspired by equivalents like &lt;a href=&quot;https:&#x2F;&#x2F;www.crummy.com&#x2F;software&#x2F;BeautifulSoup&#x2F;&quot;&gt;“beautiful
soup”&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;There is a table of hex colour codes used by
&lt;a href=&quot;https:&#x2F;&#x2F;bulbapedia.bulbagarden.net&#x2F;wiki&#x2F;Category:Type_color_templates&quot;&gt;Bulbapedia&lt;&#x2F;a&gt;
for each pokemon type. I’d like top be able to use this for plots made
with my &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;pokedex&quot;&gt;&lt;code&gt;pokedex&lt;&#x2F;code&gt; package&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;webscraping-with-rvest&quot;&gt;Webscraping with &lt;code&gt;rvest&lt;&#x2F;code&gt;&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;get-the-data&quot;&gt;Get the data&lt;&#x2F;h3&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;read_html&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;https:&#x2F;&#x2F;bulbapedia.bulbagarden.net&#x2F;wiki&#x2F;Category:Type_color_templates&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;html_nodes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;.wikitable&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  .&lt;span class=&quot;z-meta z-item-access z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-brackets z-double z-begin z-r&quot;&gt;[[&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-item-access z-r&quot;&gt;&lt;span class=&quot;z-meta z-item-access z-arguments z-r&quot;&gt;&lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-item-access z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-brackets z-double z-end z-r&quot;&gt;]]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;html_table&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; pokemon_colour_table
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This very simple pipe goes to the url and detects all html nodes with a
class of &lt;code&gt;&amp;quot;wikitable&amp;quot;&lt;&#x2F;code&gt; and puts them in a list. It then takes the first
element (of one in this case), converts it into a table, and assigns it
to a variable &lt;code&gt;pokemon_colour_table&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;clean-the-data&quot;&gt;Clean the data&lt;&#x2F;h3&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon_colour_table &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  janitor&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;clean_names&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;slice&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-other z-r&quot;&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;75&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;-&lt;&#x2F;span&gt;video_game_types_3&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;rename&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;type_full&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; video_game_types&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;colour&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; video_game_types_2&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_full &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;!=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;type&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;tolower&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;str_trim&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;str_remove_all&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_full&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;color|light|dark|&lt;span class=&quot;z-constant z-character z-escape z-r&quot;&gt;\\&lt;&#x2F;span&gt;:&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;colour_var&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;case_when&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
      &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;str_detect&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_full&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;light&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;light&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
      &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;str_detect&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_full&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;dark&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;dark&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;colour&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;paste0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;#&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; colour&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;-&lt;&#x2F;span&gt;type_full&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; colour_var&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; colour&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; type_colours
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Cleaning the data is the more irritating part, as always. First,
&lt;code&gt;janitor::clean_names()&lt;&#x2F;code&gt; does a bunch of sane default things to make
sure our table names are snakecase, with no mad characters and
duplication etc.. Then, as we only want the first part we slice it, and
as we only want the first 2 columns, we drop the third. We then give the
remaining columns sane names, and remove rows that have empty strings.&lt;&#x2F;p&gt;
&lt;p&gt;The meat of the data cleaning comes next, parsing the label column to
get just the type out and convert it to lower case and putting it into a
new column, then conditionally checking if the row is a variant
light&#x2F;dark hue, or the default, and making a column to represent that.
Finally we convert the colour code to an actual hex string.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;format-for-ggplot2-colour-scale&quot;&gt;Format for &lt;code&gt;ggplot2&lt;&#x2F;code&gt; colour scale&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;code&gt;ggplot2&lt;&#x2F;code&gt; wants the scale as a named list. Making this in a tidy way is
very straightforward.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;type_colours &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;is.na&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;colour_var&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;-&lt;&#x2F;span&gt;colour_var&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;colour&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;set_names&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;colour&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;pull&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;colour&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; pokemon_type_scale_colours
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In this particular case we select all the values that &lt;em&gt;do not&lt;&#x2F;em&gt; have a
&lt;code&gt;colour_var&lt;&#x2F;code&gt; value, i.e. the defaults, drop the &lt;code&gt;colour_var&lt;&#x2F;code&gt; column, and
set the names of the &lt;code&gt;colour&lt;&#x2F;code&gt; column to the &lt;em&gt;value&lt;&#x2F;em&gt; of the type column.
We have to do this because &lt;code&gt;scale_*_manual()&lt;&#x2F;code&gt; in ggplot will expect a
named list, where the names are the &lt;code&gt;type&lt;&#x2F;code&gt; categorical variable, and the
contents of the list are the hex colour codes for that type. Then when
we &lt;code&gt;pull&lt;&#x2F;code&gt; that column into a list we will have a named list.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;theming&quot;&gt;Theming&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;add-a-font-with-showtext&quot;&gt;Add a font with &lt;code&gt;showtext&lt;&#x2F;code&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Keeping the video game flavour, lets also make a quick theme using the a
video game font. We can use
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;yixuan&#x2F;showtext&quot;&gt;&lt;code&gt;showtext&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; to easily add the
“Press Start 2P” font from google fonts.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;showtext&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;font_add_google&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Press Start 2P&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;showtext_auto&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then, starting from the &lt;code&gt;theme_minimal&lt;&#x2F;code&gt; we can replace the default font,
and rotate the text labels on the bottom axis.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function z-name z-r&quot;&gt;&lt;span class=&quot;z-entity z-name z-function z-r&quot;&gt;theme_pokedex&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-r&quot;&gt;&lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-r&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-r&quot;&gt;function&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;theme_minimal&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%+replace%&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;theme&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
      &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;text&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;element_text&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;family&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Press Start 2P&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
      &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;axis.text.x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;element_text&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;angle&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;-&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;90&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;

&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;theme_set&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;theme_pokedex&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;eeveelutions&quot;&gt;Eeveelutions&lt;&#x2F;h2&gt;
&lt;p&gt;To demonstrate, lets make a simple plot showing the key stats of the
eeveelutions.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;evolution_chain_id &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;67&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;identifier&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; hp&lt;span class=&quot;z-keyword z-other z-r&quot;&gt;:&lt;&#x2F;span&gt;speed&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type_1&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;pivot_longer&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;cols&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;c&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;hp&lt;span class=&quot;z-keyword z-other z-r&quot;&gt;:&lt;&#x2F;span&gt;speed&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
               &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;names_to&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;stat&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; stat&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; value&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;fill&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; type_1&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_col&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;facet_wrap&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;. &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; identifier&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;scale_fill_manual&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;values&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; pokemon_type_scale_colours&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;eeveelutions stats&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;dev-to-uploads.s3.amazonaws.com&#x2F;i&#x2F;eugomzb1g1v9z6ytyry4.png&quot; alt=&quot;Alt Text&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Writing R packages, fast</title>
        <published>2020-06-10T00:00:00+00:00</published>
        <updated>2020-06-10T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/writing-r-packages-fast-474c/" type="text/html"/>
        <id>https://www.daveparr.info/blog/writing-r-packages-fast-474c/</id>
        
        <content type="html">&lt;p&gt;R packages are great. R users have a rich ecosystem of extensions to
help us doing various things. We have our own &lt;em&gt;integrated&lt;&#x2F;em&gt; package
management system,
&lt;a href=&quot;https:&#x2F;&#x2F;cran.r-project.org&#x2F;doc&#x2F;FAQ&#x2F;R-FAQ.html#What-is-CRAN_003f&quot;&gt;CRAN&lt;&#x2F;a&gt;,
and we also have &lt;a href=&quot;https:&#x2F;&#x2F;www.r-pkg.org&#x2F;&quot;&gt;Metacran&lt;&#x2F;a&gt; which gives us an
easy way to work out how popular specific packages are used. R also
makes it ‘easy’ for you to write your own packages! Sort of.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;how-can-i-create-and-r-package&quot;&gt;How can I create and R package?&lt;&#x2F;h1&gt;
&lt;p&gt;CRAN suggests making an R package &lt;a href=&quot;https:&#x2F;&#x2F;cran.r-project.org&#x2F;doc&#x2F;FAQ&#x2F;R-FAQ.html#How-can-I-create-an-R-package_003f&quot;&gt;is really
simple&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;5.5 How can I create an R package? A package consists of a subdirectory containing a file DESCRIPTION and the subdirectories R, data, demo, exec, inst, man, po, src, and tests (some of which can be missing). The package subdirectory may also contain files INDEX, NAMESPACE, configure, cleanup, LICENSE, LICENCE, COPYING and NEWS.
See section “Creating R packages” in Writing R Extensions, for details. This manual is included in the R distribution, see What documentation exists for R?, and gives information on package structure, the configure and cleanup mechanisms, and on automated package checking and building.
R version 1.3.0 has added the function package.skeleton() which will set up directories, save data and code, and create skeleton help files for a set of R functions and datasets.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;So I just run the function &lt;code&gt;package.skeleton()&lt;&#x2F;code&gt;, and then I just fill in
some R code right? Well, you could. But also, please don’t. Having done
it that way myself the first few times, you &lt;em&gt;can&lt;&#x2F;em&gt; do that, but that
doesn’t mean you &lt;em&gt;should&lt;&#x2F;em&gt;. Luckily R is a programming language, and
people use programming languages to automate things. So obviously people
have built packages the slow way that will help you build your package
&lt;a href=&quot;https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=gAjR4_CbPpQ&quot;&gt;easier, better, faster&lt;&#x2F;a&gt;.
We should use those instead!&lt;&#x2F;p&gt;
&lt;h1 id=&quot;starting-a-project&quot;&gt;Starting a project&lt;&#x2F;h1&gt;
&lt;p&gt;You should be using RStudio. It’s an &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rstudio&#x2F;rstudio&quot;&gt;Open
Source&lt;&#x2F;a&gt; IDE for R specifically,
which is &lt;a href=&quot;https:&#x2F;&#x2F;rstudio.com&#x2F;&quot;&gt;free to download&lt;&#x2F;a&gt;. The fastest way to
start your project is to open RStudio, and go to &lt;code&gt;File &amp;gt; New Project &amp;gt; New Directory &amp;gt; R Package&lt;&#x2F;code&gt;. Then give it a name, and make sure to create
a git repository with it.&lt;&#x2F;p&gt;
&lt;p&gt;You now have a Hello World package. It contains a function called
&lt;code&gt;hello&lt;&#x2F;code&gt; in the &lt;code&gt;R&lt;&#x2F;code&gt; directory, with a few comments and notes about short
cuts. You will be able to &lt;strong&gt;Build&lt;&#x2F;strong&gt; the package, and you can run a
&lt;strong&gt;Check&lt;&#x2F;strong&gt;, which will give you a warning, and run the &lt;strong&gt;Test&lt;&#x2F;strong&gt; which
will give you an error.&lt;&#x2F;p&gt;
&lt;p&gt;You’ll also have a few other files and folders. &lt;code&gt;man&lt;&#x2F;code&gt; will hold the
manual, or documentation. The &lt;code&gt;DESCRIPTION&lt;&#x2F;code&gt; gives you a bunch of
metadata, and the &lt;code&gt;NAMESPACE&lt;&#x2F;code&gt; will only have the line
&lt;code&gt;exportPattern(&amp;quot;^[[:alpha:]]+&amp;quot;)&lt;&#x2F;code&gt;. Don’t worry about that for now, we’ll
fix it in a moment. &lt;code&gt;.Rbuildignore&lt;&#x2F;code&gt; is a bit like the &lt;code&gt;.gitignore&lt;&#x2F;code&gt;. It
will just contain references for R to &lt;em&gt;not&lt;&#x2F;em&gt; use when running &lt;strong&gt;Build&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;setting-up-a-package-and-managing-package-structure-withusethis&quot;&gt;Setting up a package and managing package structure with&lt;code&gt;usethis&lt;&#x2F;code&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;I talked about &lt;a href=&quot;https:&#x2F;&#x2F;usethis.r-lib.org&#x2F;&quot;&gt;&lt;code&gt;usethis&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; in my &lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;daveparr&#x2F;testing-my-dev-to-api-package-with-testthat-webmockr-and-vcr-2dgm&quot;&gt;last
post&lt;&#x2F;a&gt;,
but didn’t do it nearly the justice it deserves. The best place to start
is &lt;a href=&quot;https:&#x2F;&#x2F;usethis.r-lib.org&#x2F;#usage&quot;&gt;Usage&lt;&#x2F;a&gt; and then have a look at the
&lt;a href=&quot;https:&#x2F;&#x2F;usethis.r-lib.org&#x2F;reference&#x2F;index.html&quot;&gt;Reference&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;In my projects I tend to use these functions to set up each one:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;use_pipe()&lt;&#x2F;code&gt; to allow the package to use pipes from &lt;code&gt;magrittr&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;use_testthat()&lt;&#x2F;code&gt; to set up tests that for the package&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;use_package()&lt;&#x2F;code&gt; to include a dependency, such as &lt;code&gt;ggplot2&lt;&#x2F;code&gt; or
&lt;code&gt;readr&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;use_vignette()&lt;&#x2F;code&gt; to include long form documentation&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;use_readme_rmd()&lt;&#x2F;code&gt;&#x2F;&lt;code&gt;use_readme_md()&lt;&#x2F;code&gt; to create Readmes&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;use_badge()&lt;&#x2F;code&gt; to fill in those Readmes with badges&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;And then to write my package I tend to use these functions to write it:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;use_r()&lt;&#x2F;code&gt; to create a new R file to source&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;use_test()&lt;&#x2F;code&gt; to create a new test for a specific open R file&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;use_data()&lt;&#x2F;code&gt; to include data sets in my packages&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;So you can do all these things manually, and maybe the first time you
should. Maybe you should learn that to use a package you need to modify
the &lt;code&gt;Imports&lt;&#x2F;code&gt; field in the &lt;code&gt;DESCRIPTION&lt;&#x2F;code&gt;, and maybe you need to learn
that to make &lt;code&gt;testthat&lt;&#x2F;code&gt; work in your package you need to make a specific
&lt;code&gt;test&lt;&#x2F;code&gt; folder, and then include a &lt;code&gt;testthat.R&lt;&#x2F;code&gt; file to make it work.
However, I also don’t need to implement my own class every time I want
to make an object that holds a data matrix either, and I also don’t need
to know how the interpreter &lt;em&gt;actually&lt;&#x2F;em&gt; works when I run my &lt;code&gt;hello&lt;&#x2F;code&gt;
function. There’s a reason why we don’t write in 1 and 0, and it’s the
same reason I don’t see the value in writing my own &lt;code&gt;NAMESPACE&lt;&#x2F;code&gt; files
any more. I can do it, but it’s a simple boring task that I’ve done a
bunch of times before, and that at this stage I’m actually likely to get
more wrong than the computer. Talking of which…&lt;&#x2F;p&gt;
&lt;h1 id=&quot;namespace-self-documenting-code-and-self-coding-documentation&quot;&gt;&lt;code&gt;NAMESPACE&lt;&#x2F;code&gt;, self-documenting code and self-coding documentation&lt;&#x2F;h1&gt;
&lt;p&gt;The &lt;code&gt;NAMESPACE&lt;&#x2F;code&gt; helps your package understand what functions it sources
from what other packages, and what functions it allows to be used. &lt;a href=&quot;http:&#x2F;&#x2F;r-pkgs.had.co.nz&#x2F;namespace.html&quot;&gt;The
R packages book&lt;&#x2F;a&gt; has a chapter
on it that goes into detail, but the key thing to really understand is
&lt;em&gt;how&lt;&#x2F;em&gt; to use it.&lt;&#x2F;p&gt;
&lt;p&gt;As an example, lets run &lt;code&gt;usethis::use_pipe()&lt;&#x2F;code&gt;. This will set-up our
package to allow us to use the &lt;code&gt;%&amp;gt;%&lt;&#x2F;code&gt; operator to chain functions. Our
console tells us:&lt;&#x2F;p&gt;
&lt;div class=&quot;crt scanlines&quot;&gt;
  &lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;● Run `devtools::document()`
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;

&lt;&#x2F;div&gt;
&lt;p&gt;We also have a new file &lt;code&gt;.&#x2F;R&#x2F;utils-pipe.R&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; Pipe operator
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; See \code{magrittr::\link[magrittr]{\%&amp;gt;\%}} for details.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@name&lt;&#x2F;span&gt; %&amp;gt;%
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@rdname&lt;&#x2F;span&gt; pipe
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@keywords&lt;&#x2F;span&gt; internal
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@export&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; magrittr %&amp;gt;%
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@usage&lt;&#x2F;span&gt; lhs \%&amp;gt;\% rhs
&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-language z-r&quot;&gt;NULL&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;So this is a file that’s all comments? Not quite. This is a Roxygen
comment block with &lt;code&gt;#&#x27;&lt;&#x2F;code&gt;, and it has special powers. It won’t actually be
executed if this file is sourced, but if we &lt;em&gt;document&lt;&#x2F;em&gt; our package, the
process will read these comment blocks, and the &lt;code&gt;@&lt;&#x2F;code&gt; tags, and populate
out the documentation in &lt;code&gt;.&#x2F;man&lt;&#x2F;code&gt;. As we got prompted though, we need to
run the documentation process manually, so lets do that with
&lt;code&gt;devtools::document()&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;div class=&quot;crt scanlines&quot;&gt;
  &lt;pre data-lang=&quot;sh&quot; class=&quot;language-sh z-code&quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;Updating&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; making.packages documentation&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;First&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; time using roxygen2. Upgrading automatically...&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;Writing&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; NAMESPACE&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;Loading&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; making.packages&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;Writing&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; NAMESPACE&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;Writing&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; pipe.Rd&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;

&lt;&#x2F;div&gt;
&lt;p&gt;Now we have some changes. Our &lt;code&gt;NAMESPACE&lt;&#x2F;code&gt; LOOKS LIKE THIS:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-comment z-line z-number-sign z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&lt;&#x2F;span&gt; Generated by roxygen2: do not edit by hand
&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;export&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;%&amp;gt;%&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;importFrom&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;magrittr&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;%&amp;gt;%&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;and we have a new &lt;code&gt;.&#x2F;man&#x2F;pipe.Rd&lt;&#x2F;code&gt; file:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;% Generated by roxygen2&lt;span class=&quot;z-keyword z-other z-r&quot;&gt;:&lt;&#x2F;span&gt; do not edit by hand
% Please edit documentation &lt;span class=&quot;z-keyword z-operator z-word z-r&quot;&gt;in&lt;&#x2F;span&gt; R&lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;&#x2F;&lt;&#x2F;span&gt;utils&lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;-&lt;&#x2F;span&gt;pipe.R
\name&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;\%&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;\%&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
\alias&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;\%&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;\%&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
\title&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;Pipe operator&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
\usage&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
lhs \%&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;\% rhs
&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
\description&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
See \code&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;magrittr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;\link&lt;span class=&quot;z-meta z-item-access z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-brackets z-single z-begin z-r&quot;&gt;[&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-item-access z-r&quot;&gt;&lt;span class=&quot;z-meta z-item-access z-arguments z-r&quot;&gt;magrittr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-item-access z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-brackets z-single z-end z-r&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;\%&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;\%&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt; for details.
&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
\keyword&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;internal&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;What’s happened? A few things:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Roxygen was associated with our package build to parse and process
the comments&lt;&#x2F;li&gt;
&lt;li&gt;Roxygen re-wrote the &lt;code&gt;NAMESPACE&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Roxygen read the Roxygen comments in the &lt;code&gt;.&#x2F;R&#x2F;utils-pipe.R&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Roxygen used those special comments to put an import and an export
line into the &lt;code&gt;NAMESPACE&lt;&#x2F;code&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;export&lt;&#x2F;code&gt; will allow users to use the &lt;code&gt;%&amp;gt;%&lt;&#x2F;code&gt; when they load
our package&lt;&#x2F;li&gt;
&lt;li&gt;The &lt;code&gt;importFrom&lt;&#x2F;code&gt; will allow us to use the &lt;code&gt;%&amp;gt;%&lt;&#x2F;code&gt; in our own code
in the package itself&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;Roxygen populated the manual page for the function so we can see it
in the RStudio help.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;Compare the two comment blocks now. What are the differences?&lt;&#x2F;p&gt;
&lt;h2 id=&quot;roxygen-comments&quot;&gt;Roxygen comments&lt;&#x2F;h2&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; Pipe operator
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; See \code{magrittr::\link[magrittr]{\%&amp;gt;\%}} for details.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@name&lt;&#x2F;span&gt; %&amp;gt;%
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@rdname&lt;&#x2F;span&gt; pipe
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@keywords&lt;&#x2F;span&gt; internal
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@export&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; magrittr %&amp;gt;%
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@usage&lt;&#x2F;span&gt; lhs \%&amp;gt;\% rhs
&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-language z-r&quot;&gt;NULL&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;roxygenised-rd&quot;&gt;Roxygenised &lt;code&gt;.Rd&lt;&#x2F;code&gt;&lt;&#x2F;h2&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;% Generated by roxygen2&lt;span class=&quot;z-keyword z-other z-r&quot;&gt;:&lt;&#x2F;span&gt; do not edit by hand
% Please edit documentation &lt;span class=&quot;z-keyword z-operator z-word z-r&quot;&gt;in&lt;&#x2F;span&gt; R&lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;&#x2F;&lt;&#x2F;span&gt;utils&lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;-&lt;&#x2F;span&gt;pipe.R
\name&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;\%&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;\%&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
\alias&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;\%&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;\%&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
\title&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;Pipe operator&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
\usage&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
lhs \%&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;\% rhs
&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
\description&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
See \code&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;magrittr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;\link&lt;span class=&quot;z-meta z-item-access z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-brackets z-single z-begin z-r&quot;&gt;[&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-item-access z-r&quot;&gt;&lt;span class=&quot;z-meta z-item-access z-arguments z-r&quot;&gt;magrittr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-item-access z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-brackets z-single z-end z-r&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;\%&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;\%&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt; for details.
&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
\keyword&lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;internal&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;So the first big one is formatting. The first one looks (mostly) human
readable, while the second one has a lot more cruft. This cruft is
basically LaTeX. The order has been changed around and few of the labels
are a little different, but there is another big change. &lt;code&gt;@export&lt;&#x2F;code&gt; and
&lt;code&gt;@importFrom&lt;&#x2F;code&gt; aren’t in the documentation! Those were &lt;em&gt;only&lt;&#x2F;em&gt; included
to help Roxygen populate the &lt;code&gt;NAMESPACE&lt;&#x2F;code&gt; file. So you can see that those
two tags are actually amongst the most important things to include in
documenting other functions. If you check in the &lt;code&gt;DESCRIPTION&lt;&#x2F;code&gt; file we
now &lt;em&gt;also&lt;&#x2F;em&gt; have a new &lt;code&gt;Imports&lt;&#x2F;code&gt; field in the YAML with &lt;code&gt;magrittr&lt;&#x2F;code&gt; being
the only entry. Did you notice that there was no &lt;em&gt;actual&lt;&#x2F;em&gt; R code in this
function? It actually explicitly contained &lt;code&gt;NULL&lt;&#x2F;code&gt;. All of this was
purely generated from the documentation, but now we actually have a new
piece of fundamental functionality in our package. Weird huh?&lt;&#x2F;p&gt;
&lt;h1 id=&quot;the-package-skeleton-s-connected-to-the-comment-bone-the-comment-bone-s-connected-to-the-sinew-imports&quot;&gt;The package skeleton’s connected to the comment bone. The comment bone’s connected to the sinew imports.&lt;&#x2F;h1&gt;
&lt;p&gt;So now you’re all prepared to write your own package. You know how to
start a new package project, how to set it up with &lt;code&gt;usethis&lt;&#x2F;code&gt; and how to
document functions with Roxygen. Hold up though. That thing about not
having to do the basically the same fiddly boring job multiple times in
each package? I really meant it. The cool R kids don’t even write their
own Roxygen any more.&lt;&#x2F;p&gt;
&lt;p&gt;Go back to your &lt;code&gt;.&#x2F;R&#x2F;hello.R&lt;&#x2F;code&gt; file, and ditch those boring vanilla &lt;code&gt;#&lt;&#x2F;code&gt;
comments. Now source the function into your global environment so you
can run it interactively. Now &lt;code&gt;install.packages(&amp;quot;sinew&amp;quot;)&lt;&#x2F;code&gt;, and run
&lt;code&gt;sinew::makeOxygen(hello)&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@description&lt;&#x2F;span&gt; FUNCTION_DESCRIPTION
&lt;&#x2F;span&gt;
&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@return&lt;&#x2F;span&gt; OUTPUT_DESCRIPTION
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@details&lt;&#x2F;span&gt; DETAILS
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@examples&lt;&#x2F;span&gt; 
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; \dontrun{
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; if(interactive()){
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  #EXAMPLE1
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  }
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; }
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@rdname&lt;&#x2F;span&gt; hello
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@export&lt;&#x2F;span&gt; 
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;So &lt;a href=&quot;https:&#x2F;&#x2F;yonicd.github.io&#x2F;sinew&#x2F;&quot;&gt;sinew&lt;&#x2F;a&gt; has built us a template for
Roxygen, and put the function name in? Cute, but I don’t need that to
write one word for me. OK, how about something a bit more real world.
I’ve been &lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;daveparr&#x2F;posting-straight-from-rmd-to-dev-to-1j4p&quot;&gt;making a wrapper for the dev.to
API&lt;&#x2F;a&gt;
(using all these methods). If I go get my &lt;code&gt;post_new_article&lt;&#x2F;code&gt; function
and run &lt;code&gt;sinew::makeOxygen(post_new_article)&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;div class=&quot;crt scanlines&quot;&gt;
  &lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@title&lt;&#x2F;span&gt; FUNCTION_TITLE
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@description&lt;&#x2F;span&gt; FUNCTION_DESCRIPTION
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@param&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;file&lt;&#x2F;span&gt; PARAM_DESCRIPTION
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@param&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;key&lt;&#x2F;span&gt; PARAM_DESCRIPTION, Default: NA
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@return&lt;&#x2F;span&gt; OUTPUT_DESCRIPTION
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@details&lt;&#x2F;span&gt; DETAILS
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@examples&lt;&#x2F;span&gt; 
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; \dontrun{
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; if(interactive()){
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  #EXAMPLE1
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  }
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; }
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@seealso&lt;&#x2F;span&gt; 
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  \code{\link[rmarkdown]{yaml_front_matter}},\code{\link[rmarkdown]{render}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  \code{\link[readr]{read_file}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  \code{\link[stringr]{str_remove}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  \code{\link[glue]{glue}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  \code{\link[httr]{POST}},\code{\link[httr]{add_headers}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@rdname&lt;&#x2F;span&gt; post_new_article
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@export&lt;&#x2F;span&gt; 
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; rmarkdown yaml_front_matter render
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; readr read_file
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; stringr str_remove
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; glue glue
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; httr POST add_headers
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;

&lt;&#x2F;div&gt;
&lt;p&gt;This is my output. Sinew inspects my function, and then &lt;em&gt;derives&lt;&#x2F;em&gt; the
functions I need to import and adds them to the Roxygen comment block.
It also links the functions in the &lt;code&gt;@seealso&lt;&#x2F;code&gt; which will show up in the
docs. Remember that these now get &lt;em&gt;automatically&lt;&#x2F;em&gt; added to the
&lt;code&gt;NAMESPACE&lt;&#x2F;code&gt; and &lt;code&gt;DESCRIPTIONS&lt;&#x2F;code&gt; where they need to be, each time I
document my package. It’s also understood what arguments my function
takes, and populated them with the defaults, if present. Now, why would
you bother writing this by hand any more?&lt;&#x2F;p&gt;
&lt;h1 id=&quot;tl-dr&quot;&gt;TL;DR&lt;&#x2F;h1&gt;
&lt;ol&gt;
&lt;li&gt;Start your package in the RStudio IDE as a new project&lt;&#x2F;li&gt;
&lt;li&gt;Set up your package with &lt;code&gt;usethis&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Populate your Roxygen comments with &lt;code&gt;sinew&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Profit!&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Building my first Django project with a Database</title>
        <published>2020-06-05T00:00:00+00:00</published>
        <updated>2020-06-05T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/building-my-first-django-project-with-a-database-4j09/" type="text/html"/>
        <id>https://www.daveparr.info/blog/building-my-first-django-project-with-a-database-4j09/</id>
        
        <content type="html">&lt;p&gt;I’m working through &lt;a href=&quot;https:&#x2F;&#x2F;djangoforbeginners.com&#x2F;&quot;&gt;Django for Beginners by William S. Vincent&lt;&#x2F;a&gt;. Chapter 4 starts using a database to act as a data store for a Message Board app.&lt;&#x2F;p&gt;
&lt;p&gt;This seemed very related to what my buddies do with Laravel, where migrations are run when the data Model in the backend needs to be changed. I was actually a little surprised that at no point did I need to write any SQL though. As someone who has spent their professional life asking databases for info, I was actually a tiny bit disappointed 😜. &lt;&#x2F;p&gt;
&lt;p&gt;I’m starting to become curious about this &lt;code&gt;manage.py&lt;&#x2F;code&gt; file though. All I have in my workspace to represent it is:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;py&quot; class=&quot;language-py z-code&quot;&gt;&lt;code class=&quot;language-py&quot; data-lang=&quot;py&quot;&gt;&lt;span class=&quot;z-source z-python&quot;&gt;&lt;span class=&quot;z-comment z-line z-number-sign z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-python&quot;&gt;#&lt;&#x2F;span&gt;!&#x2F;usr&#x2F;bin&#x2F;env python
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-block z-documentation z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-begin z-python&quot;&gt;&amp;quot;&amp;quot;&amp;quot;&lt;&#x2F;span&gt;Django&amp;#39;s command-line utility for administrative tasks.&lt;span class=&quot;z-punctuation z-definition z-comment z-end z-python&quot;&gt;&amp;quot;&amp;quot;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-statement z-import z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-import z-python&quot;&gt;import&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;os&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-statement z-import z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-import z-python&quot;&gt;import&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;sys&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;


&lt;span class=&quot;z-meta z-function z-python&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-python&quot;&gt;&lt;span class=&quot;z-keyword z-declaration z-function z-python&quot;&gt;def&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-entity z-name z-function z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;main&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-function z-begin z-python&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;os&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;environ&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;setdefault&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;DJANGO_SETTINGS_MODULE&lt;span class=&quot;z-punctuation z-definition z-string z-end z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-python&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;blog_project.settings&lt;span class=&quot;z-punctuation z-definition z-string z-end z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-meta z-statement z-exception z-try z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-exception z-try z-python&quot;&gt;try&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-block z-exception z-try z-python&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
        &lt;span class=&quot;z-meta z-statement z-import z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-import z-from z-python&quot;&gt;from&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-statement z-import z-python&quot;&gt;&lt;span class=&quot;z-meta z-import-source z-python&quot;&gt; &lt;span class=&quot;z-meta z-import-path z-python&quot;&gt;&lt;span class=&quot;z-meta z-import-name z-python&quot;&gt;django&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-import-name z-python&quot;&gt;core&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-import-name z-python&quot;&gt;management&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-statement z-import z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-import z-python&quot;&gt;import&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-statement z-import z-python&quot;&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-statement z-import z-python&quot;&gt; &lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;execute_from_command_line&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-meta z-statement z-exception z-catch z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-exception z-catch z-python&quot;&gt;except&lt;&#x2F;span&gt; &lt;span class=&quot;z-support z-type z-exception z-python&quot;&gt;ImportError&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-exception z-catch z-as z-python&quot;&gt;as&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-statement z-exception z-catch z-python&quot;&gt; &lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;exc&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-statement z-exception z-catch z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-block z-exception z-catch z-python&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
        &lt;span class=&quot;z-meta z-statement z-raise z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-flow z-raise z-python&quot;&gt;raise&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-support z-type z-exception z-python&quot;&gt;ImportError&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;
            &lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-python&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-python&quot;&gt;Couldn&amp;#39;t import Django. Are you sure it&amp;#39;s installed and &lt;span class=&quot;z-punctuation z-definition z-string z-end z-python&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
            &lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-python&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-python&quot;&gt;available on your PYTHONPATH environment variable? Did you &lt;span class=&quot;z-punctuation z-definition z-string z-end z-python&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
            &lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-python&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-double z-python&quot;&gt;forget to activate a virtual environment?&lt;span class=&quot;z-punctuation z-definition z-string z-end z-python&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
        &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-statement z-raise z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-flow z-raise z-from z-python&quot;&gt;from&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-statement z-raise z-python&quot;&gt; &lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;exc&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;execute_from_command_line&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;sys&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-accessor z-dot z-python&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;argv&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;


&lt;span class=&quot;z-meta z-statement z-conditional z-if z-python&quot;&gt;&lt;span class=&quot;z-keyword z-control z-conditional z-if z-python&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-support z-variable z-magic z-python&quot;&gt;__name__&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-comparison z-python&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-string z-python&quot;&gt;&lt;span class=&quot;z-string z-quoted z-single z-python&quot;&gt;__main__&lt;span class=&quot;z-punctuation z-definition z-string z-end z-python&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-block z-conditional z-if z-python&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-meta z-function-call z-python&quot;&gt;&lt;span class=&quot;z-meta z-qualified-name z-python&quot;&gt;&lt;span class=&quot;z-variable z-function z-python&quot;&gt;&lt;span class=&quot;z-meta z-generic-name z-python&quot;&gt;main&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-python&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-python&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-python&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;So it’s obviously getting some more code under the hood, but I’m starting to think it has super powers. It starts projects and apps, it makes users, it runs migrations and tests as well as the local server. For something that hasn’t even really been mentioned other than a line of text to type into the CLI my curiosity is definitely rising. Unfortunately &lt;code&gt;python manage.py makecoffee&#x27; is the only thing that hasn&#x27;t worked so far. What are your favourite powers of &lt;&#x2F;code&gt;manage.py`?&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Building my first Django project with pages</title>
        <published>2020-06-03T00:00:00+00:00</published>
        <updated>2020-06-03T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/building-my-first-django-project-with-pages-kjn/" type="text/html"/>
        <id>https://www.daveparr.info/blog/building-my-first-django-project-with-pages-kjn/</id>
        
        <content type="html">&lt;p&gt;I’m working through &lt;a href=&quot;https:&#x2F;&#x2F;djangoforbeginners.com&#x2F;&quot;&gt;Django for Beginners by William S. Vincent&lt;&#x2F;a&gt;. Chapter 3 starts using templates and introduces Class-Based Views.&lt;&#x2F;p&gt;
&lt;p&gt;There is a section introducing Class-Based views, and then mentioning older Function-Based views. It was interesting to see this evidence of the framework progressing, though it’s not so surprising for something that’s a decade or so old!&lt;&#x2F;p&gt;
&lt;p&gt;The templating syntax was really neat. I’d seen very similar in Hugo and Jekyll, and so the idea of having a kind of ‘placeholder’ with &lt;code&gt;“{% block content %}{% endblock content %}&lt;&#x2F;code&gt; was nice to use. I’ve admittedly done very little webdev though. I was curious what other approaches might be common alternatives? If you have an example please let me know in the comments!&lt;&#x2F;p&gt;
&lt;p&gt;Something that was curious to me was the inversion of structure in django vs hugo.&lt;&#x2F;p&gt;
&lt;p&gt;In hugo, I’ve very regularly used partials such as in &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;satRdays&#x2F;hugo-satrdays-theme&#x2F;blob&#x2F;cfc0873e03a7f278f8e09227875affbfcc50169f&#x2F;layouts&#x2F;index.html&quot;&gt;the SatRdays theme here&lt;&#x2F;a&gt;. Here, I have a single home page with my headers and footers, and ‘inject’ a partial into it with &lt;code&gt;{{ partial &amp;quot;nav.html&amp;quot; . }}&lt;&#x2F;code&gt;. In django I feel like it kind of works the other way. We create a project, and then the equivalent to a hugo partial would actually be a django app within the project? Then, each app shares top level content through lines like &lt;code&gt;{% extends &#x27;base.html&#x27; %}&lt;&#x2F;code&gt; within each apps template?&lt;&#x2F;p&gt;
&lt;p&gt;It seems like it might be more brittle to me, but maybe also more powerful? There’s more duplicate lines to get wrong, but also more opportunities to vary what it does?&lt;&#x2F;p&gt;
&lt;p&gt;What do veteran djangians(is that right?) think? Does anyone use both Hugo and Django, but for different projects and for specific reasons?&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Testing my dev.to API package with testthat, webmockr and vcr</title>
        <published>2020-06-03T00:00:00+00:00</published>
        <updated>2020-06-03T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/testing-my-dev-to-api-package-with-testthat-webmockr-and-vcr-2dgm/" type="text/html"/>
        <id>https://www.daveparr.info/blog/testing-my-dev-to-api-package-with-testthat-webmockr-and-vcr-2dgm/</id>
        
        <content type="html">&lt;p&gt;I’ve been working on an &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;dev.to.ol&quot;&gt;open source R package wrapping the dev.to
API&lt;&#x2F;a&gt;. After a bit of prototyping
the core feature and then some iterative development to make it a bit
more useful to a user, it’s starting to settle into something that is
worth testing\*.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;testing-in-r&quot;&gt;Testing in R&lt;&#x2F;h2&gt;
&lt;p&gt;Sometimes people seem a little surprised that this is something R users&#x2F;
Data Scientists even think about, but R is a programming language, just
like all the others, except different, just like all the others. Testing
in modern tidyverse R is usually accomplished by the
&lt;a href=&quot;https:&#x2F;&#x2F;testthat.r-lib.org&#x2F;&quot;&gt;&lt;code&gt;testthat&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; package. If you are more
familiar with testing in other languages, this quote from the Overview
might help:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;testthat draws inspiration from the xUnit family of testing packages, as well as from many of the innovative ruby testing libraries, like rspec, testy, bacon and cucumber.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h3 id=&quot;a-note-on-usethis&quot;&gt;A note on &lt;code&gt;usethis&lt;&#x2F;code&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;In R we have a rich ecosystem of developer tools to help us make
packages. &lt;code&gt;testthat&lt;&#x2F;code&gt; is one. Another one is &lt;code&gt;usethis&lt;&#x2F;code&gt;. See what they did
there? Anyway, for the purpose of this article, you just need to know
that a package called &lt;code&gt;usethis&lt;&#x2F;code&gt; helps us set up things for us to make
development easier. In the future I might write something more about it
¯_(ツ)_&#x2F;¯.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;testthat&quot;&gt;&lt;code&gt;testthat&lt;&#x2F;code&gt;&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;setting-up-testthat&quot;&gt;Setting up &lt;code&gt;testthat&lt;&#x2F;code&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Assuming that you have a well formatted R Package structure, you can
easily enable a testing framework and all the boiler plate you might
need with one line:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;usethis&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;use_testthat&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Which will do a few things for you and tell you what it’s doing.
&lt;div class=&quot;crt scanlines&quot;&gt;
  &lt;pre data-lang=&quot;sh&quot; class=&quot;language-sh z-code&quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;✔&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Setting active project to &lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&#x2F;Users&#x2F;davidparr&#x2F;Documents&#x2F;example.testthat&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;✔&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Adding &lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;testthat&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; to Suggests field in DESCRIPTION&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;✔&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Creating &lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;tests&#x2F;testthat&#x2F;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;✔&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Writing &lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;tests&#x2F;testthat.R&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;●&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Call &lt;span class=&quot;z-meta z-group z-expansion z-command z-backticks z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-shell&quot;&gt;`&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-shell&quot;&gt;&lt;span class=&quot;z-entity z-name z-function z-shell&quot;&gt;use_test&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-shell&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-shell&quot;&gt;)&lt;&#x2F;span&gt;` to initialize a basic test file and open it for editing.
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;

&lt;&#x2F;div&gt;
&lt;&#x2F;p&gt;
&lt;p&gt;From there, we can use &lt;code&gt;usethis::use_test()&lt;&#x2F;code&gt;. If you have a file open in
RStudio which is an &lt;code&gt;*.R&lt;&#x2F;code&gt; file containing function definitions it will
then make a new test file for you:&lt;&#x2F;p&gt;
&lt;div class=&quot;crt scanlines&quot;&gt;
  &lt;pre data-lang=&quot;sh&quot; class=&quot;language-sh z-code&quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;✔&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Increasing &lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;testthat&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; version to &lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&amp;gt;= 2.1.0&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; in DESCRIPTION&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;✔&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Writing &lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;tests&#x2F;testthat&#x2F;test-hello.R&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;●&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Modify &lt;span class=&quot;z-string z-quoted z-single z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;tests&#x2F;testthat&#x2F;test-hello.R&lt;span class=&quot;z-punctuation z-definition z-string z-end z-shell&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;

&lt;&#x2F;div&gt;
&lt;p&gt;The contents of that test file will be silly boilerplate, so now it’s
time to do some real work.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;writing-a-testthat-test&quot;&gt;Writing a &lt;code&gt;testthat&lt;&#x2F;code&gt; test&lt;&#x2F;h3&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;test_that&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;multiplication works&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;expect_equal&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;2&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;*&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;4&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This is the boilerplate. If you run it, you might be surprised that
nothing happens! Well, actually a lot of stuff happens, but it doesn’t
really tell you about it by design. If you make a test that isn’t going
to pass however…&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;test_that&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;maths works&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;expect_equal&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;2&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;*&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;5&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;div class=&quot;crt scanlines&quot;&gt;
  &lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;## Error: Test failed: &amp;#39;maths works&amp;#39;
## * &amp;lt;text&amp;gt;:2: 2 * 2 not equal to 5.
## 1&#x2F;1 mismatches
## [1] 4 - 5 == -1
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;

&lt;&#x2F;div&gt;

An error! Just what we wanted! so this is the basis of testing with
&lt;code&gt;testthat&lt;&#x2F;code&gt;. Write a &lt;code&gt;test_that()&lt;&#x2F;code&gt; function, which has a name, and then a
block of expectations to check against.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;webmockr&quot;&gt;&lt;code&gt;webmockr&lt;&#x2F;code&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;So this works fine for traditional unit tests, where we can give
discrete calculations, or check that a given function gives a specific
output end to end, where we control both the test, but also the function
as a whole. But what if we’re reliant on some ‘external’ process that we
might not control. The dev.to API for instance? I’m not employed by
dev.to (through I am &lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;daveparr&#x2F;i-made-my-dev-to-content-into-a-website-to-find-a-new-job-2kn5&quot;&gt;looking for a new
opportunity&lt;&#x2F;a&gt;),
so I don’t get to play around inside the API system, but I do need to
prove that any code I write will behave the way I want it to based on
their API requests and responses. A simple way to prove this is to
&lt;em&gt;mock&lt;&#x2F;em&gt; their service (i.e. impersonate it, not tell it it’s silly). This
is where &lt;a href=&quot;https:&#x2F;&#x2F;docs.ropensci.org&#x2F;webmockr&#x2F;&quot;&gt;&lt;code&gt;webmockr&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; comes in.
&lt;code&gt;webmockr&lt;&#x2F;code&gt; is an:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;“R library for stubbing and setting expectations on HTTP requests”&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Perfect. Let’s write something using both &lt;code&gt;testthat&lt;&#x2F;code&gt; and &lt;code&gt;webmockr&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;writing-a-webmockr-test&quot;&gt;Writing a &lt;code&gt;webmockr&lt;&#x2F;code&gt; test&lt;&#x2F;h3&gt;
&lt;p&gt;In &lt;code&gt;webmockr&lt;&#x2F;code&gt; we make &lt;em&gt;stubs&lt;&#x2F;em&gt;. These are fake, minimal objects that are
similar to test fixtures. We know their properties, because we made
them, and we want to make sure that any functions we write interact with
these objects in a predictable way. Another way of looking at them is as
a fake API. They look like an API, with responses and status codes, but
they only exist in our test suite. This means I don’t need to bombard
dev.to with requests any more to make sure I haven’t broken anything.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;webmockr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;enable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;adapter&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;httr&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

webmockr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;stub_registry_clear&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

webmockr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;stub_request&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;get&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;https:&#x2F;&#x2F;dev.to&#x2F;api&#x2F;users&#x2F;me&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  webmockr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;to_return&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;body&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;success!&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;status&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;200&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

my_user &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; dev.to.ol&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;get_my_user&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;test_that&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;stubbed response is 200&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;expect_is&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;my_user&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;response&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;expect_equal&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;my_user&lt;span class=&quot;z-keyword z-accessor z-dollar z-r&quot;&gt;$&lt;&#x2F;span&gt;status_code&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;200&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This code first of all sets up our test file to understand that requests
will be sent as if from the &lt;code&gt;httr&lt;&#x2F;code&gt; package. It then clears the registry,
just to make sure nothing is left in a cache. It then populates the now
empty cache with a new stub. This stub will respond to a &lt;code&gt;GET&lt;&#x2F;code&gt; request
to the URL, and will return a simple text body, and a 200 status code.
The function I want to test is then run, which in this environment hits
the &lt;em&gt;stub&lt;&#x2F;em&gt;, not the real api. The object that is returned is then
checked by &lt;code&gt;test_that&lt;&#x2F;code&gt; to make sure it is a &lt;code&gt;response&lt;&#x2F;code&gt; type object, and
that is has a status code that has the value 200.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;good-enough-but-is-it-actually-enough&quot;&gt;Good enough, but is it actually enough?&lt;&#x2F;h3&gt;
&lt;p&gt;This proves a few, specific things. That the function returns a
&lt;code&gt;response&lt;&#x2F;code&gt; that has a 200 status code if it trys to &lt;code&gt;GET&lt;&#x2F;code&gt; from that
specific URL. However, APIs actually return quite a lot of information
by default and maybe I care about more things than a 200 status code.
They can also have quite complex structures, so using this method to
make a fake response could get &lt;em&gt;very&lt;&#x2F;em&gt; awkward if I am trying to make a
realistic response. Also, what if the structure of the api changes
underneath us? It is in beta after all. A big change would mean all
those carefully written pipes would have to be rewritten by me every
time. Blergh. Luckily we have a solution for that too!&lt;&#x2F;p&gt;
&lt;h2 id=&quot;vcr&quot;&gt;&lt;code&gt;vcr&lt;&#x2F;code&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;docs.ropensci.org&#x2F;vcr&#x2F;&quot;&gt;&lt;code&gt;vcr&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; does not stand for &lt;code&gt;Very Cool Responses&lt;&#x2F;code&gt;, but I think it should. From it’s own description:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Record HTTP calls and replay them&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;It’s an R port of a ruby gem of the same name, this package allows you
to ‘record’ the response of an API to a YAML file ‘cassette’. You can
then ‘play’ the ‘cassette’ back during the test as if the API was being
actually called. If you’re still not sure where the name comes from,
then you might be a little to young to &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;TheEllenShow&#x2F;status&#x2F;1116056186606850048&quot;&gt;get the
reference&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;setting-up-vcr&quot;&gt;Setting up &lt;code&gt;vcr&lt;&#x2F;code&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;code&gt;vcr&lt;&#x2F;code&gt; has a few things it needs in a project to run, and though it
doesn’t have its &lt;em&gt;own&lt;&#x2F;em&gt; entry in &lt;code&gt;usethis&lt;&#x2F;code&gt;, it does have it’s own
set-up function in a similar style:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;vcr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;use_vcr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;div class=&quot;crt scanlines&quot;&gt;
  &lt;pre data-lang=&quot;sh&quot; class=&quot;language-sh z-code&quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span class=&quot;z-source z-shell z-bash&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;◉&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Using package: vcr.example  &lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;◉&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; assuming fixtures at: tests&#x2F;fixtures  &lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;✓&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Adding vcr to Suggests field in DESCRIPTION  &lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;✓&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Creating directory: .&#x2F;tests&#x2F;testthat  &lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;◉&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Looking for testthat.R file or similar  &lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;✓&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; tests&#x2F;testthat.R: added  &lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;✓&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Adding vcr config to tests&#x2F;testthat&#x2F;helper-vcr.example.R  &lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;✓&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Adding example test file tests&#x2F;testthat&#x2F;test-vcr_example.R  &lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;✓&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; .gitattributes: added  &lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;◉&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-shell&quot;&gt; Learn more about &lt;span class=&quot;z-meta z-group z-expansion z-command z-backticks z-shell&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-group z-begin z-shell&quot;&gt;`&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-shell&quot;&gt;&lt;span class=&quot;z-variable z-function z-shell&quot;&gt;vcr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-group z-end z-shell&quot;&gt;`&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;: https:&#x2F;&#x2F;books.ropensci.org&#x2F;http-testing&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;

&lt;&#x2F;div&gt;
&lt;p&gt;From there, we can use the normal &lt;code&gt;testthat&lt;&#x2F;code&gt; flow. Here’s an example
using the &lt;code&gt;POST&lt;&#x2F;code&gt; to write a new article.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;test_that&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;post new article&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
  vcr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;use_cassette&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;post_new_article&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
    new_article &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; dev.to.ol&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;post_new_article&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;file&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;.&#x2F;test.Rmd&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;expect_is&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;new_article&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;response&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;expect_equal&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;new_article&lt;span class=&quot;z-keyword z-accessor z-dollar z-r&quot;&gt;$&lt;&#x2F;span&gt;status_code&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;201&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Well, that’s an easy change! The only difference from the first test is
that we have wrapped the function we are testing in a &lt;code&gt;use_cassette&lt;&#x2F;code&gt;
block, inside the &lt;code&gt;test_that&lt;&#x2F;code&gt; block. Now, the first time this function
is run, you &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;dev.to.ol&#x2F;blob&#x2F;master&#x2F;tests&#x2F;fixtures&#x2F;post_new_article.yml&quot;&gt;get
this&lt;&#x2F;a&gt;.
A huge YAML file that describes the response of the actual API. Now,
every time the test is run, that cassette will get loaded as the ‘mock’,
and it’s so much more developed than our stub! We can test against
anything we want in the response, and even better, the response is
totally human readable.&lt;&#x2F;p&gt;
&lt;p&gt;What about changes? What happens if you make a change to the data you
use to test the function that invalidates the &lt;code&gt;cassette&lt;&#x2F;code&gt;? What if the
dev.to spec changes? Easy, all you do is delete the test and re-run. The
function will then go and get a new response, and populate the file
again. Your tests then run against the new file. You can even commit
these to version control. Then you can tell exactly when an API change
occurred, and what was different afterwards.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;thanks-scott&quot;&gt;Thanks Scott&lt;&#x2F;h2&gt;
&lt;p&gt;Both the &lt;code&gt;webmockr&lt;&#x2F;code&gt; and &lt;code&gt;vcr&lt;&#x2F;code&gt; packages are being maintained by @sckott,
who is an active writer here on dev.to. and I think he’s really worth a
follow. He also works on &lt;a href=&quot;https:&#x2F;&#x2F;ropensci.org&#x2F;&quot;&gt;ROpenSci&lt;&#x2F;a&gt;, which I
think is also a really cool project. If you are working with R on a
scientific&#x2F;research project you should be extra interested.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Yes, I know that TDD exists. IMHO: No, I don’t think it’s a bad thing, but also no, I don’t think it’s always something to use everywhere all the time.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Building my first Django project</title>
        <published>2020-06-01T00:00:00+00:00</published>
        <updated>2020-06-01T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/building-my-first-django-project-4fi3/" type="text/html"/>
        <id>https://www.daveparr.info/blog/building-my-first-django-project-4fi3/</id>
        
        <content type="html">&lt;p&gt;I’m working through &lt;a href=&quot;https:&#x2F;&#x2F;djangoforbeginners.com&#x2F;&quot;&gt;Django for Beginners by William S. Vincent&lt;&#x2F;a&gt;. The second chapter gets us into developing our first app. It simply displays a single page with an unformatted Hello World on it, but I really appreciated how the project is so fully fleshed out end to end. You start a project with a clean &lt;code&gt;pipenv&lt;&#x2F;code&gt;, and make the files and folders through the CLI. The django framework provides some really nice methods to ‘boilerplate’ the multiple files needed in each project, and having this introduced at the start and then fill in the details later when you are hands on is definitely the best way to go.&lt;&#x2F;p&gt;
&lt;p&gt;Introducing migrations and the url-view-model[-template] core concepts was pretty simple in practice, though a little confusing initially. “I’ve just made a bunch of files with this single &lt;code&gt;startapp&lt;&#x2F;code&gt; command, what do they all do?” was admittedly my first reaction. &lt;&#x2F;p&gt;
&lt;p&gt;The best part of the way this book is set up is the definition of done used in the core workflow. A project isn’t done unless it has a commit history, is hosted on GitHub and deployed on Heroku. I’m really a fan of approaching deployment in Chapter 2, just like version control and dev environments in Chapter 1. These concepts are your friends, not your monsters :)&lt;&#x2F;p&gt;
&lt;p&gt;Incidentally, having only been aware of Heroku in passing, I really like the PAAS set up. Very usable, the cli tools make the whole thing a doddle and the end satisfaction of being able to point at something that’s actually on the web and say ‘I did that!’ is always a little more satisfying than ‘It works on my machine?’.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Setting up a Django dev environment</title>
        <published>2020-05-27T00:00:00+00:00</published>
        <updated>2020-05-27T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/setting-up-a-django-dev-environment-17b7/" type="text/html"/>
        <id>https://www.daveparr.info/blog/setting-up-a-django-dev-environment-17b7/</id>
        
        <content type="html">&lt;p&gt;I’m working through &lt;a href=&quot;https:&#x2F;&#x2F;djangoforbeginners.com&#x2F;&quot;&gt;Django for Beginners by William S. Vincent&lt;&#x2F;a&gt;. The first part is about setting up your dev environment. The book is setup to start for a &lt;em&gt;complete&lt;&#x2F;em&gt; beginner level, which is really nice. It starts from introducing the basics of the CLI for both Mac and Windows systems, and then some simple terminal commands with &lt;code&gt;cd&lt;&#x2F;code&gt;, &lt;code&gt;ls&lt;&#x2F;code&gt; etc.&lt;&#x2F;p&gt;
&lt;p&gt;It then goes on to help with installation of Python3, &lt;code&gt;git&lt;&#x2F;code&gt;, &lt;code&gt;pipenv&lt;&#x2F;code&gt; and &lt;code&gt;django&lt;&#x2F;code&gt;, all great stuff for getting started, plus it set’s a great baseline for the rest of the book.&lt;&#x2F;p&gt;
&lt;p&gt;For anyone who has worked at all with terminals, version control, isolating environments and code editors, 90% of this will be already done on the machine, but I still think it’s worth putting in. Having it laid out for you at the start of your programming experience that version control and the terminal are part of the process I think helps with the hump I’ve seen in more experienced beginners where &lt;code&gt;git&lt;&#x2F;code&gt; and &lt;code&gt;pipenv&lt;&#x2F;code&gt; are Yet Another Thing To Learn and so get pushed back in the learning pathway more out of fear than anything else.&lt;&#x2F;p&gt;
&lt;p&gt;Personally, I zipped through the setup in a few minutes. Hello World django app next!&lt;&#x2F;p&gt;
&lt;p&gt;Has anyone else seen the ‘git is yet another thing to learn’ hump? Maybe even had it? How did you overcome it?&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>I made my dev.to content into a website to find a new job</title>
        <published>2020-05-25T00:00:00+00:00</published>
        <updated>2020-05-25T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/i-made-my-dev-to-content-into-a-website-to-find-a-new-job-2kn5/" type="text/html"/>
        <id>https://www.daveparr.info/blog/i-made-my-dev-to-content-into-a-website-to-find-a-new-job-2kn5/</id>
        
        <content type="html">&lt;p&gt;After discovering &lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;stackbit&#x2F;project-benatar-publishing-dev-powered-websites-with-stackbit-lfo&quot;&gt;this post&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;devteam&#x2F;you-can-now-generate-self-hostable-static-blogs-right-from-your-dev-content-via-stackbit-7a5&quot;&gt;this post&lt;&#x2F;a&gt;, I decided to use this tooling to get a very simple job done to help me look for work.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;context&quot;&gt;Context&lt;&#x2F;h2&gt;
&lt;p&gt;I’ve been using dev.to a little over the last year, and a lot more over the last month. It makes sense for me to use this content in my job hunt. I also had a languishing personal page. Originally made as a little experiment with hugo, it hadn’t seen love in a while, and due to some jankey usage of high quality photos performance wise it was pretty bad. I’d been meaning to overhaul it for a while, and when the dev.to x stackbit collab came to my attention, it was a perfect fit.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;goals&quot;&gt;Goals&lt;&#x2F;h2&gt;
&lt;ol&gt;
&lt;li&gt;Use the content I’ve written, and will be continuing to write, to prove I know at least a few things about programming.&lt;&#x2F;li&gt;
&lt;li&gt;Get that content wrapped up neatly with a contact page, a statement that I’m looking for work, and a brief about me&lt;&#x2F;li&gt;
&lt;li&gt;Use my daveparr.info domain&lt;&#x2F;li&gt;
&lt;li&gt;Make the website more performant than it’s current iteration&lt;&#x2F;li&gt;
&lt;li&gt;Use a clean, simple, slightly professional theme&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h2 id=&quot;method&quot;&gt;Method&lt;&#x2F;h2&gt;
&lt;ol&gt;
&lt;li&gt;Read the instructions in @ben ’s &lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;devteam&#x2F;you-can-now-generate-self-hostable-static-blogs-right-from-your-dev-content-via-stackbit-7a5&quot;&gt;post&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Go through the creation flow&lt;&#x2F;li&gt;
&lt;li&gt;Assign the domain in netlify (I had a netlify hosted JAMstack previously, and my domain was already loaded in there. YMMV)&lt;&#x2F;li&gt;
&lt;li&gt;Clone the project @stackbit created from GitHub, and follow the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;daveparrinfo&#x2F;blob&#x2F;master&#x2F;README.md&quot;&gt;readme&lt;&#x2F;a&gt; they left there to help you authenticate correctly&lt;&#x2F;li&gt;
&lt;li&gt;Update the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;daveparrinfo&#x2F;commit&#x2F;d8836e723d49ccd13f5655e7f58346dfa4ade17f&quot;&gt;boilerplate stuff&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Push the changes back to GitHub&lt;&#x2F;li&gt;
&lt;li&gt;Profit&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h2 id=&quot;hiccup&quot;&gt;Hiccup&lt;&#x2F;h2&gt;
&lt;p&gt;I was a little surprised when my local copy suddenly got all my blog files &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;daveparrinfo&#x2F;commit&#x2F;1987c701187b45a85d8b0448a8c577c47ab8b2ac&quot;&gt;that I then just commited&lt;&#x2F;a&gt;, but that seemed to be ok. Pretty sure I’ve not broken anything :)&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-end&quot;&gt;The End&lt;&#x2F;h2&gt;
&lt;p&gt;Goals achieved, faster website, with better styling, that will be kept more up to date.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;p-s&quot;&gt;P.S.&lt;&#x2F;h2&gt;
&lt;p&gt;If you are reading this &lt;em&gt;on&lt;&#x2F;em&gt; my &lt;a href=&quot;https:&#x2F;&#x2F;www.daveparr.info&#x2F;blog&#x2F;i-made-my-dev-to-content-into-a-website-to-find-a-new-job-2kn5&#x2F;daveparr.info&quot;&gt;website&lt;&#x2F;a&gt;, this is all actually managed through a headless CMS called &lt;a href=&quot;https:&#x2F;&#x2F;www.daveparr.info&#x2F;blog&#x2F;i-made-my-dev-to-content-into-a-website-to-find-a-new-job-2kn5&#x2F;dev.to&quot;&gt;dev.to&lt;&#x2F;a&gt;. You can use the link to my profile on the left of this article. If you are reading this on dev.to you can see my running website at &lt;a href=&quot;https:&#x2F;&#x2F;www.daveparr.info&#x2F;blog&#x2F;i-made-my-dev-to-content-into-a-website-to-find-a-new-job-2kn5&#x2F;daveparr.info&quot;&gt;daveparr.info&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Posting straight from Rmd to DEV.TO (for real this time)</title>
        <published>2020-05-24T00:00:00+00:00</published>
        <updated>2020-05-24T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/posting-straight-from-rmd-to-dev-to-1j4p/" type="text/html"/>
        <id>https://www.daveparr.info/blog/posting-straight-from-rmd-to-dev-to-1j4p/</id>
        
        <content type="html">&lt;p&gt;I’ve spent a little time fleshing out my &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;dev.to.ol&quot;&gt;open source R package&lt;&#x2F;a&gt; to post from &lt;code&gt;.Rmd&lt;&#x2F;code&gt;
straight to dev.to.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;update-from-v1&quot;&gt;Update from V1&lt;&#x2F;h2&gt;
&lt;p&gt;The biggest difference from the &lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;daveparr&#x2F;posting-from-rmd-to-dev-to-5gld&quot;&gt;first version&lt;&#x2F;a&gt; is
that there is now a single function to move straight from an &lt;code&gt;.Rmd&lt;&#x2F;code&gt; on
disk to a post on dev.to. In V1 the user still had to:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Write an &lt;code&gt;.Rmd&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;knit&lt;&#x2F;code&gt; to &lt;code&gt;github_document&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;post_new_article&lt;&#x2F;code&gt; using my &lt;code&gt;dev.to.ol&lt;&#x2F;code&gt; package&lt;&#x2F;li&gt;
&lt;li&gt;De-duplicate the title&lt;&#x2F;li&gt;
&lt;li&gt;(Optionally) Add meta-data&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;With this new function the workflow is:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Write an &lt;code&gt;.Rmd&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;post_new_article&lt;&#x2F;code&gt; using my &lt;code&gt;dev.to.ol&lt;&#x2F;code&gt; package&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;🎉&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@title&lt;&#x2F;span&gt; Post a markdown file to dev.to
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@description&lt;&#x2F;span&gt; Create a new post from an .Rmd.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@param&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;file&lt;&#x2F;span&gt; The path to the file
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@param&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;key&lt;&#x2F;span&gt; Your API key, Default: NA
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@return&lt;&#x2F;span&gt; The response
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@details&lt;&#x2F;span&gt; Will look for an api key in the `.REnviron` file. Seems to check if the body is identical to a previous article and error if so with `&amp;quot;Body markdown has already been taken&amp;quot;`.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; The following YAML arguments are read from the file YAML frontmatter if present:
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; \describe{
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;   \item{title}{A character string}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;   \item{series}{A character string}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;   \item{published}{A boolean}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;   \item{tags}{list of character strings: \code{[&amp;quot;tag1&amp;quot;, &amp;quot;tag2&amp;quot;]}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; }
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; The default table output method renders a very large print code block.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; The workaround is to use  \code{\link[knitr]{kable}}.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@examples&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; \dontrun{
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; if(interactive()){
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  post_new_article(&amp;quot;.&#x2F;articles&#x2F;my_article.Rmd&amp;quot;)
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  }
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; }
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@seealso&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  \code{\link[rmarkdown]{yaml_front_matter}},\code{\link[rmarkdown]{render}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  \code{\link[readr]{read_file}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  \code{\link[stringr]{str_remove}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  \code{\link[glue]{glue}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  \code{\link[httr]{POST}},\code{\link[httr]{add_headers}},\code{\link[httr]{content}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@rdname&lt;&#x2F;span&gt; post_new_article
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@export&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; rmarkdown yaml_front_matter render
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; readr read_file
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; stringr str_remove
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; glue glue
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; httr POST add_headers content
&lt;&#x2F;span&gt;
post_new_article &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function z-r&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-r&quot;&gt;function&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;file&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-parameters z-r&quot;&gt;,&lt;&#x2F;span&gt;
           &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;key&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-language z-r&quot;&gt;NA&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
    check_file &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;is_postable_Rmd&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;file&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

    &lt;span class=&quot;z-keyword z-control z-conditional z-if z-r&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-parens z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;check_file&lt;span class=&quot;z-punctuation z-section z-parens z-end z-r&quot;&gt;)&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
      file_frontmatter &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; rmarkdown&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;yaml_front_matter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;file&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

      output_path &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; rmarkdown&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;render&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;.&#x2F;data&#x2F;test.Rmd&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
                                       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;output_format&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-single z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;github_document&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
                                       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;output_dir&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;getwd&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

      file_string &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; readr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;read_file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;output_path&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; %\u003e%
        stringr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;str_remove&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;glue&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;glue&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;{title}&lt;span class=&quot;z-constant z-character z-escape z-r&quot;&gt;\n&lt;&#x2F;span&gt;================&lt;span class=&quot;z-constant z-character z-escape z-r&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape z-r&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape z-r&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
                                       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; file_frontmatter&lt;span class=&quot;z-keyword z-accessor z-dollar z-r&quot;&gt;$&lt;&#x2F;span&gt;title&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

      response &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; httr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;POST&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
        &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;url&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;https:&#x2F;&#x2F;dev.to&#x2F;api&#x2F;articles&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
        httr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;add_headers&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;api-key&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;api_key&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;key&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; key&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
        &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;body&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-storage z-type z-r&quot;&gt;list&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
          &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;article&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-storage z-type z-r&quot;&gt;list&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
            &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; file_frontmatter&lt;span class=&quot;z-keyword z-accessor z-dollar z-r&quot;&gt;$&lt;&#x2F;span&gt;title&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
            &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;series&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; file_frontmatter&lt;span class=&quot;z-keyword z-accessor z-dollar z-r&quot;&gt;$&lt;&#x2F;span&gt;series&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
            &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;published&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; file_frontmatter&lt;span class=&quot;z-keyword z-accessor z-dollar z-r&quot;&gt;$&lt;&#x2F;span&gt;published&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
            &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;tags&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; file_frontmatter&lt;span class=&quot;z-keyword z-accessor z-dollar z-r&quot;&gt;$&lt;&#x2F;span&gt;tags&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
            &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;body_markdown&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; file_string
          &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
        &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
        &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;encode&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-single z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;json&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
      &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
      httr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;content&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;response&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-conditional z-else z-r&quot;&gt;else&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
      &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;message&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;attr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;check_file&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;msg&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;notable-changes&quot;&gt;Notable changes&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;extract-yaml-frontmatter-and-render-from-rmd-with-rmarkdown&quot;&gt;Extract &lt;code&gt;YAML&lt;&#x2F;code&gt; frontmatter and render from &lt;code&gt;.Rmd&lt;&#x2F;code&gt; with &lt;a href=&quot;https:&#x2F;&#x2F;rmarkdown.rstudio.com&#x2F;&quot;&gt;&lt;code&gt;rmarkdown&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;The function will now accept an &lt;code&gt;.Rmd&lt;&#x2F;code&gt; file directly which it renders to
the correct markdown output internally. This was the biggest part
missing from V1, and was easy to do with &lt;code&gt;rmarkdown::render&lt;&#x2F;code&gt;. A great
side-effect is that I can also access the &lt;code&gt;YAML&lt;&#x2F;code&gt; frontmatter of the
&lt;code&gt;.Rmd&lt;&#x2F;code&gt;, which I can use to populate the meta-data such as the series the
post is in, the tags the post is relevant to, and the published status.&lt;&#x2F;p&gt;
&lt;p&gt;### Check file is suitable with
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;hadley&#x2F;assertthat&quot;&gt;&lt;code&gt;assertthat&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Another benefit is that there is now a concrete object I can check for
correctness. I’ve adopted the &lt;code&gt;assertthat&lt;&#x2F;code&gt; package to help me, and most
of the work was &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;dev.to.ol&#x2F;commit&#x2F;ddccf8ce60adf2bc35ed61d0c0ae581a9189d32d&quot;&gt;done in this
commit&lt;&#x2F;a&gt;.
The workhorse function is
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;dev.to.ol&#x2F;blob&#x2F;master&#x2F;R&#x2F;is_postable_Rmd.R&quot;&gt;&lt;code&gt;is_postable_Rmd&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function z-name z-r&quot;&gt;&lt;span class=&quot;z-entity z-name z-function z-r&quot;&gt;is_postable_Rmd&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-r&quot;&gt;&lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-r&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-r&quot;&gt;function&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;file&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
    assertthat&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;see_if&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
    assertthat&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;is.readable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;file&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    assertthat&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;has_extension&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;file&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Rmd&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Using &lt;code&gt;assertthat::see_if&lt;&#x2F;code&gt; was really useful. It allowed me to check for
multiple conditions, and if they were both passed, it returns &lt;code&gt;TRUE&lt;&#x2F;code&gt;.
However, if they did not pass, it returns &lt;code&gt;FALSE&lt;&#x2F;code&gt; &lt;em&gt;as well as a message
attribute&lt;&#x2F;em&gt;. This meant that I could very trivially plumb that back into
the main function for user feedback as to what is the problem with the
line &lt;code&gt;message(attr(check_file, &amp;quot;msg&amp;quot;))&lt;&#x2F;code&gt;. Additionally, as I add criteria
to the function I know they will all return human, well formatted error
messages. Great work &lt;code&gt;assertthat&lt;&#x2F;code&gt;!&lt;&#x2F;p&gt;
&lt;h3 id=&quot;deduplicate-the-title-with-glue-and-stringr&quot;&gt;Deduplicate the title with &lt;a href=&quot;https:&#x2F;&#x2F;glue.tidyverse.org&#x2F;&quot;&gt;&lt;code&gt;glue&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;stringr.tidyverse.org&#x2F;&quot;&gt;&lt;code&gt;stringr&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;One of the issues with the original approach was the call to render will
generate an &lt;code&gt;.md&lt;&#x2F;code&gt; with a title &lt;em&gt;in the file&lt;&#x2F;em&gt;, but the dev.to api wants
the title &lt;em&gt;as a separate part of the call&lt;&#x2F;em&gt;. &lt;code&gt;stringr&lt;&#x2F;code&gt; and &lt;code&gt;glue&lt;&#x2F;code&gt; to the
rescue! Using &lt;code&gt;glue&lt;&#x2F;code&gt; is basically a super powered paste. It does nice
things to insert named string variables into a templated string. I use
this to make the string that is what I want to &lt;em&gt;remove&lt;&#x2F;em&gt; from the
&lt;code&gt;body_markdown&lt;&#x2F;code&gt; object, and then do the actual removal with
&lt;code&gt;str_remove&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;next-steps&quot;&gt;Next steps&lt;&#x2F;h2&gt;
&lt;p&gt;Images. The real power of Rmarkdown comes from turning code into
notebooks populated with graphics representing your data science work. I
have &lt;a href=&quot;https:&#x2F;&#x2F;dev.to&#x2F;daveparr&#x2F;is-there-an-api-endpoint-to-upload-images-to-dev-to-2acd&quot;&gt;not yet found an api endpoint for
images&lt;&#x2F;a&gt;.
The POST looks like it will allow a cover image to be included, but on
the face of it I don’t think it will allow images to be inserted at
arbitrary points in the article text. Still, I’ll start there and see
where it goes!&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Posting from .Rmd to dev.to</title>
        <published>2020-05-20T00:00:00+00:00</published>
        <updated>2020-05-20T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/posting-from-rmd-to-dev-to-5gld/" type="text/html"/>
        <id>https://www.daveparr.info/blog/posting-from-rmd-to-dev-to-5gld/</id>
        
        <content type="html">&lt;p&gt;I’ve started making an R package called
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;dev.to.ol&quot;&gt;&lt;code&gt;dev.to.ol&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;. Dev.to has an &lt;a href=&quot;https:&#x2F;&#x2F;docs.dev.to&#x2F;api&#x2F;&quot;&gt;api
which is in beta&lt;&#x2F;a&gt;, which I’m using to power
the package.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;prototype&quot;&gt;Prototype&lt;&#x2F;h2&gt;
&lt;p&gt;The first function was really just to make sure I could use the api at
all. It gets all the articles for the authenticated user. What’s my most
recent articles title?&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;dev.to.ol&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
dev.to.ol&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;get_users_articles&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-item-access z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-brackets z-double z-begin z-r&quot;&gt;[[&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-item-access z-r&quot;&gt;&lt;span class=&quot;z-meta z-item-access z-arguments z-r&quot;&gt;&lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-item-access z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-brackets z-double z-end z-r&quot;&gt;]]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-accessor z-dollar z-r&quot;&gt;$&lt;&#x2F;span&gt;title
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;div class=&quot;crt scanlines&quot;&gt;
  &lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;## Using DEVTO in .Reinviron

## [1] &amp;quot;Tidy Tuesday and space to learn&amp;quot;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;

&lt;&#x2F;div&gt;
&lt;p&gt;So how does this function work?&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@title&lt;&#x2F;span&gt; get the authenticated users articles
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@description&lt;&#x2F;span&gt; Provides lots of info on your users articles
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@param&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;key&lt;&#x2F;span&gt; the api you have set up on DEV.TO
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@return&lt;&#x2F;span&gt; article stuff
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@details&lt;&#x2F;span&gt; if no key is supplied, will check for key named DEVTO in `.Renviron`
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@examples&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; \dontrun{
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; if(interactive()){
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  get_users_articles(&amp;quot;my_api_key&amp;quot;)
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  }
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; }
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@seealso&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  \code{\link[httr]{content}},\code{\link[httr]{GET}},\code{\link[httr]{add_headers}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@rdname&lt;&#x2F;span&gt; get_users_articles
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@export&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; httr content GET add_headers
&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function z-name z-r&quot;&gt;&lt;span class=&quot;z-entity z-name z-function z-r&quot;&gt;get_users_articles&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-r&quot;&gt;&lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-r&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-r&quot;&gt;function&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;key&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-language z-r&quot;&gt;NA&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
  httr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;content&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;httr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;GET&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;url&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;https:&#x2F;&#x2F;dev.to&#x2F;api&#x2F;articles&#x2F;me&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
                          httr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;add_headers&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;api-key&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt;
                                              &lt;span class=&quot;z-keyword z-control z-conditional z-if z-r&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-parens z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;is.na&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;key&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-r&quot;&gt;)&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
                                                key
                                              &lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-conditional z-else z-r&quot;&gt;else&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
                                                &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;message&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Using DEVTO in .Renviron&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
                                                &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;Sys.getenv&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;DEVTO&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
                                              &lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Very simply&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;It uses &lt;code&gt;httr&lt;&#x2F;code&gt; to do most of the work through a &lt;code&gt;GET&lt;&#x2F;code&gt; request.&lt;&#x2F;li&gt;
&lt;li&gt;It allows a user to supply their own api key as an argument.&lt;&#x2F;li&gt;
&lt;li&gt;If the user has left that argument as the default &lt;code&gt;NA&lt;&#x2F;code&gt;, it will use
the environmental variable named &lt;code&gt;DEVTO&lt;&#x2F;code&gt;. This can be set with an
&lt;code&gt;.Renviron&lt;&#x2F;code&gt; file at the project or user level that looks like this:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;!-- end list --&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;DEVTO=&amp;quot;obviouslynotmyrealkey&amp;quot;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;motivation&quot;&gt;Motivation&lt;&#x2F;h2&gt;
&lt;p&gt;So as R users, we have a great tool baked into our language: rmarkdown.
I use it for nearly everything. We also have some great tools to magnify
it’s power, such as R Notebooks, blogdown, package down and distill.
Some great R people are making the effort to put content here such as
Julia Silge (@juliasilge) and Colin Fay (@colinfay), though they are
already well established bloggers, and are publishing from their main
website through RSS. It’s a great solution for them but personally I was
looking at dev.to as a great way to &lt;em&gt;not&lt;&#x2F;em&gt; have to have a whole website.
So what do you do if you want to publish a blog, but don’t want to
actually maintain a full website? What if you also want to be able to be
part of the great dev.to community? What if you’re both of those things
and also find you have a large volume of time on your hands? You write a
package to put &lt;code&gt;.Rmd&lt;&#x2F;code&gt;s onto dev.to as simply as possible.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;workflow&quot;&gt;Workflow&lt;&#x2F;h2&gt;
&lt;p&gt;My current process is this:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Write an Rmarkdown&lt;&#x2F;li&gt;
&lt;li&gt;Render to &lt;code&gt;github_document&lt;&#x2F;code&gt; style markdown&lt;&#x2F;li&gt;
&lt;li&gt;Open the markdown file I just made&lt;&#x2F;li&gt;
&lt;li&gt;Copy and paste the output to the dev.to UI&lt;&#x2F;li&gt;
&lt;li&gt;Fill in the meta-date&lt;&#x2F;li&gt;
&lt;li&gt;Hit publish&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;An ideal process would be:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Write an Rmarkdown&lt;&#x2F;li&gt;
&lt;li&gt;Hit publish&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;Lets see, that’s…&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;removed_work &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;4&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;6&lt;&#x2F;span&gt;

scales&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;label_percent&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;removed_work&lt;span class=&quot;z-punctuation z-section z-parens z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;div class=&quot;crt scanlines&quot;&gt;
  &lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;## [1] &amp;quot;67%&amp;quot;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;

&lt;&#x2F;div&gt;
&lt;p&gt;Wow, gains&lt;&#x2F;p&gt;
&lt;h2 id=&quot;minimum-viable-function&quot;&gt;Minimum Viable Function&lt;&#x2F;h2&gt;
&lt;p&gt;So, the key piece of the package is to get a function that will jump my
markdown output from my computer onto dev.to. There are lots more bits
that I should have, but that part is the most important.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@title&lt;&#x2F;span&gt; Post a markdown file to dev.to
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@description&lt;&#x2F;span&gt; Create a new post well rendered markdown file
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@param&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;key&lt;&#x2F;span&gt; Your API key, Default: NA
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@param&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;file&lt;&#x2F;span&gt; The path to the file, Default: file
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@return&lt;&#x2F;span&gt; The response
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@details&lt;&#x2F;span&gt; Will look for an api key in the `.REnviron` file. Seems to check if the body is identical to a previous article and error if so with `&amp;quot;Body markdown has already been taken&amp;quot;`.
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@examples&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; \dontrun{
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; if(interactive()){
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  post_new_article(&amp;quot;.&#x2F;articles&#x2F;my_article.md&amp;quot;)
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  }
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; }
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@seealso&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  \code{\link[httr]{POST}},\code{\link[httr]{add_headers}},\code{\link[httr]{verbose}},\code{\link[httr]{content}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt;  \code{\link[readr]{read_file}}
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@rdname&lt;&#x2F;span&gt; post_new_article
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@export&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; httr POST add_headers verbose content
&lt;&#x2F;span&gt;&lt;span class=&quot;z-comment z-line z-roxygen z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-r&quot;&gt;#&amp;#39;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;@importFrom&lt;&#x2F;span&gt; readr read_file
&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function z-name z-r&quot;&gt;&lt;span class=&quot;z-entity z-name z-function z-r&quot;&gt;post_new_article&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-r&quot;&gt;&lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-r&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-r&quot;&gt;function&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;key&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-language z-r&quot;&gt;NA&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-parameters z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;file&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; file&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;

  response &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; httr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;POST&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;url&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;https:&#x2F;&#x2F;dev.to&#x2F;api&#x2F;articles&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    httr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;add_headers&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;api-key&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt;
                        &lt;span class=&quot;z-keyword z-control z-conditional z-if z-r&quot;&gt;if&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-parens z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;is.na&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;key&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-r&quot;&gt;)&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
                          key
                        &lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-control z-conditional z-else z-r&quot;&gt;else&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
                          &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;message&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Using DEVTO in .Renviron&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
                          &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;Sys.getenv&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;DEVTO&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
                        &lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;body&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-storage z-type z-r&quot;&gt;list&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;article&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-storage z-type z-r&quot;&gt;list&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
      &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-single z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;title&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
      &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;body_markdown&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; readr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;read_file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;file&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; file&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;encode&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-single z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;json&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    httr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;verbose&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
  httr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;content&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;response&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Lots of similar things as the earlier function. Api key is all the same
code (don’t worry, when I have to write it a third time, I’ll abstract
it ;P). There are three key changes.&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;use &lt;code&gt;httr::POST&lt;&#x2F;code&gt; instead of &lt;code&gt;httr::GET&lt;&#x2F;code&gt; because here I’m giving the
api info, not requesting it.&lt;&#x2F;li&gt;
&lt;li&gt;use the &lt;code&gt;body&lt;&#x2F;code&gt; argument to enclose the info I am sending the api,
with a list of 1 item &lt;code&gt;article&lt;&#x2F;code&gt; which itself is a list of 2 items
&lt;code&gt;title&lt;&#x2F;code&gt; and &lt;code&gt;body_markdown&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;use &lt;code&gt;readr::read_file&lt;&#x2F;code&gt; to read the markdown file I want to post into
memory so it can be sent to the api&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h2 id=&quot;so-does-it-work&quot;&gt;So does it work?&lt;&#x2F;h2&gt;
&lt;p&gt;If you can read this, yes 🦾&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Tidy Tuesday and space to learn</title>
        <published>2020-05-19T00:00:00+00:00</published>
        <updated>2020-05-19T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/tidy-tuesday-and-space-to-learn-162o/" type="text/html"/>
        <id>https://www.daveparr.info/blog/tidy-tuesday-and-space-to-learn-162o/</id>
        
        <content type="html">&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rfordatascience&#x2F;tidytuesday&quot;&gt;TidyTusdays&lt;&#x2F;a&gt; are a
weekly R Community event where people learn about RStats by practising
with a different data set each week. Last week the &lt;a href=&quot;https:&#x2F;&#x2F;www.meetup.com&#x2F;Cardiff-R-User-Group&#x2F;&quot;&gt;Cardiff R User
group&lt;&#x2F;a&gt; worked on the
volcanoes data-set :volcano:, and something in it really tripped me up.
We’ve done this a few times now, and are building up our work in &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;CaRdiffR&#x2F;tidy_thursdays&quot;&gt;this
GitHub repo&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;tidyverse&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
volcano &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; readr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;read_csv&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-single z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;rfordatascience&#x2F;tidytuesday&#x2F;master&#x2F;data&#x2F;2020&#x2F;2020-05-12&#x2F;volcano.csv&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;data-structure&quot;&gt;Data structure&lt;&#x2F;h2&gt;
&lt;p&gt;Let’s have a look at what the data is&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;volcano &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;str&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;div class=&quot;crt scanlines&quot;&gt;
  &lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;## tibble [958 × 26] (S3: spec_tbl_df&#x2F;tbl_df&#x2F;tbl&#x2F;data.frame)
##  $ volcano_number          : num [1:958] 283001 355096 342080 213004 321040 ...
##  $ volcano_name            : chr [1:958] &amp;quot;Abu&amp;quot; &amp;quot;Acamarachi&amp;quot; &amp;quot;Acatenango&amp;quot; &amp;quot;Acigol-Nevsehir&amp;quot; ...
##  $ primary_volcano_type    : chr [1:958] &amp;quot;Shield(s)&amp;quot; &amp;quot;Stratovolcano&amp;quot; &amp;quot;Stratovolcano(es)&amp;quot; &amp;quot;Caldera&amp;quot; ...
##  $ last_eruption_year      : chr [1:958] &amp;quot;-6850&amp;quot; &amp;quot;Unknown&amp;quot; &amp;quot;1972&amp;quot; &amp;quot;-2080&amp;quot; ...
##  $ country                 : chr [1:958] &amp;quot;Japan&amp;quot; &amp;quot;Chile&amp;quot; &amp;quot;Guatemala&amp;quot; &amp;quot;Turkey&amp;quot; ...
##  $ region                  : chr [1:958] &amp;quot;Japan, Taiwan, Marianas&amp;quot; &amp;quot;South America&amp;quot; &amp;quot;México and Central America&amp;quot; &amp;quot;Mediterranean and Western Asia&amp;quot; ...
##  $ subregion               : chr [1:958] &amp;quot;Honshu&amp;quot; &amp;quot;Northern Chile, Bolivia and Argentina&amp;quot; &amp;quot;Guatemala&amp;quot; &amp;quot;Turkey&amp;quot; ...
##  $ latitude                : num [1:958] 34.5 -23.3 14.5 38.5 46.2 ...
##  $ longitude               : num [1:958] 131.6 -67.6 -90.9 34.6 -121.5 ...
##  $ elevation               : num [1:958] 641 6023 3976 1683 3742 ...
##  $ tectonic_settings       : chr [1:958] &amp;quot;Subduction zone &#x2F; Continental crust (&amp;gt;25 km)&amp;quot; &amp;quot;Subduction zone &#x2F; Continental crust (&amp;gt;25 km)&amp;quot; &amp;quot;Subduction zone &#x2F; Continental crust (&amp;gt;25 km)&amp;quot; &amp;quot;Intraplate &#x2F; Continental crust (&amp;gt;25 km)&amp;quot; ...
##  $ evidence_category       : chr [1:958] &amp;quot;Eruption Dated&amp;quot; &amp;quot;Evidence Credible&amp;quot; &amp;quot;Eruption Observed&amp;quot; &amp;quot;Eruption Dated&amp;quot; ...
##  $ major_rock_1            : chr [1:958] &amp;quot;Andesite &#x2F; Basaltic Andesite&amp;quot; &amp;quot;Dacite&amp;quot; &amp;quot;Andesite &#x2F; Basaltic Andesite&amp;quot; &amp;quot;Rhyolite&amp;quot; ...
##  $ major_rock_2            : chr [1:958] &amp;quot;Basalt &#x2F; Picro-Basalt&amp;quot; &amp;quot;Andesite &#x2F; Basaltic Andesite&amp;quot; &amp;quot;Dacite&amp;quot; &amp;quot;Dacite&amp;quot; ...
##  $ major_rock_3            : chr [1:958] &amp;quot;Dacite&amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot;Basalt &#x2F; Picro-Basalt&amp;quot; ...
##  $ major_rock_4            : chr [1:958] &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot;Andesite &#x2F; Basaltic Andesite&amp;quot; ...
##  $ major_rock_5            : chr [1:958] &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; ...
##  $ minor_rock_1            : chr [1:958] &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot;Basalt &#x2F; Picro-Basalt&amp;quot; &amp;quot; &amp;quot; ...
##  $ minor_rock_2            : chr [1:958] &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; ...
##  $ minor_rock_3            : chr [1:958] &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; ...
##  $ minor_rock_4            : chr [1:958] &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; ...
##  $ minor_rock_5            : chr [1:958] &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; &amp;quot; ...
##  $ population_within_5_km  : num [1:958] 3597 0 4329 127863 0 ...
##  $ population_within_10_km : num [1:958] 9594 7 60730 127863 70 ...
##  $ population_within_30_km : num [1:958] 117805 294 1042836 218469 4019 ...
##  $ population_within_100_km: num [1:958] 4071152 9092 7634778 2253483 393303 ...
##  - attr(*, &amp;quot;spec&amp;quot;)=
##   .. cols(
##   ..   volcano_number = col_double(),
##   ..   volcano_name = col_character(),
##   ..   primary_volcano_type = col_character(),
##   ..   last_eruption_year = col_character(),
##   ..   country = col_character(),
##   ..   region = col_character(),
##   ..   subregion = col_character(),
##   ..   latitude = col_double(),
##   ..   longitude = col_double(),
##   ..   elevation = col_double(),
##   ..   tectonic_settings = col_character(),
##   ..   evidence_category = col_character(),
##   ..   major_rock_1 = col_character(),
##   ..   major_rock_2 = col_character(),
##   ..   major_rock_3 = col_character(),
##   ..   major_rock_4 = col_character(),
##   ..   major_rock_5 = col_character(),
##   ..   minor_rock_1 = col_character(),
##   ..   minor_rock_2 = col_character(),
##   ..   minor_rock_3 = col_character(),
##   ..   minor_rock_4 = col_character(),
##   ..   minor_rock_5 = col_character(),
##   ..   population_within_5_km = col_double(),
##   ..   population_within_10_km = col_double(),
##   ..   population_within_30_km = col_double(),
##   ..   population_within_100_km = col_double()
##   .. )
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;

&lt;&#x2F;div&gt;
&lt;h2 id=&quot;objective&quot;&gt;Objective&lt;&#x2F;h2&gt;
&lt;p&gt;Lots of character columns, and some with some slightly funky formatting,
such as &lt;code&gt;&#x2F;&lt;&#x2F;code&gt; and variations on a theme with &lt;code&gt;(s)&lt;&#x2F;code&gt; and &lt;code&gt;(es)&lt;&#x2F;code&gt;. We’ve also
got a bunch of ‘sparse’ data in the columns that start with &lt;code&gt;major_rock&lt;&#x2F;code&gt;
or &lt;code&gt;minor_rock&lt;&#x2F;code&gt; that look like spaces. R has a rich set of tools for
dealing with missing data a little more effectively, so lets
clean this up by setting the missing data to be explicit &lt;code&gt;NA&lt;&#x2F;code&gt;. In this
case, as the column is a character type, we need to &lt;code&gt;NA_character&lt;&#x2F;code&gt; to
fill it up.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;failing-solution&quot;&gt;Failing solution&lt;&#x2F;h2&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;volcano &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate_at&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;.vars&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;vars&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;starts_with&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;c&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;major_rock&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;minor_rock&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;.funs&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;case_when&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
      . &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-language z-r&quot;&gt;NA_character_&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
      &lt;span class=&quot;z-constant z-language z-r&quot;&gt;TRUE&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; .
    &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;starts_with&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;c&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;major_rock&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;minor_rock&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;head&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  knitr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_1&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_2&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_3&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_4&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_5&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_1&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_2&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_3&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_4&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_5&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Rhyolite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;Well, that doesn’t quite work. What I want is to have the blank spots
filled up with &lt;code&gt;NA&lt;&#x2F;code&gt;. Is it my code? It’s not the most basic solution,
using some of the tidyeval concepts such as &lt;code&gt;vars&lt;&#x2F;code&gt; and &lt;code&gt;funs&lt;&#x2F;code&gt;. Lets make
it as simple as possible.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;volcano &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;major_rock_5 &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  knitr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: right&quot;&gt;volcano_number&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;volcano_name&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;primary_volcano_type&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;last_eruption_year&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;country&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;region&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;subregion&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;latitude&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;longitude&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;elevation&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;tectonic_settings&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;evidence_category&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_1&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_2&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_3&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_4&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_5&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_1&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_2&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_3&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_4&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_5&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;population_within_5_km&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;population_within_10_km&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;population_within_30_km&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;population_within_100_km&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;Odd. I can’t find any values that are just spaces, even though they are
printed out that way! I know they are there, I can see them! Luckily,
the point of these projects is to learn, and to learn from each other in
the group :school:.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;problem&quot;&gt;Problem&lt;&#x2F;h2&gt;
&lt;p&gt;My buddy &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;HeathrTurnr&quot;&gt;Heather&lt;&#x2F;a&gt; was I think a little
surprised when I demonstrated this, but within a few minutes she’d
worked it out. It’s encoded as a &lt;em&gt;non_breaking space&lt;&#x2F;em&gt;. She linked this
blog in our chat about &lt;a href=&quot;https:&#x2F;&#x2F;blog.tonytsai.name&#x2F;blog&#x2F;2017-12-04-detecting-non-breaking-space-in-r&#x2F;&quot;&gt;non-braking
spaces&lt;&#x2F;a&gt;
and offered us the cryptic solution:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;&amp;quot;\u00A0&amp;quot;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The blog goes into detail about what this is but the tl;dr is: “It looks
like a space but it’s not and it’s &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Non-breaking_space&quot;&gt;designed that
way&lt;&#x2F;a&gt;”.&lt;&#x2F;p&gt;
&lt;p&gt;So a quick tweak to the code and…&lt;&#x2F;p&gt;
&lt;h2 id=&quot;functional-solution&quot;&gt;Functional solution&lt;&#x2F;h2&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;volcano &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate_at&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;.vars&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;vars&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;starts_with&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;c&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;major_rock&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;minor_rock&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;.funs&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;case_when&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
      . &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape z-r&quot;&gt;\u&lt;&#x2F;span&gt;00A0&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-language z-r&quot;&gt;NA_character_&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
      &lt;span class=&quot;z-constant z-language z-r&quot;&gt;TRUE&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; .
    &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;starts_with&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;c&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;major_rock&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;minor_rock&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;head&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  knitr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_1&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_2&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_3&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_4&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_5&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_1&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_2&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_3&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_4&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_5&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Rhyolite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h2 id=&quot;full-solution&quot;&gt;Full solution&lt;&#x2F;h2&gt;
&lt;p&gt;Success! After digging around a little, I discovered &lt;code&gt;str_trim&lt;&#x2F;code&gt; and
&lt;code&gt;str_squish&lt;&#x2F;code&gt; can be used for this as well to make a perfectly tidy
solution!&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;volcano &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate_at&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;.vars&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;vars&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;starts_with&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;c&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;major_rock&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;minor_rock&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;.funs&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;case_when&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
      &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;str_trim&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;.&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-language z-r&quot;&gt;NA_character_&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
      &lt;span class=&quot;z-constant z-language z-r&quot;&gt;TRUE&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; .
    &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;starts_with&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;c&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;major_rock&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;minor_rock&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;head&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  knitr&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_1&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_2&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_3&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_4&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;major_rock_5&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_1&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_2&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_3&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_4&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;minor_rock_5&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Rhyolite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Andesite &#x2F; Basaltic Andesite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Dacite&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Basalt &#x2F; Picro-Basalt&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;Let’s try and breakdown what is happening in this solution by concept,
and then outline the routine in human language to finish.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;concepts&quot;&gt;Concepts&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;non-breaking-spaces&quot;&gt;Non-breaking spaces&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;the ‘missing’ values are not real spaces, they are &lt;em&gt;non-breaking
spaces&lt;&#x2F;em&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;stringr.tidyverse.org&#x2F;reference&#x2F;str_trim.html&quot;&gt;&lt;code&gt;stringr::str_trim&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;
and &lt;code&gt;stringr::str_squish&lt;&#x2F;code&gt; removes space from either the ends or all
the way through a character string depending on what else is
happening in the string and what you need from the solution.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;dplyr.tidyverse.org&#x2F;reference&#x2F;mutate_all.html&quot;&gt;&lt;code&gt;mutate_at&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;
is a buddy of &lt;code&gt;mutate&lt;&#x2F;code&gt;, where you use &lt;em&gt;functional programming&lt;&#x2F;em&gt; style
to apply a function over a collection of columns.&lt;&#x2F;li&gt;
&lt;li&gt;this means that for the context of evaluation, we will be getting
&lt;code&gt;&amp;quot;&amp;quot;&lt;&#x2F;code&gt;, where as previously we were seeing &lt;code&gt;&amp;quot; &amp;quot;&lt;&#x2F;code&gt; which was actually
encoded as &lt;code&gt;&amp;quot;\u00A0&amp;quot;&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;variable-selection&quot;&gt;Variable selection&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;dplyr.tidyverse.org&#x2F;reference&#x2F;select.html#useful-functions&quot;&gt;&lt;code&gt;starts_with&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;
is a select helper that is designed for cases when a related value
is stretch wide across multiple columns with similar names, and
returns a vector of column names filtered to your criteria.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;dplyr.tidyverse.org&#x2F;reference&#x2F;vars.html&quot;&gt;&lt;code&gt;vars&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;
automatically &lt;em&gt;quotes&lt;&#x2F;em&gt; the names of the columns to &lt;em&gt;evaluate&lt;&#x2F;em&gt; later
in context and is almost always used as a wrapper to the &lt;code&gt;.var =&lt;&#x2F;code&gt;
argument when it’s supported by a function.&lt;&#x2F;li&gt;
&lt;li&gt;this means that we will be doing on operation on each of the columns
selected.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;formula-function&quot;&gt;Formula function&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;.funs =&lt;&#x2F;code&gt; argument, like &lt;code&gt;.var =&lt;&#x2F;code&gt;, has a counterpart
&lt;a href=&quot;https:&#x2F;&#x2F;dplyr.tidyverse.org&#x2F;reference&#x2F;funs.html&quot;&gt;&lt;code&gt;funs()&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;, but
this is being deprecated in favour of the &lt;em&gt;expression notation&lt;&#x2F;em&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;dplyr.tidyverse.org&#x2F;reference&#x2F;case_when.html&quot;&gt;&lt;code&gt;case_when&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;
is an alternative version of the more common &lt;code&gt;if else&lt;&#x2F;code&gt; operation.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;~&lt;&#x2F;code&gt; is a special operator that is key to the expression notation. It
effectively separates the Left Hand Side (LHS) of an expression from
the Right Hand Side (RHS). It’s used in two ways in this code.
&lt;code&gt;case_when&lt;&#x2F;code&gt; uses full expressions to represent what should happen on
the RHS when the criteria of the LHS is met. &lt;code&gt;.funs =&lt;&#x2F;code&gt; uses it to
make a lambda style formula. This is sometimes referred to as a
&lt;a href=&quot;https:&#x2F;&#x2F;dplyr.tidyverse.org&#x2F;articles&#x2F;programming.html#quoting&quot;&gt;&lt;em&gt;quosure&lt;&#x2F;em&gt;&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;.&lt;&#x2F;code&gt; is also a special operator, and I recommend reading the
&lt;a href=&quot;https:&#x2F;&#x2F;magrittr.tidyverse.org&#x2F;reference&#x2F;pipe.html&quot;&gt;documentation of
pipe&lt;&#x2F;a&gt; &lt;code&gt;%&amp;gt;%&lt;&#x2F;code&gt;. The
idea of it here is to reference the data being operated on itself.
In this specific case, it’s each value from each of the selected
columns for equivalence to an empty space.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;step-by-step&quot;&gt;Step-by-step&lt;&#x2F;h2&gt;
&lt;p&gt;Did you follow all that? It’s a minefield I know, but it allows us to do
something very powerful in only a few lines. As an alternative way of
understanding what this does, here’s the step by step:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Get all the columns that start with either &lt;code&gt;&amp;quot;major_rock&#x27;&lt;&#x2F;code&gt; or
&lt;code&gt;&amp;quot;minor_rock&amp;quot;&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;For each of the those columns trim any value at the start or end
that is whitespace, including non-breaking white space temporarily,
without modifying the underlying data&lt;&#x2F;li&gt;
&lt;li&gt;If the value after that is an empty string, replace it in the same
column with the &lt;code&gt;NA&lt;&#x2F;code&gt; value for characters&lt;&#x2F;li&gt;
&lt;li&gt;If the value after does not pass that test, use the original value&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;So do you &lt;em&gt;have to&lt;&#x2F;em&gt; program this way? No, not really. You could manually
create the list of columns you want to modify, but that would be prone
to human error and what if you end up with &lt;code&gt;&amp;quot;minor_rock_6&amp;quot;&lt;&#x2F;code&gt; or
&lt;code&gt;&amp;quot;major_rock_100&amp;quot;&lt;&#x2F;code&gt;? You could always make a traditional &lt;code&gt;if else&lt;&#x2F;code&gt;
structure, but that can get long fast if there are multiple conditions
to check for. How about using the character string &lt;code&gt;&amp;quot;\u00A0&amp;quot;&lt;&#x2F;code&gt; to test
for equivalence? Well, that would work now, but how do you pick up if
they change suddenly to actual spaces? Or another whitespace encoding?
Programming like this keeps code readable, maintainable, and robust.&lt;&#x2F;p&gt;
&lt;p&gt;Is this overkill for tidy Tuesdays? Yes, absolutely. Are the problems
that you solve with this approach purely academic? No, not at all. Plus,
doing all that work in 129 characters is pretty neat. Excluding spaces.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Pocket Monster BMI</title>
        <published>2020-05-13T00:00:00+00:00</published>
        <updated>2020-05-13T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/pocket-monster-bmi-1ao0/" type="text/html"/>
        <id>https://www.daveparr.info/blog/pocket-monster-bmi-1ao0/</id>
        
        <content type="html">&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;pokedex&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;tidyverse&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;knitr&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;how-big-is-a-pocket-monster&quot;&gt;How big is a Pocket Monster?&lt;&#x2F;h1&gt;
&lt;p&gt;Pokemon is a combination of ‘Pocket’ and ‘Monster’. So they’re all
pretty small right? Not quite.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;scale_format &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; scales&lt;span class=&quot;z-punctuation z-accessor z-colons z-r&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;number_format&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;accuracy&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;big.mark&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;,&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; height&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; weight&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_point&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;scale_y_continuous&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;labels&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; scale_format&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Height and Weight of Pocket Monsters&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Height (m)&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Weight (kg)&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;dev-to-uploads.s3.amazonaws.com&#x2F;i&#x2F;ma2yfumh5qno7716asn6.png&quot; alt=&quot;Alt Text&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Maybe we need to work on this graph a little. Let’s make it log scaled on
both axis. I’ll put myself in for reference too.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; height&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; weight&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_point&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_vline&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;xintercept&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;1&lt;span class=&quot;z-punctuation z-separator z-decimal z-r&quot;&gt;.&lt;&#x2F;span&gt;7&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_hline&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;yintercept&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;72&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Height and Weight of Pocket Monsters&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;subtitle&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Trainer Daves&amp;#39;s height and weight for reference&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Height (m)&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Weight (kg)&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;caption&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Log X and Y Scale&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;scale_x_log10&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;scale_y_log10&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;labels&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; scale_format&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;dev-to-uploads.s3.amazonaws.com&#x2F;i&#x2F;0rvxuys3lh1jwiggs95v.png&quot; alt=&quot;Alt Text&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;So after a log transform of the scales we have a (roughly) linear
relationship. This is what we would expect in real world data. Nothing
with a physical existence can have a 0 or negative measure for these
features. Therefore, thinking of this in terms of average can be
misleading. It will always be ‘long tailed’. It might be a stretch to
refer to them all as Pocket Monsters though.&lt;&#x2F;p&gt;
&lt;p&gt;There’s also clearly a relationship between both height and weight.
Let’s try and capture this in a single feature.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;bmi&quot;&gt;BMI&lt;&#x2F;h1&gt;
&lt;p&gt;The body mass index is a simple metric to link height and weight. Let’s
create it for our Pokemon.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function z-name z-r&quot;&gt;&lt;span class=&quot;z-entity z-name z-function z-r&quot;&gt;BMI&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-r&quot;&gt;&lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-r&quot;&gt;&lt;span class=&quot;z-storage z-type z-function z-r&quot;&gt;function&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;weight&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-parameters z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;height&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parameters z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-punctuation z-section z-braces z-begin z-r&quot;&gt;{&lt;&#x2F;span&gt;
  weight&lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;height&lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;^&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;
&lt;span class=&quot;z-punctuation z-section z-braces z-end z-r&quot;&gt;}&lt;&#x2F;span&gt;

pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;BMI&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;BMI&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;weight&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; weight&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;height&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; height&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; pokemon

pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; BMI&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_histogram&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;BMI of Pocket Monsters&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;dev-to-uploads.s3.amazonaws.com&#x2F;i&#x2F;wc0wmg7bis190lc4gqcy.png&quot; alt=&quot;Alt Text&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Well, that’s something of a surprise. Looking at the scatter plots from
earlier, there is something in the data set that is very small, but also
&lt;em&gt;extremely&lt;&#x2F;em&gt; heavy. Let’s try and work out what that is.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;arrange&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;desc&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;BMI&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;name&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; height&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; weight&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; BMI&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; genus&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;top_n&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;10&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; BMI&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: left&quot;&gt;name&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;height&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;weight&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;BMI&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;genus&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Cosmoem&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.1&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;999.9&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;99990.0000&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Protostar Pokémon&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Minior&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.3&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;40.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;444.4444&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Meteor Pokémon&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Aron&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.4&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;60.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;375.0000&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Iron Armor Pokémon&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Durant&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.3&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;33.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;366.6667&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Iron Ant Pokémon&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Clamperl&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.4&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;52.5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;328.1250&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Bivalve Pokémon&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Torkoal&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;80.4&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;321.6000&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Coal Pokémon&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Cacnea&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.4&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;51.3&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;320.6250&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Cactus Pokémon&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Munchlax&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.6&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;105.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;291.6667&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Big Eater Pokémon&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Sandygast&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;70.0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;280.0000&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Sand Heap Pokémon&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;Beldum&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;0.6&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;95.2&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;264.4444&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;Iron Ball Pokémon&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;There’s no accounting for cosmological battle entities. I’m going to
claim that the Protostar Pokemon is a little out of scope for this and
filter it out. Let’s have a look at what we’re left with.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;Dave_BMI &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;&amp;lt;-&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;BMI&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;weight&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;72&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;  &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;height&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;1&lt;span class=&quot;z-punctuation z-separator z-decimal z-r&quot;&gt;.&lt;&#x2F;span&gt;70&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;

pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;name &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;!=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Cosmoem&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; BMI&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_histogram&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_vline&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;xintercept&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; Dave_BMI&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;BMI of Pocket Monsters&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;subtitle&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Trainer Dave&amp;#39;s BMI for reference&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;caption&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Cosmoem removed&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;dev-to-uploads.s3.amazonaws.com&#x2F;i&#x2F;kj2y0tn7o91vny08qggf.png&quot; alt=&quot;Alt Text&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;So most Pokemon are actually a little bigger than me, and a few of them
are a lot bigger!
We’ve also realised that some of them might just be very different to
me, like stars, made entirely of metal or rock, or maybe even giant
dragons? Just like in the earlier article, I’m going to pivot the data
so we get a comparison for dual type Pokemon on both their types.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;name &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;!=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Cosmoem&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;name&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type_1&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type_2&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; BMI&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; height&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; weight&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;pivot_longer&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;cols&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;starts_with&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;type&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;names_to&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;slot&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;values_to&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;type&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;values_drop_na&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-language z-r&quot;&gt;TRUE&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; BMI&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_density&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_vline&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;xintercept&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; Dave_BMI&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;facet_wrap&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;. &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; type&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;scales&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;free&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Pocket Monster BMI by type&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;subtitle&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Trainer Dave&amp;#39;s BMI for reference&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;caption&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Cosmoem removed&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;dev-to-uploads.s3.amazonaws.com&#x2F;i&#x2F;yus2sxt4ss54olz64zii.png&quot; alt=&quot;Alt Text&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;So it looks like I’m not quite as hefty as Pokemon that are rock, steel,
ice, ground, fighting, dark or dragon. That makes sense. I’m also a bit
more corporeal than fairy or ghost type. Pokemon has some really big
bugs though!&lt;&#x2F;p&gt;
&lt;h1 id=&quot;game-over&quot;&gt;Game Over&lt;&#x2F;h1&gt;
&lt;p&gt;We’ve learned quite a few R programming things today. The most obvious
were some &lt;code&gt;ggplot&lt;&#x2F;code&gt; chart tools:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;geom_vline()&lt;&#x2F;code&gt; and &lt;code&gt;geom_hline()&lt;&#x2F;code&gt; make 1 dimensional lines at
specific points&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;geom_histogram()&lt;&#x2F;code&gt; and &lt;code&gt;geom_density()&lt;&#x2F;code&gt; show the distribution of a
single value across mutiple observations&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;facet_wrap()&lt;&#x2F;code&gt; can make grouped charts, which are often known as
&lt;em&gt;small multiples&lt;&#x2F;em&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;scale_x_log10()&lt;&#x2F;code&gt; and &lt;code&gt;scale_y_log10&lt;&#x2F;code&gt; is an easy way to plot a log
axis&lt;&#x2F;li&gt;
&lt;li&gt;the &lt;code&gt;scales&lt;&#x2F;code&gt; package is also useful for formatting the axis labels&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Did you also notice the first thing we did with the &lt;code&gt;scales&lt;&#x2F;code&gt; package? In
R you can assign a &lt;em&gt;function&lt;&#x2F;em&gt; to a reference. This means that we don’t
need to repeat ourselves if we want to set it up with the same arguments
multiple times, like with formatting axis with large numbers.&lt;&#x2F;p&gt;
&lt;p&gt;In the &lt;code&gt;tidyverse&lt;&#x2F;code&gt; world we also used the optional arguments in
&lt;code&gt;pivot_longer()&lt;&#x2F;code&gt; to select 2 columns to pivot on, and to drop rows we
create that have &lt;code&gt;NA&lt;&#x2F;code&gt; when the Pokemon only has 1 type.&lt;&#x2F;p&gt;
&lt;p&gt;Most importantly though, we created our own function, and it was easy!
The &lt;code&gt;BMI&lt;&#x2F;code&gt; function we created we used to make a single value,
&lt;code&gt;Dave_BMI&lt;&#x2F;code&gt;, but also to make the whole &lt;code&gt;BMI&lt;&#x2F;code&gt; column for each Pokemon in
the data set! That’s pretty cool.&lt;&#x2F;p&gt;
&lt;p&gt;From 2 known features, &lt;code&gt;weight&lt;&#x2F;code&gt; and &lt;code&gt;height&lt;&#x2F;code&gt; we made one single new
measurement &lt;code&gt;BMI&lt;&#x2F;code&gt;. This an example of something that will come up more
in later posts about machine learning which is called ‘feature
engineering’.&lt;&#x2F;p&gt;
&lt;p&gt;The next article will be going into how the Pokedex package is actually
made, both in trying to design a ‘tidy’ data set, but also how to make a
package in R!&lt;&#x2F;p&gt;
&lt;p&gt;P.S. I know that &lt;code&gt;Pocket Monster&lt;&#x2F;code&gt; is related to the pokeballs they fit in, but that’s a less fun title.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Introducing the Pokedex package</title>
        <published>2020-05-09T00:00:00+00:00</published>
        <updated>2020-05-09T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/introducing-the-pokedex-package-5416/" type="text/html"/>
        <id>https://www.daveparr.info/blog/introducing-the-pokedex-package-5416/</id>
        
        <content type="html">&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;pokedex&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;tidyverse&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;library&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;knitr&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;how-many-pokemon-in-the-package&quot;&gt;How many Pokemon in the package?&lt;&#x2F;h2&gt;
&lt;p&gt;I’ve tried to make the data set ‘tidy’ from the start, so we can use
&lt;code&gt;summarise&lt;&#x2F;code&gt; to count them, and &lt;code&gt;kable&lt;&#x2F;code&gt; to make some dev.to friendly
markdown tables.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;summarise&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;count&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;n&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: right&quot;&gt;count&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;807&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h2 id=&quot;types&quot;&gt;Types&lt;&#x2F;h2&gt;
&lt;p&gt;Types are pretty key to Pokemon. Lets have a quick look at the Kanto
starters and types.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;top_n&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;n&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;-&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;9&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;wt&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; species_id&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;identifier&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type_1&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type_2&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: left&quot;&gt;identifier&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;type_1&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: left&quot;&gt;type_2&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;bulbasaur&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;grass&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;poison&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;ivysaur&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;grass&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;poison&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;venusaur&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;grass&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;poison&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;charmander&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;fire&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;charmeleon&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;fire&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;charizard&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;fire&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;flying&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;squirtle&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;water&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;wartortle&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;water&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;blastoise&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;water&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: left&quot;&gt;NA&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h2 id=&quot;single-and-dual-types&quot;&gt;Single and dual types&lt;&#x2F;h2&gt;
&lt;p&gt;So Pokemon can have either 1 or 2 types. What’s the split between single
type and dual type Pokemon?&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;dual_type&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;case_when&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;is.na&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_2&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-language z-r&quot;&gt;TRUE&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
                               &lt;span class=&quot;z-constant z-language z-r&quot;&gt;TRUE&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-language z-r&quot;&gt;FALSE&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;group_by&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;dual_type&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;summarise&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;count&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;n&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: left&quot;&gt;dual_type&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: right&quot;&gt;count&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;FALSE&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;405&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;TRUE&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: right&quot;&gt;402&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;So, it’s nearly a 50:50 split of Pokemon that are single type to Pokemon
that have 2 types.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;how-many-by-type&quot;&gt;How many by type?&lt;&#x2F;h2&gt;
&lt;p&gt;But there are also quite a few types of Pokemon. Starting with the
primary type, lets make a quick chart to understand the distribution of
primary types. Using &lt;code&gt;group_by&lt;&#x2F;code&gt; will mean the &lt;code&gt;summarise&lt;&#x2F;code&gt; gets
calculated &lt;em&gt;per group&lt;&#x2F;em&gt;. We can then pipe directly into &lt;code&gt;ggplot&lt;&#x2F;code&gt; for a
col chart with &lt;code&gt;geom_col&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;group_by&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_1&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;summarise&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;count&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;n&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; type_1&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; count&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_col&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Pokemon by primary type&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;dev-to-uploads.s3.amazonaws.com&#x2F;i&#x2F;v9nfgl5rwqt0zp18i44s.png&quot; alt=&quot;Pokemon by primary type&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Lots of water type Pokemon, and lots of normal type Pokemon, but very
few flying types. Interesting. How about the secondary types?&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;is.na&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_2&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;group_by&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_2&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;summarise&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;count&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;n&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; type_2&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; count&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_col&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Pokemon by secondary type&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;caption&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;For Pokemon with dual type&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;dev-to-uploads.s3.amazonaws.com&#x2F;i&#x2F;7r4iuz9whihop7b5cjrh.png&quot; alt=&quot;Pokemon by secondary type&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Look at all those ’mons with flying as a secondary type! The thing is
that, game-wise, the &lt;em&gt;order&lt;&#x2F;em&gt; of the typing doesn’t matter. We can easily
count the occurrence of a specific type in either primary or secondary
position with &lt;code&gt;pivot_longer&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;pivot_longer&lt;&#x2F;code&gt; is actually a newer tidyverse function. It is
complemented with &lt;code&gt;pivot_wider&lt;&#x2F;code&gt; and this pair are intended to eventually
replace &lt;code&gt;spread&lt;&#x2F;code&gt; and &lt;code&gt;gather&lt;&#x2F;code&gt;. By filtering out the &lt;code&gt;NA&lt;&#x2F;code&gt; I remove any
observations of secondary types for Pokemon that don’t actually have
them.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;identifier&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type_1&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type_2&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;pivot_longer&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;-&lt;&#x2F;span&gt;identifier&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;names_to&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;slot&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;values_to&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;type&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;group_by&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;summarise&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;count&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;n&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;is.na&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; type&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; count&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_col&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Pokemon by either type&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;caption&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;This will count a dual type Pokemon twice,\
once for each type&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;dev-to-uploads.s3.amazonaws.com&#x2F;i&#x2F;v5uh6xygkrq7rjikajce.png&quot; alt=&quot;Alt Text&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;So is there any consistency in order at all?&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_1 &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;ghost&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;amp;&lt;&#x2F;span&gt; type_2 &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;fire&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-r&quot;&gt;)&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;|&lt;&#x2F;span&gt;
           &lt;span class=&quot;z-punctuation z-section z-parens z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_1 &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;fire&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;amp;&lt;&#x2F;span&gt; type_2 &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;ghost&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;select&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;identifier&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type_1&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type_2&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;## # A tibble: 4 x 3
##   identifier  type_1 type_2
##   &amp;lt;chr&amp;gt;       &amp;lt;chr&amp;gt;  &amp;lt;chr&amp;gt; 
## 1 litwick     ghost  fire  
## 2 lampent     ghost  fire  
## 3 chandelure  ghost  fire  
## 4 blacephalon fire   ghost
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;It doesn’t look like it. a &lt;code&gt;ghost fire&lt;&#x2F;code&gt; Pokemon and a &lt;code&gt;fire ghost&lt;&#x2F;code&gt;
Pokemon both turn up. I’d like to see what the coincidence rate is of
each type in dual type Pokemon, so I need to get some ordering in. I can
use &lt;code&gt;case_when&lt;&#x2F;code&gt; in &lt;code&gt;mutate&lt;&#x2F;code&gt; to create a two new columns in the data. I
can make 2 in one call because &lt;code&gt;mutate&lt;&#x2F;code&gt; supports multiple &lt;em&gt;expressions&lt;&#x2F;em&gt;,
each of which names a column, and then operates conditionally on the
other 2 type columns. These new columns will:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;always have a value in the column &lt;code&gt;type_1_ordered&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;if the Pokemon is dual type, have a value in &lt;code&gt;type_2_ordered&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;always have the types alphabetically ordered between the two
columns. i.e. it will always be &lt;code&gt;fire, ghost&lt;&#x2F;code&gt;, never &lt;code&gt;ghost, fire&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;type_1_ordered&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;case_when&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;is.na&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_2&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; type_1&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
                               type_1 &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;lt;&lt;&#x2F;span&gt; type_2 &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; type_1&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
                               &lt;span class=&quot;z-constant z-language z-r&quot;&gt;TRUE&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; type_2&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;type_2_ordered&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;case_when&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_1 &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;&amp;gt;&lt;&#x2F;span&gt; type_2 &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; type_1&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
                               &lt;span class=&quot;z-constant z-language z-r&quot;&gt;TRUE&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; type_2&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt; pokemon
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;What might the distribution be of the flying secondary type, per primary
type?&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;type_combined&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;case_when&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;is.na&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_2_ordered&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;paste&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_1_ordered&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type_2_ordered&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
    &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;is.na&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_2_ordered&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-other z-r&quot;&gt;~&lt;&#x2F;span&gt; type_1_ordered
  &lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;group_by&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_combined&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;summarise&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;count&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;n&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;arrange&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;desc&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;count&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;mutate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;type_combined&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;as_factor&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_combined&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; type_combined&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; count&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_col&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Count of Pokemon by dual type&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt;
       &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;caption&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Ordered by count&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;theme&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;axis.text.x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;element_text&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;angle&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;90&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;dev-to-uploads.s3.amazonaws.com&#x2F;i&#x2F;fz5flcvh8dbtfh3zvh9s.png&quot; alt=&quot;Alt Text&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;So the most often occurring dual type is flying normal. That explains
the first 2 charts. It’s a bit tricky to see the rest though. Lets make
a more useful plot.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;group_by&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_1_ordered&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type_2_ordered&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;is.na&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_2_ordered&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;summarise&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;count&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;n&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ggplot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;aes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;x&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; type_1_ordered&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;y&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; type_2_ordered&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;size&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; count&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;geom_point&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-arithmetic z-r&quot;&gt;+&lt;&#x2F;span&gt;
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;labs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;title&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-string z-quoted z-double z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-begin z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;Coincidence of a particular dual type&lt;span class=&quot;z-punctuation z-definition z-string z-end z-r&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;dev-to-uploads.s3.amazonaws.com&#x2F;i&#x2F;v6qbe0h2nh6n4vz4bnmz.png&quot; alt=&quot;Alt Text&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;So &lt;code&gt;flying normal&lt;&#x2F;code&gt; has the biggest count, with there being quite a few
&lt;code&gt;bug flying&lt;&#x2F;code&gt;. That makes sense, as so many bug Pokemon have wings!
There are also lot’s of &lt;code&gt;bug poison&lt;&#x2F;code&gt; and &lt;code&gt;grass poison&lt;&#x2F;code&gt;. That makes
sense too, as so many bugs and plants are poisonous! How many Pokemon
have unique types though?&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;r&quot; class=&quot;language-r z-code&quot;&gt;&lt;code class=&quot;language-r&quot; data-lang=&quot;r&quot;&gt;&lt;span class=&quot;z-source z-r&quot;&gt;pokemon &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;group_by&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_1_ordered&lt;span class=&quot;z-punctuation z-separator z-arguments z-r&quot;&gt;,&lt;&#x2F;span&gt; type_2_ordered&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;!&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;is.na&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;type_2_ordered&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;summarise&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;count&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;n&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-support z-function z-r&quot;&gt;filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;count &lt;span class=&quot;z-keyword z-operator z-logical z-r&quot;&gt;==&lt;&#x2F;span&gt; &lt;span class=&quot;z-constant z-numeric z-float z-decimal z-r&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;ungroup&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;summarise&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-r&quot;&gt;count&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-r&quot;&gt;=&lt;&#x2F;span&gt; &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;n&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-other z-r&quot;&gt;%&amp;gt;%&lt;&#x2F;span&gt; 
  &lt;span class=&quot;z-meta z-function-call z-name z-r&quot;&gt;&lt;span class=&quot;z-variable z-function z-r&quot;&gt;kable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function-call z-arguments z-r&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-begin z-r&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-arguments z-end z-r&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: right&quot;&gt;count&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right&quot;&gt;24&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;24 Pokemon have unique dual types. Out of 807 that isn’t very many!
Maybe these Pokemon might be particularly useful? I’ll try and work it
out…&lt;&#x2F;p&gt;
&lt;h2 id=&quot;game-over&quot;&gt;Game Over&lt;&#x2F;h2&gt;
&lt;p&gt;This post has been a simple example of both the data in the package, but
also the &lt;code&gt;tidyverse&lt;&#x2F;code&gt; methods of doing Exploratory Data Analysis. You can
find out more about tidyverse &lt;a href=&quot;https:&#x2F;&#x2F;www.tidyverse.org&#x2F;&quot;&gt;here&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I got the raw data from &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;veekun&#x2F;pokedex&quot;&gt;this repo by
veekun&lt;&#x2F;a&gt;. My package is available
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;pokedex&quot;&gt;here&lt;&#x2F;a&gt;, and the particular version
I used for this post is
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;DaveParr&#x2F;pokedex&#x2F;commit&#x2F;67638e8bc52d58bb0c38534b7c2acc9a78b42053&quot;&gt;here&lt;&#x2F;a&gt;.
Though it’s in a pretty raw state, I hope to improve over time.&lt;&#x2F;p&gt;
&lt;p&gt;I made this package to have a bigish, diverse set of data to play with,
that lots of people recognise, and that has some inherent real world
application. Pokemon is a huge franchise with multiple instalments. Lots
of people have played it, and even if you haven’t you probably have an
intuition about what a Pokemon is, and what data about a Pokemon might
make sense, and mean in context with other Pokemon. Feel free to fork
and mess around with as you like. I hope its fun, and maybe even
useful!&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Local gitlab runners, &#x27;no such image&#x27;, docker and disk space</title>
        <published>2020-01-10T00:00:00+00:00</published>
        <updated>2020-01-10T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/gotcha-local-gitlab-runners-no-such-image-docker-and-disk-space-7ei/" type="text/html"/>
        <id>https://www.daveparr.info/blog/gotcha-local-gitlab-runners-no-such-image-docker-and-disk-space-7ei/</id>
        
        <content type="html">&lt;p&gt;&lt;div class=&quot;crt scanlines&quot;&gt;
  &lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Davids-MacBook-Pro:data-science davidparr$ gitlab-runner exec docker &amp;#39;anomaly detection&amp;#39;
Runtime platform                                    arch=amd64 os=darwin pid=72331 revision=a8a019e0 version=12.3.0
WARNING: You most probably have uncommitted changes. 
WARNING: These changes will not be tested.         
Running with gitlab-runner 12.3.0 (a8a019e0)
Using Docker executor with image rocker&#x2F;tidyverse:latest ...
Authenticating with credentials from &#x2F;Users&#x2F;davidparr&#x2F;.docker&#x2F;config.json
Pulling docker image rocker&#x2F;tidyverse:latest ...
ERROR: Preparation failed: Error: No such image: rocker&#x2F;tidyverse:latest (executor_docker.go:195:0s)
Will be retried in 3s ...
Using Docker executor with image rocker&#x2F;tidyverse:latest ...
Authenticating with credentials from &#x2F;Users&#x2F;davidparr&#x2F;.docker&#x2F;config.json
Pulling docker image rocker&#x2F;tidyverse:latest ...
ERROR: Preparation failed: Error: No such image: rocker&#x2F;tidyverse:latest (executor_docker.go:195:0s)
Will be retried in 3s ...
Using Docker executor with image rocker&#x2F;tidyverse:latest ...
Authenticating with credentials from &#x2F;Users&#x2F;davidparr&#x2F;.docker&#x2F;config.json
Pulling docker image rocker&#x2F;tidyverse:latest ...
ERROR: Preparation failed: Error: No such image: rocker&#x2F;tidyverse:latest (executor_docker.go:195:0s)
Will be retried in 3s ...
ERROR: Job failed (system failure): Error: No such image: rocker&#x2F;tidyverse:latest (executor_docker.go:195:0s)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;

&lt;&#x2F;div&gt;

But you &lt;em&gt;know&lt;&#x2F;em&gt; the image exists. It’s &lt;em&gt;definately&lt;&#x2F;em&gt; a thing. Look, &lt;a href=&quot;https:&#x2F;&#x2F;hub.docker.com&#x2F;r&#x2F;rocker&#x2F;tidyverse&#x2F;&quot;&gt;it’s right here&lt;&#x2F;a&gt;. I can even &lt;strong&gt;RUN IT IN PRODUCTION&lt;&#x2F;strong&gt; so why is it not running on my machine?&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.daveparr.info&#x2F;blog&#x2F;gotcha-local-gitlab-runners-no-such-image-docker-and-disk-space-7ei&#x2F;.&#x2F;4t9ogf06iqphsaewwxvt.jpg&quot; alt=&quot;A shrugging emogi with the text: it works in production&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Turns out gitlab, as brilliant as I’m normally finding their CICD solution, is lying to you. The image &lt;em&gt;does&lt;&#x2F;em&gt; exist, you &lt;em&gt;aren’t&lt;&#x2F;em&gt; mad, just not seeing the whole picture. &lt;&#x2F;p&gt;
&lt;div class=&quot;crt scanlines&quot;&gt;
  &lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Davids-MacBook-Pro:data-science davidparr$ docker pull rocker&#x2F;tidyverse
Using default tag: latest
latest: Pulling from rocker&#x2F;tidyverse
16ea0e8c8879: Pull complete 
7ce39da2c1e2: Extracting [==================================================\u003e]  222.8MB&#x2F;222.8MB
ff1bceed0bef: Download complete 
e36d273bec5a: Download complete 
d3acc34c6c77: Download complete 
14d07989ce8b: Download complete 
73b6bcbfcb26: Download complete 
70b803ec0e47: Download complete 
failed to register layer: Error processing tar file(exit status 1): write &#x2F;usr&#x2F;lib&#x2F;gcc&#x2F;x86_64-linux-gnu&#x2F;8&#x2F;libsupc++.a: no space left on device
Davids-MacBook-Pro:data-science davidparr$ docker pull rocker&#x2F;tidyverse
Using default tag: latest
latest: Pulling from rocker&#x2F;tidyverse
16ea0e8c8879: Pull complete 
7ce39da2c1e2: Extracting [===================\u003e                               ]  85.23MB&#x2F;222.8MB
ff1bceed0bef: Download complete 
e36d273bec5a: Download complete 
d3acc34c6c77: Download complete 
14d07989ce8b: Download complete 
73b6bcbfcb26: Download complete 
70b803ec0e47: Downloading [==================================================\u003e]  324.8MB&#x2F;324.8MB
write &#x2F;var&#x2F;lib&#x2F;docker&#x2F;tmp&#x2F;GetImageBlob686008714: no space left on device
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;

&lt;&#x2F;div&gt;
&lt;p&gt;&lt;em&gt;That’s&lt;&#x2F;em&gt; the error message we needed. It turns out that after a while, your local machines ‘Sparse Image’, that has all your docker images, containers, networks and registries, and also resizes it’s on disk footprint as you use docker, will get filled up with old images, containers and other cruft. &lt;&#x2F;p&gt;
&lt;p&gt;There is a bit more info &lt;a href=&quot;https:&#x2F;&#x2F;forums.docker.com&#x2F;t&#x2F;no-space-left-on-device-error&#x2F;10894&quot;&gt;in this thread&lt;&#x2F;a&gt; but the short version is that you probably just want to run &lt;code&gt;docker system prune -a&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;This command is documented to &amp;quot;Remove unused data&amp;quot;, and when run will tell you all about what it’s going to do:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all images without at least one container associated to them
  - all build cache
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;For my use cases this is perfect. All the images I need in practice are backed up on the cloud and can be rebuilt from code when needed (as they should be), leaving my disk memory to be able to be treated a little more like active memory, hot swapping in and out containers as needed, keeping the disk space tidy and minimal. &lt;&#x2F;p&gt;
&lt;p&gt;In the end I received this lovely message:&lt;&#x2F;p&gt;
&lt;pre class=&quot;z-code&quot;&gt;&lt;code&gt;&lt;span class=&quot;z-text z-plain&quot;&gt;Total reclaimed space: 10.24GB
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And we’re back to happy local emulation of my CI&#x2F;CD pipeline. Now if only I could optimise my R testing image…&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>The Real Difference (TM) between Python and R for Data Science</title>
        <published>2019-08-27T00:00:00+00:00</published>
        <updated>2019-08-27T00:00:00+00:00</updated>
        <author>
          <name>Unknown</name>
        </author>
        <link rel="alternate" href="https://www.daveparr.info/blog/the-real-difference-tm-between-python-and-r-for-data-science-280i/" type="text/html"/>
        <id>https://www.daveparr.info/blog/the-real-difference-tm-between-python-and-r-for-data-science-280i/</id>
        
        <content type="html">&lt;h2 id=&quot;batman-vs-superman&quot;&gt;Batman vs Superman&lt;&#x2F;h2&gt;
&lt;p&gt;Data science has a two language problem. R and python are &lt;strong&gt;both&lt;&#x2F;strong&gt; &lt;em&gt;the&lt;&#x2F;em&gt; language for data science. This has lead to some pretty abstract, generic and sometimes absurd definitions between the two languages. The worst is probably this image:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.daveparr.info&#x2F;blog&#x2F;the-real-difference-tm-between-python-and-r-for-data-science-280i&#x2F;.&#x2F;Ce8VP0FWIAI0ad2.jpeg&quot; alt=&quot;RBat vs pyman&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Data science is such a wide term, with sometimes a very diverse or even poor understanding in business, that clickbaity titles giving superficial answers abound. I’ve tracked down the &lt;a href=&quot;http:&#x2F;&#x2F;ucanalytics.com&#x2F;blogs&#x2F;r-vs-python-comparison-and-awsome-books-free-pdfs-to-learn-them&#x2F;&quot;&gt;source of this image&lt;&#x2F;a&gt;, which has also floated around on twitter &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;lisachwinter&#x2F;status&#x2F;715814232676298753&quot;&gt;once (2016)&lt;&#x2F;a&gt; or &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;cmastication&#x2F;status&#x2F;1037486624500854784&quot;&gt;twice (2018)&lt;&#x2F;a&gt;. To give the author of the post his dues, the article it’s derived from is interesting, and I hope the SEO bonus from publishing as the film hype cycle grew got him some extra book sales (the books he links to are actually &lt;em&gt;really&lt;&#x2F;em&gt; worth reading).&lt;&#x2F;p&gt;
&lt;p&gt;I first came across it on (a now removed) instagram post where it was literally captioned &amp;quot;How to pass any data-science interview&amp;quot; on an account specifically advertising it’s data science recruitment services. I’m not against pop-culture&#x2F;programming bleed over in any form (I’ve done enough Pokemon programming talks that any horse I get on has to be less Rapidash and more Ponyta), but at the point that people who are trying to break into the industry are being told this is &lt;em&gt;valuable information to tell an interviewer&lt;&#x2F;em&gt;, then there is evidently a gap between needs and knowledge.&lt;&#x2F;p&gt;
&lt;p&gt;The difference, and decision for the ‘right’ tool for the job is actually defined by a mixture of internal and external factors. Both languages, in themselves, do the job of data ingest, processing, analysis, modelling and prediction equally well. Both can be deployed on-premises or on the cloud. Both  Minor differences in syntax, and major differences in deployment tooling become the defining factors.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;internals-syntax-and-ecosystem&quot;&gt;INTERNALS: Syntax and ecosystem&lt;&#x2F;h2&gt;
&lt;p&gt;Any programming language is little more than syntax. Functional, Object-oriented, Imperative and more, in various combinations, with specific conventions and patterns. Curiously both &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;R_(programming_language)&quot;&gt;R&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Python_(programming_language)&quot;&gt;Python&lt;&#x2F;a&gt; are ‘Multi-paradigm’ according to Wikipedia. This means that multiple, different styles can be used depending on the problem at hand. You can write python in an OO way, or a functional way. R is often thought of as functional, though it allows the construction of classes, and objects with methods, and side-effects, so it’s not a ‘pure functional’ language.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;however-how-do-people-actually-write-code-for-data-science&quot;&gt;However, how do &lt;em&gt;people&lt;&#x2F;em&gt; actually write code for data science?&lt;&#x2F;h3&gt;
&lt;p&gt;In R, data science is a &lt;em&gt;first class application&lt;&#x2F;em&gt; (and maybe even &lt;em&gt;sole aplication&lt;&#x2F;em&gt;?). &lt;a href=&quot;https:&#x2F;&#x2F;www.tidyverse.org&#x2F;&quot;&gt;Tidyverse&lt;&#x2F;a&gt; is arguably the de facto way to write most R projects now. With RStudio giving it full corporate support and funding an eco-system of tooling, most R I write, have seen others write, and I’ve taught people to write is in this style. Pipes &lt;code&gt;-&amp;gt;&lt;&#x2F;code&gt; chain function calls with non-standard evaluation of arguments, Rmarkdown documents, ggplot visualisation and shiny apps are an R data scientists solution of choice. Tidyverse is itself &lt;em&gt;functionally inspired&lt;&#x2F;em&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;purrr.tidyverse.org&#x2F;articles&#x2F;other-langs.html&quot;&gt;purrr explicitly states this&lt;&#x2F;a&gt; and &lt;a href=&quot;http:&#x2F;&#x2F;adv-r.had.co.nz&#x2F;Functional-programming.html&quot;&gt;Hadley Wickham directly argues that &amp;quot;R, at its heart, is a functional programming (FP) language.&amp;quot;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Python is &lt;em&gt;everywhere&lt;&#x2F;em&gt;. Data science in Python isn’t pythons only reason for existence. &lt;a href=&quot;https:&#x2F;&#x2F;www.scipy.org&#x2F;&quot;&gt;scipy&lt;&#x2F;a&gt; is the python tool chain for data science. numpy and pandas are best of buddies, and matplotlib is a front runner for graphics. This collection of tools is far less cohesive though, with scikit learn, seaborn and jupyter notebooks also being hugely popular, but totally removed from the scipy ecosystem. These tools therefore need a bit more work to mould into a full product. Object Oriented programming is also more popular, &lt;a href=&quot;https:&#x2F;&#x2F;towardsdatascience.com&#x2F;a-data-scientist-should-know-at-least-this-much-python-oop-d63f37eaac4d&quot;&gt;even for&lt;&#x2F;a&gt; &lt;a href=&quot;https:&#x2F;&#x2F;towardsdatascience.com&#x2F;object-oriented-programming-for-data-scientists-build-your-ml-estimator-7da416751f64&quot;&gt;data science&lt;&#x2F;a&gt;. This means you’ll be calling objects more directly, and explicitly pulling out methods on objects with &lt;code&gt;myObject.method&lt;&#x2F;code&gt; more often.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;what-does-that-mean-for-me&quot;&gt;What does that mean for me?&lt;&#x2F;h3&gt;
&lt;p&gt;Do you understand functional programming or object oriented programming already, or is one immediately making sense over the other? Great, use that one. 
Do you already have an ecosystem of certain tools? Great, use whatever you already have.
Do you already have colleagues that you need to work with? Great, use whatever they are.
Do you already have a support network around you for one language but not the other? Great, don’t make life harder than it needs to be.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;externals-application-and-deployment&quot;&gt;EXTERNALS: Application and deployment&lt;&#x2F;h2&gt;
&lt;p&gt;What if you don’t have an easy answer though? You’re starting a new project, or you are the only programmer in the business? Then the choice becomes harder to get right, but more clear the more experience you have. When you know both tools &lt;em&gt;can achieve&lt;&#x2F;em&gt; the same job, you have to choose which one does it &lt;em&gt;more easily&lt;&#x2F;em&gt;. I’ve found that I will reach for python and R equally now I’ve been working professionally in both for a while, however, &lt;em&gt;which&lt;&#x2F;em&gt; I use is defined pretty clearly.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;when-to-use-r&quot;&gt;When to use R&lt;&#x2F;h3&gt;
&lt;p&gt;R encapsulates statistic and mathematical ideas clearly and robustly. Depending on where you get your dependencies from you can have a very clear idea of the likely ‘correctness’ of the library. Roughly &lt;a href=&quot;https:&#x2F;&#x2F;ropensci.org&#x2F;&quot;&gt;ROpenSci&lt;&#x2F;a&gt; is more rigorous and stable than &lt;a href=&quot;https:&#x2F;&#x2F;cran.r-project.org&#x2F;&quot;&gt;CRAN&lt;&#x2F;a&gt; which is better than github. Tidyverse pipes, NSE, purrr give a tightly coupled working environment where syntax is consistent, terse, and trivially refactored. ggplot and RMarkdown give business consumable outputs from the start, where code can be kept tightly coupled to narrative and reporting, but also infinitely customisable to produce something that would get past marketing without a glance. Many academic publications rely on R and RMarkdown for both research and publication. If you need to make interactive output, shiny is a straightforward application framework, with a tight to everything else in this ecosystem.&lt;&#x2F;p&gt;
&lt;p&gt;R is for &lt;strong&gt;analysts&lt;&#x2F;strong&gt; who need to be &lt;em&gt;certain&lt;&#x2F;em&gt; of the underlying data processing &lt;em&gt;immediately&lt;&#x2F;em&gt;, produce and iterate on &lt;em&gt;reporting&lt;&#x2F;em&gt; outputs &lt;em&gt;as fast as possible&lt;&#x2F;em&gt; and write the &lt;em&gt;least code&lt;&#x2F;em&gt; for the most return. &lt;a href=&quot;https:&#x2F;&#x2F;qz.com&#x2F;1661487&#x2F;hadley-wickham-on-the-future-of-r-python-and-the-tidyverse&#x2F;&quot;&gt;Hadley effectively said as much last week&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;I think R Markdown is an amazing contribution to R. … When you are doing data analysis typing speed is actually a bottleneck.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h3 id=&quot;when-to-use-python&quot;&gt;When to use Python&lt;&#x2F;h3&gt;
&lt;p&gt;Python is &lt;a href=&quot;https:&#x2F;&#x2F;insights.stackoverflow.com&#x2F;survey&#x2F;2019#technology-_-programming-scripting-and-markup-languages&quot;&gt;already used tonnes more than R&lt;&#x2F;a&gt; because data science isn’t it’s &lt;em&gt;only&lt;&#x2F;em&gt; job. Data engineers use it very heavily, back-end and even front-end developers use it for all kinds of projects, wether it is data intensive or not. In many linux distributions (including Mac) it’s actually installed as part of your machine when you put the operating system on. It’s also arguably a &lt;em&gt;cloud native&lt;&#x2F;em&gt; language. AWS lambda functions &lt;a href=&quot;https:&#x2F;&#x2F;aws.amazon.com&#x2F;lambda&#x2F;features&#x2F;&quot;&gt;support it out of the box&lt;&#x2F;a&gt;, and Microsoft &lt;a href=&quot;https:&#x2F;&#x2F;www.theregister.co.uk&#x2F;2019&#x2F;08&#x2F;20&#x2F;microsoft_azure_functions&#x2F;&quot;&gt;recently copied them&lt;&#x2F;a&gt;. This is doubly interesting as Microsoft bought one of the &lt;a href=&quot;https:&#x2F;&#x2F;blogs.technet.microsoft.com&#x2F;machinelearning&#x2F;2015&#x2F;04&#x2F;06&#x2F;microsoft-closes-acquisition-of-revolution-analytics&#x2F;&quot;&gt;biggest R consultancies in 2015&lt;&#x2F;a&gt;, but as of yet R is not a natively supported language in much of Microsofts ecosystem. It’s definitely got more baked in R support than AWS (&lt;a href=&quot;https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;power-bi&#x2F;desktop-r-visuals&quot;&gt;PowerBI&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;techcommunity.microsoft.com&#x2F;t5&#x2F;AI-Customer-Engineering-Team&#x2F;Understanding-your-R-strategy-options-on-the-Azure-AI-Platform&#x2F;ba-p&#x2F;735626?WT.mc_id=Revolutions-blog-davidsmi%5Cu0026WT.mc_id=Revolutions-blog-davidsmi&quot;&gt;many others&lt;&#x2F;a&gt;), but has made moves to &lt;a href=&quot;https:&#x2F;&#x2F;blog.revolutionanalytics.com&#x2F;2019&#x2F;05&#x2F;cran-snapshots-and-you.html&quot;&gt;potentially trim back MRAN&lt;&#x2F;a&gt;. All this means that Python is spoken by most developers, that python is supported by most big cloud providers, and that python is probably already built into whatever you are working on.&lt;&#x2F;p&gt;
&lt;p&gt;Python is for &lt;strong&gt;developers&lt;&#x2F;strong&gt; who need to &lt;em&gt;deploy software&lt;&#x2F;em&gt; within a &lt;em&gt;traditional software environment&lt;&#x2F;em&gt; in a &lt;em&gt;more traditional development&lt;&#x2F;em&gt; workflow, where &lt;em&gt;first-class cloud support&lt;&#x2F;em&gt; matters, and integration with &lt;em&gt;existing code&lt;&#x2F;em&gt; is of top priority.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;&#x2F;h2&gt;
&lt;p&gt;R doesn’t &lt;a href=&quot;https:&#x2F;&#x2F;resources.rstudio.com&#x2F;rstudio-conf-2019&#x2F;it-depends-a-dialog-about-dependencies&quot;&gt;necessarily deploy easily into software development&lt;&#x2F;a&gt; (not strictly related, but great talk that’s relevant to the problem), though it is definitely possible (I’ve done it), you have to put in more work to get a roughly similar result. In many situations, that trade off might not be worth it.&lt;&#x2F;p&gt;
&lt;p&gt;Python doesn’t necessarily fit into BI and academic workflows, thought it’s definitely possible (I’ve also done it), you have to put in more work to get a roughly similar result. In many situations, that trade off might not be worth it.&lt;&#x2F;p&gt;
&lt;p&gt;Superman, Batman, Detective Work, Intelligence, Cunning, Usage of Tools, More Brain than Muscles, Muscle Power, Super Strength, Elegance, Wide Range, More Muscles than Brain are not meaningful differentiators.&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
