Uwe Ligges wrote: > Clark Allan wrote: >> >>i know that one should try and limit the amount of looping in R >>programs. i have supplied some code below. i am interested in seeing how >>the code cold be rewritten if we dont use the loops. > > It is not always a good thing to remove loops (without having looked at > each details of the code below). > "Compromise" is the keyword.
If you have big routines for each iteration and especially you have back references in the data structures you are manipulating, it becomes really _hard to translate_ loop statements to filter-map-accumulator routines provided by R (i.e. *apply functions). I really cannot find my way in some situations. What I did so far is to write those routines in C. Dirty hack :( Maybe one should write a tutorial: "Howto avoid loops in R" by giving possible scenarios. --vst ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
