Monthly Archives: October 2015

Looking at speed

by Karl-Kuno Kunze

This post wants to remind you of the package compiler by Luke Tierney and to somehow save the honor of the for loop that is rather likely to be discredited by R users.

As an ardent admirer of all functions with a ply inside I cannot help but praise the elegance of avoiding everything with a for inside. However, every now and then fervent disregard of the for loop may lead to more elegant but slower code. In the following we write some purely demonstrative code and take a look at time consumption.

Continue reading

Looking at closures

by Karl-Kuno Kunze

This post gives you an idea of what a closure is. I first motivate why it is helpful to know about the concept. Then I introduce the notion of an environment. Having this we build a closure.

Sometimes you may run into error messages like: object of type ‘closure’ is not subsettable. To understand what R wants to tell you here, the notion of a closure is of quite some help. To put it briefly: A closure is a function together with an environment.

Continue reading