Comparing Iterator Performance in R

Kevin Feasel

2019-06-21

R

Ulrik Stervbo has a performance comparison for for, apply, and map functions in R:

It is usually said, that for– and while-loops should be avoided in R. I was curious about just how the different alternatives compare in terms of speed.

The first loop is perhaps the worst I can think of – the return vector is initialized without type and length so that the memory is constantly being allocated.

The performance of map isn’t great, though the benefits to me are less about performance and more about readability. H/T R-bloggers

Related Posts

Icon Maps in R

Laura Ellis shows how you can build maps full of little icons: That was ok, but we should try to make the images more aesthetically pleasing using the magick package. We make each image transparent with the image_transparent() function. We can also make the resulting image a specific color with image_colorize(). I then saved the […]

Read More

R User Salaries By Country

Capri Granville shares a chart showing a box plot of salaries for professional R users by country: Interesting analysis done in R, about salaries of R developers broken down by country, featuring salary range and median salary.  The dataset consists of survey answers from nearly 90,000 respondents. About 5,000 of them reported using R for “extensive development […]

Read More

Categories

June 2019
MTWTFSS
« May Jul »
 12
3456789
10111213141516
17181920212223
24252627282930