The lazy person’s perspective on programming: why you should code

Lots of people (myself included) bang on about coding. How great it is, how valuable it’s been, etc. You’re probably a bit bored of it. But if you’re not just yet, allow me to explain why it is probably a good idea for you to pick it up. Why am I uniquely qualified to do this? I’m not, but I haven’t seen this reason for coding advocated so I thought some may appreciate it. I’ve been using the programming language R for over 2 years. I’m by no means an expert, but I’ve been able to conduct and write a few studies completely in R. I’m going to focus on R because this is what I know, but this idea applies to all coding languages.

If you pick up programming without any prior knowledge, it’s not easy. R is infamous for having a pretty steep learning curve which, unfortunately, is true. So why would a person with a penchant for being lazy, like myself, bother to pick it up?

Who you calling lazy?

If I don’t have to do something, I generally won’t do it[note]This is why whenever I adopt a new habit I have to promise/convince myself it is essential, otherwise I know it won’t happen.[/note]. The perfect example of this is statistical analyses. During my undergraduate degree, I was taught (like almost everyone else) using SPSS.

I hated it. Not just SPSS, but stats in general. I didn’t understand what I was doing, I didn’t know what the results really meant (beyond significant p-value=good, non-significant p-value=bad), and overall it was a bit of a mess[note]This in no way should be taken as an indictment of my stats tutors at undergrad, but as my unwillingness to engage with the content.[/note]. Because you could get by with pressing buttons in SPSS, that’s what I did. I didn’t need to really understand what I was doing or what it meant. All I needed was to follow the recipes for certain tests and voilà, I’d get a result. I did well enough in my BSc and moved on to the next step in my career, knowing at some point I’d have to do statistics again (but not for a while).

First contact

I didn’t hear about the use of coding in psychology until some time after my BSc. There were a lot of people talking about it on social media, especially Twitter, and how great it was. I thought I’d give it a shot, see what all the fuss was about. I downloaded R, opened it, and stared at a blank page. But I wasn’t going to throw in the towel just yet. I started two different online courses on R (neither of which I finished). But it was enough to give me a very basic understanding of how to use base R and run a few simple commands.

What really helped me get to grips with using R (and what I recommend to everyone as the best way to gain proficiency in coding) was having a problem I wanted to analyse and visualise. This came first in the shape of analysing the various blog sources for my blog feed (PsychBrief, 2017) and later in the form of my survey on why psychologists leave academia (PsychBrief, 2017). Through consulting knowledgeable people (both in meatspace and on social media) and repeatedly banging my head against the brick wall of recalcitrant code, I eventually learned how to analyse data and visualise it in a multitude of ways.

Why I needed coding

Some of you will rightly point out that I could do all these things with SPSS if I put in the same amount of effort. Besides the fact I couldn’t access SPSS, there was another major benefit to coding. It’s much harder[note]Though certainly not impossible[/note] to mindlessly analyse data and pump out results without any understanding of what they mean when coding. Because you have to find the right code to use, you need to understand what data you have, what you’re trying to do, and why. It gives you a built-in opportunity to think about what you’re doing; it slows down your analysis (McElreath, 2017). This meant I couldn’t take the shortcut of disengaging my brain and going through the motions of statistical analysis.

Not only has this resulted in me gaining a better understanding of statistical analysis, but I genuinely love statistics now. Learning about statistical concepts excites me, and it’s all because I forced myself to start thinking about it. When I was randomly slapping a black box, the whole process was an unpleasant mystery to me. Now, it’s an opportunity to deepen my understanding. Even though I’m naturally quite lazy, taking up coding has been one of the best decisions I’ve ever made. It wasn’t easy at first. But there are so many helpful people out there willing to lend support and enough good resources available you’ll find something that works for you. If you’re not interested in coding, that’s totally fine; you can do great work with SPSS etc. But because I’m quite lazy, it made me a better scientist. It might make you a better scientist too.

Note

Here are some introductory resources for R you may find useful. I’ll provide some comments if I’ve used them or found them helpful.

R Programming – This is one of the courses I first picked up when learning R (and didn’t finish). A good introduction to the basic concepts, though I found it pretty dry.

R for cats – I haven’t used this resource, but I wish I had when I was first learning!

YaRrr! The Pirate’s Guide to R – Another resource I wish I had used when I began coding.

Improving your statistical inferences – This isn’t strictly about learning R; it focuses more on the underlying statistical concepts (which I found very informative). But it gives you the opportunity to perform all the exercises in R.

R resources – For a thoroughly overwhelming (but genuinely useful) compendium of R resources, this page is great. Shop around, choose one you like the look of, and take it for a spin.

GuidedTrack – This website teaches you to code by making web applications. I’ve not tried it but it looks very cool and having a goal to work towards will definitely help maintain motivation.

RStudio Cloud – Online software which allows you to code and share in R without having to download the program or worry about file storage.

References

McElreath, R. (2017). First World Modelling Problems. Available at: http://elevanth.org/blog/2017/08/28/first-world-modeling-problems/

PsychBrief (2017). Improving the psychological methods feed. Available at: https://psychbrief.com/why-people-leave-academia-results/

PsychBrief (2017). Why people leave academia – the results. Available at: https://psychbrief.com/why-people-leave-academia-results/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: