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…
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…
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.
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.
As a language built by statisticians rather than programmers, R can seem…
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:
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.
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…
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…
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.
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…