Skip to content
Prev 345313 / 398500 Next

How to speed up list access in R?

Thanks to all for the help everyone! For the moment I'll stick with 
Bill's solution, but I'll check out the other recommendations as well.

Regarding the issue of slow looks ups for lists, are there any hash map 
implementations in R that are faster? I like using fairly simple logic 
and data structures when prototyping and then only optimize code when 
and where it's necessary which is why I'm curious about these basic objects.

On another note, is there a vector style implementation that changes the 
vectors in place? If I'm not mistaken, the append operation creates and 
returns a new vector each time which is line with the functional nature 
of R. If there were some way to have it mutable, it could be much 
faster. This is fairly standard in many languages. Behind the scenes 
memory is allocated at say 2 times the current size so that you only 
need log(n) extensions when building up a vector like this. Are there 
any such equivalents in R? I presume that lists are mutable (am I 
wrong?), but they seem to have the lookup slowdown problem.

Again thanks a lot!

Cheers,
Thomas
On 10/30/2014 12:05 PM, William Dunlap wrote: