<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rory Spanton on Medium]]></title>
        <description><![CDATA[Stories by Rory Spanton on Medium]]></description>
        <link>https://medium.com/@roryspanton?source=rss-39501aa8ce39------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9Dxmuk9000ImtW2eMuMnXw.jpeg</url>
            <title>Stories by Rory Spanton on Medium</title>
            <link>https://medium.com/@roryspanton?source=rss-39501aa8ce39------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 18:40:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@roryspanton/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Write Conditional Statements in R: Four Methods]]></title>
            <link>https://medium.com/data-science/how-to-write-conditional-statements-in-r-four-methods-f9bedbae0683?source=rss-39501aa8ce39------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9bedbae0683</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[rstats]]></category>
            <dc:creator><![CDATA[Rory Spanton]]></dc:creator>
            <pubDate>Tue, 13 Jun 2023 18:49:52 GMT</pubDate>
            <atom:updated>2023-06-13T18:49:52.271Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn powerful ways to go beyond if-else statements and level up your R code</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yyEUNnk0dn3UhQUl" /><figcaption>Photo by <a href="https://unsplash.com/@gcalebjones?utm_source=medium&amp;utm_medium=referral">Caleb Jones</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>You won’t get far in programming without conditional statements.</p><p>Conditional statements execute code based on the result of a true-or-false condition. They’re an essential part of coding, and this is especially true in R. Whether you’re using R for data analysis, machine learning, software development, or something else, conditional statements have infinite uses.</p><p>But, most beginners in R don’t realize that there are many ways to write them. Many people learn basic if-else statements and stop there. But, there are often neater, more efficient ways to write conditional statements. Advanced R programmers know each of these techniques and when to use them. So, how can you learn to do the same?</p><p>In this article, we’ll take a look at four different ways to write conditional statements in R. We’ll also cover the strengths and limitations of each technique, and when to use each one.</p><h3>How to write an if-else statement in R</h3><p>The most straightforward way of writing conditional statements in R is by using the if and else keywords. This will be most familiar if you already know another programming language, and it’s often the technique that new R users learn first.</p><p>A standard if statement in R looks like this:</p><pre>if (condition) {<br>  # Code to execute<br>}</pre><p>Here, condition is a logical expression that returns either TRUE or FALSE. If the condition returns TRUE, any code inside the curly braces is executed. If it returns FALSE, the code inside the brackets is not executed, and R moves on to the next line of code in the script.</p><p>To see how this works in practice, we can take the following example.</p><pre>age &lt;- 25<br><br>if (age &gt;= 18) {<br>  age_group &lt;- &quot;adult&quot;<br>}</pre><p>Here, we have a variable that contains an age. The if statement then evaluates whether the value of age is greater than or equal to 18. This is true in this case, so the variable age_group takes a value of “adult”.</p><p>This is an easy way of checking a simple condition and doing something if it’s true. But what if we want our statement to run some code if the condition is false?</p><p>If else statements are an extension of the basic if statement. To understand them, we can add to our previous example.</p><pre>if (age &gt;= 18) {<br>  age_group &lt;- &quot;adult&quot;<br>} else {<br>  age_group &lt;- &quot;child&quot;<br>}</pre><p>This code works just like the last example, with one exception. Instead of moving on when the condition is FALSE, the code inside the curly brackets after else gets executed. This means that if age is greater than or equal to 18, age_groupis assigned a value of “adult”. If not, age_group is set to “child”.</p><p>If-else statements are a straightforward way of controlling the code in an R script. They’re easily understood, can be extended to take many conditions, and can execute complex code that’s many lines long.</p><p>But, if-else statements can take up a lot of space. For simple expressions like the one above, there are other ways of doing exactly the same operation without using five lines of code.</p><p>In fact, it’s possible to write if-else statements using one line of code.</p><h3>Inline conditional statements in R</h3><p>Inline conditional statements are a neat way of expressing “if-else” logic in a single line of code. There are a couple of ways to write them.</p><h4>Inline if else statement</h4><p>First, it’s possible to write a simple inline statement using the if and else keywords. This takes the form below:</p><pre>age_group &lt;- if (age &gt;= 18) &quot;adult&quot; else &quot;child&quot;</pre><p>This statement works the same way as the previous example. The only difference is that now, we’ve condensed the phrasing to fit on one line. If the condition is TRUE, the value of age_group gets updated to whatever is before the else keyword — in this case, “adult”. If it were FALSE, age_group would be assigned whatever comes after else.</p><p>The big difference here is that we now assign the result of the whole conditional statement to the variable age_group. This improves on the repetitive phrasing in the standard if-else example, where we had to write this assignment twice.</p><h4>Base-R ifelse function</h4><p>If you prefer, you can use the ifelse function instead. The code below uses this function to execute the same logic as the previous examples.</p><pre>age_group &lt;- ifelse(age &gt;= 18, &quot;adult&quot;, &quot;child&quot;)</pre><p>The ifelse function takes three arguments. First, comes the condition, then a value to return if the condition is true, and a value to return if the condition is false.</p><p>This is a clean, straightforward way of writing a short conditional statement. It also has another advantage; it’s vectorized.</p><p><a href="https://towardsdatascience.com/make-your-r-code-10x-faster-vectorization-explained-in-3-minutes-9eb4cdd7a49e">Make Your R Code 10x Faster: Vectorization Explained in 3 Minutes</a></p><p>Vectorization is an important concept in R. If a function is vectorized, it automatically applies to multiple values instead of just one. To see an example with the ifelse function, let’s assign more values to our variable age, and run the code again.</p><pre>age &lt;- c(16, 45, 23, 82)<br><br>age_group &lt;- ifelse(age &gt;= 18, &quot;adult&quot;, &quot;child&quot;)<br># Returns &quot;child&quot; &quot;adult&quot; &quot;adult&quot; &quot;adult&quot;</pre><p>The ifelse function automatically evaluates all the values in age, returning a sequence of corresponding outputs. This makes ifelse a clean way of evaluating lots of simple conditions without needing slow, messy loops.</p><h3>Conditional indexing in R</h3><p>Although ifelse can evaluate many inputs easily, there are other ways to do this.</p><p><a href="https://rspatial.org/intr/4-indexing.html">Indexing</a> allows R programmers to access specific parts of a data structure that contains many values. For example, if we wanted to get the third element in the vector age from the last example, we could index age with 3 inside square brackets:</p><pre>age &lt;- c(16, 45, 23, 82)<br><br>age<br># Returns 16, 45, 23, 82<br><br>age[3]<br># Returns 23</pre><p>It’s most common to use numbers to index values with certain positions, like in the code above. But, many beginner R programmers don’t know that you can also use logical conditions when indexing. This opens up all sorts of possibilities.</p><p>Let’s create some example data to illustrate some of these options. This includes some information about users, such as age, as in the previous examples. But, rather than being stored in a vector, each user’s information is stored row-wise in a tibble. This is the kind of data structure you’d be likely to see if dealing with user data in a professional setting, so it’s useful to know how to apply conditional logic to it.</p><pre>set.seed(123)<br><br>user_data &lt;- tibble(<br>  user_id = 1:10,<br>  age = floor(runif(10, min = 13, max = 35)),<br>  region = sample(c(&quot;UK&quot;, &quot;USA&quot;, &quot;EU&quot;), 10, replace = TRUE)<br>)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NQUtYSE8o3j0tCgXlIqLww.png" /><figcaption>The data created by the code above.</figcaption></figure><p>Tibbles and data frames are made up of vectors, which means we can index them in the same way. This allows us to do all sorts of things.</p><h4>Extracting values in a column based on a condition</h4><p>Here’s some code that extracts any values of the user_id column where the user’s age is under 18.</p><pre>user_data$user_id[user_data$age &lt; 18]<br># Returns 6</pre><h4>Replacing values in a column based on a condition</h4><p>Here’s how to recode all the “UK” rows in the region column as “EU”.</p><pre>user_data$region[user_data$region == &quot;UK&quot;] &lt;- &quot;EU&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2wOPhJRglqI1BFG0oIsdtg.png" /><figcaption>The result of the code above, where the “UK” region values have been replaced with “EU”.</figcaption></figure><h4>Filtering a dataset with conditional indexing</h4><p>We can even use conditional subsetting to filter the whole dataset. Here’s a method of filtering all the rows where the region is “USA”. Note that after the logical condition here, we include a comma to tell R that we’re indexing by row. If we wanted to filter by column, we could add a condition after the comma.</p><pre>user_data[user_data$region == &quot;USA&quot;,]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZOvbVhE1YkAaRDFaEmSPMQ.png" /><figcaption>The result of the code above.</figcaption></figure><p>These are just a few applications of conditional indexing in R. If you need to do a quick conditional operation on data, chances are there’s a one-line solution for it using this method.</p><h3>Tidyverse case_when function</h3><p>The case_when function is from the tidyverse family of packages. It’s another way of applying conditional statements across a set of many values and is once again useful when working with datasets.</p><p>We can use the data from the last example to show how to create a new column based on conditional statements with case_when.</p><pre>user_data %&gt;%<br>  mutate(drinking_age = case_when(region == &quot;USA&quot; &amp; age &gt;= 21 ~ TRUE,<br>                                  region == &quot;EU&quot; &amp; age &gt;= 18 ~ TRUE,<br>                                  .default = FALSE))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0NrUVzD60QKsbh0e--vQhw.png" /><figcaption>The result of the code above, with the new column “drinking_age”.</figcaption></figure><p>This code determines whether our site users are legally allowed to drink alcohol based on their age and location. Here, each condition is on a different line in the case_when statement. If the condition is true, we can return a value after the tilde (~) symbol — in this case, TRUE. If neither of the conditions are satisfied, the value returned is specified by the .default setting. All the values are stored in a new column, drinking_age.</p><p>If this seems a bit unfamiliar, here’s the equivalent if else statement:</p><pre>if (region == &quot;USA&quot; &amp; age &gt;= 21) {<br>  drinking_age &lt;- TRUE<br>} else if (region == &quot;EU&quot; &amp; age &gt;= 18) {<br>  drinking_age &lt;- TRUE<br>} else {<br>  drinking_age &lt;- FALSE<br>}</pre><p>Compared with the code above, it’s easy to see that case_when provides yet another way of implementing conditional statements that is more concise than the if-else statement, while being just as powerful. It’s now my go-to for creating new columns based on complex logic or multiple conditions. For tidyverse users, it’s a must-adopt feature.</p><h3>When to use different kinds of conditional statements</h3><p>The methods I’ve covered only truly start to shine when you put them to work in your own code. Only by playing around with new approaches and getting comfortable with them will you reap their full benefits and achieve R programming fluency.</p><p>So, when should you use each type of conditional statement?</p><p>As with any choice between approaches in programming, there isn’t a straight answer. That said, here are some rough guidelines I use to help me choose between different ways of writing conditional statements.</p><ul><li>If I’m working on a problem that requires lots of complex, multi-line code to get executed upon certain conditions, I often prefer if-else statements. Using other methods often gets messy and hard to maintain in these situations.</li><li>For problems with simpler conditions and shorter code chunks to return, I like inline if-else statements. There’s no point in making a straightforward solution longer than it needs to be!</li><li>If working with datasets or creating columns based on conditions, I use case_when. It works well with the other tidyverse functions I use and is easy to debug and maintain.</li><li>If I’m working with datasets and don’t want to load extra packages, I’ll use conditional indexing. It doesn’t need any extra dependencies and often runs fast too.</li></ul><p>My advice? Have a play around with each technique and see what sticks for you. At the very least, you might pick up one new way of making your code better.</p><p>So, <strong>if</strong> you liked this article, why not share your favourite conditional statement? <strong>Else… </strong>thanks for staying until the end anyway!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9bedbae0683" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-to-write-conditional-statements-in-r-four-methods-f9bedbae0683">How to Write Conditional Statements in R: Four Methods</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Five Things I Learned From My First R Programming Event]]></title>
            <link>https://medium.com/data-science/five-things-i-learned-from-my-first-r-programming-event-3fceb3caa6a1?source=rss-39501aa8ce39------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fceb3caa6a1</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[rstats]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Rory Spanton]]></dc:creator>
            <pubDate>Thu, 11 May 2023 13:39:44 GMT</pubDate>
            <atom:updated>2023-05-13T20:46:01.675Z</atom:updated>
            <content:encoded><![CDATA[<h4>Lessons about R, data science, and engaging an audience from SatRDays London</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rL_chWq6Wu7EdKFX" /><figcaption>Photo by <a href="https://unsplash.com/@xteemu?utm_source=medium&amp;utm_medium=referral">Teemu Paananen</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Last month, I did something I’d never done before. I attended an in-person event all about data science — specifically, doing data science in the R programming language.</p><p>Conferences aren’t new to me. As a researcher in psychology, I’ve attended and presented at many conferences in my field. But, despite being a long-time R enthusiast, I hadn’t ever got the chance to go to a non-academic conference about data analysis. So, when I got an opportunity to attend SatRDays London, a one-day event all about R, I threw myself at it.</p><p>It was a great decision. I learned a lot about R and its uses in many industries, some of which I’d never even heard of before. I also got to talk to lots of other people who are as geeky about R as me, which was a real treat.</p><p>Here are five of the most powerful things I learned from SatRDays.</p><h3>1. R has more uses than I ever thought</h3><p>Think you know all the things R can do? Think again.</p><p>I sometimes hear data scientists write off R as a specialist language with only a few uses. They say if you’re not doing bioinformatics, academic research, or hardcore statistics, no one in your field uses R. Python is the general-purpose, “do everything” language you should use instead.</p><p>This is true to a certain extent — other languages like Python are more widely used than R and are valuable in their own right. But that doesn’t mean that R can’t tackle many important tasks in various sectors.</p><p>The range of talks at SatRDays was incredible. Every speaker was from a different company, presenting new and interesting ways they use R for data analysis in their industry.</p><p>I listened to data journalists, financial auditors, internet performance analysts, air quality practitioners, and many more share their experiences with R. As an academic, half of these sectors weren’t even on my radar before the conference. Hearing from these people opened my eyes to the wealth of uses for R in various business contexts.</p><p>Sure, there aren’t so many R jobs as Python jobs floating around. But let no one tell you that you’re backing yourself into a corner by learning R. It’s becoming clear that more and more companies are adopting it, and there are many new use cases to be excited about.</p><h3>2. Good R code separates calculations from actions</h3><p>This is a tip I picked up from <a href="http://russ-hyde.rbind.io/">Russ Hyde</a>’s talk on good coding practices. It might be familiar to more experienced developers, but it was new and useful to me.</p><p>When programming, it’s often best to compartmentalize your code into user-defined functions. This helps to avoid repetition in your scripts and ensures your code is reusable and easy to maintain. But, some ways of splitting your code into different functions are better than others.</p><p>For instance, consider a short script that reads in some data, cleans it up, and then writes it to a new file. This script consists of many steps, but we can classify each of them into two categories: calculations and actions.</p><pre>read_csv(&quot;sales_data.csv&quot;) %&gt;%<br>  select(date, transaction_id, category, item_price) %&gt;%<br>  filter(date == &quot;2023-05-10&quot;) %&gt;%<br>  group_by(category) %&gt;%<br>  summarise(day_turnover = sum(item_price)) %&gt;%<br>  write_csv(&quot;sales_summaries/day_turnover_2023-05-10.csv&quot;)</pre><p>Calculations are steps that will return the same output each time, given a certain input. Operations like filtering datasets and calculating summary statistics are good examples of this. Because they return predictable results without any side effects, it’s easy to write automated tests to confirm that they’re working properly.</p><p>Actions, by comparison, are much harder to test. They have side effects, such as writing data to a file, that are more difficult to contain. They may also be affected by RNG or other variables in the global environment. This makes testing them a challenge, often requiring dummy files or a controlled environment.</p><p>The tip is this: whenever possible, separate actions from calculations.</p><p>Here’s an example using the code I introduced earlier. Rather than having actions and calculations in a block, I separate them into two functions. All the actions that read and write data are contained in one function, and all my calculations are in another.</p><pre>calculate_turnover &lt;- function(sales_data, day) {<br>  sales_data %&gt;%<br>    select(date, transaction_id, category, item_price) %&gt;%<br>    filter(date == day) %&gt;%<br>    group_by(category) %&gt;%<br>    summarise(day_turnover = sum(item_price))<br>}<br><br>action_turnover &lt;- function(day) {<br>  read_csv(&quot;sales_data.csv&quot;) %&gt;%<br>    calculate_turnover(day) %&gt;%<br>    write_csv(paste0(&quot;sales_summarise/day_turnover_&quot;, day, &quot;.csv&quot;))<br>}<br><br>action_turnover(&quot;2023-05-10&quot;)</pre><p>This makes for neat, compartmentalized code. Testing the calculations is a breeze, as they’re tidied away from any side effects of the actions. This separation also makes my actions easier to test.</p><p>“Oh yeah, they do that all the time in game dev, too”, replied one of my colleagues as I told him about this approach. If you come from a software development background, you likely might already know about this. But folks in the data industry arrive from all sorts of places and sometimes never learn those kinds of tricks. While I’ve taught myself some good coding principles, this was a new one for me, and I’ll make more use of it going forward.</p><h3>3. Rigorous testing is essential and expected</h3><p>Speaking of testing, it was a common theme across the whole conference.</p><p>One talk by Vyara Apostolova and Laura Cole from the National Audit Office had a heavy focus on tests and checks. Their work involves taking important government models and reproducing them in R. Along the way, they meticulously test every assumption in each model, checking for errors and discrepancies.</p><p>This can take years from start to finish. But, this meticulous work is vital for spotting costly errors. They revealed that their work has saved millions of pounds from being wasted on unnecessary costs resulting from mistakes in financial models. All because they test, check, and evaluate everything they code within a rigorous framework.</p><p>Throughout the rest of the talks, audience questions often related to testing. If someone presented a cool new way of doing something with R, the first thing people wanted to know was how they’d test it.</p><p>Although R is built into our academic teaching and practice in my workplace, testing is highly undervalued. Coming from an outside perspective, SatRDays made me realize just how important it is for data professionals to have robust, automated procedures for checking their work.</p><p>Whether you’re already working with data or trying to break into the industry, testing can cement the value of your work. Coming out of SatRDays, I’m planning to improve my software testing chops before looking for a job in a few months.</p><h3>4. Learning R can be hilarious</h3><p>I’ve written before about how <a href="https://medium.com/towards-data-science/make-learning-r-fun-with-these-5-packages-3c3f6ca82c96">fun</a> learning R can be. But I had never laughed out loud at a data science talk before SatRDays.</p><p>If I had to pick a favourite talk from the whole day, it’d be <a href="https://www.datawookie.dev/blog/">Andrew Collier</a>’s “Sidekicks of the Tidyverse”. In this presentation, Andrew walked through some lesser-known functions in the tidyverse, and how they complement more commonly used functions.</p><p>Explaining how code works in a talk is a tough task. You walk a tightrope, balancing between being informative and not losing your audience in technicalities. All the talks at SatRDays achieved this balance, but Andrew did so with stand-out humour and style.</p><p>His talk was peppered with pop-culture references and jokes that perfectly gauged the taste of the audience. Besides being funny, these worked to relate new concepts to information the audience already knew.</p><p>Using humour in a presentation means putting yourself out there. Getting some laughs out of your audience is a uniquely warm and validating experience. The feeling you get when your jokes echo around a silent room is the complete opposite. Such are the highs and lows of presenting.</p><p>That said, humour is a great tool in technical presentations, even if doesn’t always work out. Rather than being an entertaining distraction, it can even make your explanations better if used well. Going forward, I’ll try to add a little more humour to my talks to make them stand out.</p><h3>5. The R community is one-of-a-kind</h3><p>The R community is amazing.</p><p>This point shouldn’t come as a surprise to anyone who knows me well. I encourage community engagement when <a href="https://towardsdatascience.com/how-to-learn-r-for-data-science-fast-d47408d0becf">learning R</a> and even when choosing which software packages to use.</p><p><a href="https://towardsdatascience.com/tidyverse-vs-base-r-how-to-choose-the-best-framework-for-you-29b702bdb384">Tidyverse vs. Base-R: How To Choose The Best Framework For You</a></p><p>But, I’d never occupied the same space as so many R users and professionals before. I didn’t know anyone at the start of the day, so I was banking on finding at least a couple of nice people to talk to. I was a little nervous, to tell the truth.</p><p>I needn’t have worried. Everyone I met was friendly, approachable, and interesting to talk to. I’m not an extrovert or a natural at networking, but I ended up staying on my feet and chatting with people during all the breaks. I know for a fact that’s not a given at all events — I’ve spent a few lonely lunches without company before, so I was especially glad of it here.</p><p>The R community is diversifying, too. Ella Kaye and Heather Turner talked about their ongoing work to get members of underrepresented groups involved in maintaining the R language. Right now, most major contributors to the language are Western men nearing the end of their careers. To keep R working and evolving with the times, it’s important to pass the torch to a more diverse set of contributors from around the world. Ella and Heather shared various initiatives and events they’re setting up to make this happen, all of which sounded like promising steps forward.</p><p>I was pleased to see this diversity reflected in the audience. Although I counted myself among many other white, bespectacled men in attendance, there were plenty of others with different genders, traits and backgrounds. I got a sense that everyone was included and that the organizers were actively facilitating this.</p><p>If there’s a moral here, it’s that you shouldn’t be afraid to connect with people, especially in the R community. They can give you invaluable insight into jobs, companies, and technologies that can move your career forward. And, at least in my experience, they’re really nice.</p><p>Going to an R event was a great experience, and I’m hoping to do it again sometime. I learned not just about my favourite language, but the people and the industries that use it. It’s safe to say I’ll be taking a lot away from SatRDays and acting on my newfound knowledge in the months to come.</p><p>If you do anything after reading this, find some events centred around your favourite data science technologies and see if you can go to one. Jumping Rivers, the company that organized SatRDays, have a <a href="https://jumpingrivers.github.io/meetingsR/index.html">list of R events</a> to look into. Other groups like <a href="https://www.rladies.org/">RLadies</a> often run in-person meetups all around the world too.</p><p>Going to a new event can be intimidating, but if it’s relevant to you and your interests, it’s likely to pay off.</p><p><strong>Want to get all my articles on R programming, data science, and more delivered straight to your inbox? </strong><a href="https://roryspanton.medium.com/subscribe"><strong>Subscribe here</strong></a><strong>.</strong></p><p>For full access to all my stories on Medium, sign up for a membership with <a href="https://medium.com/@roryspanton/membership">this link</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fceb3caa6a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/five-things-i-learned-from-my-first-r-programming-event-3fceb3caa6a1">Five Things I Learned From My First R Programming Event</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Profile and Speed Test Code in R]]></title>
            <link>https://levelup.gitconnected.com/how-to-profile-and-speed-test-code-in-r-ef8508eaef80?source=rss-39501aa8ce39------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef8508eaef80</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[rstats]]></category>
            <dc:creator><![CDATA[Rory Spanton]]></dc:creator>
            <pubDate>Mon, 27 Mar 2023 00:43:43 GMT</pubDate>
            <atom:updated>2023-03-27T00:43:43.698Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn speed testing by analyzing big tech stock prices</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3T6GsRPr3KO7ldEKV2LeYA.jpeg" /><figcaption><a href="https://www.pexels.com/photo/man-in-sports-clothing-checking-his-stopwatch-5037300/">Photo by Ketut Subiyanto</a></figcaption></figure><p>The difference between good code and great code is often speed.</p><p>When you’re repeating computationally expensive tasks, small speed improvements add up. Speed is also crucial if you’re developing software for other people. Time is precious, and no one likes waiting an age for code to run.</p><p>So, how can you measure the execution time of your code, and how can you see which expressions are slowing your code down?</p><p>If you’re an R programmer, there are several packages and tools that can help you answer both of these questions.</p><p>In the spirit of efficiency, let’s get straight into using them.</p><h3>How to tell how fast your R code is running</h3><p>An easy way to tell how fast your R code is running is by using the <a href="https://cran.r-project.org/web/packages/tictoc/tictoc.pdf">tictoc</a> package. All you need to do is load the package, and call two functions. Calling tic starts a timer and calling toc stops the timer and returns the amount of time elapsed in seconds.</p><pre>library(tidyverse)<br>library(tictoc)<br><br>tic()<br><br>tech_stocks &lt;- read_csv(&quot;https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-02-07/big_tech_stock_prices.csv&quot;)<br><br>toc()</pre><p>We can see tic and toc timing a chunk of code in the example above. Here, we measure the time it takes to load a dataset about stock prices from GitHub. The speed of any operation will vary based on your computer. On my machine, the result was a time of 1.81 seconds, printed to the R console.</p><p>This is a convenient way of seeing how fast your code is running. It’s useful for rough measurements and slots easily into existing scripts.</p><p>But, tictoc can’t tell you which parts of your code are running slow or fast. It just gives a rough indication of the time it takes to run a selection of code once. To get more information about which operations are slowing your code down, you need to start profiling.</p><h3>How to profile code in R</h3><p>Profiling allows you to see exactly what each part of your R code is doing, and how long it takes to run. Using RStudio, you can profile your code with the profvis package and the profiling interface.</p><p>To explore this tool, let’s analyze some of the stock prices from the data we loaded in the last example.</p><p>In the code below, we filter the data to focus on the “big five&quot; tech stocks — META, AAPL, AMZN, NFLX, and GOOGL — and analyze changes in their closing price.</p><pre># Filter tech stocks to only include FAANG prices from last year, calculate daily pct gain<br>stock_pct_gain &lt;- tech_stocks %&gt;%<br>  filter(stock_symbol %in% c(&quot;META&quot;, &quot;AAPL&quot;, &quot;AMZN&quot;, &quot;NFLX&quot;, &quot;GOOGL&quot;) &amp; date &gt; &quot;2022-03-18&quot;) %&gt;%<br>  mutate(gainloss = (close - open)/open)<br><br># Get the mean daily gain/loss percentage for FAANG stocks<br>stock_pct_gain %&gt;%<br>  group_by(stock_symbol) %&gt;%<br>  summarise(mean(gainloss))<br><br># Plot closing prices of FAANG stocks<br>stock_pct_gain %&gt;%<br>  ggplot(aes(y = close, x = date, colour = stock_symbol)) +<br>  geom_line() +<br>  labs(x = &quot;Date&quot;, y = &quot;Close&quot;) +<br>  scale_x_date(date_breaks = &quot;2 months&quot;) +<br>  scale_y_continuous(breaks = seq(100, 400, 50)) +<br>  theme_classic()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*75i9tysZTdk-lnhaKOj5vQ.png" /></figure><p>This code returns some summary statistics and a line graph of each stock’s closing price, seen above. There are two ways to profile this code.</p><ul><li>Highlight it with the cursor, then select “Profiling -&gt; Profile Selected Line(s)” from the RStudio toolbar</li><li>Surround the code inside the profvis function. Use the format profvis({ code here })</li></ul><p>Both options bring up a user interface with information about our code speed. The folks at Posit have put together a <a href="https://support.posit.co/hc/en-us/articles/218221837-Profiling-R-code-with-the-RStudio-IDE">comprehensive guide</a> to this interface, but for now we’ll be focusing on the “Data” tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*jGgo3FIrulu4rMYT3HoVhw.png" /><figcaption>The “Data” tab in the profiling interface (screenshot by author)</figcaption></figure><p>Selecting this tab gives the comparative speed and memory used by each operation in our code. From this, we can see that the code surrounded by profvis ran for a total of 50 ms. Of the operations we profiled, filter took the longest to execute. This means that optimizing this operation will be the best way to make our code run faster.</p><p>We can now compare the speed of different alternatives to dplyr::filter. While we previously used tictoc to time our code, it can’t make precise measurements or easily compare the speeds of different chunks of code. For this, there is a better solution.</p><h3>Speed testing code with microbenchmark</h3><p>Unlike tictoc, the <a href="https://cran.r-project.org/web/packages/microbenchmark/microbenchmark.pdf">microbenchmark</a> package gives sub-second measures of how fast your code is running. Its microbenchmark function measures execution time to the nanosecond, allowing a precise comparison of different expressions.</p><p>It runs each expression you give it a hundred times and returns the average execution time and several other performance metrics. Execution time varies between runs, so these stats give a more comprehensive measure of your code’s speed than a single measurement.</p><p>We can use microbenchmark to measure the execution time of different filter functions to improve the speed of our last example. R has many functions that filter rows from data sets, so it’s important to compare them and choose the fastest.</p><p>For this test, I had four expressions to compare: one using dplyr::filter, another using base::subset, a base indexing expression, and a data.table filtering expression. As written below, they all give the same output.</p><pre># Define stocks of interest<br>big_tech &lt;- c(&quot;META&quot;, &quot;AAPL&quot;, &quot;AMZN&quot;, &quot;NFLX&quot;, &quot;GOOGL&quot;)<br><br># Option 1: dplyr::filter<br>dplyr::filter(tech_stocks, stock_symbol %in% big_tech &amp; date &gt; &quot;2022-03-18&quot;)<br><br># Option 2: base::subset<br>base::subset(tech_stocks, stock_symbol %in% big_tech &amp; date &gt; &quot;2022-03-18&quot;)<br><br># Option 3: base indexing<br>tech_stocks[(tech_stocks$stock_symbol %in% big_tech &amp; tech_stocks$date &gt; &quot;2022-03-18&quot;),]<br><br># Option 4: data.table filtering<br>tech_stocks_dt &lt;- data.table::as.data.table(tech_stocks)<br>tech_stocks_dt[stock_symbol %in% big_tech &amp; date &gt; &quot;2022-03-18&quot;,]</pre><p>To give these functions to microbenchmark, we first store them in a list as <a href="http://adv-r.had.co.nz/Computing-on-the-language.html">unevaluated expressions</a> using the substitute function. This stores each expression itself, rather than its result, allowing it to be evaluated later by microbenchmark.</p><p>We can then give each list item a name. These names will act as labels in the microbenchmark output, making the results much neater.</p><pre># Storing each as inside a list<br>expressions &lt;- list()<br><br>expressions[[1]] &lt;- substitute(dplyr::filter(tech_stocks, stock_symbol %in% big_tech &amp; date &gt; &quot;2022-03-18&quot;))<br>expressions[[2]] &lt;- substitute(base::subset(tech_stocks, stock_symbol %in% big_tech &amp; date &gt; &quot;2022-03-18&quot;))<br>expressions[[3]] &lt;- substitute(tech_stocks[(tech_stocks$stock_symbol %in% big_tech &amp; tech_stocks$date &gt; &quot;2022-03-18&quot;),])<br>expressions[[4]] &lt;- substitute(tech_stocks_dt[stock_symbol %in% big_tech &amp; date &gt; &quot;2022-03-18&quot;,])<br><br>names(expressions) &lt;- c(&quot;dplyr::filter&quot;, &quot;base::subset&quot;, &quot;base indexing&quot;, &quot;data.table filtering&quot;)</pre><p>With this done, we can test our list of unevaluated expressions using microbenchmark. We can also specify how many times each expression should be run. The default is 100, but I’ve set it to 200 in this example.</p><pre>library(microbenchmark)<br><br>microbenchmark(list = expressions, times = 200)</pre><p>The output of microbenchmark provides timing statistics for each function we tested. There’s a lot of information, but the most useful for us is the mean execution time. This reveals large speed differences. dplyr::filter took an average of 25380 microseconds to run — over 10 times slower than the other expressions.</p><p>This is justifies swapping out dplyr::filter for one of the faster alternatives we tested, like the Base-R indexing approach. Speed isn’t the only factor one should account for when choosing between functions from Base-R, tidyverse, or other packages. However, the Base-R approach was the fastest in this comparison, and so would be preferable if time was our main concern.</p><p><a href="https://towardsdatascience.com/tidyverse-vs-base-r-how-to-choose-the-best-framework-for-you-29b702bdb384">Tidyverse vs. Base-R: How To Choose The Best Framework For You</a></p><h3>Should you always speed test R code?</h3><p>Speed testing is essential for writing efficient analyses or software in R. But, profiling and benchmarking everything you write takes time. Is it really worth doing for every script you write?</p><p>There are a few factors that determine whether speed testing is necessary in a given case.</p><p>One of these is usage. If you’re writing a one-off analysis that will only be run a couple of times, then it may not be worth speed testing. But, if you’re developing software or analyses that will be run often by many users, it’s worth the effort to make sure your code is as efficient as possible.</p><p>Another factor to consider is computational expense. Imagine you have code that involves demanding operations like manipulating large datasets or doing complex simulations. If this code already takes a long time to run, profiling and optimizing it could save hours in execution time. Speed testing this code would therefore be a worthwhile investment, even if you’re the only one using it.</p><p>In general, it’s good practice to speed test your code. As with any habit, it gets easier the more you do it. Speed testing can also help you become a more efficient programmer, as it highlights commonly-used expressions in your code that are slow and pushes you to find better alternatives.</p><p>If you’re developing any code that’ll be shared, regularly used, or computationally expensive, give it a try. It won’t just make your code faster. It’ll make you a better programmer.</p><p><strong>Want to get all my articles on R programming, data science, and more delivered straight to your inbox? </strong><a href="https://roryspanton.medium.com/subscribe"><strong>Subscribe here</strong></a><strong>.</strong></p><p>For full access to all my stories on Medium, sign up for a membership with <a href="https://medium.com/@roryspanton/membership">this link</a>.</p><h3>Level Up Coding</h3><p>Thanks for being a part of our community! Before you go:</p><ul><li>👏 Clap for the story and follow the author 👉</li><li>📰 View more content in the <a href="https://levelup.gitconnected.com/?utm_source=pub&amp;utm_medium=post">Level Up Coding publication</a></li><li>💰 Free coding interview course ⇒ <a href="https://skilled.dev/?utm_source=luc&amp;utm_medium=article">View Course</a></li><li>🔔 Follow us: <a href="https://twitter.com/gitconnected">Twitter</a> | <a href="https://www.linkedin.com/company/gitconnected">LinkedIn</a> | <a href="https://newsletter.levelup.dev/">Newsletter</a></li></ul><p>🚀👉 <a href="https://jobs.levelup.dev/talent/welcome?referral=true"><strong>Join the Level Up talent collective and find an amazing job</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef8508eaef80" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/how-to-profile-and-speed-test-code-in-r-ef8508eaef80">How to Profile and Speed Test Code in R</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Got Paid To Take Down My Most Popular Medium Article]]></title>
            <link>https://medium.com/illumination/i-got-paid-to-take-down-my-most-popular-medium-article-54e15dd52e56?source=rss-39501aa8ce39------2</link>
            <guid isPermaLink="false">https://medium.com/p/54e15dd52e56</guid>
            <category><![CDATA[publishing]]></category>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[freelancing]]></category>
            <dc:creator><![CDATA[Rory Spanton]]></dc:creator>
            <pubDate>Sat, 11 Mar 2023 04:56:03 GMT</pubDate>
            <atom:updated>2023-03-11T04:56:03.627Z</atom:updated>
            <content:encoded><![CDATA[<h4>What I learned from my first republication deal as a writer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YM0Q64R0av1ILGxNGIJbxA.png" /><figcaption><a href="https://www.pexels.com/photo/a-laptop-on-a-table-5703527/">Photo by Tima Miroshnichenko from Pexels</a>. Image edited by author.</figcaption></figure><p>I’m immediately suspicious whenever I get an email that offers me money. Being a casual writer with a small audience, I don’t get lots of opportunities flooding my inbox. The only emails I get that promise me money are from long-lost relatives or Nigerian royalty. They go straight into my junk folder.</p><p>So, you can imagine my surprise when I get a message from an editor at a careers website. A message saying that they liked one of my most popular Medium articles and that they wanted to pay me to take it down and republish it on their site.</p><p>A month later I had an article on a popular website and was several hundred dollars richer. You can <a href="https://builtin.com/software-engineering-perspectives/fizzbuzz">read it here</a> if you like.</p><p>I couldn’t believe it. The first company to pay me for an article came to <em>me</em>. Mind — blown.</p><p>Here’s exactly how it happened, and what I learned from the process.</p><p>I wrote the article in question years ago, back in late 2020. Like much of my writing on Medium, it was a technical article about programming. Specifically, how to solve a common software engineering interview question using the R programming language.</p><p>If you think that sounds boring, then fair enough; it’s a bit of a niche topic. But, this intersection of careers and data science helped it do well online. Over two years, it got 70K views, though most of these were from external sources like Google.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*ehSIqssZNWltXKSforDyxg.png" /><figcaption>A screenshot of the stats for my article when it was still on Medium. That’s a lot of external traffic.</figcaption></figure><p>Something that helped my article’s reach was taking it off the partner program for a while. I noticed that 99% of my views were coming from external sources and I wasn’t making much money from Medium member reads. I wondered if making it free would drive further traffic to the article and act as an entry point to some of my other content.</p><p>I was right. Google latched onto my article and recommended it widely, driving consistent traffic for years. I suspect this is how the editor found my work.</p><p>Before publishing my article, they reformatted it to fit their site theme and gave it a light copy-edit.</p><p>This experience was insightful in itself. I’d never worked with a professional editor before outside of an academic context, so to see them trim the fat from my work was enlightening. Some of their amendments made me say aloud “why did I ever phrase it like that in the first place?”. I remembered it when writing my next piece, that’s for sure.</p><p>Once the piece came out, I took down the original and got paid.</p><p>In all, it was a great experience. The editor was helpful and the whole process was smooth, even though it was new to me.</p><p>I’ll admit, I got lucky with this situation. But I also learned some valuable lessons about writing and selling my work as a freelancer.</p><h4>1. Free content makes you visible</h4><p>I used to think that all the content I put on Medium needed to be behind a paywall. What’s the point of being in the partner program if I’m not making use of it?</p><p>I still meter most of my content on Medium. But, selling this article taught me that keeping some of your content free can pay you back in the long run. The extra few dollars I’d have made keeping my article paywalled might have lost me the chance to sell it for hundreds more.</p><p>Other writers have used visibility to their advantage. <a href="https://medium.com/u/14d5c41e0264">Zulie Rane</a> has <a href="https://www.youtube.com/watch?v=OmZWKyysOzM">talked extensively</a> about how she built up her career as a freelance writer by releasing helpful, SEO-friendly articles on popular topics. Being visible helped clients find her, leading to a six-figure writing career.</p><p>This approach is especially useful for writers from countries that Medium won’t pay out to. You can still leverage your free content for money, and other opportunities might come to you as a result.</p><h4>2. Write articles that solve problems</h4><p>I suspect that one of the reasons my article got found and valued in the first place was its topic. Rather than being purely technical, it addressed a specific, well known problem.</p><p>Giving programming advice that solved a common job interview question resonated with a wider audience than a more general-purpose guide. People are much more likely to read informative articles that give them solutions that matter to them personally.</p><p>Writing articles that solve problems also appeals more to companies. Every decent company has problem-focused mission. The one that acquired my article helps tech professionals get hired, and so a combination of tech and career advice was a perfect fit.</p><p>This was made clear to me when I asked if they’d be interested in acquiring any of my other articles. I never heard back. I now know this is because the articles I offered weren’t problem-focused, and so didn’t fit with their mission.</p><h4>3. As a new writer, seek out professional editors</h4><p>When I was editing my article on Medium years ago, I remember thinking it was pretty neat. I had run it through Hemingway editor, cut down unnecessary phrases and made it as clear as I could. I only saw how much further I could go when I worked with a pro.</p><p>Seeing how they formatted the article was helpful too. Good editors are masters of using formatting features like quotes, boxes, and embedded content to put emphasis on important points. Seeing them do this gave me good ideas on how to make key parts of my future pieces stand out.</p><p>Again, successful Medium writers have talked about the benefits of having your work edited. <a href="https://medium.com/u/51e7eb466f57">Sean Kernan</a>’s <a href="https://medium.com/@seanjkernan/a-professional-editor-ripped-my-writing-to-shreds-here-are-the-lowlights-b841648565c3">experience</a> having his writing critiqued by a professional editor (who also happened to be his girlfriend) is a favourite of mine.</p><p>I realize that “professional editors make your writing better” isn’t groundbreaking advice. But, I’d still encourage any newer writers to submit to publications where their work gets a light edit from someone who does it for a living.</p><p>Take notes of the things they change, and you’ll be able to apply some of those lessons in your next piece.</p><p>Being approached about republishing one of my articles was a great experience. I was fortunate to get a glimpse into the process of editing and finalizing a paid article deal without having to pitch anything.</p><p>I also gained a big confidence boost, and I plan on pitching more content to similar sites in the future. Opportunities don’t often wander into my inbox, so I’d rather take action than wait around for another lucky chance.</p><p>I doubt I’ll get such a good deal for a while, but nothing will stop me from trying.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54e15dd52e56" width="1" height="1" alt=""><hr><p><a href="https://medium.com/illumination/i-got-paid-to-take-down-my-most-popular-medium-article-54e15dd52e56">I Got Paid To Take Down My Most Popular Medium Article</a> was originally published in <a href="https://medium.com/illumination">ILLUMINATION</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Tried Shepper, A Seriously Underrated Side Hustle App]]></title>
            <link>https://medium.com/the-side-hustle-club/i-tried-shepper-a-seriously-underrated-side-hustle-app-47fc746f3801?source=rss-39501aa8ce39------2</link>
            <guid isPermaLink="false">https://medium.com/p/47fc746f3801</guid>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[gig-economy]]></category>
            <category><![CDATA[side-hustle]]></category>
            <category><![CDATA[money]]></category>
            <category><![CDATA[uk]]></category>
            <dc:creator><![CDATA[Rory Spanton]]></dc:creator>
            <pubDate>Mon, 06 Mar 2023 15:36:56 GMT</pubDate>
            <atom:updated>2023-03-11T10:03:05.893Z</atom:updated>
            <content:encoded><![CDATA[<h4>Here’s how much I earned and whether I’ll keep using it</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pBrkkWErqRcl4HInE4fqkQ.jpeg" /><figcaption><a href="https://www.pexels.com/photo/focused-young-man-taking-picture-of-morning-scenery-on-smartphone-4453152/">Photo by Helena Lopes from Pexels</a></figcaption></figure><p>Most apps that pay you for doing manual tasks suck.</p><p>Grinding through surveys or tedious phone games at home for a £10 Amazon voucher has never been my idea of a good time.</p><p>So, I was intrigued when I came across Shepper; an app that pays you to take photos and perform product checks in the real world.</p><p>It sounded like a great concept, yet after looking around, I couldn’t find many stories of people who’d actually used it. That, and their rating on the Google Play store is 2.0 out of 5. What’s the catch?</p><p>I decided to find out.</p><p>Here’s my unaffiliated, honest review of Shepper.</p><h3>What is Shepper?</h3><p>Shepper is an app that has workers conduct in-store checks and similar jobs in exchange for cash.</p><p>The content of these checks varies. Workers (or Shepherds, as the app calls them) might be asked to take photos of promotional displays in stores, find certain billboards or adverts in set locations, or covertly ask staff about products in “mystery shopping” tasks.</p><p>All this happens through the Shepper app, where workers can sign up for jobs, answer questions and take photos during checks. Once a check is complete, the responses and photos go off to Shepper’s review team.</p><p>If there are major discrepancies in a worker’s responses or photos, then the job is rejected and placed back on the market for others to retry. If all is well, the check is accepted and the worker gets paid. It’s pretty straightforward.</p><h3>My experience using Shepper</h3><p>I first tried Shepper three months ago and have since completed nearly 20 jobs. I’ve mainly stuck to basic jobs that involve taking photos of in-store displays, and occasionally asking follow up questions to store employees.</p><p>My experience with the app itself has been positive, and the instructions for checks are clear and easy to follow. If you follow these instructions and take clear photos, your checks are unlikely to get rejected, too. I get the impression that the review team try to fix small errors and only reject checks if bigger mistakes happen.</p><p>Most of my interactions with store employees on Shepper checks have been smooth. Once you explain what you’re doing, most staff allow you to go right ahead, although I’ve had some react more cautiously and check my permission documents and ID on the app before allowing me to proceed. Some of these conversations can be a bit awkward, but you learn to roll with it after a few jobs.</p><p>For braver Shepherds, “mystery shop” jobs task you with having extended conversations with staff and then secretly reporting their responses later. I haven’t tried any yet — I’m too introverted for that.</p><p>Overall, working on Shepper has been a good experience.</p><p>I see Shepper jobs as a real-life equivalent of minor side quests in a video game. They’re not always tons of fun, but they’re varied and quick enough to be interesting.</p><h3>How much money can you make with Shepper?</h3><p>The <a href="https://shepper.com/how-much-can-you-earn-with-shepper/">Shepper website</a> will tell you that jobs will pay anywhere from £2 to £20, depending on how many tasks they involve.</p><p>This sounds simple, but in practice, there’s more to choosing good jobs than just the money.</p><p>Some jobs will inevitably be further away, requiring longer travel times to reach. Shepper might pay you £6 for a 10-minute job, but if you’re travelling 20 minutes each way to get there and back, that becomes £6 for 50 minutes of total effort. Not worth it, right?</p><p>That said, finding jobs that are close together can help boost your hourly pay. I’ve earned £20 for 30 minutes of work (travel included) by taking well-priced jobs that were close together near my location. That’s not a bad rate.</p><p>As shown below, I’ve earned £101 in total on Shepper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YKmGzyTpbWscdjg69br5aA.png" /><figcaption>An earnings summary on Shepper, taken as a screenshot from the app by the author.</figcaption></figure><p>Although that reflects slightly below average earnings according to Shepper (the average worker earns £54 a month, apparently), I’m still happy with it. I haven’t put much time into the app and have been selective with the jobs I’ve taken, so it makes sense that I haven’t earned loads of money.</p><p>Top Shepherds can make several thousand pounds per year, so there’s certainly scope for good earnings.</p><h3>Are there any downsides to working on Shepper?</h3><p>Although I’ve enjoyed working on Shepper, I can see some potential downsides to it.</p><ul><li>Right now, Shepper only operates inside UK territory. This means that if you don’t live there, you can’t take on jobs with them</li><li>If you live in a rural area with fewer stores, you’ll likely have fewer jobs available nearby. This could reduce your earnings</li><li>Shepper isn’t scalable like some other side hustles. The <a href="https://shepper.com/how-much-can-you-earn-with-shepper/">highest earning </a>Shepherd made £7k in 2020. While that’s a lot, it’s lower than the top earnings for something like creating an online course</li></ul><p>It’s also important to realise there aren’t always lots of jobs available. While this isn’t necessarily a downside — Shepper is only a side hustle, after all — it’s good to manage your expectations. If you’re looking for a constant stream of jobs available all week, you’ll be disappointed.</p><p>From my perspective, this is app’s biggest limitation. Hopefully the team at Shepper can release more regular checks in the future to improve on this.</p><h3>Is Shepper a good side hustle?</h3><p>Yes. I think Shepper is a worthwhile side hustle for those looking to bring in some extra money.</p><p>While it won’t make you rich, it’s a legitimate way to bring in some cash that’ll add up over time. There are plenty of positives to working on the app.</p><ul><li>You can accept as many or as few jobs as you like, whenever you want</li><li>Hourly rates can be high, depending on the pay rates and locations of available jobs</li><li>It’s not likely to be made obsolete by AI any time soon because it relies on workers physically travelling to locations</li></ul><p>Right now, Shepper seems underrated. I see many areas on the map where decent jobs hang around uncompleted for days. If you join and find you’re in one of these “quiet” areas, you could be able to earn good money with little competition.</p><p>I like Shepper. I doubt that I’ll become a high earner on the app any time soon. But, it gets me outside, makes a change from the rest of my daily work, and gives me some extra cash.</p><p>If you live in the UK and need some spare cash, don’t be put off by the Google reviews and give it a go.</p><p>That is unless you live near me and want to take all the local jobs. In that case, it’s not for you, and you should definitely try something else.</p><p><a href="https://sidehustleclub.substack.com/embed">Side Hustle Club | Marx | Substack</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47fc746f3801" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-side-hustle-club/i-tried-shepper-a-seriously-underrated-side-hustle-app-47fc746f3801">I Tried Shepper, A Seriously Underrated Side Hustle App</a> was originally published in <a href="https://medium.com/the-side-hustle-club">The Side Hustle Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tidyverse vs. Base-R: How To Choose The Best Framework For You]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/tidyverse-vs-base-r-how-to-choose-the-best-framework-for-you-29b702bdb384?source=rss-39501aa8ce39------2"><img src="https://cdn-images-1.medium.com/max/2600/1*XFu0_97BmpzMm33nFK2roQ.jpeg" width="5238"></a></p><p class="medium-feed-snippet">The pros and cons of the most popular approaches to R programming</p><p class="medium-feed-link"><a href="https://medium.com/data-science/tidyverse-vs-base-r-how-to-choose-the-best-framework-for-you-29b702bdb384?source=rss-39501aa8ce39------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/tidyverse-vs-base-r-how-to-choose-the-best-framework-for-you-29b702bdb384?source=rss-39501aa8ce39------2</link>
            <guid isPermaLink="false">https://medium.com/p/29b702bdb384</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[rstats]]></category>
            <dc:creator><![CDATA[Rory Spanton]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 19:37:58 GMT</pubDate>
            <atom:updated>2023-02-27T19:37:58.567Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to Group Data in R: Going Beyond “group_by”]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/going-beyond-group-by-how-to-group-data-in-r-af30f19c1ff2?source=rss-39501aa8ce39------2"><img src="https://cdn-images-1.medium.com/max/2600/0*ybY3O-zbk-xXuUu6" width="5472"></a></p><p class="medium-feed-snippet">Go from beginner to advanced with these grouping workflows</p><p class="medium-feed-link"><a href="https://medium.com/data-science/going-beyond-group-by-how-to-group-data-in-r-af30f19c1ff2?source=rss-39501aa8ce39------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/going-beyond-group-by-how-to-group-data-in-r-af30f19c1ff2?source=rss-39501aa8ce39------2</link>
            <guid isPermaLink="false">https://medium.com/p/af30f19c1ff2</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[r-programming]]></category>
            <category><![CDATA[rstats]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Rory Spanton]]></dc:creator>
            <pubDate>Wed, 15 Feb 2023 15:15:27 GMT</pubDate>
            <atom:updated>2023-02-22T11:24:26.669Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to Use Map Functions for Data Science in R]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/how-to-use-map-functions-for-data-science-in-r-8180c2ed6d79?source=rss-39501aa8ce39------2"><img src="https://cdn-images-1.medium.com/max/2600/0*613HeqlPt7hHwIAF" width="5472"></a></p><p class="medium-feed-snippet">Learn powerful functional programming tools from the tidyverse</p><p class="medium-feed-link"><a href="https://medium.com/data-science/how-to-use-map-functions-for-data-science-in-r-8180c2ed6d79?source=rss-39501aa8ce39------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/how-to-use-map-functions-for-data-science-in-r-8180c2ed6d79?source=rss-39501aa8ce39------2</link>
            <guid isPermaLink="false">https://medium.com/p/8180c2ed6d79</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[rstats]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Rory Spanton]]></dc:creator>
            <pubDate>Thu, 02 Feb 2023 16:04:29 GMT</pubDate>
            <atom:updated>2023-02-02T16:04:29.288Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to Reverse Code an Interval Scale in R]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/how-to-reverse-code-an-interval-scale-in-r-917c13e4888e?source=rss-39501aa8ce39------2"><img src="https://cdn-images-1.medium.com/max/2600/1*_382EzOsYeKfhNxGjM_OYA.jpeg" width="6000"></a></p><p class="medium-feed-snippet">An easy way to clean questionnaire and measurement data</p><p class="medium-feed-link"><a href="https://medium.com/data-science/how-to-reverse-code-an-interval-scale-in-r-917c13e4888e?source=rss-39501aa8ce39------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/how-to-reverse-code-an-interval-scale-in-r-917c13e4888e?source=rss-39501aa8ce39------2</link>
            <guid isPermaLink="false">https://medium.com/p/917c13e4888e</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[rstats]]></category>
            <category><![CDATA[data-cleaning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Rory Spanton]]></dc:creator>
            <pubDate>Tue, 01 Nov 2022 04:34:46 GMT</pubDate>
            <atom:updated>2023-02-22T11:16:53.921Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[No, You’re Not “Right-Brained”]]></title>
            <link>https://medium.com/mind-cafe/you-might-be-creative-but-youre-not-right-brained-e04fcda3eb66?source=rss-39501aa8ce39------2</link>
            <guid isPermaLink="false">https://medium.com/p/e04fcda3eb66</guid>
            <category><![CDATA[psychology]]></category>
            <category><![CDATA[personal-development]]></category>
            <category><![CDATA[split-brain]]></category>
            <category><![CDATA[creativity]]></category>
            <category><![CDATA[neuroscience]]></category>
            <dc:creator><![CDATA[Rory Spanton]]></dc:creator>
            <pubDate>Mon, 26 Sep 2022 18:02:18 GMT</pubDate>
            <atom:updated>2023-02-22T11:09:23.346Z</atom:updated>
            <content:encoded><![CDATA[<h4>Don’t be fooled by neuroscience’s biggest myth</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Tg7R17FbffdP2zJC" /><figcaption>Photo by <a href="https://unsplash.com/@natcon773?utm_source=medium&amp;utm_medium=referral">Natasha Connell</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As someone who researches how humans think and behave, I often come face-to-face with psychological myths. It’s scary how many people think we only use 10% of our brains or that psychologists can somehow read minds.</p><p>Believe me, I’d be way better at my job if I could.</p><p>Many of these beliefs are harmless. But sometimes, they reflect more important misconceptions about how our mind works. These mistruths can lead us to adopt counterproductive views of ourselves. Or worse yet, change our behaviour based on false premises.</p><p>And of all the beliefs that might make this happen, none is more common than the “split-brain” myth. It goes like this:</p><p>A human brain has two halves connected by a mass of neural pathways deep in the middle. These halves of the brain have opposing purposes. The left side is the brain’s logical centre, responsible for systematic thought and reasoning. By contrast, the right side is creative and forms the basis for art and other imaginative pursuits.</p><p>One of these halves of the brain is more dominant than the other. If you see yourself as a creative type, it’s because your right brain is leading the way. Or something like that.</p><p>This idea appears everywhere. Visual depictions of the creative left brain versus logical right brain come in all forms, from clipart to fine art. It crops up in top-selling <a href="https://www.goodreads.com/en/book/show/627206.The_New_Drawing_on_the_Right_Side_of_the_Brain">books</a>, expensive <a href="https://www.rightbrainbusinessplan.com/courses/">courses</a> and otherwise reputable sources. I’ve even heard people who studied psychology at school mention it.</p><p>Unfortunately, the split-brain myth is false.</p><p>Yet like any misunderstanding, it is derived from a grain of truth. In this case, that truth is a history of fascinating research that gives us priceless insights into how our minds work.</p><h3>A Brain of Two Halves</h3><p>For centuries, researchers have seen that the left and right sides of the brain can be responsible for different cognitive functions. Scientists knew that language impairment could result from damage to the brain’s left hemisphere <a href="https://www.nature.com/articles/nrn1009">as early as the 1860s</a>.</p><p>One hundred years later, a series of <a href="https://www.science.org/doi/pdf/10.1126/science.7112125?casa_token=FP-UtlF5MdkAAAAA:bc6FxDAy10sT6G_xElzmpWmVwrVCAU_Y4N7i0KHB5jOByX01CQUAEy5FssFDwMcT9L7iSakYCt4">Nobel Prize-winning experiments</a> studied patients who had the connection between the left and right sides of their brain severed. These individuals’ left hemispheres were mostly responsible for their language and speech production. By contrast, their right hemispheres were responsible for much of their visual processing.</p><p>It’s easy to see how these findings shaped the public’s view of how our brain works. The linguistic and analytical capacity of the left hemisphere seemed very separate from the visual and creative ability of the right. But what about the idea that one side of the brain is dominant?</p><p>In some tasks, one side of our brain can seem dominant. For example, when controlling our movements, the right side of our brain controls the left side of our body and vice versa. In the same way, each of our eyes sends visual information to the opposite side of the brain.</p><p>Most of us have clear preferences for one of these sides. If you’re right-handed, the part of your brain that controls hand movement in your left hemisphere is more adept than its counterpart on the right. Naively, this might be interpreted as “dominance”.</p><p>So given these differences between the left and right sides of the brain, why is the split-brain myth false?</p><h3>A Whole Lot of Evidence</h3><p>The distinction between left and right brain function is not as clear as these early results would have you think. While it’s true that each side of our brain can specialise in different tasks, these specialisms are affected by many factors.</p><p>Going back to language, here are a few results from more recent studies:</p><ul><li><a href="https://doi.org/10.1016/j.bandl.2008.11.005">Key language structures</a> in the left side of the brain are no larger in volume than their counterparts on the right.</li><li><a href="https://doi.org/10.1016/j.bandl.2005.04.007">Right-side damage</a> to the brain has also been found to cause language impairments.</li><li><a href="https://doi.org/10.1523/JNEUROSCI.4383-08.2008">People with stronger connections</a> between either side of the brain rely less on the left side for language processing.</li></ul><p><a href="https://doi.org/10.1371/journal.pbio.1001767">The list goes on</a>. Simply put, if you’re good at verbal reasoning, it’s not because you’re blessed with a strong left brain.</p><p>It’s also untrue that creativity is a product of the right side of the brain. Newer <a href="https://doi.org/10.1016/j.neuroimage.2011.08.008">brain imaging studies</a> have shown that creative thought activates many regions on both sides.</p><p>In sum, there is no scientific evidence that people are either “left-brained” or “right-brained”. Sure, the left side of the brain has a key role in language processing. But the right side also helps out, and the extent to which it does so depends upon many complex factors. Creativity doesn’t only originate in the right side of the brain either.</p><p>The split-brain myth is untrue.</p><p>And that matters.</p><p>Despite research to the contrary, people still buy into the split-brain myth. They read books about it, and pay for expensive business courses that tell them their managerial style based on whether they’re “left or right-brained”.</p><p>And in doing so, they internalise all sorts of falsehoods. That you are either systematic or creative by nature, but not both. That you have an arbitrary biological cap on your logical or imaginative capacity. That, to make better art, all you have to do is “learn to shut your left brain up” or something comparably nutty.</p><p>In reality, you should not limit yourself on account of these things.</p><p>You can be a systematic thinker and have heaps of creativity at the same time. Many of the best scientists I know fall into this category, and it’s often the very reason that they excel.</p><p>Nor is your creative or logical ability set in stone by the dominant side of your brain. In truth, the human brain is anything but static and inflexible. If patients with severe left-side injuries can adapt to regain normal language, you can surely learn new skills and styles of thinking.</p><p>Although research has debunked the split-brain myth, it is still embedded in the public consciousness. The only way we can get past it is to collectively recognise it as incorrect.</p><p>So the next time you see some split-brain silliness in the wild, don’t fall for it. You and your brain deserve better than that.</p><p>Want to read all my articles on psychology, science, and more? Sign up for a Medium membership at <a href="https://medium.com/@roryspanton/membership">this link</a> and get full access to all my writing and every other story on Medium. This also helps me directly, as I get a small contribution from your membership fee at no extra cost to you.</p><p>You can also get all my new articles delivered straight to your inbox whenever I post by <a href="https://roryspanton.medium.com/subscribe">subscribing here</a>. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e04fcda3eb66" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mind-cafe/you-might-be-creative-but-youre-not-right-brained-e04fcda3eb66">No, You’re Not “Right-Brained”</a> was originally published in <a href="https://medium.com/mind-cafe">Mind Cafe</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>