Skip to content

May meeting: Loop vs Map Showdown!

Photo of Janine
Hosted By
Janine and Till
May meeting: Loop vs Map Showdown!

Details

Productivity in R often boils down to automating repetitive steps, and iterating over a structured dataset is a common task in more complex data manipulation.

There are many ways to achieve this: While some feel most comfortable writing procedural for-loops, others Vectorize() their functions in order to pass them multiple values at once. Yet another camp swears by the functional style of purrr's map() and reduce() functions (the tidy alternative to the the *apply family of functions in base R). And a fourth category of useRs struggle to get their head wrapped around serializiation in the first place. (Let's just ignore the hopeless cases who write straight-up recursive functions with no concern for stack size.)

It has been rumored that a more functional style makes everything faster – but is that really true? Doesn't it make the code just too hard to read? And can any loop really be replaced by a map?

For our May meeting, let's challenge the functional fanboys and *girls among us. Bring a contained, reproducible example loop (side effects welcome!) and we will ask the mapheads to reformulate it as a higher order function.

As always, useRs of all backgrounds and at all levels of expertise are invited to participate. Learning R is not a competition. Come join us!

Photo of Campus useR Group Frankfurt group
Campus useR Group Frankfurt
See more events