[R] How to iterate through two objects of class "list" fast?

Wolski wolski at molgen.mpg.de
Wed Jun 2 15:47:30 CEST 2004


I have 2 list objects
One list contains the data (list1) the second list2 contains the e.g linear model for each element of list 1.
list2 <- lapply(list1,mylm,response) I obtain list 2 by something like this.

now I have a function myfunc  which takes an element from list1 and the coresponding element from list2 does something and ....

list3[[x]] <- myfunc(list1[[x]],list2[[x]])

Until now I am runnign this in a for(x in 1:length(list1)) loop. But "for" loops are slow especially if list3 is HUGE.

What can I do?


More information about the R-help mailing list