[R] How to iterate through two objects of class "list" fast?
p.dalgaard at biostat.ku.dk
Wed Jun 2 16:13:19 CEST 2004
"Wolski" <wolski at molgen.mpg.de> writes:
> 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?
Use mapply(). I wouldn't expect the for loop to be all that slow
unless you have forgotten to allocate memory for the result list up
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help