Toggle light / dark theme

Automating repetitive tasks with loops and functions.


Many R users get into R programming from a statistics background rather than a programming/software engineering background, having previously used software such as SPSS, Excel etc. As such they may not have an understanding of some of the programming techniques that can be leveraged to improve code. This can include making the code more modular which in turn makes it easier to find and resolve bugs, but also can be used to automate repetitive tasks, such as producing tables and plots etc.

This short post in c ludes some of the basic programming techniques that can be used to improve the quality and maintainability of R scripts. This will also save you a whole lot of time if you are carrying out repetitive tasks that are only marginally different. We assume that you have a basic understanding of writing simple scripts in R.

Let’s start with a simple example. Let’s say we have some data from several different groups. In this case 3 animals (tigers, swans and badgers) and we have collected some data on relating to this (a score and value of some kind).

If the finding really is the result of new fundamental particles then it will finally be the breakthrough that physicists have been yearning for for decades.


When CERN’s gargantuan accelerator, the Large Hadron Collider (LHC), fired up ten years ago, hopes abounded that new particles would soon be discovered that could help us unravel physics’ deepest mysteries. Dark matter, microscopic black holes, and hidden dimensions were just some of the possibilities. But aside from the spectacular discovery of the Higgs boson, the project has failed to yield any clues as to what might lie beyond the standard model of particle physics, our current best theory of the micro-cosmos.

So our new paper from LHCb, one of the four giant LHC experiments, is likely to set physicists’ hearts beating just a little faster. After analyzing trillions of collisions produced over the last decade, we may be seeing evidence of something altogether new – potentially the carrier of a brand new force of nature.

But the excitement is tempered by extreme caution. The standard model has withstood every experimental test thrown at it since it was assembled in the 1970s, so to claim that we’re finally seeing something it can’t explain requires extraordinary evidence.

A DIY microscope made out of LEGO bricks and smartphone lenses could be a powerful learning tool, teaching children not only how to use microscopes, but also how they work.

Seeing is learning: Microscopes are an essential scientific tool, right up there with bunsen burners and petri dishes, which means they’re also essential to any child’s science education.

But even when young people have access to microscopes, they’re often only taught how to use the instruments — put a slide here, look through there — and not how they actually work.

We have just checked the Tesla estimated delivery times (for new orders) of all four electric car models available in the U.S.

There are some interesting findings, as the hectic extension of delivery times has slowed down, and in some cases, even stopped or reversed. The prices have also remained unchanged since November 12.

Let’s start with the Model 3. The queue for the entry-level RWD version with an LFP battery appears to decrease as the estimated delivery time is the same as over one and a half months ago (June or October, depending on the wheel option). The Long Range AWD and Performance versions moved up a bit — to March and February. As we can see, the higher price/higher margin versions are prioritized (it will be common for all models).