Photo by Cathryn Lavery on Unsplash

It’s easy to forget about the little things in your routine. When life gets hectic, minor responsibilities like watering houseplants, taking out the bins, and cleaning your computer often get forgotten.

Even as someone who researches human memory for a living, I still suck at keeping track of things like this. Having a global pandemic in the background doesn’t help my mental capacity either.

If you’re like me, thankfully you can fix this with a little basic code. By using a common online to-do list in conjunction with a Python script, it’s easy to set up custom repeating alerts based…

Photo by CDC on Unsplash

Probabilities can be hard to calculate, especially in complex scenarios. One way to get around this is to turn probabilistic situations into code. By running this code many times, one can approximate the probability of a certain outcome without having to derive it directly. This is a simulation, and it’s very useful when tackling a wealth of problems.

A friend recently came to me with such a problem. Inspired while under lockdown, he was designing a mod for a turn-based strategy game which introduced disease as a game mechanic. The premise was that traders (characters in-game) travelling along a fixed…

Photo by Birmingham Museums Trust on Unsplash

Many people believe that a person’s facial features give an accurate representation of their personality and potential behaviour. Popular depictions of shady characters in the media feature protruding brows, hard stares, large noses, and other stereotypical hallmarks of an untrustworthy person. Academics throughout history even attempted the organised study of physiognomy; the prediction of personality traits and antisocial behaviour using only facial characteristics.

In actuality, the belief that facial features are linked with behaviour and personality is false. Physiognomy has long been decried as racist pseudoscience and left in the wake of modern personality psychology.

So scientists were surprised when…

Photo by Braden Collum on Unsplash

Learning R can take a lot of time. But while it’s impossible to become an expert overnight, there are plenty of things you can do to speed up the learning process. I’ve put together some recommendations for streamlining your path to R proficiency, based on my own experience.

I should note right away that everyone’s experiences are different. Some people learn R in different ways and still achieve success. That said, I’ve got a lot of value from the following tips, as have many other people I know.

1. Learn the Fundamentals of Programming First

As a language built by statisticians rather than programmers, R can seem…

Photo by Joshua Reddekopp on Unsplash

Practice is an essential part of learning. But in my experience learning programming, finding useful tasks and projects to reinforce your skills is tough. This is especially true of programming for data analysis. Finding meaningful and interesting data is really hard if you don’t know where to look.

Luckily, there are plenty of great datasets and projects out there. When searching for your next project, it’s worth considering a couple of things:

  • Not every project has to be complicated. I’ve learned a lot from trying tasks that can be summed up in a single sentence.
  • Projects that aren’t related to…

R Fundamentals

Photo by Erlend Ekseth on Unsplash

Data analysis often involves many steps. A typical journey from raw data to results might involve filtering cases, transforming values, summarising data, and then running a statistical test. But how can we link all these steps together, while keeping our code efficient and readable? Enter the pipe, R’s most important operator for data processing.

What does the pipe do?

The pipe operator, written as %>%, has been a longstanding feature of the magrittr package for R. It takes the output of one function and passes it into another function as an argument. This allows us to link a sequence of analysis steps.

To visualise this…

Image: Anthony Fomin / Unsplash

Sometimes, it’s easy to get frustrated when learning programming. Perhaps you’ve been working on the same concept for an hour or two. Perhaps your progress is slow. Perhaps this is all happening at 6pm on a Friday in the middle of a global pandemic. I’ve been there, and I imagine I’m not alone.

Thankfully for R programmers, there are packages that help bring joy back into the learning process. What’s more, they’re easy to understand and can make amusing additions to recreational projects.

Below, I’ve put together five of my favourite ‘just for fun’ R packages. Each example is very…

Lady types on keyboard while looking at code on her screen.
Lady types on keyboard while looking at code on her screen.
Image: Kelly Sikkema / Unsplash

The FizzBuzz problem is a classic test given in coding interviews. The task is simple:

Print integers 1 to N, but print “Fizz” if an integer is divisible by 3, “Buzz” if an integer is divisible by 5, and “FizzBuzz” if an integer is divisible by both 3 and 5.

There are many ways to achieve the desired output, but some methods are better than others. Great solutions to FizzBuzz don’t “just work”. They adhere to good programming principles, allow flexibility for later changes, and play to a language’s strengths. …

Edit and file convert as many images as you like with functional programming.

Photo: Josh Hild on Unsplash

Most programmers may use R as a tool for statistics or ‘conventional’ data analyses. Granted, as a researcher, this is often what I use it for too.

But the power of R extends much further, helped by a range of packages that greatly expand its functionality. Combine this with the capacity for functional programming, and solutions to a wider array of problems are plentiful.

The magick package is a great example of this. A wrapper of the C++ library ImageMagick, this package provides a variety of straightforward…

Rory Spanton

PhD Researcher (human memory). Making sense of data, doing and discussing science, and writing code.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store