[R] filling a list faster

Balazs Torma torma at sztaki.hu
Fri Jul 13 12:19:59 CEST 2007


    first I create a list:

l <- list("1"<-c(1,2,3))

    then I run the following cycle, it takes over a minute(!) to  
complete on a very fast mashine:

for(i in (1:10^5)) l[[length(l)+1]] <- c(i,i+1,i)

How can I fill a list faster? (This is just a demo test, the elements  
of the list are calculated iteratively in an algorithm)

Are there any packages and documents on how to use more advanced and  
fast data structures like linked-lists, hash-tables or trees for  

Thank you,
Balazs Torma

More information about the R-help mailing list